From 3c71c42827766f66c300cf1f32679c33c54950c8 Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Fri, 21 Jul 2017 22:42:30 -0700 Subject: [PATCH] svga: emit sampler constants only if sampler view exists It is possible to have holes in the shader emitter's sampler_target array. 0 sampler_target does not necessarily mean there is no sampler view specified since texture buffer target has the value 0. With this patch, a sampler_view array is added to the shader emitter structure to specify if there is a sampler view for each texture unit. Only if there is a sampler view, we will emit constant for texcoord scale factor or texture buffer size for that sampler view. Fixes a rendering issue with Turbine after commit 1020e960440. Reviewed-by: Brian Paul --- src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index a864616..30046ca 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -134,6 +134,7 @@ struct svga_shader_emitter_v10 /* Samplers */ unsigned num_samplers; + boolean sampler_view[PIPE_MAX_SAMPLERS]; /**< True if sampler view exists*/ ubyte sampler_target[PIPE_MAX_SAMPLERS]; /**< TGSI_TEXTURE_x */ ubyte sampler_return_type[PIPE_MAX_SAMPLERS]; /**< TGSI_RETURN_TYPE_x */ @@ -2322,6 +2323,7 @@ emit_vgpu10_declaration(struct svga_shader_emitter_v10 *emit, emit->sampler_target[unit] = decl->SamplerView.Resource; /* Note: we can ignore YZW return types for now */ emit->sampler_return_type[unit] = decl->SamplerView.ReturnTypeX; + emit->sampler_view[unit] = TRUE; } return TRUE; @@ -2886,14 +2888,17 @@ emit_constant_declaration(struct svga_shader_emitter_v10 *emit) for (i = 0; i < emit->num_samplers; i++) { - /* Texcoord scale factors for RECT textures */ - if (emit->key.tex[i].unnormalized) { - emit->texcoord_scale_index[i] = total_consts++; - } + if (emit->sampler_view[i]) { + + /* Texcoord scale factors for RECT textures */ + if (emit->key.tex[i].unnormalized) { + emit->texcoord_scale_index[i] = total_consts++; + } - /* Texture buffer sizes */ - if (emit->sampler_target[i] == TGSI_TEXTURE_BUFFER) { - emit->texture_buffer_size_index[i] = total_consts++; + /* Texture buffer sizes */ + if (emit->sampler_target[i] == TGSI_TEXTURE_BUFFER) { + emit->texture_buffer_size_index[i] = total_consts++; + } } } -- 2.7.4