instead of keeping the IR indefinitely in st_vp_variant.
This trivially fixes Selection/Feedback/RasterPos for NIR.
Reviewed-by: Dave Airlie <airlied@redhat.com>
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
/* must get these after state validation! */
- vp = (struct st_vertex_program *)st->vp;
- vp_variant = st->vp_variant;
-
- struct pipe_shader_state state = {0};
- state.type = PIPE_SHADER_IR_TGSI;
- state.tokens = vp_variant->tokens;
+ struct st_common_variant_key key;
+ /* We have to use memcpy to make sure that all bits are copied. */
+ memcpy(&key, &st->vp_variant->key, sizeof(key));
+ key.is_draw_shader = true;
- if (!vp_variant->draw_shader) {
- vp_variant->draw_shader = draw_create_vertex_shader(draw, &state);
- }
+ vp = (struct st_vertex_program *)st->vp;
+ vp_variant = st_get_vp_variant(st, st->vp, &key);
/*
* Set up the draw module's state.
draw_set_viewport_states(draw, 0, 1, &st->state.viewport[0]);
draw_set_clip_state(draw, &st->state.clip);
draw_set_rasterizer_state(draw, &st->state.rasterizer, NULL);
- draw_bind_vertex_shader(draw, vp_variant->draw_shader);
+ draw_bind_vertex_shader(draw, vp_variant->base.driver_shader);
set_feedback_vertex_format(ctx);
/* Must setup these after state validation! */
#include "program/programopt.h"
#include "compiler/nir/nir.h"
+#include "draw/draw_context.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
}
}
- if (target == GL_VERTEX_PROGRAM_ARB) {
- struct st_vp_variant *vpv = (struct st_vp_variant *)v;
-
- if (vpv->draw_shader)
- draw_delete_vertex_shader( st->draw, vpv->draw_shader );
-
- if (vpv->tokens)
- ureg_free_tokens(vpv->tokens);
- }
-
free(v);
}
if (ST_DEBUG & DEBUG_PRINT_IR)
nir_print_shader(state.ir.nir, stderr);
- vpv->base.driver_shader = pipe->create_vs_state(pipe, &state);
-
- /* When generating a NIR program, we usually don't have TGSI tokens.
- * However, we do create them for ARB_vertex_program / fixed-function VS
- * programs which we may need to use with the draw module for legacy
- * feedback/select emulation. If they exist, copy them.
- *
- * TODO: Lowering for shader variants is not applied to TGSI when
- * generating a NIR shader.
- */
- if (stvp->state.tokens)
- vpv->tokens = tgsi_dup_tokens(stvp->state.tokens);
+ if (key->is_draw_shader)
+ vpv->base.driver_shader = draw_create_vertex_shader(st->draw, &state);
+ else
+ vpv->base.driver_shader = pipe->create_vs_state(pipe, &state);
return vpv;
}
if (ST_DEBUG & DEBUG_PRINT_IR)
tgsi_dump(state.tokens, 0);
- vpv->base.driver_shader = pipe->create_vs_state(pipe, &state);
- /* Save this for selection/feedback/rasterpos. */
- vpv->tokens = state.tokens;
+ if (key->is_draw_shader)
+ vpv->base.driver_shader = draw_create_vertex_shader(st->draw, &state);
+ else
+ vpv->base.driver_shader = pipe->create_vs_state(pipe, &state);
+
return vpv;
}
/* for user-defined clip-planes */
uint8_t lower_ucp;
+
+ /* Whether st_variant::driver_shader is for the draw module,
+ * not for the driver.
+ */
+ bool is_draw_shader;
};
*/
struct st_common_variant_key key;
- /**
- * The shader variant saved for the draw module to later emulate
- * selection/feedback/rasterpos.
- */
- const struct tgsi_token *tokens;
-
- /** For using our private draw module (glRasterPos) */
- struct draw_vertex_shader *draw_shader;
-
/** similar to that in st_vertex_program, but with edgeflags info too */
GLuint num_inputs;