diff options
author | Brian Paul <[email protected]> | 2017-12-15 14:30:26 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2017-12-20 11:23:16 -0700 |
commit | 76fc24ba8d71cdbb76a354d6fd7b893139222d70 (patch) | |
tree | 44dcaf031212a10771c6eb379a0b3c5ff3b8ca10 /src | |
parent | cd7705de443d34aeddb3a68cc8d6b762a2808261 (diff) |
glsl: use bitwise operators in varying_matches::compute_packing_class()
The mix of bitwise operators with * and + to compute the packing_class
values was a little weird. Just use bitwise ops instead.
v2: add assertion to make sure interpolation bits fit without collision,
per Timothy. Basically, rewrite function to be simpler.
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/link_varyings.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp index 7821b1ec816..5d398894d71 100644 --- a/src/compiler/glsl/link_varyings.cpp +++ b/src/compiler/glsl/link_varyings.cpp @@ -1982,12 +1982,17 @@ 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) | - (var->data.patch << 2) | - (var->data.must_be_shader_input << 3); - packing_class *= 8; - packing_class += var->is_interpolation_flat() + const unsigned interp = var->is_interpolation_flat() ? unsigned(INTERP_MODE_FLAT) : var->data.interpolation; + + assert(interp < (1 << 3)); + + const unsigned packing_class = (interp << 0) | + (var->data.centroid << 3) | + (var->data.sample << 4) | + (var->data.patch << 5) | + (var->data.must_be_shader_input << 6); + return packing_class; } |