1898
1902
blorp_update_clear_color(UNUSED struct blorp_batch *batch,
1899
const struct brw_blorp_surface_info *info,
1903
const struct brw_blorp_surface_info *info)
1902
if (info->clear_color_addr.buffer && op == ISL_AUX_OP_FAST_CLEAR) {
1905
assert(info->clear_color_addr.buffer != NULL);
1903
1906
#if GFX_VER == 11
1904
blorp_emit(batch, GENX(PIPE_CONTROL), pipe) {
1905
pipe.CommandStreamerStallEnable = true;
1909
const unsigned inlinedata_dw = 2 * 2;
1910
const unsigned num_dwords = GENX(MI_ATOMIC_length) + inlinedata_dw;
1912
struct blorp_address clear_addr = info->clear_color_addr;
1913
uint32_t *dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
1914
.DataSize = MI_ATOMIC_QWORD,
1915
.ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
1917
.MemoryAddress = clear_addr);
1918
/* dw starts at dword 1, but we need to fill dwords 3 and 5 */
1919
dw[2] = info->clear_color.u32[0];
1921
dw[4] = info->clear_color.u32[1];
1924
clear_addr.offset += 8;
1925
dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
1926
.DataSize = MI_ATOMIC_QWORD,
1927
.ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
1929
.ReturnDataControl = true,
1931
.MemoryAddress = clear_addr);
1932
/* dw starts at dword 1, but we need to fill dwords 3 and 5 */
1933
dw[2] = info->clear_color.u32[2];
1935
dw[4] = info->clear_color.u32[3];
1938
blorp_emit(batch, GENX(PIPE_CONTROL), pipe) {
1939
pipe.StateCacheInvalidationEnable = true;
1940
pipe.TextureCacheInvalidationEnable = true;
1908
const unsigned inlinedata_dw = 2 * 2;
1909
const unsigned num_dwords = GENX(MI_ATOMIC_length) + inlinedata_dw;
1911
struct blorp_address clear_addr = info->clear_color_addr;
1912
uint32_t *dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
1913
.DataSize = MI_ATOMIC_QWORD,
1914
.ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
1916
.MemoryAddress = clear_addr);
1917
/* dw starts at dword 1, but we need to fill dwords 3 and 5 */
1918
dw[2] = info->clear_color.u32[0];
1920
dw[4] = info->clear_color.u32[1];
1923
clear_addr.offset += 8;
1924
dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
1925
.DataSize = MI_ATOMIC_QWORD,
1926
.ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
1928
.ReturnDataControl = true,
1930
.MemoryAddress = clear_addr);
1931
/* dw starts at dword 1, but we need to fill dwords 3 and 5 */
1932
dw[2] = info->clear_color.u32[2];
1934
dw[4] = info->clear_color.u32[3];
1942
1937
#elif GFX_VER >= 9
1944
/* According to Wa_2201730850, in the Clear Color Programming Note
1945
* under the Red channel, "Software shall write the converted Depth
1946
* Clear to this dword." The only depth formats listed under the red
1947
* channel are IEEE_FP and UNORM24_X8. These two requirements are
1948
* incompatible with the UNORM16 depth format, so just ignore that case
1949
* and simply perform the conversion for all depth formats.
1951
union isl_color_value fixed_color = info->clear_color;
1952
if (GFX_VER == 12 && isl_surf_usage_is_depth(info->surf.usage)) {
1953
isl_color_value_pack(&info->clear_color, info->surf.format,
1957
for (int i = 0; i < 4; i++) {
1958
blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1959
sdi.Address = info->clear_color_addr;
1960
sdi.Address.offset += i * 4;
1961
sdi.ImmediateData = fixed_color.u32[i];
1964
sdi.ForceWriteCompletionCheck = true;
1969
/* The RENDER_SURFACE_STATE::ClearColor field states that software should
1970
* write the converted depth value 16B after the clear address:
1972
* 3D Sampler will always fetch clear depth from the location 16-bytes
1973
* above this address, where the clear depth, converted to native
1974
* surface format by software, will be stored.
1978
if (isl_surf_usage_is_depth(info->surf.usage)) {
1979
blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1980
sdi.Address = info->clear_color_addr;
1981
sdi.Address.offset += 4 * 4;
1982
sdi.ImmediateData = fixed_color.u32[0];
1939
/* According to Wa_2201730850, in the Clear Color Programming Note under
1940
* the Red channel, "Software shall write the converted Depth Clear to this
1941
* dword." The only depth formats listed under the red channel are IEEE_FP
1942
* and UNORM24_X8. These two requirements are incompatible with the UNORM16
1943
* depth format, so just ignore that case and simply perform the conversion
1944
* for all depth formats.
1946
union isl_color_value fixed_color = info->clear_color;
1947
if (GFX_VER == 12 && isl_surf_usage_is_depth(info->surf.usage)) {
1948
isl_color_value_pack(&info->clear_color, info->surf.format,
1952
for (int i = 0; i < 4; i++) {
1953
blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1954
sdi.Address = info->clear_color_addr;
1955
sdi.Address.offset += i * 4;
1956
sdi.ImmediateData = fixed_color.u32[i];
1983
1959
sdi.ForceWriteCompletionCheck = true;
1964
/* The RENDER_SURFACE_STATE::ClearColor field states that software should
1965
* write the converted depth value 16B after the clear address:
1967
* 3D Sampler will always fetch clear depth from the location 16-bytes
1968
* above this address, where the clear depth, converted to native
1969
* surface format by software, will be stored.
1973
if (isl_surf_usage_is_depth(info->surf.usage)) {
1989
1974
blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1990
1975
sdi.Address = info->clear_color_addr;
1991
sdi.ImmediateData = ISL_CHANNEL_SELECT_RED << 25 |
1992
ISL_CHANNEL_SELECT_GREEN << 22 |
1993
ISL_CHANNEL_SELECT_BLUE << 19 |
1994
ISL_CHANNEL_SELECT_ALPHA << 16;
1995
if (isl_format_has_int_channel(info->view.format)) {
1996
for (unsigned i = 0; i < 4; i++) {
1997
assert(info->clear_color.u32[i] == 0 ||
1998
info->clear_color.u32[i] == 1);
2000
sdi.ImmediateData |= (info->clear_color.u32[0] != 0) << 31;
2001
sdi.ImmediateData |= (info->clear_color.u32[1] != 0) << 30;
2002
sdi.ImmediateData |= (info->clear_color.u32[2] != 0) << 29;
2003
sdi.ImmediateData |= (info->clear_color.u32[3] != 0) << 28;
2005
for (unsigned i = 0; i < 4; i++) {
2006
assert(info->clear_color.f32[i] == 0.0f ||
2007
info->clear_color.f32[i] == 1.0f);
2009
sdi.ImmediateData |= (info->clear_color.f32[0] != 0.0f) << 31;
2010
sdi.ImmediateData |= (info->clear_color.f32[1] != 0.0f) << 30;
2011
sdi.ImmediateData |= (info->clear_color.f32[2] != 0.0f) << 29;
2012
sdi.ImmediateData |= (info->clear_color.f32[3] != 0.0f) << 28;
1976
sdi.Address.offset += 4 * 4;
1977
sdi.ImmediateData = fixed_color.u32[0];
1978
sdi.ForceWriteCompletionCheck = true;
1984
blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1985
sdi.Address = info->clear_color_addr;
1986
sdi.ImmediateData = ISL_CHANNEL_SELECT_RED << 25 |
1987
ISL_CHANNEL_SELECT_GREEN << 22 |
1988
ISL_CHANNEL_SELECT_BLUE << 19 |
1989
ISL_CHANNEL_SELECT_ALPHA << 16;
1990
if (isl_format_has_int_channel(info->view.format)) {
1991
for (unsigned i = 0; i < 4; i++) {
1992
assert(info->clear_color.u32[i] == 0 ||
1993
info->clear_color.u32[i] == 1);
1995
sdi.ImmediateData |= (info->clear_color.u32[0] != 0) << 31;
1996
sdi.ImmediateData |= (info->clear_color.u32[1] != 0) << 30;
1997
sdi.ImmediateData |= (info->clear_color.u32[2] != 0) << 29;
1998
sdi.ImmediateData |= (info->clear_color.u32[3] != 0) << 28;
2000
for (unsigned i = 0; i < 4; i++) {
2001
assert(info->clear_color.f32[i] == 0.0f ||
2002
info->clear_color.f32[i] == 1.0f);
2004
sdi.ImmediateData |= (info->clear_color.f32[0] != 0.0f) << 31;
2005
sdi.ImmediateData |= (info->clear_color.f32[1] != 0.0f) << 30;
2006
sdi.ImmediateData |= (info->clear_color.f32[2] != 0.0f) << 29;
2007
sdi.ImmediateData |= (info->clear_color.f32[3] != 0.0f) << 28;
2020
2014
blorp_exec_3d(struct blorp_batch *batch, const struct blorp_params *params)
2022
2016
if (!(batch->flags & BLORP_BATCH_NO_UPDATE_CLEAR_COLOR)) {
2023
blorp_update_clear_color(batch, ¶ms->dst, params->fast_clear_op);
2024
blorp_update_clear_color(batch, ¶ms->depth, params->hiz_op);
2017
if (params->fast_clear_op == ISL_AUX_OP_FAST_CLEAR &&
2018
params->dst.clear_color_addr.buffer != NULL) {
2019
blorp_update_clear_color(batch, ¶ms->dst);
2022
if (params->hiz_op == ISL_AUX_OP_FAST_CLEAR &&
2023
params->depth.clear_color_addr.buffer != NULL) {
2024
blorp_update_clear_color(batch, ¶ms->depth);
2027
2028
#if GFX_VER >= 8