~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/draw/draw_llvm.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
#include "gallivm/lp_bld_pack.h"
53
53
#include "gallivm/lp_bld_format.h"
54
54
#include "gallivm/lp_bld_misc.h"
 
55
#include "gallivm/lp_bld_jit_sample.h"
55
56
#include "tgsi/tgsi_exec.h"
56
57
#include "tgsi/tgsi_dump.h"
57
58
 
143
144
   return dvbuffer_type;
144
145
}
145
146
 
146
 
 
147
 
/**
148
 
 * Create LLVM type for struct draw_jit_texture
149
 
 */
150
 
static LLVMTypeRef
151
 
create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
152
 
{
153
 
   LLVMTargetDataRef target = gallivm->target;
154
 
   LLVMTypeRef texture_type;
155
 
   LLVMTypeRef elem_types[DRAW_JIT_TEXTURE_NUM_FIELDS];
156
 
   LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
157
 
 
158
 
   elem_types[DRAW_JIT_TEXTURE_WIDTH]  =
159
 
   elem_types[DRAW_JIT_TEXTURE_HEIGHT] =
160
 
   elem_types[DRAW_JIT_TEXTURE_DEPTH] =
161
 
   elem_types[DRAW_JIT_TEXTURE_NUM_SAMPLES] =
162
 
   elem_types[DRAW_JIT_TEXTURE_SAMPLE_STRIDE] =
163
 
   elem_types[DRAW_JIT_TEXTURE_FIRST_LEVEL] =
164
 
   elem_types[DRAW_JIT_TEXTURE_LAST_LEVEL] = int32_type;
165
 
   elem_types[DRAW_JIT_TEXTURE_BASE] =
166
 
      LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
167
 
   elem_types[DRAW_JIT_TEXTURE_ROW_STRIDE] =
168
 
   elem_types[DRAW_JIT_TEXTURE_IMG_STRIDE] =
169
 
   elem_types[DRAW_JIT_TEXTURE_MIP_OFFSETS] =
170
 
      LLVMArrayType(int32_type, PIPE_MAX_TEXTURE_LEVELS);
171
 
 
172
 
   texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
173
 
                                          ARRAY_SIZE(elem_types), 0);
174
 
 
175
 
   (void) target; /* silence unused var warning for non-debug build */
176
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
177
 
                          target, texture_type,
178
 
                          DRAW_JIT_TEXTURE_WIDTH);
179
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, height,
180
 
                          target, texture_type,
181
 
                          DRAW_JIT_TEXTURE_HEIGHT);
182
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, depth,
183
 
                          target, texture_type,
184
 
                          DRAW_JIT_TEXTURE_DEPTH);
185
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, base,
186
 
                          target, texture_type,
187
 
                          DRAW_JIT_TEXTURE_BASE);
188
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, row_stride,
189
 
                          target, texture_type,
190
 
                          DRAW_JIT_TEXTURE_ROW_STRIDE);
191
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, img_stride,
192
 
                          target, texture_type,
193
 
                          DRAW_JIT_TEXTURE_IMG_STRIDE);
194
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, first_level,
195
 
                          target, texture_type,
196
 
                          DRAW_JIT_TEXTURE_FIRST_LEVEL);
197
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, last_level,
198
 
                          target, texture_type,
199
 
                          DRAW_JIT_TEXTURE_LAST_LEVEL);
200
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, mip_offsets,
201
 
                          target, texture_type,
202
 
                          DRAW_JIT_TEXTURE_MIP_OFFSETS);
203
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, num_samples,
204
 
                          target, texture_type,
205
 
                          DRAW_JIT_TEXTURE_NUM_SAMPLES);
206
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, sample_stride,
207
 
                          target, texture_type,
208
 
                          DRAW_JIT_TEXTURE_SAMPLE_STRIDE);
209
 
 
210
 
   LP_CHECK_STRUCT_SIZE(struct draw_jit_texture, target, texture_type);
211
 
 
212
 
   return texture_type;
213
 
}
214
 
 
215
 
 
216
 
/**
217
 
 * Create LLVM type for struct draw_jit_sampler
218
 
 */
219
 
static LLVMTypeRef
220
 
create_jit_sampler_type(struct gallivm_state *gallivm, const char *struct_name)
221
 
{
222
 
   LLVMTargetDataRef target = gallivm->target;
223
 
   LLVMTypeRef sampler_type;
224
 
   LLVMTypeRef elem_types[DRAW_JIT_SAMPLER_NUM_FIELDS];
225
 
 
226
 
   elem_types[DRAW_JIT_SAMPLER_MIN_LOD] =
227
 
   elem_types[DRAW_JIT_SAMPLER_MAX_LOD] =
228
 
   elem_types[DRAW_JIT_SAMPLER_LOD_BIAS] =
229
 
   elem_types[DRAW_JIT_SAMPLER_MAX_ANISO] = LLVMFloatTypeInContext(gallivm->context);
230
 
   elem_types[DRAW_JIT_SAMPLER_BORDER_COLOR] =
231
 
      LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
232
 
 
233
 
   sampler_type = LLVMStructTypeInContext(gallivm->context, elem_types,
234
 
                                          ARRAY_SIZE(elem_types), 0);
235
 
 
236
 
   (void) target; /* silence unused var warning for non-debug build */
237
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, min_lod,
238
 
                          target, sampler_type,
239
 
                          DRAW_JIT_SAMPLER_MIN_LOD);
240
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, max_lod,
241
 
                          target, sampler_type,
242
 
                          DRAW_JIT_SAMPLER_MAX_LOD);
243
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, lod_bias,
244
 
                          target, sampler_type,
245
 
                          DRAW_JIT_SAMPLER_LOD_BIAS);
246
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, border_color,
247
 
                          target, sampler_type,
248
 
                          DRAW_JIT_SAMPLER_BORDER_COLOR);
249
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, max_aniso,
250
 
                          target, sampler_type,
251
 
                          DRAW_JIT_SAMPLER_MAX_ANISO);
252
 
 
253
 
   LP_CHECK_STRUCT_SIZE(struct draw_jit_sampler, target, sampler_type);
254
 
 
255
 
   return sampler_type;
256
 
}
257
 
 
258
 
 
259
 
/**
260
 
 * Create LLVM type for struct draw_jit_texture
261
 
 */
262
 
static LLVMTypeRef
263
 
create_jit_image_type(struct gallivm_state *gallivm, const char *struct_name)
264
 
{
265
 
   LLVMTargetDataRef target = gallivm->target;
266
 
   LLVMTypeRef image_type;
267
 
   LLVMTypeRef elem_types[DRAW_JIT_IMAGE_NUM_FIELDS];
268
 
   LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
269
 
 
270
 
   elem_types[DRAW_JIT_IMAGE_WIDTH]  =
271
 
   elem_types[DRAW_JIT_IMAGE_HEIGHT] =
272
 
   elem_types[DRAW_JIT_IMAGE_DEPTH] =
273
 
   elem_types[DRAW_JIT_IMAGE_ROW_STRIDE] =
274
 
   elem_types[DRAW_JIT_IMAGE_IMG_STRIDE] =
275
 
   elem_types[DRAW_JIT_IMAGE_NUM_SAMPLES] =
276
 
   elem_types[DRAW_JIT_IMAGE_SAMPLE_STRIDE] = int32_type;
277
 
   elem_types[DRAW_JIT_IMAGE_BASE] =
278
 
      LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
279
 
 
280
 
   image_type = LLVMStructTypeInContext(gallivm->context, elem_types,
281
 
                                          ARRAY_SIZE(elem_types), 0);
282
 
 
283
 
   (void) target; /* silence unused var warning for non-debug build */
284
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, width,
285
 
                          target, image_type,
286
 
                          DRAW_JIT_IMAGE_WIDTH);
287
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, height,
288
 
                          target, image_type,
289
 
                          DRAW_JIT_IMAGE_HEIGHT);
290
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, depth,
291
 
                          target, image_type,
292
 
                          DRAW_JIT_IMAGE_DEPTH);
293
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, base,
294
 
                          target, image_type,
295
 
                          DRAW_JIT_IMAGE_BASE);
296
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, row_stride,
297
 
                          target, image_type,
298
 
                          DRAW_JIT_IMAGE_ROW_STRIDE);
299
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, img_stride,
300
 
                          target, image_type,
301
 
                          DRAW_JIT_IMAGE_IMG_STRIDE);
302
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, num_samples,
303
 
                          target, image_type,
304
 
                          DRAW_JIT_IMAGE_NUM_SAMPLES);
305
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, sample_stride,
306
 
                          target, image_type,
307
 
                          DRAW_JIT_IMAGE_SAMPLE_STRIDE);
308
 
 
309
 
   LP_CHECK_STRUCT_SIZE(struct draw_jit_image, target, image_type);
310
 
 
311
 
   return image_type;
312
 
}
313
 
 
314
 
 
315
147
/**
316
148
 * Create LLVM type for struct draw_jit_context
317
149
 */
318
150
static LLVMTypeRef
319
 
create_jit_context_type(struct gallivm_state *gallivm, const char *struct_name)
 
151
create_vs_jit_context_type(struct gallivm_state *gallivm, const char *struct_name)
320
152
{
321
 
   LLVMTypeRef buffer_type = lp_build_create_jit_buffer_type(gallivm);
322
 
   LLVMTypeRef texture_type = create_jit_texture_type(gallivm, "texture");
323
 
   LLVMTypeRef sampler_type = create_jit_sampler_type(gallivm, "sampler");
324
 
   LLVMTypeRef image_type = create_jit_image_type(gallivm, "image");
325
 
 
326
153
   LLVMTargetDataRef target = gallivm->target;
327
154
   LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
328
 
   LLVMTypeRef elem_types[DRAW_JIT_CTX_NUM_FIELDS];
329
 
 
330
 
   elem_types[DRAW_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_CONST_BUFFERS);
331
 
   elem_types[DRAW_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0);
332
 
   elem_types[DRAW_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0);
333
 
   elem_types[DRAW_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type, PIPE_MAX_SHADER_SAMPLER_VIEWS);
334
 
   elem_types[DRAW_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type, PIPE_MAX_SAMPLERS);
335
 
   elem_types[DRAW_JIT_CTX_IMAGES] = LLVMArrayType(image_type, PIPE_MAX_SHADER_IMAGES);
336
 
   elem_types[DRAW_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
337
 
   elem_types[DRAW_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0);
 
155
   LLVMTypeRef elem_types[DRAW_VS_JIT_CTX_NUM_FIELDS];
 
156
 
 
157
   elem_types[DRAW_VS_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0);
 
158
   elem_types[DRAW_VS_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0);
 
159
 
338
160
   LLVMTypeRef context_type = LLVMStructTypeInContext(gallivm->context, elem_types, ARRAY_SIZE(elem_types), 0);
339
161
 
340
162
   (void) target; /* silence unused var warning for non-debug build */
341
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, constants,
342
 
                          target, context_type, DRAW_JIT_CTX_CONSTANTS);
343
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, planes,
344
 
                          target, context_type, DRAW_JIT_CTX_PLANES);
345
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, viewports,
346
 
                          target, context_type, DRAW_JIT_CTX_VIEWPORT);
347
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, textures,
348
 
                          target, context_type,
349
 
                          DRAW_JIT_CTX_TEXTURES);
350
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, samplers,
351
 
                          target, context_type,
352
 
                          DRAW_JIT_CTX_SAMPLERS);
353
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, images,
354
 
                          target, context_type, DRAW_JIT_CTX_IMAGES);
355
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, ssbos,
356
 
                          target, context_type, DRAW_JIT_CTX_SSBOS);
357
 
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, aniso_filter_table,
358
 
                          target, context_type, DRAW_JIT_CTX_ANISO_FILTER_TABLE);
359
 
   LP_CHECK_STRUCT_SIZE(struct draw_jit_context,
 
163
   LP_CHECK_MEMBER_OFFSET(struct draw_vs_jit_context, planes,
 
164
                          target, context_type, DRAW_VS_JIT_CTX_PLANES);
 
165
   LP_CHECK_MEMBER_OFFSET(struct draw_vs_jit_context, viewports,
 
166
                          target, context_type, DRAW_VS_JIT_CTX_VIEWPORT);
 
167
   LP_CHECK_STRUCT_SIZE(struct draw_vs_jit_context,
360
168
                        target, context_type);
361
169
 
362
170
   return context_type;
369
177
static LLVMTypeRef
370
178
create_gs_jit_context_type(struct gallivm_state *gallivm,
371
179
                           unsigned vector_length,
372
 
                           LLVMTypeRef buffer_type,
373
 
                           LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
374
 
                           LLVMTypeRef image_type,
375
180
                           const char *struct_name)
376
181
{
377
182
   LLVMTargetDataRef target = gallivm->target;
380
185
   LLVMTypeRef elem_types[DRAW_GS_JIT_CTX_NUM_FIELDS];
381
186
   LLVMTypeRef context_type;
382
187
 
383
 
   elem_types[DRAW_GS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
384
 
                                                         LP_MAX_TGSI_CONST_BUFFERS);
385
188
   elem_types[DRAW_GS_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4),
386
189
                                                                      DRAW_TOTAL_CLIP_PLANES), 0);
387
190
   elem_types[DRAW_GS_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0); /* viewports */
388
191
 
389
 
   elem_types[DRAW_GS_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
390
 
                                                        PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
391
 
   elem_types[DRAW_GS_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
392
 
                                                        PIPE_MAX_SAMPLERS); /* samplers */
393
 
   elem_types[DRAW_GS_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
394
 
                                                      PIPE_MAX_SHADER_IMAGES); /* images */
 
192
 
395
193
   elem_types[DRAW_GS_JIT_CTX_PRIM_LENGTHS] = LLVMPointerType(LLVMPointerType(int_type, 0), 0);
396
194
   elem_types[DRAW_GS_JIT_CTX_EMITTED_VERTICES] = LLVMPointerType(LLVMVectorType(int_type,
397
195
                                                                                 vector_length), 0);
398
196
   elem_types[DRAW_GS_JIT_CTX_EMITTED_PRIMS] = LLVMPointerType(LLVMVectorType(int_type,
399
197
                                                                              vector_length), 0);
400
198
 
401
 
   elem_types[DRAW_GS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
402
 
                                                     LP_MAX_TGSI_SHADER_BUFFERS);
403
 
   elem_types[DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
404
 
 
405
199
   context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
406
200
                                          ARRAY_SIZE(elem_types), 0);
407
201
 
408
202
   (void) target; /* silence unused var warning for non-debug build */
409
 
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, constants,
410
 
                          target, context_type, DRAW_GS_JIT_CTX_CONSTANTS);
411
203
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, planes,
412
204
                          target, context_type, DRAW_GS_JIT_CTX_PLANES);
413
205
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, viewports,
414
206
                          target, context_type, DRAW_GS_JIT_CTX_VIEWPORT);
415
 
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, textures,
416
 
                          target, context_type,
417
 
                          DRAW_GS_JIT_CTX_TEXTURES);
418
 
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, samplers,
419
 
                          target, context_type,
420
 
                          DRAW_GS_JIT_CTX_SAMPLERS);
421
207
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, prim_lengths,
422
208
                          target, context_type,
423
209
                          DRAW_GS_JIT_CTX_PRIM_LENGTHS);
427
213
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, emitted_prims,
428
214
                          target, context_type,
429
215
                          DRAW_GS_JIT_CTX_EMITTED_PRIMS);
430
 
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, ssbos,
431
 
                          target, context_type, DRAW_GS_JIT_CTX_SSBOS);
432
 
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, images,
433
 
                          target, context_type, DRAW_GS_JIT_CTX_IMAGES);
434
 
   LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, aniso_filter_table,
435
 
                          target, context_type, DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE);
436
216
   LP_CHECK_STRUCT_SIZE(struct draw_gs_jit_context,
437
217
                        target, context_type);
438
 
 
439
218
   return context_type;
440
219
}
441
220
 
495
274
}
496
275
 
497
276
 
498
 
/**
499
 
 * Create LLVM type for struct vertex_header;
500
 
 */
501
 
static LLVMTypeRef
502
 
create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
503
 
{
504
 
   LLVMTargetDataRef target = gallivm->target;
505
 
   LLVMTypeRef elem_types[3];
506
 
   LLVMTypeRef vertex_header;
507
 
   char struct_name[24];
508
 
 
509
 
   snprintf(struct_name, 23, "vertex_header%d", data_elems);
510
 
 
511
 
   elem_types[DRAW_JIT_VERTEX_VERTEX_ID]  = LLVMIntTypeInContext(gallivm->context, 32);
512
 
   elem_types[DRAW_JIT_VERTEX_CLIP_POS]  = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
513
 
   elem_types[DRAW_JIT_VERTEX_DATA]  = LLVMArrayType(elem_types[1], data_elems);
514
 
 
515
 
   vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
516
 
                                           ARRAY_SIZE(elem_types), 0);
517
 
 
518
 
   /* these are bit-fields and we can't take address of them
519
 
      LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,
520
 
      target, vertex_header,
521
 
      DRAW_JIT_VERTEX_CLIPMASK);
522
 
      LP_CHECK_MEMBER_OFFSET(struct vertex_header, edgeflag,
523
 
      target, vertex_header,
524
 
      DRAW_JIT_VERTEX_EDGEFLAG);
525
 
      LP_CHECK_MEMBER_OFFSET(struct vertex_header, pad,
526
 
      target, vertex_header,
527
 
      DRAW_JIT_VERTEX_PAD);
528
 
      LP_CHECK_MEMBER_OFFSET(struct vertex_header, vertex_id,
529
 
      target, vertex_header,
530
 
      DRAW_JIT_VERTEX_VERTEX_ID);
531
 
   */
532
 
   (void) target; /* silence unused var warning for non-debug build */
533
 
   LP_CHECK_MEMBER_OFFSET(struct vertex_header, clip_pos,
534
 
                          target, vertex_header,
535
 
                          DRAW_JIT_VERTEX_CLIP_POS);
536
 
   LP_CHECK_MEMBER_OFFSET(struct vertex_header, data,
537
 
                          target, vertex_header,
538
 
                          DRAW_JIT_VERTEX_DATA);
539
 
 
540
 
   assert(LLVMABISizeOfType(target, vertex_header) ==
541
 
          offsetof(struct vertex_header, data[data_elems]));
542
 
 
543
 
   return vertex_header;
544
 
}
545
 
 
546
 
 
547
 
/**
548
 
 * Create LLVM type for struct draw_tcs_jit_context
549
 
 */
550
 
static LLVMTypeRef
551
 
create_tcs_jit_context_type(struct gallivm_state *gallivm,
552
 
                            unsigned vector_length,
553
 
                            LLVMTypeRef buffer_type,
554
 
                            LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
555
 
                            LLVMTypeRef image_type,
556
 
                            const char *struct_name)
557
 
{
558
 
   LLVMTargetDataRef target = gallivm->target;
559
 
   LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
560
 
   LLVMTypeRef elem_types[DRAW_TCS_JIT_CTX_NUM_FIELDS];
561
 
   LLVMTypeRef context_type;
562
 
 
563
 
 
564
 
   elem_types[DRAW_TCS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
565
 
                                                          LP_MAX_TGSI_CONST_BUFFERS);
566
 
   elem_types[DRAW_TCS_JIT_CTX_DUMMY1] = LLVMInt32TypeInContext(gallivm->context);
567
 
   elem_types[DRAW_TCS_JIT_CTX_DUMMY2] = LLVMInt32TypeInContext(gallivm->context);
568
 
 
569
 
   elem_types[DRAW_TCS_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
570
 
                                                         PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
571
 
   elem_types[DRAW_TCS_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
572
 
                                                         PIPE_MAX_SAMPLERS); /* samplers */
573
 
   elem_types[DRAW_TCS_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
574
 
                                                       PIPE_MAX_SHADER_IMAGES); /* images */
575
 
 
576
 
   elem_types[DRAW_TCS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
577
 
                                                      LP_MAX_TGSI_SHADER_BUFFERS);
578
 
   elem_types[DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
579
 
 
580
 
   context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
581
 
                                          ARRAY_SIZE(elem_types), 0);
582
 
 
583
 
   (void) target; /* silence unused var warning for non-debug build */
584
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, constants,
585
 
                          target, context_type, DRAW_TCS_JIT_CTX_CONSTANTS);
586
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, textures,
587
 
                          target, context_type,
588
 
                          DRAW_TCS_JIT_CTX_TEXTURES);
589
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, samplers,
590
 
                          target, context_type,
591
 
                          DRAW_TCS_JIT_CTX_SAMPLERS);
592
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, ssbos,
593
 
                          target, context_type, DRAW_TCS_JIT_CTX_SSBOS);
594
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, images,
595
 
                          target, context_type, DRAW_TCS_JIT_CTX_IMAGES);
596
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, aniso_filter_table,
597
 
                          target, context_type, DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE);
598
 
   LP_CHECK_STRUCT_SIZE(struct draw_tcs_jit_context,
599
 
                        target, context_type);
600
 
 
601
 
   return context_type;
602
 
}
603
 
 
604
 
 
605
277
static LLVMTypeRef
606
278
create_tcs_jit_input_type_deref(struct gallivm_state *gallivm)
607
279
{
654
326
 
655
327
 
656
328
/**
657
 
 * Create LLVM type for struct draw_tes_jit_context
658
 
 */
659
 
static LLVMTypeRef
660
 
create_tes_jit_context_type(struct gallivm_state *gallivm,
661
 
                            unsigned vector_length,
662
 
                            LLVMTypeRef buffer_type,
663
 
                            LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
664
 
                            LLVMTypeRef image_type,
665
 
                            const char *struct_name)
666
 
{
667
 
   LLVMTargetDataRef target = gallivm->target;
668
 
   LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
669
 
   LLVMTypeRef elem_types[DRAW_TES_JIT_CTX_NUM_FIELDS];
670
 
   LLVMTypeRef context_type;
671
 
 
672
 
   elem_types[DRAW_TES_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
673
 
                                                          LP_MAX_TGSI_CONST_BUFFERS);
674
 
   elem_types[DRAW_TES_JIT_CTX_DUMMY1] = LLVMInt32TypeInContext(gallivm->context);
675
 
   elem_types[DRAW_TES_JIT_CTX_DUMMY2] = LLVMInt32TypeInContext(gallivm->context);
676
 
 
677
 
   elem_types[DRAW_TES_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
678
 
                                                         PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
679
 
   elem_types[DRAW_TES_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
680
 
                                                         PIPE_MAX_SAMPLERS); /* samplers */
681
 
   elem_types[DRAW_TES_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
682
 
                                                       PIPE_MAX_SHADER_IMAGES); /* images */
683
 
 
684
 
   elem_types[DRAW_TES_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
685
 
                                                      LP_MAX_TGSI_SHADER_BUFFERS);
686
 
   elem_types[DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
687
 
 
688
 
   context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
689
 
                                          ARRAY_SIZE(elem_types), 0);
690
 
 
691
 
   (void) target; /* silence unused var warning for non-debug build */
692
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, constants,
693
 
                          target, context_type, DRAW_TES_JIT_CTX_CONSTANTS);
694
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, textures,
695
 
                          target, context_type,
696
 
                          DRAW_TES_JIT_CTX_TEXTURES);
697
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, samplers,
698
 
                          target, context_type,
699
 
                          DRAW_TES_JIT_CTX_SAMPLERS);
700
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, ssbos,
701
 
                          target, context_type, DRAW_TES_JIT_CTX_SSBOS);
702
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, images,
703
 
                          target, context_type, DRAW_TES_JIT_CTX_IMAGES);
704
 
   LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, aniso_filter_table,
705
 
                          target, context_type, DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE);
706
 
   LP_CHECK_STRUCT_SIZE(struct draw_tes_jit_context,
707
 
                        target, context_type);
708
 
 
709
 
   return context_type;
710
 
}
711
 
 
712
 
 
713
 
/**
714
329
 * Create LLVM types for various structures.
715
330
 */
716
331
static void
717
 
create_jit_types(struct draw_llvm_variant *variant)
 
332
create_vs_jit_types(struct draw_llvm_variant *variant)
718
333
{
719
334
   struct gallivm_state *gallivm = variant->gallivm;
720
335
 
721
 
   variant->context_type = create_jit_context_type(gallivm, "draw_jit_context");
 
336
   variant->context_type = create_vs_jit_context_type(gallivm, "draw_vs_jit_context");
722
337
   variant->context_ptr_type = LLVMPointerType(variant->context_type, 0);
723
338
 
 
339
   variant->resources_type = lp_build_jit_resources_type(gallivm);
 
340
   variant->resources_ptr_type = LLVMPointerType(variant->resources_type, 0);
 
341
 
724
342
   variant->buffer_type = create_jit_dvbuffer_type(gallivm, "draw_vertex_buffer");
725
343
   variant->buffer_ptr_type = LLVMPointerType(variant->buffer_type, 0);
726
344
 
733
351
get_context_ptr_type(struct draw_llvm_variant *variant)
734
352
{
735
353
   if (!variant->context_ptr_type)
736
 
      create_jit_types(variant);
 
354
      create_vs_jit_types(variant);
737
355
   return variant->context_ptr_type;
738
356
}
739
357
 
742
360
get_buffer_ptr_type(struct draw_llvm_variant *variant)
743
361
{
744
362
   if (!variant->buffer_ptr_type)
745
 
      create_jit_types(variant);
 
363
      create_vs_jit_types(variant);
746
364
   return variant->buffer_ptr_type;
747
365
}
748
366
 
751
369
get_vb_ptr_type(struct draw_llvm_variant *variant)
752
370
{
753
371
   if (!variant->vb_ptr_type)
754
 
      create_jit_types(variant);
 
372
      create_vs_jit_types(variant);
755
373
   return variant->vb_ptr_type;
756
374
}
757
375
 
897
515
   }
898
516
   variant->gallivm = gallivm_create(module_name, llvm->context, &cached);
899
517
 
900
 
   create_jit_types(variant);
 
518
   create_vs_jit_types(variant);
901
519
 
902
520
   if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
903
521
      if (llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_TGSI)
907
525
      draw_llvm_dump_variant_key(&variant->key);
908
526
   }
909
527
 
910
 
   variant->vertex_header_type = create_jit_vertex_header(variant->gallivm, num_inputs);
 
528
   variant->vertex_header_type = lp_build_create_jit_vertex_header_type(variant->gallivm, num_inputs);
911
529
   variant->vertex_header_ptr_type = LLVMPointerType(variant->vertex_header_type, 0);
912
530
 
913
531
   draw_llvm_generate(llvm, variant);
969
587
            const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
970
588
            const struct lp_bld_tgsi_system_values *system_values,
971
589
            LLVMValueRef context_ptr,
 
590
            LLVMValueRef resources_ptr,
972
591
            const struct lp_build_sampler_soa *draw_sampler,
973
592
            const struct lp_build_image_soa *draw_image,
974
 
            boolean clamp_vertex_color,
 
593
            bool clamp_vertex_color,
975
594
            struct lp_build_mask_context *bld_mask)
976
595
{
977
596
   struct draw_llvm *llvm = variant->llvm;
978
597
   const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.tokens;
979
598
   LLVMValueRef consts_ptr =
980
 
      draw_jit_context_constants(variant, context_ptr);
 
599
      lp_jit_resources_constants(variant->gallivm, variant->resources_type, resources_ptr);
981
600
   LLVMValueRef ssbos_ptr =
982
 
      draw_jit_context_ssbos(variant, context_ptr);
 
601
      lp_jit_resources_ssbos(variant->gallivm, variant->resources_type, resources_ptr);
983
602
 
984
603
   struct lp_build_tgsi_params params;
985
604
   memset(&params, 0, sizeof(params));
991
610
   params.inputs = inputs;
992
611
   params.context_type = variant->context_type;
993
612
   params.context_ptr = context_ptr;
 
613
   params.resources_type = variant->resources_type;
 
614
   params.resources_ptr = resources_ptr;
994
615
   params.sampler = draw_sampler;
995
616
   params.info = &llvm->draw->vs.vertex_shader->info;
996
617
   params.ssbo_ptr = ssbos_ptr;
997
618
   params.image = draw_image;
998
 
   params.aniso_filter_table = draw_jit_context_aniso_filter_table(variant, context_ptr);
 
619
   params.aniso_filter_table = lp_jit_resources_aniso_filter_table(variant->gallivm,
 
620
                                                                   variant->resources_type,
 
621
                                                                   resources_ptr);
999
622
 
1000
623
   if (llvm->draw->vs.vertex_shader->state.ir.nir &&
1001
624
       llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_NIR) {
1058
681
   aos = lp_build_fetch_rgba_aos(gallivm,
1059
682
                                 format_desc,
1060
683
                                 lp_float32_vec4_type(),
1061
 
                                 FALSE,
 
684
                                 false,
1062
685
                                 map_ptr,
1063
686
                                 stride, zero, zero,
1064
687
                                 NULL);
1129
752
   }
1130
753
 
1131
754
   lp_build_fetch_rgba_soa(gallivm, format_desc,
1132
 
                           fetch_type, FALSE, map_ptr, offset,
 
755
                           fetch_type, false, map_ptr, offset,
1133
756
                           blduivec.zero, blduivec.zero,
1134
757
                           NULL, inputs);
1135
758
 
1150
773
 
1151
774
static void
1152
775
store_aos(struct gallivm_state *gallivm,
 
776
          bool is_per_prim,
1153
777
          LLVMTypeRef io_type,
1154
778
          LLVMValueRef io_ptr,
1155
779
          LLVMValueRef index,
1157
781
{
1158
782
   LLVMTypeRef data_ptr_type = LLVMPointerType(lp_build_vec_type(gallivm, lp_float32_vec4_type()), 0);
1159
783
   LLVMBuilderRef builder = gallivm->builder;
1160
 
   LLVMValueRef data_ptr = draw_jit_header_data(gallivm, io_type, io_ptr);
1161
 
   LLVMTypeRef data_type = LLVMStructGetTypeAtIndex(io_type, DRAW_JIT_VERTEX_DATA);
 
784
   LLVMValueRef data_ptr;
 
785
   LLVMTypeRef data_type;
1162
786
   LLVMValueRef indices[3];
1163
787
 
1164
788
   indices[0] = lp_build_const_int32(gallivm, 0);
1165
789
   indices[1] = index;
1166
790
   indices[2] = lp_build_const_int32(gallivm, 0);
1167
791
 
 
792
   if (!is_per_prim) {
 
793
      data_ptr = lp_jit_vertex_header_data(gallivm, io_type, io_ptr);
 
794
      data_type = LLVMStructGetTypeAtIndex(io_type, LP_JIT_VERTEX_HEADER_DATA);
 
795
   } else {
 
796
      data_ptr = io_ptr;
 
797
      data_type = io_type;
 
798
   }
 
799
 
1168
800
   data_ptr = LLVMBuildGEP2(builder, data_type, data_ptr, indices, 3, "");
1169
801
   data_ptr = LLVMBuildPointerCast(builder, data_ptr, data_ptr_type, "");
1170
802
 
1171
803
#if DEBUG_STORE
1172
 
   lp_build_printf(gallivm, "    ---- %p storing attribute %d (io = %p)\n", data_ptr, index, io_ptr);
 
804
   if (is_per_prim)
 
805
      lp_build_printf(gallivm, "    ---- %p storing prim attribute %d (io = %p)\n", data_ptr, index, io_ptr);
 
806
   else
 
807
      lp_build_printf(gallivm, "    ---- %p storing attribute %d (io = %p)\n", data_ptr, index, io_ptr);
1173
808
#endif
1174
809
 
1175
810
   /* Unaligned store due to the vertex header */
1230
865
}
1231
866
 
1232
867
 
1233
 
static void
1234
 
store_aos_array(struct gallivm_state *gallivm,
1235
 
                struct lp_type soa_type,
1236
 
                LLVMTypeRef io_type,
1237
 
                LLVMValueRef io_ptr,
1238
 
                LLVMValueRef *indices,
1239
 
                LLVMValueRef* aos,
1240
 
                int attrib,
1241
 
                int num_outputs,
1242
 
                LLVMValueRef clipmask,
1243
 
                boolean need_edgeflag)
 
868
void
 
869
draw_store_aos_array(struct gallivm_state *gallivm,
 
870
                     struct lp_type soa_type,
 
871
                     LLVMTypeRef io_type,
 
872
                     LLVMValueRef io_ptr,
 
873
                     LLVMValueRef *indices,
 
874
                     LLVMValueRef* aos,
 
875
                     int attrib,
 
876
                     LLVMValueRef clipmask,
 
877
                     bool need_edgeflag, bool is_per_prim)
1244
878
{
1245
879
   LLVMBuilderRef builder = gallivm->builder;
1246
880
   LLVMValueRef attr_index = lp_build_const_int32(gallivm, attrib);
1261
895
      io_ptrs[i] = LLVMBuildGEP2(builder, io_type, io_ptr, &inds[i], 1, "");
1262
896
   }
1263
897
 
1264
 
   if (attrib == 0) {
 
898
   if (attrib == 0 && !is_per_prim) {
1265
899
      /* store vertex header for each of the n vertices */
1266
900
      LLVMValueRef val, cliptmp;
1267
901
      int vertex_id_pad_edgeflag;
1276
910
      } else {
1277
911
         vertex_id_pad_edgeflag = (0xffff << 16);
1278
912
      }
1279
 
      val = lp_build_const_int_vec(gallivm, lp_int_type(soa_type),
1280
 
                                   vertex_id_pad_edgeflag);
 
913
      if (vector_length == 1)
 
914
         val = lp_build_const_int32(gallivm, vertex_id_pad_edgeflag);
 
915
      else
 
916
         val = lp_build_const_int_vec(gallivm, lp_int_type(soa_type),
 
917
                                      vertex_id_pad_edgeflag);
 
918
 
1281
919
      /* OR with the clipmask */
1282
920
      cliptmp = LLVMBuildOr(builder, val, clipmask, "");
1283
921
      for (unsigned i = 0; i < vector_length; i++) {
1284
 
         LLVMValueRef id_ptr = draw_jit_header_id(gallivm, io_type, io_ptrs[i]);
1285
 
         val = LLVMBuildExtractElement(builder, cliptmp, linear_inds[i], "");
 
922
         LLVMValueRef id_ptr = lp_jit_vertex_header_id(gallivm, io_type, io_ptrs[i]);
 
923
         if (vector_length > 1)
 
924
            val = LLVMBuildExtractElement(builder, cliptmp, linear_inds[i], "");
 
925
         else
 
926
            val = cliptmp;
1286
927
         val = adjust_mask(gallivm, val);
1287
928
#if DEBUG_STORE
1288
929
         lp_build_printf(gallivm, "io = %p, index %d, clipmask = %x\n",
1294
935
 
1295
936
   /* store for each of the n vertices */
1296
937
   for (int i = 0; i < vector_length; i++) {
1297
 
      store_aos(gallivm, io_type, io_ptrs[i], attr_index, aos[i]);
 
938
      store_aos(gallivm, is_per_prim, io_type, io_ptrs[i], attr_index, aos[i]);
1298
939
   }
1299
940
}
1300
941
 
1309
950
               int num_outputs,
1310
951
               struct lp_type soa_type,
1311
952
               int primid_slot,
1312
 
               boolean need_edgeflag)
 
953
               bool need_edgeflag)
1313
954
{
1314
955
   LLVMBuilderRef builder = gallivm->builder;
1315
956
 
1358
999
         }
1359
1000
      }
1360
1001
 
1361
 
      store_aos_array(gallivm,
1362
 
                      soa_type,
1363
 
                      io_type,
1364
 
                      io,
1365
 
                      indices,
1366
 
                      aos,
1367
 
                      attrib,
1368
 
                      num_outputs,
1369
 
                      clipmask,
1370
 
                      need_edgeflag);
 
1002
      draw_store_aos_array(gallivm,
 
1003
                           soa_type,
 
1004
                           io_type,
 
1005
                           io,
 
1006
                           indices,
 
1007
                           aos,
 
1008
                           attrib,
 
1009
                           clipmask,
 
1010
                           need_edgeflag, false);
1371
1011
   }
1372
1012
#if DEBUG_STORE
1373
1013
   lp_build_printf(gallivm, "   # storing end\n");
1408
1048
   soa[3] = LLVMBuildLoad2(builder, single_type, outputs[idx][3], ""); /*w0 w1 .. wn*/
1409
1049
 
1410
1050
   for (int i = 0; i < vs_type.length; i++) {
1411
 
      clip_ptrs[i] = draw_jit_header_clip_pos(gallivm, io_type, io_ptrs[i]);
 
1051
      clip_ptrs[i] = lp_jit_vertex_header_clip_pos(gallivm, io_type, io_ptrs[i]);
1412
1052
   }
1413
1053
 
1414
1054
   lp_build_transpose_aos(gallivm, vs_type, soa, soa);
1446
1086
   LLVMTypeRef vs_type_llvm = lp_build_vec_type(gallivm, vs_type);
1447
1087
   LLVMValueRef out3 = LLVMBuildLoad2(builder, vs_type_llvm, outputs[pos][3], ""); /*w0 w1 .. wn*/
1448
1088
   LLVMValueRef const1 = lp_build_const_vec(gallivm, f32_type, 1.0);       /*1.0 1.0 1.0 1.0*/
1449
 
   LLVMValueRef vp_ptr = draw_jit_context_viewports(variant, context_ptr);
 
1089
   LLVMValueRef vp_ptr = draw_vs_jit_context_viewports(variant, context_ptr);
1450
1090
 
1451
1091
   /* We treat pipe_viewport_state as a float array */
1452
1092
   const int scale_index_offset = offsetof(struct pipe_viewport_state, scale) / sizeof(float);
1501
1141
                  struct draw_llvm_variant_key *key,
1502
1142
                  LLVMTypeRef context_type,
1503
1143
                  LLVMValueRef context_ptr,
1504
 
                  boolean *have_clipdist)
 
1144
                  bool *have_clipdist)
1505
1145
{
1506
1146
   LLVMBuilderRef builder = gallivm->builder;
1507
1147
   LLVMValueRef mask; /* stores the <nxi32> clipmasks */
1515
1155
   const unsigned pos = llvm->draw->vs.position_output;
1516
1156
   const unsigned cv = llvm->draw->vs.clipvertex_output;
1517
1157
   int num_written_clipdistance = llvm->draw->vs.vertex_shader->info.num_written_clipdistance;
1518
 
   boolean have_cd = false;
1519
 
   boolean clip_user = key->clip_user;
 
1158
   bool have_cd = false;
 
1159
   bool clip_user = key->clip_user;
1520
1160
   unsigned ucp_enable = key->ucp_enable;
1521
1161
   unsigned cd[2];
1522
1162
 
1618
1258
   }
1619
1259
 
1620
1260
   if (clip_user) {
1621
 
      LLVMValueRef planes_ptr = draw_jit_context_planes(gallivm, context_type, context_ptr);
 
1261
      LLVMValueRef planes_ptr = draw_vs_jit_context_planes(gallivm, context_type, context_ptr);
1622
1262
      LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
1623
1263
      LLVMTypeRef planes_type = LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES);
1624
1264
      LLVMValueRef indices[3];
1635
1275
            int i;
1636
1276
            i = plane_idx - 6;
1637
1277
 
1638
 
            *have_clipdist = TRUE;
 
1278
            *have_clipdist = true;
1639
1279
            if (i < 4) {
1640
1280
               clipdist = LLVMBuildLoad2(builder, vec_type, outputs[cd[0]][i], "");
1641
1281
            } else {
1701
1341
                const struct lp_type vs_type,
1702
1342
                LLVMTypeRef clipmask_bool_type,
1703
1343
                LLVMValueRef clipmask_bool_ptr,
1704
 
                boolean edgeflag_in_clipmask)
 
1344
                bool edgeflag_in_clipmask)
1705
1345
{
1706
1346
   LLVMBuilderRef builder = gallivm->builder;
1707
1347
   LLVMTypeRef int8_type = LLVMInt8TypeInContext(gallivm->context);
1738
1378
static LLVMValueRef
1739
1379
draw_gs_llvm_fetch_input(const struct lp_build_gs_iface *gs_iface,
1740
1380
                         struct lp_build_context * bld,
1741
 
                         boolean is_vindex_indirect,
 
1381
                         bool is_vindex_indirect,
1742
1382
                         LLVMValueRef vertex_index,
1743
 
                         boolean is_aindex_indirect,
 
1383
                         bool is_aindex_indirect,
1744
1384
                         LLVMValueRef attrib_index,
1745
1385
                         LLVMValueRef swizzle_index)
1746
1386
{
1842
1482
                  outputs, clipmask,
1843
1483
                  gs_info->num_outputs, gs_type,
1844
1484
                  -1,
1845
 
                  FALSE);
 
1485
                  false);
1846
1486
   lp_build_endif(&if_ctx);
1847
1487
}
1848
1488
 
1916
1556
   struct gallivm_state *gallivm = variant->gallivm;
1917
1557
   LLVMContextRef context = gallivm->context;
1918
1558
   LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
1919
 
   LLVMTypeRef arg_types[13];
 
1559
   LLVMTypeRef arg_types[14];
1920
1560
   unsigned num_arg_types = ARRAY_SIZE(arg_types);
1921
1561
   LLVMTypeRef func_type;
1922
1562
   LLVMValueRef context_ptr;
 
1563
   LLVMValueRef resources_ptr;
1923
1564
   LLVMBasicBlockRef block;
1924
1565
   LLVMBuilderRef builder;
1925
1566
   char func_name[64];
1954
1595
    * (though this would be fixable here, but couldn't just broadcast
1955
1596
    * the values).
1956
1597
    */
1957
 
   const boolean bypass_viewport = key->has_gs_or_tes || key->bypass_viewport ||
1958
 
                                   vs_info->writes_viewport_index;
1959
 
   const boolean enable_cliptest = !key->has_gs_or_tes && (key->clip_xy ||
 
1598
   const bool bypass_viewport = key->has_gs_or_tes || key->bypass_viewport ||
 
1599
                                vs_info->writes_viewport_index;
 
1600
   const bool enable_cliptest = !key->has_gs_or_tes && (key->clip_xy ||
1960
1601
                                                    key->clip_z ||
1961
1602
                                                    key->clip_user ||
1962
1603
                                                    key->need_edgeflags);
1963
1604
   LLVMValueRef variant_func;
1964
1605
   const unsigned pos = draw->vs.position_output;
1965
1606
   const unsigned cv = draw->vs.clipvertex_output;
1966
 
   boolean have_clipdist = FALSE;
 
1607
   bool have_clipdist = false;
1967
1608
   struct lp_bld_tgsi_system_values system_values;
1968
1609
 
1969
1610
   memset(&system_values, 0, sizeof(system_values));
1972
1613
 
1973
1614
   i = 0;
1974
1615
   arg_types[i++] = get_context_ptr_type(variant);       /* context */
 
1616
   arg_types[i++] = variant->resources_ptr_type;       /* context */
1975
1617
   arg_types[i++] = get_vertex_header_ptr_type(variant); /* vertex_header */
1976
1618
   arg_types[i++] = get_buffer_ptr_type(variant);        /* vbuffers */
1977
1619
   arg_types[i++] = int32_type;                          /* count */
1984
1626
   arg_types[i++] = LLVMPointerType(int32_type, 0);      /* fetch_elts  */
1985
1627
   arg_types[i++] = int32_type;                          /* draw_id */
1986
1628
   arg_types[i++] = int32_type;                          /* view_id */
 
1629
   assert(i == ARRAY_SIZE(arg_types));
1987
1630
 
1988
1631
   func_type = LLVMFunctionType(LLVMInt8TypeInContext(context),
1989
1632
                                arg_types, num_arg_types, 0);
2000
1643
      return;
2001
1644
 
2002
1645
   context_ptr               = LLVMGetParam(variant_func, 0);
2003
 
   io_ptr                    = LLVMGetParam(variant_func, 1);
2004
 
   vbuffers_ptr              = LLVMGetParam(variant_func, 2);
2005
 
   count                     = LLVMGetParam(variant_func, 3);
2006
 
   start                     = LLVMGetParam(variant_func, 4);
 
1646
   resources_ptr             = LLVMGetParam(variant_func, 1);
 
1647
   io_ptr                    = LLVMGetParam(variant_func, 2);
 
1648
   vbuffers_ptr              = LLVMGetParam(variant_func, 3);
 
1649
   count                     = LLVMGetParam(variant_func, 4);
 
1650
   start                     = LLVMGetParam(variant_func, 5);
2007
1651
   /*
2008
1652
    * XXX: stride is actually unused. The stride we use is strictly calculated
2009
1653
    * from the number of outputs (including the draw_extra outputs).
2010
1654
    * Should probably fix some day (we need a new vs just because of extra
2011
1655
    * outputs which the generated vs won't touch).
2012
1656
    */
2013
 
   stride                    = LLVMGetParam(variant_func, 5);
2014
 
   vb_ptr                    = LLVMGetParam(variant_func, 6);
2015
 
   system_values.instance_id = LLVMGetParam(variant_func, 7);
2016
 
   vertex_id_offset          = LLVMGetParam(variant_func, 8);
2017
 
   system_values.base_instance = LLVMGetParam(variant_func, 9);
2018
 
   fetch_elts                = LLVMGetParam(variant_func, 10);
2019
 
   system_values.draw_id     = LLVMGetParam(variant_func, 11);
2020
 
   system_values.view_index  = LLVMGetParam(variant_func, 12);
 
1657
   stride                    = LLVMGetParam(variant_func, 6);
 
1658
   vb_ptr                    = LLVMGetParam(variant_func, 7);
 
1659
   system_values.instance_id = LLVMGetParam(variant_func, 8);
 
1660
   vertex_id_offset          = LLVMGetParam(variant_func, 9);
 
1661
   system_values.base_instance = LLVMGetParam(variant_func, 10);
 
1662
   fetch_elts                = LLVMGetParam(variant_func, 11);
 
1663
   system_values.draw_id     = LLVMGetParam(variant_func, 12);
 
1664
   system_values.view_index  = LLVMGetParam(variant_func, 13);
2021
1665
 
2022
1666
   lp_build_name(context_ptr, "context");
 
1667
   lp_build_name(resources_ptr, "resources");
2023
1668
   lp_build_name(io_ptr, "io");
2024
1669
   lp_build_name(vbuffers_ptr, "vbuffers");
2025
1670
   lp_build_name(count, "count");
2041
1686
   LLVMPositionBuilderAtEnd(builder, block);
2042
1687
 
2043
1688
   memset(&vs_type, 0, sizeof vs_type);
2044
 
   vs_type.floating = TRUE; /* floating point values */
2045
 
   vs_type.sign = TRUE;     /* values are signed */
2046
 
   vs_type.norm = FALSE;    /* values are not limited to [0,1] or [-1,1] */
 
1689
   vs_type.floating = true; /* floating point values */
 
1690
   vs_type.sign = true;     /* values are signed */
 
1691
   vs_type.norm = false;    /* values are not limited to [0,1] or [-1,1] */
2047
1692
   vs_type.width = 32;      /* 32-bit float */
2048
1693
   vs_type.length = vector_length;
2049
1694
 
2060
1705
   fake_buf_ptr = LLVMBuildGEP2(builder, LLVMInt8TypeInContext(context), fake_buf, &bld.zero, 1, "");
2061
1706
 
2062
1707
   /* code generated texture sampling */
2063
 
   sampler = draw_llvm_sampler_soa_create(draw_llvm_variant_key_samplers(key),
 
1708
   sampler = lp_bld_llvm_sampler_soa_create(draw_llvm_variant_key_samplers(key),
2064
1709
                                          MAX2(key->nr_samplers,
2065
1710
                                               key->nr_sampler_views));
2066
 
   image = draw_llvm_image_soa_create(draw_llvm_variant_key_images(key),
 
1711
   image = lp_bld_llvm_image_soa_create(draw_llvm_variant_key_images(key),
2067
1712
                                      key->nr_images);
2068
1713
 
2069
1714
   step = lp_build_const_int32(gallivm, vector_length);
2075
1720
   }
2076
1721
 
2077
1722
   have_elts = LLVMBuildICmp(builder, LLVMIntNE,
2078
 
                             LLVMConstPointerNull(arg_types[10]), fetch_elts, "");
 
1723
                             LLVMConstPointerNull(arg_types[11]), fetch_elts, "");
2079
1724
 
2080
1725
   fetch_max = LLVMBuildSub(builder, count, bld.one, "fetch_max");
2081
1726
   fetch_max = lp_build_broadcast_scalar(&blduivec, fetch_max);
2245
1890
                                       LLVMPointerType(LLVMInt8TypeInContext(context),
2246
1891
                                                       0), "");
2247
1892
         tmp = lp_build_gather(gallivm, vs_type.length,
2248
 
                               32, bld.type, TRUE,
2249
 
                               fetch_elts, tmp, FALSE);
 
1893
                               32, bld.type, true,
 
1894
                               fetch_elts, tmp, false);
2250
1895
         LLVMBuildStore(builder, tmp, index_store);
2251
1896
      }
2252
1897
      lp_build_else(&if_ctx);
2315
1960
                  ptr_aos,
2316
1961
                  &system_values,
2317
1962
                  context_ptr,
 
1963
                  resources_ptr,
2318
1964
                  sampler,
2319
1965
                  image,
2320
1966
                  key->clamp_vertex_color,
2361
2007
   }
2362
2008
   lp_build_loop_end_cond(&lp_loop, count, step, LLVMIntUGE);
2363
2009
 
2364
 
   draw_llvm_sampler_soa_destroy(sampler);
2365
 
   draw_llvm_image_soa_destroy(image);
 
2010
   lp_bld_llvm_sampler_soa_destroy(sampler);
 
2011
   lp_bld_llvm_image_soa_destroy(image);
2366
2012
 
2367
2013
   /* return clipping boolean value for function */
2368
2014
   ret = clipmask_booli8(gallivm, vs_type, blduivec.vec_type, clipmask_bool_ptr,
2378
2024
draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
2379
2025
{
2380
2026
   struct draw_llvm_variant_key *key;
2381
 
   struct draw_sampler_static_state *draw_sampler;
2382
 
   struct draw_image_static_state *draw_image;
 
2027
   struct lp_sampler_static_state *draw_sampler;
 
2028
   struct lp_image_static_state *draw_image;
2383
2029
 
2384
2030
   key = (struct draw_llvm_variant_key *)store;
2385
2031
 
2393
2039
   key->bypass_viewport = llvm->draw->bypass_viewport;
2394
2040
   key->clip_halfz = llvm->draw->rasterizer->clip_halfz;
2395
2041
   /* XXX assumes edgeflag output not at 0 */
2396
 
   key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? TRUE : FALSE);
 
2042
   key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? true : false);
2397
2043
   key->ucp_enable = llvm->draw->rasterizer->clip_plane_enable;
2398
2044
   key->has_gs_or_tes = llvm->draw->gs.geometry_shader != NULL || llvm->draw->tes.tess_eval_shader != NULL;
2399
2045
   key->num_outputs = draw_total_vs_outputs(llvm->draw);
2467
2113
void
2468
2114
draw_llvm_dump_variant_key(struct draw_llvm_variant_key *key)
2469
2115
{
2470
 
   struct draw_sampler_static_state *sampler = draw_llvm_variant_key_samplers(key);
2471
 
   struct draw_image_static_state *image = draw_llvm_variant_key_images(key);
 
2116
   struct lp_sampler_static_state *sampler = draw_llvm_variant_key_samplers(key);
 
2117
   struct lp_image_static_state *image = draw_llvm_variant_key_images(key);
2472
2118
   debug_printf("clamp_vertex_color = %u\n", key->clamp_vertex_color);
2473
2119
   debug_printf("clip_xy = %u\n", key->clip_xy);
2474
2120
   debug_printf("clip_z = %u\n", key->clip_z);
2508
2154
                             uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
2509
2155
                             uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS])
2510
2156
{
2511
 
   struct draw_jit_texture *jit_tex;
2512
 
 
2513
 
   switch (shader_stage) {
2514
 
   case PIPE_SHADER_VERTEX:
2515
 
      assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_context.textures));
2516
 
      jit_tex = &draw->llvm->jit_context.textures[sview_idx];
2517
 
      break;
2518
 
   case PIPE_SHADER_GEOMETRY:
2519
 
      assert(sview_idx < ARRAY_SIZE(draw->llvm->gs_jit_context.textures));
2520
 
      jit_tex = &draw->llvm->gs_jit_context.textures[sview_idx];
2521
 
      break;
2522
 
   case PIPE_SHADER_TESS_CTRL:
2523
 
      assert(sview_idx < ARRAY_SIZE(draw->llvm->tcs_jit_context.textures));
2524
 
      jit_tex = &draw->llvm->tcs_jit_context.textures[sview_idx];
2525
 
      break;
2526
 
   case PIPE_SHADER_TESS_EVAL:
2527
 
      assert(sview_idx < ARRAY_SIZE(draw->llvm->tes_jit_context.textures));
2528
 
      jit_tex = &draw->llvm->tes_jit_context.textures[sview_idx];
2529
 
      break;
2530
 
   default:
2531
 
      assert(0);
2532
 
      return;
2533
 
   }
2534
 
 
 
2157
   struct lp_jit_texture *jit_tex;
 
2158
 
 
2159
   assert(shader_stage < DRAW_MAX_SHADER_STAGE);
 
2160
   assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_resources[shader_stage].textures));
 
2161
 
 
2162
   jit_tex = &draw->llvm->jit_resources[shader_stage].textures[sview_idx];
2535
2163
   jit_tex->width = width;
2536
2164
   jit_tex->height = height;
2537
2165
   jit_tex->depth = depth;
2560
2188
                           uint32_t num_samples,
2561
2189
                           uint32_t sample_stride)
2562
2190
{
2563
 
   struct draw_jit_image *jit_image;
2564
 
 
2565
 
   switch (shader_stage) {
2566
 
   case PIPE_SHADER_VERTEX:
2567
 
      assert(idx < ARRAY_SIZE(draw->llvm->jit_context.images));
2568
 
      jit_image = &draw->llvm->jit_context.images[idx];
2569
 
      break;
2570
 
   case PIPE_SHADER_GEOMETRY:
2571
 
      assert(idx < ARRAY_SIZE(draw->llvm->gs_jit_context.images));
2572
 
      jit_image = &draw->llvm->gs_jit_context.images[idx];
2573
 
      break;
2574
 
   case PIPE_SHADER_TESS_CTRL:
2575
 
      assert(idx < ARRAY_SIZE(draw->llvm->tcs_jit_context.images));
2576
 
      jit_image = &draw->llvm->tcs_jit_context.images[idx];
2577
 
      break;
2578
 
   case PIPE_SHADER_TESS_EVAL:
2579
 
      assert(idx < ARRAY_SIZE(draw->llvm->tes_jit_context.images));
2580
 
      jit_image = &draw->llvm->tes_jit_context.images[idx];
2581
 
      break;
2582
 
   default:
2583
 
      assert(0);
2584
 
      return;
2585
 
   }
 
2191
   struct lp_jit_image *jit_image;
 
2192
 
 
2193
   assert(shader_stage < DRAW_MAX_SHADER_STAGE);
 
2194
   assert(idx < ARRAY_SIZE(draw->llvm->jit_resources[shader_stage].images));
 
2195
 
 
2196
   jit_image = &draw->llvm->jit_resources[shader_stage].images[idx];
2586
2197
 
2587
2198
   jit_image->width = width;
2588
2199
   jit_image->height = height;
2600
2211
draw_llvm_set_sampler_state(struct draw_context *draw,
2601
2212
                            enum pipe_shader_type shader_type)
2602
2213
{
2603
 
   switch (shader_type) {
2604
 
   case PIPE_SHADER_VERTEX:
2605
 
      for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_VERTEX]; i++) {
2606
 
         struct draw_jit_sampler *jit_sam = &draw->llvm->jit_context.samplers[i];
2607
 
 
2608
 
         if (draw->samplers[PIPE_SHADER_VERTEX][i]) {
2609
 
            const struct pipe_sampler_state *s
2610
 
               = draw->samplers[PIPE_SHADER_VERTEX][i];
2611
 
            jit_sam->min_lod = s->min_lod;
2612
 
            jit_sam->max_lod = s->max_lod;
2613
 
            jit_sam->lod_bias = s->lod_bias;
2614
 
            jit_sam->max_aniso = s->max_anisotropy;
2615
 
            COPY_4V(jit_sam->border_color, s->border_color.f);
2616
 
         }
2617
 
      }
2618
 
      break;
2619
 
   case PIPE_SHADER_GEOMETRY:
2620
 
      for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_GEOMETRY]; i++) {
2621
 
         struct draw_jit_sampler *jit_sam = &draw->llvm->gs_jit_context.samplers[i];
2622
 
 
2623
 
         if (draw->samplers[PIPE_SHADER_GEOMETRY][i]) {
2624
 
            const struct pipe_sampler_state *s
2625
 
               = draw->samplers[PIPE_SHADER_GEOMETRY][i];
2626
 
            jit_sam->min_lod = s->min_lod;
2627
 
            jit_sam->max_lod = s->max_lod;
2628
 
            jit_sam->lod_bias = s->lod_bias;
2629
 
            jit_sam->max_aniso = s->max_anisotropy;
2630
 
            COPY_4V(jit_sam->border_color, s->border_color.f);
2631
 
         }
2632
 
      }
2633
 
      break;
2634
 
   case PIPE_SHADER_TESS_CTRL:
2635
 
      for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_TESS_CTRL]; i++) {
2636
 
         struct draw_jit_sampler *jit_sam = &draw->llvm->tcs_jit_context.samplers[i];
2637
 
 
2638
 
         if (draw->samplers[PIPE_SHADER_TESS_CTRL][i]) {
2639
 
            const struct pipe_sampler_state *s
2640
 
               = draw->samplers[PIPE_SHADER_TESS_CTRL][i];
2641
 
            jit_sam->min_lod = s->min_lod;
2642
 
            jit_sam->max_lod = s->max_lod;
2643
 
            jit_sam->lod_bias = s->lod_bias;
2644
 
            jit_sam->max_aniso = s->max_anisotropy;
2645
 
            COPY_4V(jit_sam->border_color, s->border_color.f);
2646
 
         }
2647
 
      }
2648
 
      break;
2649
 
   case PIPE_SHADER_TESS_EVAL:
2650
 
      for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_TESS_EVAL]; i++) {
2651
 
         struct draw_jit_sampler *jit_sam = &draw->llvm->tes_jit_context.samplers[i];
2652
 
 
2653
 
         if (draw->samplers[PIPE_SHADER_TESS_EVAL][i]) {
2654
 
            const struct pipe_sampler_state *s
2655
 
               = draw->samplers[PIPE_SHADER_TESS_EVAL][i];
2656
 
            jit_sam->min_lod = s->min_lod;
2657
 
            jit_sam->max_lod = s->max_lod;
2658
 
            jit_sam->lod_bias = s->lod_bias;
2659
 
            jit_sam->max_aniso = s->max_anisotropy;
2660
 
            COPY_4V(jit_sam->border_color, s->border_color.f);
2661
 
         }
2662
 
      }
2663
 
      break;
2664
 
   default:
2665
 
      assert(0);
2666
 
      break;
 
2214
   assert(shader_type < DRAW_MAX_SHADER_STAGE);
 
2215
   for (unsigned i = 0; i < draw->num_samplers[shader_type]; i++) {
 
2216
      struct lp_jit_sampler *jit_sam = &draw->llvm->jit_resources[shader_type].samplers[i];
 
2217
 
 
2218
      if (draw->samplers[shader_type][i]) {
 
2219
         const struct pipe_sampler_state *s
 
2220
            = draw->samplers[shader_type][i];
 
2221
         jit_sam->min_lod = s->min_lod;
 
2222
         jit_sam->max_lod = s->max_lod;
 
2223
         jit_sam->lod_bias = s->lod_bias;
 
2224
         jit_sam->max_aniso = s->max_anisotropy;
 
2225
         COPY_4V(jit_sam->border_color, s->border_color.f);
 
2226
      }
2667
2227
   }
2668
2228
}
2669
2229
 
2695
2255
create_gs_jit_types(struct draw_gs_llvm_variant *var)
2696
2256
{
2697
2257
   struct gallivm_state *gallivm = var->gallivm;
2698
 
   LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
2699
 
 
2700
 
   texture_type = create_jit_texture_type(gallivm, "texture");
2701
 
   sampler_type = create_jit_sampler_type(gallivm, "sampler");
2702
 
   image_type = create_jit_image_type(gallivm, "image");
2703
 
   buffer_type = lp_build_create_jit_buffer_type(gallivm);
2704
2258
 
2705
2259
   var->context_type = create_gs_jit_context_type(gallivm,
2706
2260
                                             var->shader->base.vector_length,
2707
 
                                             buffer_type,
2708
 
                                             texture_type, sampler_type,
2709
 
                                             image_type,
2710
2261
                                             "draw_gs_jit_context");
2711
2262
   var->context_ptr_type = LLVMPointerType(var->context_type, 0);
2712
2263
 
 
2264
   var->resources_type = lp_build_jit_resources_type(gallivm);
 
2265
   var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
2713
2266
   var->input_array_type = create_gs_jit_input_type(gallivm);
2714
2267
}
2715
2268
 
2753
2306
   struct gallivm_state *gallivm = variant->gallivm;
2754
2307
   LLVMContextRef context = gallivm->context;
2755
2308
   LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
2756
 
   LLVMTypeRef arg_types[8];
 
2309
   LLVMTypeRef arg_types[9];
2757
2310
   LLVMTypeRef func_type;
2758
2311
   LLVMValueRef variant_func;
2759
2312
   LLVMValueRef context_ptr;
 
2313
   LLVMValueRef resources_ptr;
2760
2314
   LLVMValueRef prim_id_ptr;
2761
2315
   LLVMBasicBlockRef block;
2762
2316
   LLVMBuilderRef builder;
2785
2339
 
2786
2340
   LLVMTypeRef prim_id_type = LLVMVectorType(int32_type, vector_length);
2787
2341
   arg_types[0] = get_gs_context_ptr_type(variant);    /* context */
2788
 
   arg_types[1] = variant->input_array_type;           /* input */
2789
 
   arg_types[2] = LLVMPointerType(variant->vertex_header_ptr_type, 0);     /* vertex_header */
2790
 
   arg_types[3] = int32_type;                          /* num_prims */
2791
 
   arg_types[4] = int32_type;                          /* instance_id */
2792
 
   arg_types[5] = LLVMPointerType(prim_id_type, 0);    /* prim_id_ptr */
2793
 
   arg_types[6] = int32_type;
 
2342
   arg_types[1] = variant->resources_ptr_type;
 
2343
   arg_types[2] = variant->input_array_type;           /* input */
 
2344
   arg_types[3] = LLVMPointerType(variant->vertex_header_ptr_type, 0);     /* vertex_header */
 
2345
   arg_types[4] = int32_type;                          /* num_prims */
 
2346
   arg_types[5] = int32_type;                          /* instance_id */
 
2347
   arg_types[6] = LLVMPointerType(prim_id_type, 0);    /* prim_id_ptr */
2794
2348
   arg_types[7] = int32_type;
 
2349
   arg_types[8] = int32_type;
2795
2350
 
2796
2351
   func_type = LLVMFunctionType(int32_type, arg_types, ARRAY_SIZE(arg_types), 0);
2797
2352
 
2808
2363
   if (gallivm->cache && gallivm->cache->data_size)
2809
2364
      return;
2810
2365
   context_ptr               = LLVMGetParam(variant_func, 0);
2811
 
   input_array               = LLVMGetParam(variant_func, 1);
2812
 
   io_ptr                    = LLVMGetParam(variant_func, 2);
2813
 
   num_prims                 = LLVMGetParam(variant_func, 3);
2814
 
   system_values.instance_id = LLVMGetParam(variant_func, 4);
2815
 
   prim_id_ptr               = LLVMGetParam(variant_func, 5);
2816
 
   system_values.invocation_id = LLVMGetParam(variant_func, 6);
2817
 
   system_values.view_index  = LLVMGetParam(variant_func, 7);
 
2366
   resources_ptr             = LLVMGetParam(variant_func, 1);
 
2367
   input_array               = LLVMGetParam(variant_func, 2);
 
2368
   io_ptr                    = LLVMGetParam(variant_func, 3);
 
2369
   num_prims                 = LLVMGetParam(variant_func, 4);
 
2370
   system_values.instance_id = LLVMGetParam(variant_func, 5);
 
2371
   prim_id_ptr               = LLVMGetParam(variant_func, 6);
 
2372
   system_values.invocation_id = LLVMGetParam(variant_func, 7);
 
2373
   system_values.view_index  = LLVMGetParam(variant_func, 8);
2818
2374
 
2819
2375
   lp_build_name(context_ptr, "context");
 
2376
   lp_build_name(resources_ptr, "resources");
2820
2377
   lp_build_name(input_array, "input");
2821
2378
   lp_build_name(io_ptr, "io");
2822
2379
   lp_build_name(num_prims, "num_prims");
2847
2404
   lp_build_context_init(&bld, gallivm, lp_type_int(32));
2848
2405
 
2849
2406
   memset(&gs_type, 0, sizeof gs_type);
2850
 
   gs_type.floating = TRUE; /* floating point values */
2851
 
   gs_type.sign = TRUE;     /* values are signed */
2852
 
   gs_type.norm = FALSE;    /* values are not limited to [0,1] or [-1,1] */
 
2407
   gs_type.floating = true; /* floating point values */
 
2408
   gs_type.sign = true;     /* values are signed */
 
2409
   gs_type.norm = false;    /* values are not limited to [0,1] or [-1,1] */
2853
2410
   gs_type.width = 32;      /* 32-bit float */
2854
2411
   gs_type.length = vector_length;
2855
2412
 
2856
 
   consts_ptr = draw_gs_jit_context_constants(variant, context_ptr);
 
2413
   consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
2857
2414
 
2858
 
   ssbos_ptr = draw_gs_jit_context_ssbos(variant, context_ptr);
 
2415
   ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
2859
2416
 
2860
2417
   /* code generated texture sampling */
2861
 
   sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
 
2418
   sampler = lp_bld_llvm_sampler_soa_create(variant->key.samplers,
2862
2419
                                          MAX2(variant->key.nr_samplers,
2863
2420
                                               variant->key.nr_sampler_views));
2864
 
   image = draw_llvm_image_soa_create(draw_gs_llvm_variant_key_images(&variant->key),
 
2421
   image = lp_bld_llvm_image_soa_create(draw_gs_llvm_variant_key_images(&variant->key),
2865
2422
                                      variant->key.nr_images);
2866
2423
   mask_val = generate_mask_value(variant, gs_type);
2867
2424
   lp_build_mask_begin(&mask, gallivm, gs_type, mask_val);
2887
2444
   params.system_values = &system_values;
2888
2445
   params.context_type = variant->context_type;
2889
2446
   params.context_ptr = context_ptr;
 
2447
   params.resources_type = variant->resources_type;
 
2448
   params.resources_ptr = resources_ptr;
2890
2449
   params.sampler = sampler;
2891
2450
   params.info = &llvm->draw->gs.geometry_shader->info;
2892
2451
   params.gs_iface = (const struct lp_build_gs_iface *)&gs_iface;
2893
2452
   params.ssbo_ptr = ssbos_ptr;
2894
2453
   params.image = image;
2895
2454
   params.gs_vertex_streams = variant->shader->base.num_vertex_streams;
2896
 
   params.aniso_filter_table = draw_gs_jit_context_aniso_filter_table(variant, context_ptr);
 
2455
   params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm,
 
2456
                                                                   variant->resources_type,
 
2457
                                                                   resources_ptr);
2897
2458
 
2898
2459
   if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI)
2899
2460
      lp_build_tgsi_soa(variant->gallivm,
2906
2467
                       &params,
2907
2468
                       outputs);
2908
2469
 
2909
 
   draw_llvm_sampler_soa_destroy(sampler);
2910
 
   draw_llvm_image_soa_destroy(image);
 
2470
   lp_bld_llvm_sampler_soa_destroy(sampler);
 
2471
   lp_bld_llvm_image_soa_destroy(image);
2911
2472
 
2912
2473
   lp_build_mask_end(&mask);
2913
2474
 
2961
2522
 
2962
2523
   create_gs_jit_types(variant);
2963
2524
 
2964
 
   variant->vertex_header_type = create_jit_vertex_header(variant->gallivm, num_outputs);
 
2525
   variant->vertex_header_type = lp_build_create_jit_vertex_header_type(variant->gallivm, num_outputs);
2965
2526
   variant->vertex_header_ptr_type = LLVMPointerType(variant->vertex_header_type, 0);
2966
2527
 
2967
2528
   draw_gs_llvm_generate(llvm, variant);
3010
2571
draw_gs_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
3011
2572
{
3012
2573
   struct draw_gs_llvm_variant_key *key;
3013
 
   struct draw_sampler_static_state *draw_sampler;
3014
 
   struct draw_image_static_state *draw_image;
 
2574
   struct lp_sampler_static_state *draw_sampler;
 
2575
   struct lp_image_static_state *draw_image;
3015
2576
 
3016
2577
   key = (struct draw_gs_llvm_variant_key *)store;
3017
2578
 
3062
2623
void
3063
2624
draw_gs_llvm_dump_variant_key(struct draw_gs_llvm_variant_key *key)
3064
2625
{
3065
 
   struct draw_sampler_static_state *sampler = key->samplers;
3066
 
   struct draw_image_static_state *image = draw_gs_llvm_variant_key_images(key);
 
2626
   struct lp_sampler_static_state *sampler = key->samplers;
 
2627
   struct lp_image_static_state *image = draw_gs_llvm_variant_key_images(key);
3067
2628
 
3068
2629
   debug_printf("clamp_vertex_color = %u\n", key->clamp_vertex_color);
3069
2630
   for (unsigned i = 0 ; i < key->nr_sampler_views; i++) {
3081
2642
create_tcs_jit_types(struct draw_tcs_llvm_variant *var)
3082
2643
{
3083
2644
   struct gallivm_state *gallivm = var->gallivm;
3084
 
   LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
3085
 
 
3086
 
   texture_type = create_jit_texture_type(gallivm, "texture");
3087
 
   sampler_type = create_jit_sampler_type(gallivm, "sampler");
3088
 
   image_type = create_jit_image_type(gallivm, "image");
3089
 
   buffer_type = lp_build_create_jit_buffer_type(gallivm);
3090
 
 
3091
 
   var->context_type = create_tcs_jit_context_type(gallivm,
3092
 
                                              0,
3093
 
                                              buffer_type,
3094
 
                                              texture_type, sampler_type,
3095
 
                                              image_type,
3096
 
                                              "draw_tcs_jit_context");
 
2645
 
 
2646
   var->resources_type = lp_build_jit_resources_type(gallivm);
 
2647
   var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
3097
2648
   var->input_array_type = create_tcs_jit_input_type(gallivm);
3098
2649
   var->output_array_type = create_tcs_jit_output_type(gallivm);
3099
 
   var->context_ptr_type = LLVMPointerType(var->context_type, 0);
3100
2650
}
3101
2651
 
3102
2652
 
3103
2653
static LLVMTypeRef
3104
 
get_tcs_context_ptr_type(struct draw_tcs_llvm_variant *variant)
 
2654
get_tcs_resources_ptr_type(struct draw_tcs_llvm_variant *variant)
3105
2655
{
3106
 
   if (!variant->context_ptr_type)
 
2656
   if (!variant->resources_ptr_type)
3107
2657
      create_tcs_jit_types(variant);
3108
 
   return variant->context_ptr_type;
 
2658
   return variant->resources_ptr_type;
3109
2659
}
3110
2660
 
3111
2661
 
3112
2662
static LLVMValueRef
3113
2663
draw_tcs_llvm_emit_fetch_input(const struct lp_build_tcs_iface *tes_iface,
3114
2664
                               struct lp_build_context *bld,
3115
 
                               boolean is_vindex_indirect,
 
2665
                               bool is_vindex_indirect,
3116
2666
                               LLVMValueRef vertex_index,
3117
 
                               boolean is_aindex_indirect,
 
2667
                               bool is_aindex_indirect,
3118
2668
                               LLVMValueRef attrib_index,
3119
 
                               boolean is_sindex_indirect,
 
2669
                               bool is_sindex_indirect,
3120
2670
                               LLVMValueRef swizzle_index)
3121
2671
{
3122
2672
   const struct draw_tcs_llvm_iface *tcs = draw_tcs_llvm_iface(tes_iface);
3173
2723
static LLVMValueRef
3174
2724
draw_tcs_llvm_emit_fetch_output(const struct lp_build_tcs_iface *tes_iface,
3175
2725
                                struct lp_build_context *bld,
3176
 
                                boolean is_vindex_indirect,
 
2726
                                bool is_vindex_indirect,
3177
2727
                                LLVMValueRef vertex_index,
3178
 
                                boolean is_aindex_indirect,
 
2728
                                bool is_aindex_indirect,
3179
2729
                                LLVMValueRef attrib_index,
3180
 
                                boolean is_sindex_indirect,
 
2730
                                bool is_sindex_indirect,
3181
2731
                                LLVMValueRef swizzle_index,
3182
2732
                                uint32_t name)
3183
2733
{
3238
2788
draw_tcs_llvm_emit_store_output(const struct lp_build_tcs_iface *tes_iface,
3239
2789
                                struct lp_build_context *bld,
3240
2790
                                unsigned name,
3241
 
                                boolean is_vindex_indirect,
 
2791
                                bool is_vindex_indirect,
3242
2792
                                LLVMValueRef vertex_index,
3243
 
                                boolean is_aindex_indirect,
 
2793
                                bool is_aindex_indirect,
3244
2794
                                LLVMValueRef attrib_index,
3245
 
                                boolean is_sindex_indirect,
 
2795
                                bool is_sindex_indirect,
3246
2796
                                LLVMValueRef swizzle_index,
3247
2797
                                LLVMValueRef value,
3248
2798
                                LLVMValueRef mask_vec)
3345
2895
   LLVMTypeRef arg_types[7];
3346
2896
   LLVMTypeRef func_type, coro_func_type;
3347
2897
   LLVMValueRef variant_func, variant_coro;
3348
 
   LLVMValueRef context_ptr;
 
2898
   LLVMValueRef resources_ptr;
3349
2899
   LLVMValueRef view_index;
3350
2900
   LLVMValueRef input_array, output_array, prim_id, patch_vertices_in;
3351
2901
   LLVMValueRef mask_val;
3369
2919
 
3370
2920
   snprintf(func_name_coro, sizeof(func_name_coro), "draw_llvm_tcs_coro_variant");
3371
2921
 
3372
 
   arg_types[0] = get_tcs_context_ptr_type(variant);    /* context */
 
2922
   arg_types[0] = get_tcs_resources_ptr_type(variant);    /* context */
3373
2923
   arg_types[1] = variant->input_array_type;           /* input */
3374
2924
   arg_types[2] = variant->output_array_type;
3375
2925
   arg_types[3] = int32_type;
3401
2951
 
3402
2952
   if (gallivm->cache && gallivm->cache->data_size)
3403
2953
      return;
3404
 
   context_ptr               = LLVMGetParam(variant_func, 0);
 
2954
   resources_ptr               = LLVMGetParam(variant_func, 0);
3405
2955
   input_array               = LLVMGetParam(variant_func, 1);
3406
2956
   output_array              = LLVMGetParam(variant_func, 2);
3407
2957
   prim_id                   = LLVMGetParam(variant_func, 3);
3408
2958
   patch_vertices_in         = LLVMGetParam(variant_func, 4);
3409
2959
   view_index                = LLVMGetParam(variant_func, 5);
3410
2960
 
3411
 
   lp_build_name(context_ptr, "context");
 
2961
   lp_build_name(resources_ptr, "resources");
3412
2962
   lp_build_name(input_array, "input");
3413
2963
   lp_build_name(output_array, "output");
3414
2964
   lp_build_name(prim_id, "prim_id");
3422
2972
   lp_build_context_init(&bld, gallivm, lp_type_int(32));
3423
2973
 
3424
2974
   memset(&tcs_type, 0, sizeof tcs_type);
3425
 
   tcs_type.floating = TRUE; /* floating point values */
3426
 
   tcs_type.sign = TRUE;     /* values are signed */
3427
 
   tcs_type.norm = FALSE;    /* values are not limited to [0,1] or [-1,1] */
 
2975
   tcs_type.floating = true; /* floating point values */
 
2976
   tcs_type.sign = true;     /* values are signed */
 
2977
   tcs_type.norm = false;    /* values are not limited to [0,1] or [-1,1] */
3428
2978
   tcs_type.width = 32;      /* 32-bit float */
3429
2979
   tcs_type.length = vector_length;
3430
2980
 
3446
2996
                       lp_build_const_int32(gallivm, 0)); /* inner loop */
3447
2997
   {
3448
2998
      LLVMValueRef args[7];
3449
 
      args[0] = context_ptr;
 
2999
      args[0] = resources_ptr;
3450
3000
      args[1] = input_array;
3451
3001
      args[2] = output_array;
3452
3002
      args[3] = prim_id;
3489
3039
   block = LLVMAppendBasicBlockInContext(gallivm->context, variant_coro, "entry");
3490
3040
   LLVMPositionBuilderAtEnd(builder, block);
3491
3041
 
3492
 
   context_ptr = LLVMGetParam(variant_coro, 0);
 
3042
   resources_ptr = LLVMGetParam(variant_coro, 0);
3493
3043
   input_array = LLVMGetParam(variant_coro, 1);
3494
3044
   output_array = LLVMGetParam(variant_coro, 2);
3495
3045
   prim_id = LLVMGetParam(variant_coro, 3);
3496
3046
   patch_vertices_in = LLVMGetParam(variant_coro, 4);
3497
3047
   view_index = LLVMGetParam(variant_coro, 5);
3498
3048
 
3499
 
   consts_ptr = draw_tcs_jit_context_constants(variant, context_ptr);
 
3049
   consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
3500
3050
 
3501
 
   ssbos_ptr = draw_tcs_jit_context_ssbos(variant, context_ptr);
3502
 
   sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
 
3051
   ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
 
3052
   sampler = lp_bld_llvm_sampler_soa_create(variant->key.samplers,
3503
3053
                                          MAX2(variant->key.nr_samplers,
3504
3054
                                               variant->key.nr_sampler_views));
3505
 
   image = draw_llvm_image_soa_create(draw_tcs_llvm_variant_key_images(&variant->key),
 
3055
   image = lp_bld_llvm_image_soa_create(draw_tcs_llvm_variant_key_images(&variant->key),
3506
3056
                                      variant->key.nr_images);
3507
3057
 
3508
3058
   LLVMValueRef counter = LLVMGetParam(variant_coro, 6);
3546
3096
      params.mask = &mask;
3547
3097
      params.consts_ptr = consts_ptr;
3548
3098
      params.system_values = &system_values;
3549
 
      params.context_type = variant->context_type;
3550
 
      params.context_ptr = context_ptr;
 
3099
      params.resources_type = variant->resources_type;
 
3100
      params.resources_ptr = resources_ptr;
3551
3101
      params.sampler = sampler;
3552
3102
      params.info = &llvm->draw->tcs.tess_ctrl_shader->info;
3553
3103
      params.ssbo_ptr = ssbos_ptr;
3554
3104
      params.image = image;
3555
3105
      params.coro = &coro_info;
3556
3106
      params.tcs_iface = &tcs_iface.base;
3557
 
      params.aniso_filter_table = draw_tcs_jit_context_aniso_filter_table(variant, context_ptr);
 
3107
      params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm,
 
3108
                                                                      variant->resources_type,
 
3109
                                                                      resources_ptr);
3558
3110
 
3559
3111
      lp_build_nir_soa(variant->gallivm,
3560
3112
                       llvm->draw->tcs.tess_ctrl_shader->state.ir.nir,
3574
3126
      LLVMBuildRet(builder, coro_hdl);
3575
3127
   }
3576
3128
 
3577
 
   draw_llvm_sampler_soa_destroy(sampler);
3578
 
   draw_llvm_image_soa_destroy(image);
 
3129
   lp_bld_llvm_sampler_soa_destroy(sampler);
 
3130
   lp_bld_llvm_image_soa_destroy(image);
3579
3131
   gallivm_verify_function(gallivm, variant_func);
3580
3132
   gallivm_verify_function(gallivm, variant_coro);
3581
3133
}
3676
3228
{
3677
3229
   unsigned i;
3678
3230
   struct draw_tcs_llvm_variant_key *key;
3679
 
   struct draw_sampler_static_state *draw_sampler;
3680
 
   struct draw_image_static_state *draw_image;
 
3231
   struct lp_sampler_static_state *draw_sampler;
 
3232
   struct lp_image_static_state *draw_image;
3681
3233
 
3682
3234
   key = (struct draw_tcs_llvm_variant_key *)store;
3683
3235
 
3724
3276
void
3725
3277
draw_tcs_llvm_dump_variant_key(struct draw_tcs_llvm_variant_key *key)
3726
3278
{
3727
 
   struct draw_sampler_static_state *sampler = key->samplers;
3728
 
   struct draw_image_static_state *image = draw_tcs_llvm_variant_key_images(key);
 
3279
   struct lp_sampler_static_state *sampler = key->samplers;
 
3280
   struct lp_image_static_state *image = draw_tcs_llvm_variant_key_images(key);
3729
3281
   for (unsigned i = 0 ; i < key->nr_sampler_views; i++) {
3730
3282
      debug_printf("sampler[%i].src_format = %s\n", i,
3731
3283
                   util_format_name(sampler[i].texture_state.format));
3740
3292
create_tes_jit_types(struct draw_tes_llvm_variant *var)
3741
3293
{
3742
3294
   struct gallivm_state *gallivm = var->gallivm;
3743
 
   LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
3744
 
 
3745
 
   texture_type = create_jit_texture_type(gallivm, "texture");
3746
 
   sampler_type = create_jit_sampler_type(gallivm, "sampler");
3747
 
   image_type = create_jit_image_type(gallivm, "image");
3748
 
   buffer_type = lp_build_create_jit_buffer_type(gallivm);
3749
 
 
3750
 
   var->context_type = create_tes_jit_context_type(gallivm,
3751
 
                                              0,
3752
 
                                              buffer_type,
3753
 
                                              texture_type, sampler_type,
3754
 
                                              image_type,
3755
 
                                              "draw_tes_jit_context");
3756
 
   var->context_ptr_type = LLVMPointerType(var->context_type, 0);
3757
 
 
 
3295
 
 
3296
   var->resources_type = lp_build_jit_resources_type(gallivm);
 
3297
   var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
3758
3298
   var->input_array_deref_type = create_tes_jit_input_deref_type(gallivm);
3759
3299
   var->input_array_type = LLVMPointerType(var->input_array_deref_type, 0); /* num vertices per prim */
3760
3300
}
3761
3301
 
3762
3302
 
3763
3303
static LLVMTypeRef
3764
 
get_tes_context_ptr_type(struct draw_tes_llvm_variant *variant)
 
3304
get_tes_resources_ptr_type(struct draw_tes_llvm_variant *variant)
3765
3305
{
3766
 
   if (!variant->context_ptr_type)
 
3306
   if (!variant->resources_ptr_type)
3767
3307
      create_tes_jit_types(variant);
3768
 
   return variant->context_ptr_type;
 
3308
   return variant->resources_ptr_type;
3769
3309
}
3770
3310
 
3771
3311
 
3795
3335
static LLVMValueRef
3796
3336
draw_tes_llvm_fetch_vertex_input(const struct lp_build_tes_iface *tes_iface,
3797
3337
                                 struct lp_build_context *bld,
3798
 
                                 boolean is_vindex_indirect,
 
3338
                                 bool is_vindex_indirect,
3799
3339
                                 LLVMValueRef vertex_index,
3800
 
                                 boolean is_aindex_indirect,
 
3340
                                 bool is_aindex_indirect,
3801
3341
                                 LLVMValueRef attrib_index,
3802
 
                                 boolean is_sindex_indirect,
 
3342
                                 bool is_sindex_indirect,
3803
3343
                                 LLVMValueRef swizzle_index)
3804
3344
{
3805
3345
   const struct draw_tes_llvm_iface *tes = draw_tes_llvm_iface(tes_iface);
3857
3397
static LLVMValueRef
3858
3398
draw_tes_llvm_fetch_patch_input(const struct lp_build_tes_iface *tes_iface,
3859
3399
                                struct lp_build_context *bld,
3860
 
                                boolean is_aindex_indirect,
 
3400
                                bool is_aindex_indirect,
3861
3401
                                LLVMValueRef attrib_index,
3862
3402
                                LLVMValueRef swizzle_index)
3863
3403
{
3914
3454
   LLVMTypeRef arg_types[11];
3915
3455
   LLVMTypeRef func_type;
3916
3456
   LLVMValueRef variant_func;
3917
 
   LLVMValueRef context_ptr;
 
3457
   LLVMValueRef resources_ptr;
3918
3458
   LLVMValueRef tess_coord[2], io_ptr, input_array, num_tess_coord;
3919
3459
   LLVMValueRef view_index;
3920
3460
   LLVMValueRef tess_inner, tess_outer, prim_id, patch_vertices_in;
3945
3485
   LLVMTypeRef tess_outer_deref_type = LLVMArrayType(flt_type, 4);
3946
3486
   LLVMTypeRef tess_inner_deref_type = LLVMArrayType(flt_type, 2);
3947
3487
 
3948
 
   arg_types[0] = get_tes_context_ptr_type(variant);    /* context */
 
3488
   arg_types[0] = get_tes_resources_ptr_type(variant);    /* context */
3949
3489
   arg_types[1] = variant->input_array_type;           /* input */
3950
3490
   arg_types[2] = variant->vertex_header_ptr_type;
3951
3491
   arg_types[3] = int32_type;
3969
3509
 
3970
3510
   if (gallivm->cache && gallivm->cache->data_size)
3971
3511
      return;
3972
 
   context_ptr               = LLVMGetParam(variant_func, 0);
 
3512
   resources_ptr               = LLVMGetParam(variant_func, 0);
3973
3513
   input_array               = LLVMGetParam(variant_func, 1);
3974
3514
   io_ptr                    = LLVMGetParam(variant_func, 2);
3975
3515
   prim_id                   = LLVMGetParam(variant_func, 3);
3981
3521
   patch_vertices_in         = LLVMGetParam(variant_func, 9);
3982
3522
   view_index                = LLVMGetParam(variant_func, 10);
3983
3523
 
3984
 
   lp_build_name(context_ptr, "context");
 
3524
   lp_build_name(resources_ptr, "resources");
3985
3525
   lp_build_name(input_array, "input");
3986
3526
   lp_build_name(io_ptr, "io");
3987
3527
   lp_build_name(prim_id, "prim_id");
4005
3545
   lp_build_context_init(&bld, gallivm, lp_type_int(32));
4006
3546
 
4007
3547
   memset(&tes_type, 0, sizeof tes_type);
4008
 
   tes_type.floating = TRUE; /* floating point values */
4009
 
   tes_type.sign = TRUE;     /* values are signed */
4010
 
   tes_type.norm = FALSE;    /* values are not limited to [0,1] or [-1,1] */
 
3548
   tes_type.floating = true; /* floating point values */
 
3549
   tes_type.sign = true;     /* values are signed */
 
3550
   tes_type.norm = false;    /* values are not limited to [0,1] or [-1,1] */
4011
3551
   tes_type.width = 32;      /* 32-bit float */
4012
3552
   tes_type.length = vector_length;
4013
3553
 
4014
3554
   lp_build_context_init(&bldvec, variant->gallivm, lp_int_type(tes_type));
4015
 
   consts_ptr = draw_tes_jit_context_constants(variant, context_ptr);
4016
 
 
4017
 
   ssbos_ptr = draw_tes_jit_context_ssbos(variant, context_ptr);
4018
 
 
4019
 
   sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
 
3555
   consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
 
3556
 
 
3557
   ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
 
3558
 
 
3559
   sampler = lp_bld_llvm_sampler_soa_create(variant->key.samplers,
4020
3560
                                          MAX2(variant->key.nr_samplers,
4021
3561
                                               variant->key.nr_sampler_views));
4022
 
   image = draw_llvm_image_soa_create(draw_tes_llvm_variant_key_images(&variant->key),
 
3562
   image = lp_bld_llvm_image_soa_create(draw_tes_llvm_variant_key_images(&variant->key),
4023
3563
                                      variant->key.nr_images);
4024
3564
   step = lp_build_const_int32(gallivm, vector_length);
4025
3565
 
4056
3596
            LLVMValueRef idx = LLVMBuildAdd(builder, lp_loop.counter, lp_build_const_int32(gallivm, j), "");
4057
3597
            LLVMValueRef tc_val;
4058
3598
            if (i == 2) {
4059
 
               if (variant->shader->base.prim_mode == PIPE_PRIM_TRIANGLES) {
 
3599
               if (variant->shader->base.prim_mode == MESA_PRIM_TRIANGLES) {
4060
3600
                  tc_val = lp_build_const_float(gallivm, 1.0);
4061
3601
                  tc_val = LLVMBuildFSub(builder, tc_val, lp_build_pointer_get2(builder, flt_type, tess_coord[0], idx), "");
4062
3602
                  tc_val = LLVMBuildFSub(builder, tc_val, lp_build_pointer_get2(builder, flt_type, tess_coord[1], idx), "");
4077
3617
      params.mask = &mask;
4078
3618
      params.consts_ptr = consts_ptr;
4079
3619
      params.system_values = &system_values;
4080
 
      params.context_type = variant->context_type;
4081
 
      params.context_ptr = context_ptr;
 
3620
      params.resources_type = variant->resources_type;
 
3621
      params.resources_ptr = resources_ptr;
4082
3622
      params.sampler = sampler;
4083
3623
      params.info = &llvm->draw->tes.tess_eval_shader->info;
4084
3624
      params.ssbo_ptr = ssbos_ptr;
4085
3625
      params.image = image;
4086
3626
      params.tes_iface = &tes_iface.base;
4087
 
      params.aniso_filter_table = draw_tes_jit_context_aniso_filter_table(variant, context_ptr);
 
3627
      params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm, variant->resources_type, resources_ptr);
4088
3628
 
4089
3629
      lp_build_nir_soa(variant->gallivm,
4090
3630
                       llvm->draw->tes.tess_eval_shader->state.ir.nir,
4103
3643
                                                     lp_int_type(tes_type), 0);
4104
3644
 
4105
3645
      convert_to_aos(gallivm, variant->vertex_header_type, io, NULL, outputs, clipmask,
4106
 
                     draw_total_tes_outputs(llvm->draw), tes_type, primid_slot, FALSE);
 
3646
                     draw_total_tes_outputs(llvm->draw), tes_type, primid_slot, false);
4107
3647
   }
4108
3648
   lp_build_loop_end_cond(&lp_loop, num_tess_coord, step, LLVMIntUGE);
4109
 
   draw_llvm_sampler_soa_destroy(sampler);
4110
 
   draw_llvm_image_soa_destroy(image);
 
3649
   lp_bld_llvm_sampler_soa_destroy(sampler);
 
3650
   lp_bld_llvm_image_soa_destroy(image);
4111
3651
 
4112
3652
   LLVMBuildRet(builder, lp_build_zero(gallivm, lp_type_uint(32)));
4113
3653
   gallivm_verify_function(gallivm, variant_func);
4155
3695
 
4156
3696
   create_tes_jit_types(variant);
4157
3697
 
4158
 
   variant->vertex_header_type = create_jit_vertex_header(variant->gallivm, num_outputs);
 
3698
   variant->vertex_header_type = lp_build_create_jit_vertex_header_type(variant->gallivm, num_outputs);
4159
3699
   variant->vertex_header_ptr_type = LLVMPointerType(variant->vertex_header_type, 0);
4160
3700
 
4161
3701
   if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
4209
3749
draw_tes_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
4210
3750
{
4211
3751
   struct draw_tes_llvm_variant_key *key;
4212
 
   struct draw_sampler_static_state *draw_sampler;
4213
 
   struct draw_image_static_state *draw_image;
 
3752
   struct lp_sampler_static_state *draw_sampler;
 
3753
   struct lp_image_static_state *draw_image;
4214
3754
 
4215
3755
   key = (struct draw_tes_llvm_variant_key *)store;
4216
3756
 
4266
3806
void
4267
3807
draw_tes_llvm_dump_variant_key(struct draw_tes_llvm_variant_key *key)
4268
3808
{
4269
 
   struct draw_sampler_static_state *sampler = key->samplers;
4270
 
   struct draw_image_static_state *image = draw_tes_llvm_variant_key_images(key);
 
3809
   struct lp_sampler_static_state *sampler = key->samplers;
 
3810
   struct lp_image_static_state *image = draw_tes_llvm_variant_key_images(key);
4271
3811
 
4272
3812
   if (key->primid_needed)
4273
3813
      debug_printf("prim id output %d\n", key->primid_output);