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/drivers/dri/i965 | |
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/drivers/dri/i965')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_draw_upload.c | 21 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/genX_state_upload.c | 1 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index bc9b2566deb..dc3022bc417 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -29,6 +29,7 @@ #include "main/enums.h" #include "main/macros.h" #include "main/glformats.h" +#include "nir.h" #include "brw_draw.h" #include "brw_defines.h" @@ -454,10 +455,14 @@ brw_prepare_vertices(struct brw_context *brw) { const struct gen_device_info *devinfo = &brw->screen->devinfo; struct gl_context *ctx = &brw->ctx; + /* BRW_NEW_VERTEX_PROGRAM */ + const struct gl_program *vp = brw->programs[MESA_SHADER_VERTEX]; /* BRW_NEW_VS_PROG_DATA */ const struct brw_vs_prog_data *vs_prog_data = brw_vs_prog_data(brw->vs.base.prog_data); - GLbitfield64 vs_inputs = vs_prog_data->inputs_read; + GLbitfield64 vs_inputs = + nir_get_single_slot_attribs_mask(vs_prog_data->inputs_read, + vp->DualSlotInputs); const unsigned char *ptr = NULL; GLuint interleaved = 0; unsigned int min_index = brw->vb.min_index + brw->basevertex; @@ -486,16 +491,12 @@ brw_prepare_vertices(struct brw_context *brw) /* Accumulate the list of enabled arrays. */ brw->vb.nr_enabled = 0; while (vs_inputs) { - GLuint first = ffsll(vs_inputs) - 1; - assert (first < 64); - GLuint index = - first - DIV_ROUND_UP(_mesa_bitcount_64(vs_prog_data->double_inputs_read & - BITFIELD64_MASK(first)), 2); + const unsigned index = ffsll(vs_inputs) - 1; + assert(index < 64); + struct brw_vertex_element *input = &brw->vb.inputs[index]; - input->is_dual_slot = (vs_prog_data->double_inputs_read & BITFIELD64_BIT(first)) != 0; - vs_inputs &= ~BITFIELD64_BIT(first); - if (input->is_dual_slot) - vs_inputs &= ~BITFIELD64_BIT(first + 1); + input->is_dual_slot = (vp->DualSlotInputs & BITFIELD64_BIT(index)) != 0; + vs_inputs &= ~BITFIELD64_BIT(index); brw->vb.enabled[brw->vb.nr_enabled++] = input; } diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c index 09a42e44b08..740cb0c4d2e 100644 --- a/src/mesa/drivers/dri/i965/genX_state_upload.c +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c @@ -933,6 +933,7 @@ static const struct brw_tracked_state genX(vertices) = { .mesa = _NEW_POLYGON, .brw = BRW_NEW_BATCH | BRW_NEW_BLORP | + BRW_NEW_VERTEX_PROGRAM | BRW_NEW_VERTICES | BRW_NEW_VS_PROG_DATA, }, |