From 7c56a68c8bd45208ef7c7e6e61bfeb6147ded4b6 Mon Sep 17 00:00:00 2001 From: Jose Maria Casanova Crespo Date: Mon, 19 Aug 2019 15:05:25 +0200 Subject: [PATCH] tgsi_to_nir: only update TGSI properties of the current shader stage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The implementation introduced in "tgsi_to_nir: be careful about not losing any TGSI properties silently (v2)" updates all the TGSI properties, but it didn't take into account that the shader_info structure uses a union to store the different attributes for each shader stage. Now we only update the attributes if they affect current shader stage, avoiding to overwrite members of the union that should be overwritten. This has created hundreds of regressions in v3d. For example the TGSI_PROPERTY_VS_BLIT_SGPRS_AMD was overwritting the same position used by TGSI_PROPERY_CS_FIXED_BLOCK_DEPTH. Fixes: e3003651978 ("tgsi_to_nir: be careful about not losing any TGSI properties silently (v2)") Reviewed-by: Marek Olšák --- src/gallium/auxiliary/nir/tgsi_to_nir.c | 27 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index 1fc886991f2..79d04fae9d9 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -2464,34 +2464,43 @@ ttn_compile_init(const void *tgsi_tokens, case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS: break; /* handled in ttn_emit_declaration */ case TGSI_PROPERTY_FS_COORD_ORIGIN: - s->info.fs.origin_upper_left = value == TGSI_FS_COORD_ORIGIN_UPPER_LEFT; + if (s->info.stage == MESA_SHADER_FRAGMENT) + s->info.fs.origin_upper_left = value == TGSI_FS_COORD_ORIGIN_UPPER_LEFT; break; case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: - s->info.fs.pixel_center_integer = value == TGSI_FS_COORD_PIXEL_CENTER_INTEGER; + if (s->info.stage == MESA_SHADER_FRAGMENT) + s->info.fs.pixel_center_integer = value == TGSI_FS_COORD_PIXEL_CENTER_INTEGER; break; case TGSI_PROPERTY_FS_DEPTH_LAYOUT: - s->info.fs.depth_layout = ttn_get_depth_layout(value); + if (s->info.stage == MESA_SHADER_FRAGMENT) + s->info.fs.depth_layout = ttn_get_depth_layout(value); break; case TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION: - s->info.vs.window_space_position = value; + if (s->info.stage == MESA_SHADER_VERTEX) + s->info.vs.window_space_position = value; break; case TGSI_PROPERTY_NEXT_SHADER: s->info.next_stage = tgsi_processor_to_shader_stage(value); break; case TGSI_PROPERTY_VS_BLIT_SGPRS_AMD: - s->info.vs.blit_sgprs_amd = value; + if (s->info.stage == MESA_SHADER_VERTEX) + s->info.vs.blit_sgprs_amd = value; break; case TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH: - s->info.cs.local_size[0] = value; + if (s->info.stage == MESA_SHADER_COMPUTE) + s->info.cs.local_size[0] = value; break; case TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT: - s->info.cs.local_size[1] = value; + if (s->info.stage == MESA_SHADER_COMPUTE) + s->info.cs.local_size[1] = value; break; case TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH: - s->info.cs.local_size[2] = value; + if (s->info.stage == MESA_SHADER_COMPUTE) + s->info.cs.local_size[2] = value; break; case TGSI_PROPERTY_CS_USER_DATA_COMPONENTS_AMD: - s->info.cs.user_data_components_amd = value; + if (s->info.stage == MESA_SHADER_COMPUTE) + s->info.cs.user_data_components_amd = value; break; default: if (value) { -- 2.30.2