Lines 96-102
draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *var);
Link Here
|
96 |
* Create LLVM type for struct draw_jit_texture |
96 |
* Create LLVM type for struct draw_jit_texture |
97 |
*/ |
97 |
*/ |
98 |
static LLVMTypeRef |
98 |
static LLVMTypeRef |
99 |
create_jit_texture_type(struct gallivm_state *gallivm) |
99 |
create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name) |
100 |
{ |
100 |
{ |
101 |
LLVMTargetDataRef target = gallivm->target; |
101 |
LLVMTargetDataRef target = gallivm->target; |
102 |
LLVMTypeRef texture_type; |
102 |
LLVMTypeRef texture_type; |
Lines 120-132
create_jit_texture_type(struct gallivm_state *gallivm)
Link Here
|
120 |
elem_types[DRAW_JIT_TEXTURE_BORDER_COLOR] = |
120 |
elem_types[DRAW_JIT_TEXTURE_BORDER_COLOR] = |
121 |
LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4); |
121 |
LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4); |
122 |
|
122 |
|
|
|
123 |
#if HAVE_LLVM >= 0x0300 |
124 |
texture_type = LLVMStructCreateNamed(gallivm->context, struct_name); |
125 |
LLVMStructSetBody(texture_type, elem_types, |
126 |
Elements(elem_types), 0); |
127 |
#else |
123 |
texture_type = LLVMStructTypeInContext(gallivm->context, elem_types, |
128 |
texture_type = LLVMStructTypeInContext(gallivm->context, elem_types, |
124 |
Elements(elem_types), 0); |
129 |
Elements(elem_types), 0); |
125 |
|
130 |
|
|
|
131 |
LLVMAddTypeName(gallivm->module, struct_name, texture_type); |
132 |
|
126 |
/* Make sure the target's struct layout cache doesn't return |
133 |
/* Make sure the target's struct layout cache doesn't return |
127 |
* stale/invalid data. |
134 |
* stale/invalid data. |
128 |
*/ |
135 |
*/ |
129 |
LLVMInvalidateStructLayout(gallivm->target, texture_type); |
136 |
LLVMInvalidateStructLayout(gallivm->target, texture_type); |
|
|
137 |
#endif |
130 |
|
138 |
|
131 |
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width, |
139 |
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width, |
132 |
target, texture_type, |
140 |
target, texture_type, |
Lines 176-182
create_jit_texture_type(struct gallivm_state *gallivm)
Link Here
|
176 |
*/ |
184 |
*/ |
177 |
static LLVMTypeRef |
185 |
static LLVMTypeRef |
178 |
create_jit_context_type(struct gallivm_state *gallivm, |
186 |
create_jit_context_type(struct gallivm_state *gallivm, |
179 |
LLVMTypeRef texture_type) |
187 |
LLVMTypeRef texture_type, const char *struct_name) |
180 |
{ |
188 |
{ |
181 |
LLVMTargetDataRef target = gallivm->target; |
189 |
LLVMTargetDataRef target = gallivm->target; |
182 |
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context); |
190 |
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context); |
Lines 189-199
create_jit_context_type(struct gallivm_state *gallivm,
Link Here
|
189 |
elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */ |
197 |
elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */ |
190 |
elem_types[4] = LLVMArrayType(texture_type, |
198 |
elem_types[4] = LLVMArrayType(texture_type, |
191 |
PIPE_MAX_VERTEX_SAMPLERS); /* textures */ |
199 |
PIPE_MAX_VERTEX_SAMPLERS); /* textures */ |
192 |
|
200 |
#if HAVE_LLVM >= 0x0300 |
|
|
201 |
context_type = LLVMStructCreateNamed(gallivm->context, struct_name); |
202 |
LLVMStructSetBody(context_type, elem_types, |
203 |
Elements(elem_types), 0); |
204 |
#else |
193 |
context_type = LLVMStructTypeInContext(gallivm->context, elem_types, |
205 |
context_type = LLVMStructTypeInContext(gallivm->context, elem_types, |
194 |
Elements(elem_types), 0); |
206 |
Elements(elem_types), 0); |
|
|
207 |
LLVMAddTypeName(gallivm->module, struct_name, context_type); |
195 |
|
208 |
|
196 |
LLVMInvalidateStructLayout(gallivm->target, context_type); |
209 |
LLVMInvalidateStructLayout(gallivm->target, context_type); |
|
|
210 |
#endif |
197 |
|
211 |
|
198 |
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants, |
212 |
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants, |
199 |
target, context_type, 0); |
213 |
target, context_type, 0); |
Lines 215-221
create_jit_context_type(struct gallivm_state *gallivm,
Link Here
|
215 |
* Create LLVM type for struct pipe_vertex_buffer |
229 |
* Create LLVM type for struct pipe_vertex_buffer |
216 |
*/ |
230 |
*/ |
217 |
static LLVMTypeRef |
231 |
static LLVMTypeRef |
218 |
create_jit_vertex_buffer_type(struct gallivm_state *gallivm) |
232 |
create_jit_vertex_buffer_type(struct gallivm_state *gallivm, const char *struct_name) |
219 |
{ |
233 |
{ |
220 |
LLVMTargetDataRef target = gallivm->target; |
234 |
LLVMTargetDataRef target = gallivm->target; |
221 |
LLVMTypeRef elem_types[3]; |
235 |
LLVMTypeRef elem_types[3]; |
Lines 225-234
create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
Link Here
|
225 |
elem_types[1] = LLVMInt32TypeInContext(gallivm->context); |
239 |
elem_types[1] = LLVMInt32TypeInContext(gallivm->context); |
226 |
elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */ |
240 |
elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */ |
227 |
|
241 |
|
|
|
242 |
#if HAVE_LLVM >= 0x0300 |
243 |
vb_type = LLVMStructCreateNamed(gallivm->context, struct_name); |
244 |
LLVMStructSetBody(vb_type, elem_types, |
245 |
Elements(elem_types), 0); |
246 |
#else |
228 |
vb_type = LLVMStructTypeInContext(gallivm->context, elem_types, |
247 |
vb_type = LLVMStructTypeInContext(gallivm->context, elem_types, |
229 |
Elements(elem_types), 0); |
248 |
Elements(elem_types), 0); |
|
|
249 |
LLVMAddTypeName(gallivm->module, struct_name, vb_type); |
230 |
|
250 |
|
231 |
LLVMInvalidateStructLayout(gallivm->target, vb_type); |
251 |
LLVMInvalidateStructLayout(gallivm->target, vb_type); |
|
|
252 |
#endif |
232 |
|
253 |
|
233 |
LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride, |
254 |
LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride, |
234 |
target, vb_type, 0); |
255 |
target, vb_type, 0); |
Lines 258-267
create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
Link Here
|
258 |
elem_types[1] = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4); |
279 |
elem_types[1] = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4); |
259 |
elem_types[2] = LLVMArrayType(elem_types[1], data_elems); |
280 |
elem_types[2] = LLVMArrayType(elem_types[1], data_elems); |
260 |
|
281 |
|
|
|
282 |
#if HAVE_LLVM >= 0x0300 |
283 |
vertex_header = LLVMStructCreateNamed(gallivm->context, struct_name); |
284 |
LLVMStructSetBody(vertex_header, elem_types, |
285 |
Elements(elem_types), 0); |
286 |
#else |
261 |
vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types, |
287 |
vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types, |
262 |
Elements(elem_types), 0); |
288 |
Elements(elem_types), 0); |
|
|
289 |
LLVMAddTypeName(gallivm->module, struct_name, vertex_header); |
263 |
|
290 |
|
264 |
LLVMInvalidateStructLayout(gallivm->target, vertex_header); |
291 |
LLVMInvalidateStructLayout(gallivm->target, vertex_header); |
|
|
292 |
#endif |
265 |
|
293 |
|
266 |
/* these are bit-fields and we can't take address of them |
294 |
/* these are bit-fields and we can't take address of them |
267 |
LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask, |
295 |
LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask, |
Lines 284-291
create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
Link Here
|
284 |
target, vertex_header, |
312 |
target, vertex_header, |
285 |
DRAW_JIT_VERTEX_DATA); |
313 |
DRAW_JIT_VERTEX_DATA); |
286 |
|
314 |
|
287 |
LLVMAddTypeName(gallivm->module, struct_name, vertex_header); |
|
|
288 |
|
289 |
return vertex_header; |
315 |
return vertex_header; |
290 |
} |
316 |
} |
291 |
|
317 |
|
Lines 299-317
create_jit_types(struct draw_llvm *llvm)
Link Here
|
299 |
struct gallivm_state *gallivm = llvm->gallivm; |
325 |
struct gallivm_state *gallivm = llvm->gallivm; |
300 |
LLVMTypeRef texture_type, context_type, buffer_type, vb_type; |
326 |
LLVMTypeRef texture_type, context_type, buffer_type, vb_type; |
301 |
|
327 |
|
302 |
texture_type = create_jit_texture_type(gallivm); |
328 |
texture_type = create_jit_texture_type(gallivm, "texture"); |
303 |
LLVMAddTypeName(gallivm->module, "texture", texture_type); |
|
|
304 |
|
329 |
|
305 |
context_type = create_jit_context_type(gallivm, texture_type); |
330 |
context_type = create_jit_context_type(gallivm, texture_type, "draw_jit_context"); |
306 |
LLVMAddTypeName(gallivm->module, "draw_jit_context", context_type); |
|
|
307 |
llvm->context_ptr_type = LLVMPointerType(context_type, 0); |
331 |
llvm->context_ptr_type = LLVMPointerType(context_type, 0); |
308 |
|
332 |
|
309 |
buffer_type = LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 8), 0); |
333 |
buffer_type = LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 8), 0); |
310 |
LLVMAddTypeName(gallivm->module, "buffer", buffer_type); |
|
|
311 |
llvm->buffer_ptr_type = LLVMPointerType(buffer_type, 0); |
334 |
llvm->buffer_ptr_type = LLVMPointerType(buffer_type, 0); |
312 |
|
335 |
|
313 |
vb_type = create_jit_vertex_buffer_type(gallivm); |
336 |
vb_type = create_jit_vertex_buffer_type(gallivm, "pipe_vertex_buffer"); |
314 |
LLVMAddTypeName(gallivm->module, "pipe_vertex_buffer", vb_type); |
|
|
315 |
llvm->vb_ptr_type = LLVMPointerType(vb_type, 0); |
337 |
llvm->vb_ptr_type = LLVMPointerType(vb_type, 0); |
316 |
} |
338 |
} |
317 |
|
339 |
|