[Mesa-dev] [PATCH 5/9] glsl: use bitwise operators in varying_matches::compute_packing_class()
Brian Paul
brianp at vmware.com
Tue Dec 19 03:50:52 UTC 2017
On 12/18/2017 06:49 PM, Timothy Arceri wrote:
> On 19/12/17 07:47, Brian Paul wrote:
>> The mix of bitwise operators with * and + to compute the packing_class
>> values was a little weird. Just use bitwise ops instead.
>> ---
>> src/compiler/glsl/link_varyings.cpp | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/compiler/glsl/link_varyings.cpp
>> b/src/compiler/glsl/link_varyings.cpp
>> index 7821b1e..17d8653 100644
>> --- a/src/compiler/glsl/link_varyings.cpp
>> +++ b/src/compiler/glsl/link_varyings.cpp
>> @@ -1982,11 +1982,12 @@ varying_matches::compute_packing_class(const
>> ir_variable *var)
>> *
>> * Therefore, the packing class depends only on the interpolation
>> type.
>> */
>> - unsigned packing_class = var->data.centroid | (var->data.sample <<
>> 1) |
>> + unsigned packing_class = (var->data.centroid << 0) |
>> + (var->data.sample << 1) |
>> (var->data.patch << 2) |
>> (var->data.must_be_shader_input << 3);
>> - packing_class *= 8;
>> - packing_class += var->is_interpolation_flat()
>> + packing_class <<= 3;
>> + packing_class |= var->is_interpolation_flat()
>> ? unsigned(INTERP_MODE_FLAT) : var->data.interpolation;
>
> Should we add assert(var->data.interpolation < 7); here somewhere?
Yeah, and looking at the code again, the whole thing could be expressed
better. v2 coming.
>
> Either way series:
>
> Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Thanks.
>
>> return packing_class;
>> }
>>
More information about the mesa-dev
mailing list