nir/lower_subgroups: Lower ballot intrinsics to the specified bit size

Ballot intrinsics return a bitfield of subgroups.  In GLSL and some
SPIR-V extensions, they return a uint64_t.  In SPV_KHR_shader_ballot,
they return a uvec4.  Also, some back-ends would rather pass around
32-bit values because it's easier than messing with 64-bit all the time.
To solve this mess, we make nir_lower_subgroups take a new parameter
called ballot_bit_size and it lowers whichever thing it gets in from the
source language (uint64_t or uvec4) to a scalar with the specified
number of bits.  This replaces a chunk of the old lowering code.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
This commit is contained in:
Jason Ekstrand
2017-08-22 18:44:51 -07:00
parent 8c2bf020fd
commit a026458020
5 changed files with 84 additions and 31 deletions

View File

@@ -1854,8 +1854,6 @@ typedef struct nir_shader_compiler_options {
*/
bool use_interpolated_input_intrinsics;
unsigned max_subgroup_size;
unsigned max_unroll_iterations;
} nir_shader_compiler_options;
@@ -2486,6 +2484,7 @@ bool nir_lower_samplers_as_deref(nir_shader *shader,
const struct gl_shader_program *shader_program);
typedef struct nir_lower_subgroups_options {
uint8_t ballot_bit_size;
bool lower_to_scalar:1;
bool lower_vote_trivial:1;
bool lower_subgroup_masks:1;