[Mesa-dev] [PATCH] draw: initialize shader inputs

Roland Scheidegger sroland at vmware.com
Thu Oct 13 00:19:42 UTC 2016


Am 12.10.2016 um 18:12 schrieb Marek Olšák:
> On Wed, Oct 12, 2016 at 12:04 AM,  <sroland at vmware.com> wrote:
>> From: Roland Scheidegger <sroland at vmware.com>
>>
>> This should make the code more robust if a shader tries to use inputs which
>> aren't defined by the vertex element layout (which usually shouldn't happen).
>>
>> No piglit change.
>> ---
>>  src/gallium/auxiliary/draw/draw_llvm.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
>> index 87951fa..4270a8f 100644
>> --- a/src/gallium/auxiliary/draw/draw_llvm.c
>> +++ b/src/gallium/auxiliary/draw/draw_llvm.c
>> @@ -1705,6 +1705,13 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
>>        lp_build_printf(gallivm, " --- io %d = %p, loop counter %d\n",
>>                        io_itr, io, lp_loop.counter);
>>  #endif
>> +
>> +      for (j = draw->pt.nr_vertex_elements; j < PIPE_MAX_SHADER_INPUTS; j++) {
>> +         for (i = 0; i < TGSI_NUM_CHANNELS; i++) {
>> +            inputs[j][i] = lp_build_zero(gallivm, vs_type);
>> +         }
>> +      }
> 
> It's better to use LLVMGetUndef for uninitialized inputs and temps.
> That can eliminate more code than initializing everything to 0.
> (radeonsi uses undef)

Yes, that's true. I used zeros on purpose though for dx10 needs, albeit
I'm not sure if it's strictly necessary actually (inputs where there's
no buffer bound need to read as zero, however in this case here there's
actually a non-matching input layout, I'm not entirely sure this also
really needs to return zeros). In any case, it shouldn't usually matter
(as the additional code should disappear completely).

Roland



More information about the mesa-dev mailing list