radeonsi: set gl_FragCoord to pixel center to fix GLCTS failures

SPI_BARYC_CNTL is moved to the preamble because it's always 0.

We set frag_coord_is_center for the NIR pass to indicate that sample_pos
should be lowered differently.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32910>
This commit is contained in:
Marek Olšák
2025-01-15 21:17:33 -05:00
committed by Marge Bot
parent 9fdd8225c1
commit e0d715c626
13 changed files with 10 additions and 51 deletions
@@ -26,10 +26,6 @@ spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
spec@khr_texture_compression_astc@miptree-gles srgb-fp@sRGB decode full precision,Fail
# glcts failures
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
# These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_getactiveuniformblockiv,Fail
1 # LLVM 18.1.2
26 spec@khr_texture_compression_astc@miptree-gles srgb-fp@sRGB decode full precision,Fail
27 # glcts failures # These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
28 GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
# These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_getactiveuniformblockiv,Fail
29 # escts failures GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_getactiveuniformblockiv,Fail
30 KHR-GLES31.core.shader_image_load_store.basic-allTargets-loadStoreCS,Fail # escts failures
31 KHR-GLES31.core.shader_image_load_store.basic-allTargets-loadStoreVS,Fail KHR-GLES31.core.shader_image_load_store.basic-allTargets-loadStoreCS,Fail
@@ -29,8 +29,6 @@ spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail
spec@arb_bindless_texture@compiler@samplers@arith-bound-sampler-texture2d.frag,Crash
# glcts failures
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
KHR-GL46.shader_image_load_store.basic-allTargets-atomic,Fail
## Fail because GFX10+ removed MS texture support (see si_get_sparse_texture_virtual_page_size)
KHR-GL46.sparse_texture2_tests.SparseTexture2Allocation,Fail
1 # piglit failures
29 # glcts failures
30 GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail KHR-GL46.shader_image_load_store.basic-allTargets-atomic,Fail
31 GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail ## Fail because GFX10+ removed MS texture support (see si_get_sparse_texture_virtual_page_size)
KHR-GL46.shader_image_load_store.basic-allTargets-atomic,Fail
## Fail because GFX10+ removed MS texture support (see si_get_sparse_texture_virtual_page_size)
32 KHR-GL46.sparse_texture2_tests.SparseTexture2Allocation,Fail
33 KHR-GL46.sparse_texture2_tests.SparseTexture2Commitment,Fail
34 ## https://gitlab.freedesktop.org/mesa/mesa/-/issues/636
@@ -29,8 +29,6 @@ spec@khr_texture_compression_astc@sliced-3d-miptree-gles srgb-fp,Fail
spec@khr_texture_compression_astc@sliced-3d-miptree-gles srgb-fp@sRGB decode full precision,Fail
# glcts failures
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
KHR-GL46.shaders.uniform_block.random.nested_structs_instance_arrays.0,Fail
## Fail because GFX10+ removed MS texture support (see si_get_sparse_texture_virtual_page_size)
KHR-GL46.sparse_texture2_tests.SparseTexture2Allocation_texture_2d_multisample_array_r11f_g11f_b10f,Fail
1 # LLVM 20-dev (da439d3af47b)
29 # glcts failures
30 GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail KHR-GL46.shaders.uniform_block.random.nested_structs_instance_arrays.0,Fail
31 GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail ## Fail because GFX10+ removed MS texture support (see si_get_sparse_texture_virtual_page_size)
KHR-GL46.shaders.uniform_block.random.nested_structs_instance_arrays.0,Fail
## Fail because GFX10+ removed MS texture support (see si_get_sparse_texture_virtual_page_size)
32 KHR-GL46.sparse_texture2_tests.SparseTexture2Allocation_texture_2d_multisample_array_r11f_g11f_b10f,Fail
33 KHR-GL46.sparse_texture2_tests.SparseTexture2Allocation_texture_2d_multisample_array_r16,Fail
34 KHR-GL46.sparse_texture2_tests.SparseTexture2Allocation_texture_2d_multisample_array_r16_snorm,Fail
@@ -143,8 +143,6 @@ spec@!opengl 1.1@texwrap formats bordercolor-swizzled@GL_RGBA2- swizzled- border
spec@!opengl 1.1@texwrap formats bordercolor-swizzled@GL_RGBA4- swizzled- border color only,Fail
spec@!opengl 1.1@texwrap formats bordercolor-swizzled@GL_RGBA8- swizzled- border color only,Fail
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels,Fail
GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels_pbo,Fail
GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels_pixelstore,Fail
1 glx@glx_arb_create_context_no_error@no error Fail
143 GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels_pbo Fail
144 GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels_pixelstore Fail
145 GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels_pbo KHR-GL46.direct_state_access.framebuffers_texture_layer_attachment Fail
GTF-GL46.gtf32.GL3Tests.packed_pixels.packed_pixels_pixelstore Fail
KHR-GL46.direct_state_access.framebuffers_texture_layer_attachment Fail
146 KHR-GL46.ext_texture_shadow_lod.texturelod.samplercubeshadow_fragment Fail
147 KHR-GL46.ext_texture_shadow_lod.texture.samplercubearrayshadow_bias_fragment Fail
148 KHR-GL46.gl_spirv.spirv_glsl_to_spirv_builtin_functions_test Fail
@@ -154,8 +154,6 @@ KHR-GL46.geometry_shader.layered_rendering_fbo_no_attachment.layered_rendering_f
KHR-GL46.shader_image_load_store.advanced-sso-subroutine,Fail
KHR-GL46.shader_image_load_store.basic-allTargets-atomic,Fail
KHR-GL46.texture_cube_map_array.sampling,Fail
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
# These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
1 # piglit failures
154 KHR-GL46.shader_image_load_store.basic-allTargets-atomic,Fail
155 KHR-GL46.texture_cube_map_array.sampling,Fail
156 GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail # These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
# These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
157 GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
158 GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_getactiveuniformblockiv,Fail
159 # escts failures
@@ -138,10 +138,6 @@ spec@khr_texture_compression_astc@sliced-3d-miptree-gles srgb-fp,Fail
spec@khr_texture_compression_astc@sliced-3d-miptree-gles srgb-fp@sRGB decode full precision,Fail
spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail
# glcts failures
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
# These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_getactiveuniformblockiv,Fail
1 # piglit failures
138 spec@khr_texture_compression_astc@sliced-3d-miptree-gles srgb-fp@sRGB decode full precision,Fail
139 spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail
140 # glcts failures # These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
# These are GLCTS bugs. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10361
GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
141 GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_getactiveuniformblockiv,Fail GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_accessing_info_for_block_with_an_instance_array,Fail
142 # escts failures GTF-GL46.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_getactiveuniformblockiv,Fail
143 KHR-GLES31.core.shader_image_load_store.basic-allTargets-loadStoreCS,Fail # escts failures
@@ -51,8 +51,6 @@ wgl@wgl-multi-window-single-context,Fail
wgl@wgl-sanity,Fail
# glcts failures
GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail
GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail
KHR-GL46.direct_state_access.framebuffers_texture_attachment,Fail
KHR-GL46.direct_state_access.framebuffers_texture_layer_attachment,Fail
KHR-GL46.geometry_shader.rendering.rendering.triangles_with_adjacency_input_line_strip_output_triangle_strip_adjacency_drawcall,Fail
1 # piglit failures
51 # glcts failures
52 GTF-GL46.gtf30.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_multisample,Fail KHR-GL46.direct_state_access.framebuffers_texture_attachment,Fail
53 GTF-GL46.gtf32.GL3Tests.fragment_coord_conventions.fragment_coord_conventions_32_multisample,Fail KHR-GL46.direct_state_access.framebuffers_texture_layer_attachment,Fail
KHR-GL46.direct_state_access.framebuffers_texture_attachment,Fail
KHR-GL46.direct_state_access.framebuffers_texture_layer_attachment,Fail
54 KHR-GL46.geometry_shader.rendering.rendering.triangles_with_adjacency_input_line_strip_output_triangle_strip_adjacency_drawcall,Fail
55 KHR-GL46.geometry_shader.rendering.rendering.triangles_with_adjacency_input_triangle_strip_output_triangle_strip_adjacency_drawcall,Fail
56 KHR-GL46.shader_image_load_store.basic-allTargets-atomic,Fail
-1
View File
@@ -309,7 +309,6 @@ void si_set_tracked_regs_to_clear_state(struct si_context *ctx)
ctx->tracked_regs.reg_value[SI_TRACKED_SPI_SHADER_Z_FORMAT] = 0;
ctx->tracked_regs.reg_value[SI_TRACKED_SPI_SHADER_COL_FORMAT] = 0;
ctx->tracked_regs.reg_value[SI_TRACKED_SPI_BARYC_CNTL] = 0;
ctx->tracked_regs.reg_value[SI_TRACKED_SPI_PS_INPUT_ENA] = 0;
ctx->tracked_regs.reg_value[SI_TRACKED_SPI_PS_INPUT_ADDR] = 0;
+2
View File
@@ -2309,6 +2309,7 @@ static bool run_pre_link_optimization_passes(struct si_nir_shader_ctx *ctx)
.load_sample_positions_always_loads_current_ones = true,
.force_front_face = key->ps.opt.force_front_face_input,
.optimize_frag_coord = true,
.frag_coord_is_center = true,
/* This does a lot of things. See the description in ac_nir_lower_ps_early_options. */
.ps_iter_samples = key->ps.part.prolog.samplemask_log_ps_iter ?
(1 << key->ps.part.prolog.samplemask_log_ps_iter) :
@@ -2348,6 +2349,7 @@ static bool run_pre_link_optimization_passes(struct si_nir_shader_ctx *ctx)
} else {
ac_nir_lower_ps_early_options early_options = {
.optimize_frag_coord = true,
.frag_coord_is_center = true,
.alpha_func = COMPARE_FUNC_ALWAYS,
.spi_shader_col_format_hint = ~0,
};
-1
View File
@@ -1022,7 +1022,6 @@ struct si_shader {
struct {
unsigned spi_ps_input_ena;
unsigned spi_ps_input_addr;
unsigned spi_baryc_cntl;
unsigned spi_ps_in_control;
unsigned spi_shader_z_format;
unsigned spi_shader_col_format;
+4 -1
View File
@@ -4983,8 +4983,10 @@ static void gfx6_init_gfx_preamble_state(struct si_context *sctx)
/* Graphics registers. */
si_init_graphics_preamble_state(sctx, pm4);
if (!has_clear_state)
if (!has_clear_state) {
ac_pm4_set_reg(&pm4->base, R_02800C_DB_RENDER_OVERRIDE, 0);
ac_pm4_set_reg(&pm4->base, R_0286E0_SPI_BARYC_CNTL, 0);
}
if (sctx->family >= CHIP_POLARIS10 && !sctx->screen->info.has_small_prim_filter_sample_loc_bug) {
/* Polaris10-12 should disable small line culling, but those also have the sample loc bug,
@@ -5141,6 +5143,7 @@ static void gfx12_init_gfx_preamble_state(struct si_context *sctx)
ac_pm4_set_reg(&pm4->base, R_028648_SPI_SHADER_IDX_FORMAT,
S_028648_IDX0_EXPORT_FORMAT(V_028648_SPI_SHADER_1COMP));
ac_pm4_set_reg(&pm4->base, R_028658_SPI_BARYC_CNTL, 0);
/* The rate combiners have no effect if they are disabled like this:
* VERTEX_RATE: BYPASS_VTX_RATE_COMBINER = 1
+4 -3
View File
@@ -309,9 +309,10 @@ enum si_tracked_reg
/* 5 consecutive registers (GFX12), or 2 consecutive registers (GFX6-11) */
SI_TRACKED_SPI_SHADER_Z_FORMAT,
SI_TRACKED_SPI_SHADER_COL_FORMAT,
/* Continuing consecutive registers (GFX12), or separate register (GFX6-11) */
SI_TRACKED_SPI_BARYC_CNTL,
/* Continuing consecutive registers (GFX12), or 2 consecutive registers (GFX6-11) */
SI_TRACKED__UNUSED_GAP, /* TODO: remove */
/* 2 consecutive registers. */
SI_TRACKED_SPI_PS_INPUT_ENA,
SI_TRACKED_SPI_PS_INPUT_ADDR,
@@ -2012,8 +2012,6 @@ static void gfx6_emit_shader_ps(struct si_context *sctx, unsigned index)
radeon_opt_set_context_reg2(R_0286CC_SPI_PS_INPUT_ENA, SI_TRACKED_SPI_PS_INPUT_ENA,
shader->ps.spi_ps_input_ena,
shader->ps.spi_ps_input_addr);
radeon_opt_set_context_reg(R_0286E0_SPI_BARYC_CNTL, SI_TRACKED_SPI_BARYC_CNTL,
shader->ps.spi_baryc_cntl);
radeon_opt_set_context_reg(R_0286D8_SPI_PS_IN_CONTROL, SI_TRACKED_SPI_PS_IN_CONTROL,
shader->ps.spi_ps_in_control);
radeon_opt_set_context_reg2(R_028710_SPI_SHADER_Z_FORMAT, SI_TRACKED_SPI_SHADER_Z_FORMAT,
@@ -2034,8 +2032,6 @@ static void gfx11_dgpu_emit_shader_ps(struct si_context *sctx, unsigned index)
shader->ps.spi_ps_input_ena);
gfx11_opt_set_context_reg(R_0286D0_SPI_PS_INPUT_ADDR, SI_TRACKED_SPI_PS_INPUT_ADDR,
shader->ps.spi_ps_input_addr);
gfx11_opt_set_context_reg(R_0286E0_SPI_BARYC_CNTL, SI_TRACKED_SPI_BARYC_CNTL,
shader->ps.spi_baryc_cntl);
gfx11_opt_set_context_reg(R_0286D8_SPI_PS_IN_CONTROL, SI_TRACKED_SPI_PS_IN_CONTROL,
shader->ps.spi_ps_in_control);
gfx11_opt_set_context_reg(R_028710_SPI_SHADER_Z_FORMAT, SI_TRACKED_SPI_SHADER_Z_FORMAT,
@@ -2060,8 +2056,6 @@ static void gfx12_emit_shader_ps(struct si_context *sctx, unsigned index)
shader->ps.spi_shader_z_format);
gfx12_opt_set_context_reg(R_028654_SPI_SHADER_COL_FORMAT, SI_TRACKED_SPI_SHADER_COL_FORMAT,
shader->ps.spi_shader_col_format);
gfx12_opt_set_context_reg(R_028658_SPI_BARYC_CNTL, SI_TRACKED_SPI_BARYC_CNTL,
shader->ps.spi_baryc_cntl);
gfx12_opt_set_context_reg(R_02865C_SPI_PS_INPUT_ENA, SI_TRACKED_SPI_PS_INPUT_ENA,
shader->ps.spi_ps_input_ena);
gfx12_opt_set_context_reg(R_028660_SPI_PS_INPUT_ADDR, SI_TRACKED_SPI_PS_INPUT_ADDR,
@@ -2190,27 +2184,6 @@ static void si_shader_ps(struct si_screen *sscreen, struct si_shader *shader)
if (sscreen->info.has_rbplus && !sscreen->info.rbplus_allowed)
shader->ps.db_shader_control |= S_02880C_DUAL_QUAD_DISABLE(1);
/* SPI_BARYC_CNTL.POS_FLOAT_LOCATION
* Possible values:
* 0 -> Position = pixel center
* 1 -> Position = pixel centroid
* 2 -> Position = at sample position
*
* From GLSL 4.5 specification, section 7.1:
* "The variable gl_FragCoord is available as an input variable from
* within fragment shaders and it holds the window relative coordinates
* (x, y, z, 1/w) values for the fragment. If multi-sampling, this
* value can be for any location within the pixel, or one of the
* fragment samples. The use of centroid does not further restrict
* this value to be inside the current primitive."
*
* Meaning that centroid has no effect and we can return anything within
* the pixel. Thus, return the value at sample position, because that's
* the most accurate one shaders can get.
*/
shader->ps.spi_baryc_cntl = S_0286E0_POS_FLOAT_LOCATION(2) |
S_0286E0_POS_FLOAT_ULC(info->base.fs.pixel_center_integer) |
S_0286E0_FRONT_FACE_ALL_BITS(0);
shader->ps.spi_shader_col_format = si_get_spi_shader_col_format(shader);
shader->ps.cb_shader_mask = ac_get_cb_shader_mask(shader->key.ps.part.epilog.spi_shader_col_format);
shader->ps.spi_ps_input_ena = shader->config.spi_ps_input_ena;