From: Charmaine Lee Date: Wed, 4 Oct 2017 23:51:35 +0000 (-0700) Subject: svga: fix starting index for system values X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=be1993d6eddcb6314b71037ca40af62923aa0174;p=mesa.git svga: fix starting index for system values Currently, the starting index for system values is assigned to the next index after the highest index of the tgsi declared input registers. But the tgsi index might be different from the actual assigned index, hence this might cause overlap of indices. With this patch, the shader linker keeps track of the highest index of the translated input registers, and the next index will be used for the starting index for system values. Fixes SHIM errors running arb_copy_image-formats on SM4_1 device. Reviewed-by: Brian Paul --- diff --git a/src/gallium/drivers/svga/svga_link.c b/src/gallium/drivers/svga/svga_link.c index 9c1df0c7f3c..0bf40d153b7 100644 --- a/src/gallium/drivers/svga/svga_link.c +++ b/src/gallium/drivers/svga/svga_link.c @@ -96,11 +96,13 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, linkage->input_map[i] = j; } } + linkage->input_map_max = free_slot - 1; /* Debug */ if (SVGA_DEBUG & DEBUG_TGSI) { unsigned reg = 0; - debug_printf("### linkage info:\n"); + debug_printf("### linkage info: num_inputs=%d input_map_max=%d\n", + linkage->num_inputs, linkage->input_map_max); for (i = 0; i < linkage->num_inputs; i++) { diff --git a/src/gallium/drivers/svga/svga_link.h b/src/gallium/drivers/svga/svga_link.h index 724c61194a2..c21686eef59 100644 --- a/src/gallium/drivers/svga/svga_link.h +++ b/src/gallium/drivers/svga/svga_link.h @@ -9,6 +9,7 @@ struct svga_context; struct shader_linkage { unsigned num_inputs; + unsigned input_map_max; /* highest index of mapped inputs */ ubyte input_map[PIPE_MAX_SHADER_INPUTS]; }; diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index 2dc870ffef0..7422db247ae 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -1890,7 +1890,7 @@ alloc_immediate_int4(struct svga_shader_emitter_v10 *emit, static unsigned alloc_system_value_index(struct svga_shader_emitter_v10 *emit, unsigned index) { - const unsigned n = emit->info.file_max[TGSI_FILE_INPUT] + 1 + index; + const unsigned n = emit->linkage.input_map_max + 1 + index; assert(index < ARRAY_SIZE(emit->system_value_indexes)); emit->system_value_indexes[index] = n; return n; @@ -2377,8 +2377,8 @@ emit_system_value_declaration(struct svga_shader_emitter_v10 *emit, * index as the argument. See emit_sample_position_instructions(). */ assert(emit->version >= 41); - index = alloc_system_value_index(emit, index); emit->fs.sample_pos_sys_index = index; + index = alloc_system_value_index(emit, index); break; default: debug_printf("unexpected sytem value semantic index %u\n", @@ -6992,6 +6992,13 @@ svga_tgsi_vgpu10_translate(struct svga_context *svga, svga_link_shaders(&vs->base.info, &emit->info, &emit->linkage); } + /* Since vertex shader does not need to go through the linker to + * establish the input map, we need to make sure the highest index + * of input registers is set properly here. + */ + emit->linkage.input_map_max = MAX2((int)emit->linkage.input_map_max, + emit->info.file_max[TGSI_FILE_INPUT]); + determine_clipping_mode(emit); if (unit == PIPE_SHADER_GEOMETRY || unit == PIPE_SHADER_VERTEX) {