[Mesa-stable] [Mesa-dev] [PATCH 2/5] st/glsl_to_tgsi: fix conditional assignments to packed shader outputs

Nicolai Hähnle nicolai.haehnle at amd.com
Tue Sep 26 19:33:33 UTC 2017


On 26.09.2017 20:34, Ian Romanick wrote:
> I'm hoping to land my patch series that removes ir_assignment::condition
> either today or tomorrow.  I believe that series deletes all of this
> code... but this patch would still be useful for stable.

Yep, that series is much appreciated. If it weren't for stable, I would 
have just waited :)

Cheers,
Nicolai


> On 09/26/2017 07:42 AM, Nicolai Hähnle wrote:
>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>
>> Overriding the default (no-op) swizzle is clearly counter-productive,
>> since the whole point is putting the destination register as one of
>> the source operands so that it remains unmodified when the assignment
>> condition is false.
>>
>> Fragment depth and stencil outputs are a special case due to how their
>> source swizzles are manipulated in translate_src when compiling to
>> TGSI.
>>
>> Fixes dEQP-GLES2.functional.shaders.conditionals.if.*_vertex
>> Cc: mesa-stable at lists.freedesktop.org
>> ---
>>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 10 +++++++++-
>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> index f4870a1c606..0daf5a14285 100644
>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> @@ -2890,21 +2890,29 @@ glsl_to_tgsi_visitor::emit_block_mov(ir_assignment *ir, const struct glsl_type *
>>         }
>>         return;
>>      }
>>   
>>      assert(type->is_scalar() || type->is_vector());
>>   
>>      l->type = type->base_type;
>>      r->type = type->base_type;
>>      if (cond) {
>>         st_src_reg l_src = st_src_reg(*l);
>> -      l_src.swizzle = swizzle_for_size(type->vector_elements);
>> +
>> +      if (l_src.file == PROGRAM_OUTPUT &&
>> +          this->prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
>> +          (l_src.index == FRAG_RESULT_DEPTH || l_src.index == FRAG_RESULT_STENCIL)) {
>> +         /* This is a special case because the source swizzles will be shifted
>> +          * later to account for the difference between GLSL (where they're
>> +          * plain floats) and TGSI (where they're Z and Y components). */
>> +         l_src.swizzle = SWIZZLE_XXXX;
>> +      }
>>   
>>         if (native_integers) {
>>            emit_asm(ir, TGSI_OPCODE_UCMP, *l, *cond,
>>                 cond_swap ? l_src : *r,
>>                 cond_swap ? *r : l_src);
>>         } else {
>>            emit_asm(ir, TGSI_OPCODE_CMP, *l, *cond,
>>                 cond_swap ? l_src : *r,
>>                 cond_swap ? *r : l_src);
>>         }
>>
> 



More information about the mesa-stable mailing list