freedreno/ir3: add support for load_draw_id

This is part of adding VK_KHR_shader_draw_parameters for turnip.

IR3_DP_VTXID_BASE/IR3_DP_VTXCNT_MAX offsets are changed to match what
CP_DRAW_INDIRECT_MULTI requires.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5635>
This commit is contained in:
Jonathan Marek 2020-06-24 15:58:44 -04:00 committed by Marge Bot
parent 01799b3448
commit 16a9e233da
4 changed files with 15 additions and 4 deletions

View file

@ -1785,6 +1785,12 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr)
}
dst[0] = ctx->basevertex;
break;
case nir_intrinsic_load_draw_id:
if (!ctx->draw_id) {
ctx->draw_id = create_driver_param(ctx, IR3_DP_DRAWID);
}
dst[0] = ctx->draw_id;
break;
case nir_intrinsic_load_base_instance:
if (!ctx->base_instance) {
ctx->base_instance = create_driver_param(ctx, IR3_DP_INSTID_BASE);

View file

@ -83,7 +83,7 @@ struct ir3_context {
struct ir3_instruction *frag_face, *frag_coord;
/* For vertex shaders, keep track of the system values sources */
struct ir3_instruction *vertex_id, *basevertex, *instance_id, *base_instance;
struct ir3_instruction *vertex_id, *basevertex, *instance_id, *base_instance, *draw_id;
/* For fragment shaders: */
struct ir3_instruction *samp_id, *samp_mask_in;

View file

@ -514,8 +514,12 @@ ir3_setup_const_state(nir_shader *nir, struct ir3_shader_variant *v,
constoff += align(cnt, 4) / 4;
}
if (const_state->num_driver_params > 0)
if (const_state->num_driver_params > 0) {
/* offset cannot be 0 for vs params loaded by CP_DRAW_INDIRECT_MULTI */
if (v->type == MESA_SHADER_VERTEX && compiler->gpu_id >= 600)
constoff = MAX2(constoff, 1);
const_state->offsets.driver_param = constoff;
}
constoff += const_state->num_driver_params / 4;
if ((v->type == MESA_SHADER_VERTEX) &&

View file

@ -55,9 +55,10 @@ enum ir3_driver_param {
IR3_DP_CS_COUNT = 8, /* must be aligned to vec4 */
/* vertex shader driver params: */
IR3_DP_VTXID_BASE = 0,
IR3_DP_VTXCNT_MAX = 1,
IR3_DP_DRAWID = 0,
IR3_DP_VTXID_BASE = 1,
IR3_DP_INSTID_BASE = 2,
IR3_DP_VTXCNT_MAX = 3,
/* user-clip-plane components, up to 8x vec4's: */
IR3_DP_UCP0_X = 4,
/* .... */