elem_types[DRAW_JIT_TEXTURE_BORDER_COLOR] =
LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
-#if HAVE_LLVM >= 0x0300
- texture_type = LLVMStructCreateNamed(gallivm->context, struct_name);
- LLVMStructSetBody(texture_type, elem_types,
- Elements(elem_types), 0);
-#else
texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
+#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, texture_type);
/* Make sure the target's struct layout cache doesn't return
elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */
elem_types[4] = LLVMArrayType(texture_type,
PIPE_MAX_VERTEX_SAMPLERS); /* textures */
-#if HAVE_LLVM >= 0x0300
- context_type = LLVMStructCreateNamed(gallivm->context, struct_name);
- LLVMStructSetBody(context_type, elem_types,
- Elements(elem_types), 0);
-#else
context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
+#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, context_type);
LLVMInvalidateStructLayout(gallivm->target, context_type);
elem_types[2] =
elem_types[3] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */
-#if HAVE_LLVM >= 0x0300
- vb_type = LLVMStructCreateNamed(gallivm->context, struct_name);
- LLVMStructSetBody(vb_type, elem_types,
- Elements(elem_types), 0);
-#else
vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
+#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, vb_type);
LLVMInvalidateStructLayout(gallivm->target, vb_type);
elem_types[DRAW_JIT_VERTEX_PRE_CLIP_POS] = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
elem_types[DRAW_JIT_VERTEX_DATA] = LLVMArrayType(elem_types[1], data_elems);
-#if HAVE_LLVM >= 0x0300
- vertex_header = LLVMStructCreateNamed(gallivm->context, struct_name);
- LLVMStructSetBody(vertex_header, elem_types,
- Elements(elem_types), 0);
-#else
vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
+#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
LLVMInvalidateStructLayout(gallivm->target, vertex_header);
target, vertex_header,
DRAW_JIT_VERTEX_DATA);
+ assert(LLVMABISizeOfType(target, vertex_header) ==
+ offsetof(struct vertex_header, data[data_elems]));
+
return vertex_header;
}
LLVMBuilderRef builder,
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
- LLVMValueRef system_values_array,
+ const struct lp_bld_tgsi_system_values *system_values,
LLVMValueRef context_ptr,
struct lp_build_sampler_soa *draw_sampler,
boolean clamp_vertex_color)
vs_type,
NULL /*struct lp_build_mask_context *mask*/,
consts_ptr,
- system_values_array,
+ system_values,
NULL /*pos*/,
inputs,
outputs,
LLVMValueRef count, fetch_elts, fetch_count;
LLVMValueRef stride, step, io_itr;
LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr;
- LLVMValueRef instance_id;
- LLVMValueRef system_values_array;
LLVMValueRef zero = lp_build_const_int32(gallivm, 0);
LLVMValueRef one = lp_build_const_int32(gallivm, 1);
struct draw_context *draw = llvm->draw;
const unsigned pos = draw_current_shader_position_output(llvm->draw);
const unsigned cv = draw_current_shader_clipvertex_output(llvm->draw);
boolean have_clipdist = FALSE;
+ struct lp_bld_tgsi_system_values system_values;
+
+ memset(&system_values, 0, sizeof(system_values));
arg_types[0] = get_context_ptr_type(llvm); /* context */
arg_types[1] = get_vertex_header_ptr_type(llvm); /* vertex_header */
LLVMAddAttribute(LLVMGetParam(variant_func, i),
LLVMNoAliasAttribute);
- context_ptr = LLVMGetParam(variant_func, 0);
- io_ptr = LLVMGetParam(variant_func, 1);
- vbuffers_ptr = LLVMGetParam(variant_func, 2);
- stride = LLVMGetParam(variant_func, 5);
- vb_ptr = LLVMGetParam(variant_func, 6);
- instance_id = LLVMGetParam(variant_func, 7);
+ context_ptr = LLVMGetParam(variant_func, 0);
+ io_ptr = LLVMGetParam(variant_func, 1);
+ vbuffers_ptr = LLVMGetParam(variant_func, 2);
+ stride = LLVMGetParam(variant_func, 5);
+ vb_ptr = LLVMGetParam(variant_func, 6);
+ system_values.instance_id = LLVMGetParam(variant_func, 7);
lp_build_name(context_ptr, "context");
lp_build_name(io_ptr, "io");
lp_build_name(vbuffers_ptr, "vbuffers");
lp_build_name(stride, "stride");
lp_build_name(vb_ptr, "vb");
- lp_build_name(instance_id, "instance_id");
+ lp_build_name(system_values.instance_id, "instance_id");
if (elts) {
fetch_elts = LLVMGetParam(variant_func, 3);
lp_build_context_init(&bld, gallivm, lp_type_int(32));
- system_values_array = lp_build_system_values_array(gallivm, vs_info,
- instance_id, NULL);
-
/* function will return non-zero i32 value if any clipped vertices */
ret_ptr = lp_build_alloca(gallivm, int32_type, "");
LLVMBuildStore(builder, zero, ret_ptr);
lp_build_printf(builder, " --- io %d = %p, loop counter %d\n",
io_itr, io, lp_loop.counter);
#endif
+ system_values.vertex_id = lp_build_zero(gallivm, lp_type_uint_vec(32));
for (i = 0; i < TGSI_NUM_CHANNELS; ++i) {
LLVMValueRef true_index =
LLVMBuildAdd(builder,
&true_index, 1, "");
true_index = LLVMBuildLoad(builder, fetch_ptr, "fetch_elt");
}
-
+
+ system_values.vertex_id = LLVMBuildInsertElement(gallivm->builder,
+ system_values.vertex_id, true_index,
+ lp_build_const_int32(gallivm, i), "");
for (j = 0; j < draw->pt.nr_vertex_elements; ++j) {
struct pipe_vertex_element *velem = &draw->pt.vertex_element[j];
LLVMValueRef vb_index =
LLVMValueRef vb = LLVMBuildGEP(builder, vb_ptr, &vb_index, 1, "");
generate_fetch(gallivm, vbuffers_ptr,
&aos_attribs[j][i], velem, vb, true_index,
- instance_id);
+ system_values.instance_id);
}
}
convert_to_soa(gallivm, aos_attribs, inputs,
builder,
outputs,
ptr_aos,
- system_values_array,
+ &system_values,
context_ptr,
sampler,
variant->key.clamp_vertex_color);