diff options
author | Jason Ekstrand <[email protected]> | 2018-08-30 15:02:25 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-09-06 16:07:50 -0500 |
commit | 25efd787cfd842c0b0b900f35399e44a2e01ea39 (patch) | |
tree | be4df409f2242e2d16f10c3f8e15e6535b713769 /src/mesa/main/glspirv.c | |
parent | 1285f71d3e93f200cec0c321bb6e621d4aece7b3 (diff) |
compiler: Move double_inputs to gl_program::DualSlotInputs
Previously, we had two field in shader_info: double_inputs_read and
double_inputs. Presumably, the one was for all double inputs that are
read and the other is all that exist. However, because nir_gather_info
regenerates these two values, there is a possibility, if a variable gets
deleted, that the value of double_inputs could change over time. This
is a problem because double_inputs is used to remap the input locations
to a two-slot-per-dvec3/4 scheme for i965. If that mapping were to
change between glsl_to_nir and back-end state setup, we would fall over
when trying to map the NIR outputs back onto the GL location space.
This commit changes the way slot re-mapping works. Instead of the
double_inputs field in shader_info, it adds a DualSlotInputs bitfield to
gl_program. By having it in gl_program, we more easily guarantee that
NIR passes won't touch it after it's been set. It also makes more sense
to put it in a GL data structure since it's really a mapping from GL
slots to back-end and/or NIR slots and not really a NIR shader thing.
Tested-by: Alejandro Piñeiro <[email protected]> (ARB_gl_spirv tests)
Reviewed-by: Alejandro Piñeiro <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main/glspirv.c')
-rw-r--r-- | src/mesa/main/glspirv.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index 1c5b7dd17f3..c53fe0bd07c 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -182,20 +182,6 @@ _mesa_spirv_link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) prog->last_vert_prog = prog->_LinkedShaders[last_vert_stage - 1]->Program; } -static void -nir_compute_double_inputs(nir_shader *shader, - const nir_shader_compiler_options *options) -{ - nir_foreach_variable(var, &shader->inputs) { - if (glsl_type_is_dual_slot(glsl_without_array(var->type))) { - for (unsigned i = 0; i < glsl_count_attribute_slots(var->type, true); i++) { - uint64_t bitfield = BITFIELD64_BIT(var->data.location + i); - shader->info.vs.double_inputs |= bitfield; - } - } - } -} - nir_shader * _mesa_spirv_to_nir(struct gl_context *ctx, const struct gl_shader_program *prog, @@ -278,8 +264,10 @@ _mesa_spirv_to_nir(struct gl_context *ctx, NIR_PASS_V(nir, nir_split_per_member_structs); if (nir->info.stage == MESA_SHADER_VERTEX) { - nir_compute_double_inputs(nir, options); - nir_remap_attributes(nir, options); + uint64_t dual_slot_inputs = nir_get_dual_slot_attributes(nir); + if (options->vs_inputs_dual_locations) + nir_remap_dual_slot_attributes(nir, dual_slot_inputs); + linked_shader->Program->DualSlotInputs = dual_slot_inputs; } return nir; |