[Mesa-dev] [PATCH v2 19/28] glsl: Support double inouts

Ilia Mirkin imirkin at alum.mit.edu
Sun Feb 8 00:12:30 PST 2015


On Fri, Feb 6, 2015 at 3:54 AM, Ian Romanick <idr at freedesktop.org> wrote:
> On 02/06/2015 06:56 AM, Ilia Mirkin wrote:
>> From: Dave Airlie <airlied at gmail.com>
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> ---
>>  src/glsl/ir_set_program_inouts.cpp | 28 +++++++++++++++++++++++++---
>>  1 file changed, 25 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp
>> index 97ead75..b38742c 100644
>> --- a/src/glsl/ir_set_program_inouts.cpp
>> +++ b/src/glsl/ir_set_program_inouts.cpp
>> @@ -81,6 +81,16 @@ is_shader_inout(ir_variable *var)
>>            var->data.mode == ir_var_system_value;
>>  }
>>
>> +static inline bool
>> +is_dvec34_inout(ir_variable *var)
>> +{
>> +   const glsl_type *type = var->type->without_array();
>> +   if (type == glsl_type::dvec4_type || type == glsl_type::dvec3_type)
>> +      return true;
>> +
>> +   return false;
>
> Why not just
>
>    const glsl_type *const type = var->type->without_array();
>    return type == glsl_type::dvec4_type || type == glsl_type::dvec3_type;

Because the function was structured differently before... I added the
->without_array thing on the last iteration, but didn't do the final
cleanup. Done now.

>
> It may also be better to name this something different.  We'll do the
> same "doubling" if / when we add support for GL_AMD_gpu_shader_int64.

OK, changing to is_dual_slot().

>
>> +}
>> +
>>  static void
>>  mark(struct gl_program *prog, ir_variable *var, int offset, int len,
>>       bool is_fragment_shader)
>> @@ -94,19 +104,31 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
>>      */
>>
>>     for (int i = 0; i < len; i++) {
>> +      /* XXX Should it be i * 2 for dvec3/4? */
>> +      int idx = var->data.location + var->data.index + offset + i;
>
> I believe it should be i * 2.  Otherwise elements 0 and 1 of a dvec4
> array will partially overlap.  That seems... bad.

OK, thanks for confirming. I noticed it on my own code read, but
wasn't 100% sure.

>
>>        GLbitfield64 bitfield =
>> -         BITFIELD64_BIT(var->data.location + var->data.index + offset + i);
>> +         BITFIELD64_BIT(idx);
>> +
>> +      /* dvec3 and dvec4 take up 2 slots */
>> +      if (is_dvec34_inout(var))
>> +         bitfield |= bitfield << 1;
>>        if (var->data.mode == ir_var_shader_in) {
>>        prog->InputsRead |= bitfield;
>>           if (is_fragment_shader) {
>>              gl_fragment_program *fprog = (gl_fragment_program *) prog;
>> -            fprog->InterpQualifier[var->data.location +
>> -                                   var->data.index + offset + i] =
>> +            fprog->InterpQualifier[idx] =
>>                 (glsl_interp_qualifier) var->data.interpolation;
>>              if (var->data.centroid)
>>                 fprog->IsCentroid |= bitfield;
>>              if (var->data.sample)
>>                 fprog->IsSample |= bitfield;
>> +
>> +            /* Set the InterpQualifier of the next slot to the same as the
>> +             * current one, since dvec3 and dvec4 spans 2 slots.
>> +             */
>> +            if (is_dvec34_inout(var))
>> +               fprog->InterpQualifier[idx + 1] =
>> +                  (glsl_interp_qualifier) var->data.interpolation;
>>           }
>>        } else if (var->data.mode == ir_var_system_value) {
>>           prog->SystemValuesRead |= bitfield;
>>
>


More information about the mesa-dev mailing list