const float (*input_ptr)[4];
float (*input_data)[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS] = &shader->gs_input->data;
+ shader->llvm_prim_ids[shader->fetched_prim_count] =
+ shader->in_prim_idx;
+
input_ptr = shader->input;
for (i = 0; i < num_vertices; ++i) {
(const char *)input_ptr + (indices[i] * input_vertex_stride));
for (slot = 0, vs_slot = 0; slot < shader->info.num_inputs; ++slot) {
if (shader->info.input_semantic_name[slot] == TGSI_SEMANTIC_PRIMID) {
- (*input_data)[i][slot][0][prim_idx] = (float)shader->in_prim_idx;
- (*input_data)[i][slot][1][prim_idx] = (float)shader->in_prim_idx;
- (*input_data)[i][slot][2][prim_idx] = (float)shader->in_prim_idx;
- (*input_data)[i][slot][3][prim_idx] = (float)shader->in_prim_idx;
+ /* skip. we handle system values through gallivm */
} else {
vs_slot = draw_gs_get_input_index(
shader->info.input_semantic_name[slot],
shader->jit_context, shader->gs_input->data,
(struct vertex_header*)input,
input_primitives,
- shader->draw->instance_id);
+ shader->draw->instance_id,
+ shader->llvm_prim_ids);
return ret;
}
gs->llvm_emitted_primitives = align_malloc(vector_size, vector_size);
gs->llvm_emitted_vertices = align_malloc(vector_size, vector_size);
+ gs->llvm_prim_ids = align_malloc(vector_size, vector_size);
gs->fetch_outputs = llvm_fetch_gs_outputs;
gs->fetch_inputs = llvm_fetch_gs_input;
}
align_free(dgs->llvm_emitted_primitives);
align_free(dgs->llvm_emitted_vertices);
+ align_free(dgs->llvm_prim_ids);
align_free(dgs->gs_input);
}
struct gallivm_state *gallivm = variant->gallivm;
LLVMContextRef context = gallivm->context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
- LLVMTypeRef arg_types[5];
+ LLVMTypeRef arg_types[6];
LLVMTypeRef func_type;
LLVMValueRef variant_func;
LLVMValueRef context_ptr;
+ LLVMValueRef prim_id_ptr;
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
LLVMValueRef io_ptr, input_array, num_prims, mask_val;
LLVMValueRef consts_ptr;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];
struct lp_build_mask_context mask;
+ const struct tgsi_shader_info *gs_info = &variant->shader->base.info;
+ unsigned vector_length = variant->shader->base.vector_length;
memset(&system_values, 0, sizeof(system_values));
arg_types[2] = variant->vertex_header_ptr_type; /* vertex_header */
arg_types[3] = int32_type; /* num_prims */
arg_types[4] = int32_type; /* instance_id */
+ arg_types[5] = LLVMPointerType(
+ LLVMVectorType(int32_type, vector_length), 0); /* prim_id_ptr */
func_type = LLVMFunctionType(int32_type, arg_types, Elements(arg_types), 0);
io_ptr = LLVMGetParam(variant_func, 2);
num_prims = LLVMGetParam(variant_func, 3);
system_values.instance_id = LLVMGetParam(variant_func, 4);
+ prim_id_ptr = LLVMGetParam(variant_func, 5);
lp_build_name(context_ptr, "context");
lp_build_name(input_array, "input");
lp_build_name(io_ptr, "io");
lp_build_name(io_ptr, "num_prims");
lp_build_name(system_values.instance_id, "instance_id");
+ lp_build_name(prim_id_ptr, "prim_id_ptr");
variant->context_ptr = context_ptr;
variant->io_ptr = io_ptr;
gs_type.sign = TRUE; /* values are signed */
gs_type.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
gs_type.width = 32; /* 32-bit float */
- gs_type.length = variant->shader->base.vector_length;
+ gs_type.length = vector_length;
consts_ptr = draw_gs_jit_context_constants(variant->gallivm, context_ptr);
mask_val = generate_mask_value(variant, gs_type);
lp_build_mask_begin(&mask, gallivm, gs_type, mask_val);
+ if (gs_info->uses_primid) {
+ system_values.prim_id = LLVMBuildLoad(builder, prim_id_ptr, "prim_id");;
+ }
+
lp_build_tgsi_soa(variant->gallivm,
tokens,
gs_type,