aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2019-12-11 13:02:34 +1000
committerDave Airlie <[email protected]>2019-12-12 10:16:19 +1000
commit73f5e2d7ef7783027a5ecd71d1ada12eeaa21a10 (patch)
tree50c82ce5d5ffef113d64e98376581454ce978c50 /src
parent22a40dd1c1efe861b57a3ae43fa13481bea627fc (diff)
gallivm/draw: add support for draw_id system value.
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.h3
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c2
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir.c1
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c3
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi.h1
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c5
9 files changed, 19 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 4a3bada06e0..2c78e4709d9 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1622,7 +1622,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
struct gallivm_state *gallivm = variant->gallivm;
LLVMContextRef context = gallivm->context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
- LLVMTypeRef arg_types[11];
+ LLVMTypeRef arg_types[12];
unsigned num_arg_types = ARRAY_SIZE(arg_types);
LLVMTypeRef func_type;
LLVMValueRef context_ptr;
@@ -1689,6 +1689,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
arg_types[i++] = int32_type; /* vertex_id_offset */
arg_types[i++] = int32_type; /* start_instance */
arg_types[i++] = LLVMPointerType(int32_type, 0); /* fetch_elts */
+ arg_types[i++] = int32_type; /* draw_id */
func_type = LLVMFunctionType(LLVMInt8TypeInContext(context),
arg_types, num_arg_types, 0);
@@ -1723,6 +1724,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
vertex_id_offset = LLVMGetParam(variant_func, 8);
system_values.base_instance = LLVMGetParam(variant_func, 9);
fetch_elts = LLVMGetParam(variant_func, 10);
+ system_values.draw_id = LLVMGetParam(variant_func, 11);
lp_build_name(context_ptr, "context");
lp_build_name(io_ptr, "io");
@@ -1735,6 +1737,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
lp_build_name(vertex_id_offset, "vertex_id_offset");
lp_build_name(system_values.base_instance, "start_instance");
lp_build_name(fetch_elts, "fetch_elts");
+ lp_build_name(system_values.draw_id, "draw_id");
/*
* Function body
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h
index 914f783fd00..6edc89b63ba 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -328,7 +328,8 @@ typedef boolean
unsigned instance_id,
unsigned vertex_id_offset,
unsigned start_instance,
- const unsigned *fetch_elts);
+ const unsigned *fetch_elts,
+ unsigned draw_id);
typedef int
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 86e90c76f88..0fd0caab31b 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -196,6 +196,7 @@ struct draw_context
int eltBias;
unsigned min_index;
unsigned max_index;
+ unsigned drawid;
/** vertex arrays */
struct draw_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index f6918976310..24ac0542726 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -485,6 +485,7 @@ draw_vbo(struct draw_context *draw,
draw->pt.user.min_index = info->min_index;
draw->pt.user.max_index = info->max_index;
draw->pt.user.eltSize = info->index_size ? draw->pt.user.eltSizeIB : 0;
+ draw->pt.user.drawid = info->drawid;
if (0)
debug_printf("draw_vbo(mode=%u start=%u count=%u):\n",
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
index 0eeaf780af0..c19eda2ede4 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
@@ -429,7 +429,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
draw->instance_id,
vid_base,
draw->start_instance,
- elts);
+ elts, draw->pt.user.drawid);
/* Finished with fetch and vs:
*/
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 547161ba7fe..e5fe9eec6eb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -1167,6 +1167,7 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base,
case nir_intrinsic_load_num_work_groups:
case nir_intrinsic_load_invocation_id:
case nir_intrinsic_load_front_face:
+ case nir_intrinsic_load_draw_id:
bld_base->sysval_intrin(bld_base, instr, result);
break;
case nir_intrinsic_discard_if:
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
index a95af23ae0d..b0c034645f3 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
@@ -949,6 +949,9 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base,
case nir_intrinsic_load_front_face:
result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.front_facing);
break;
+ case nir_intrinsic_load_draw_id:
+ result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.draw_id);
+ break;
default:
break;
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index d82044f770f..5019c1dd8f6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -171,6 +171,7 @@ struct lp_bld_tgsi_system_values {
LLVMValueRef prim_id;
LLVMValueRef basevertex;
LLVMValueRef invocation_id;
+ LLVMValueRef draw_id;
LLVMValueRef thread_id;
LLVMValueRef block_id;
LLVMValueRef grid_size;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index a4606a67615..5d18cfba4ac 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -1345,6 +1345,11 @@ emit_fetch_system_value(
res = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.front_facing);
break;
+ case TGSI_SEMANTIC_DRAWID:
+ res = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.draw_id);
+ atype = TGSI_TYPE_UNSIGNED;
+ break;
+
default:
assert(!"unexpected semantic in emit_fetch_system_value");
res = bld_base->base.zero;