Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/auxiliary/draw/draw_llvm.h
4565 views
1
/**************************************************************************
2
*
3
* Copyright 2010 VMware, Inc.
4
* All Rights Reserved.
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
* copy of this software and associated documentation files (the
8
* "Software"), to deal in the Software without restriction, including
9
* without limitation the rights to use, copy, modify, merge, publish,
10
* distribute, sub license, and/or sell copies of the Software, and to
11
* permit persons to whom the Software is furnished to do so, subject to
12
* the following conditions:
13
*
14
* The above copyright notice and this permission notice (including the
15
* next paragraph) shall be included in all copies or substantial portions
16
* of the Software.
17
*
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
*
26
**************************************************************************/
27
28
#ifndef DRAW_LLVM_H
29
#define DRAW_LLVM_H
30
31
#include "draw/draw_private.h"
32
33
#include "draw/draw_vs.h"
34
#include "draw/draw_gs.h"
35
#include "draw/draw_tess.h"
36
37
#include "gallivm/lp_bld_sample.h"
38
#include "gallivm/lp_bld_limits.h"
39
40
#include "pipe/p_context.h"
41
#include "util/simple_list.h"
42
43
44
struct draw_llvm;
45
struct llvm_vertex_shader;
46
struct llvm_geometry_shader;
47
struct llvm_tess_ctrl_shader;
48
struct llvm_tess_eval_shader;
49
50
struct draw_jit_texture
51
{
52
uint32_t width;
53
uint32_t height;
54
uint32_t depth;
55
const void *base;
56
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS];
57
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
58
uint32_t first_level;
59
uint32_t last_level;
60
uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS];
61
uint32_t num_samples;
62
uint32_t sample_stride;
63
};
64
65
66
struct draw_sampler_static_state
67
{
68
/*
69
* These attributes are effectively interleaved for more sane key handling.
70
* However, there might be lots of null space if the amount of samplers and
71
* textures isn't the same.
72
*/
73
struct lp_static_sampler_state sampler_state;
74
struct lp_static_texture_state texture_state;
75
};
76
77
struct draw_image_static_state
78
{
79
struct lp_static_texture_state image_state;
80
};
81
82
83
struct draw_jit_sampler
84
{
85
float min_lod;
86
float max_lod;
87
float lod_bias;
88
float border_color[4];
89
};
90
91
92
struct draw_jit_image
93
{
94
uint32_t width;
95
uint32_t height;
96
uint32_t depth;
97
const void *base;
98
uint32_t row_stride;
99
uint32_t img_stride;
100
uint32_t num_samples;
101
uint32_t sample_stride;
102
};
103
104
enum {
105
DRAW_JIT_TEXTURE_WIDTH = 0,
106
DRAW_JIT_TEXTURE_HEIGHT,
107
DRAW_JIT_TEXTURE_DEPTH,
108
DRAW_JIT_TEXTURE_BASE,
109
DRAW_JIT_TEXTURE_ROW_STRIDE,
110
DRAW_JIT_TEXTURE_IMG_STRIDE,
111
DRAW_JIT_TEXTURE_FIRST_LEVEL,
112
DRAW_JIT_TEXTURE_LAST_LEVEL,
113
DRAW_JIT_TEXTURE_MIP_OFFSETS,
114
DRAW_JIT_TEXTURE_NUM_SAMPLES,
115
DRAW_JIT_TEXTURE_SAMPLE_STRIDE,
116
DRAW_JIT_TEXTURE_NUM_FIELDS /* number of fields above */
117
};
118
119
120
enum {
121
DRAW_JIT_SAMPLER_MIN_LOD,
122
DRAW_JIT_SAMPLER_MAX_LOD,
123
DRAW_JIT_SAMPLER_LOD_BIAS,
124
DRAW_JIT_SAMPLER_BORDER_COLOR,
125
DRAW_JIT_SAMPLER_NUM_FIELDS /* number of fields above */
126
};
127
128
129
enum {
130
DRAW_JIT_VERTEX_VERTEX_ID = 0,
131
DRAW_JIT_VERTEX_CLIP_POS,
132
DRAW_JIT_VERTEX_DATA
133
};
134
135
enum {
136
DRAW_JIT_IMAGE_WIDTH = 0,
137
DRAW_JIT_IMAGE_HEIGHT,
138
DRAW_JIT_IMAGE_DEPTH,
139
DRAW_JIT_IMAGE_BASE,
140
DRAW_JIT_IMAGE_ROW_STRIDE,
141
DRAW_JIT_IMAGE_IMG_STRIDE,
142
DRAW_JIT_IMAGE_NUM_SAMPLES,
143
DRAW_JIT_IMAGE_SAMPLE_STRIDE,
144
DRAW_JIT_IMAGE_NUM_FIELDS /* number of fields above */
145
};
146
147
/**
148
* This structure is passed directly to the generated vertex shader.
149
*
150
* It contains the derived state.
151
*
152
* Changes here must be reflected in the draw_jit_context_* macros.
153
* Changes to the ordering should be avoided.
154
*
155
* Only use types with a clear size and padding here, in particular prefer the
156
* stdint.h types to the basic integer types.
157
*/
158
struct draw_jit_context
159
{
160
const float *vs_constants[LP_MAX_TGSI_CONST_BUFFERS];
161
int num_vs_constants[LP_MAX_TGSI_CONST_BUFFERS];
162
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
163
struct pipe_viewport_state *viewports;
164
165
struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
166
struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
167
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
168
169
const uint32_t *vs_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
170
int num_vs_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
171
};
172
173
enum {
174
DRAW_JIT_CTX_CONSTANTS = 0,
175
DRAW_JIT_CTX_NUM_CONSTANTS = 1,
176
DRAW_JIT_CTX_PLANES = 2,
177
DRAW_JIT_CTX_VIEWPORT = 3,
178
DRAW_JIT_CTX_TEXTURES = 4,
179
DRAW_JIT_CTX_SAMPLERS = 5,
180
DRAW_JIT_CTX_IMAGES = 6,
181
DRAW_JIT_CTX_SSBOS = 7,
182
DRAW_JIT_CTX_NUM_SSBOS = 8,
183
DRAW_JIT_CTX_NUM_FIELDS
184
};
185
186
#define draw_jit_context_vs_constants(_gallivm, _ptr) \
187
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_CONSTANTS, "vs_constants")
188
189
#define draw_jit_context_num_vs_constants(_gallivm, _ptr) \
190
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_NUM_CONSTANTS, "num_vs_constants")
191
192
#define draw_jit_context_planes(_gallivm, _ptr) \
193
lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_CTX_PLANES, "planes")
194
195
#define draw_jit_context_viewports(_gallivm, _ptr) \
196
lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_CTX_VIEWPORT, "viewports")
197
198
#define draw_jit_context_textures(_gallivm, _ptr) \
199
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_TEXTURES, "textures")
200
201
#define draw_jit_context_samplers(_gallivm, _ptr) \
202
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_SAMPLERS, "samplers")
203
204
#define draw_jit_context_images(_gallivm, _ptr) \
205
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_IMAGES, "images")
206
207
#define draw_jit_context_vs_ssbos(_gallivm, _ptr) \
208
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_SSBOS, "vs_ssbos")
209
210
#define draw_jit_context_num_vs_ssbos(_gallivm, _ptr) \
211
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_NUM_SSBOS, "num_vs_ssbos")
212
213
214
#define draw_jit_header_id(_gallivm, _ptr) \
215
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_VERTEX_VERTEX_ID, "id")
216
217
#define draw_jit_header_clip_pos(_gallivm, _ptr) \
218
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_VERTEX_CLIP_POS, "clip_pos")
219
220
#define draw_jit_header_data(_gallivm, _ptr) \
221
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_VERTEX_DATA, "data")
222
223
224
#define draw_jit_vbuffer_stride(_gallivm, _ptr) \
225
lp_build_struct_get(_gallivm, _ptr, 0, "stride")
226
227
#define draw_jit_vbuffer_offset(_gallivm, _ptr) \
228
lp_build_struct_get(_gallivm, _ptr, 2, "buffer_offset")
229
230
enum {
231
DRAW_JIT_DVBUFFER_MAP = 0,
232
DRAW_JIT_DVBUFFER_SIZE,
233
DRAW_JIT_DVBUFFER_NUM_FIELDS /* number of fields above */
234
};
235
236
#define draw_jit_dvbuffer_map(_gallivm, _ptr) \
237
lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_DVBUFFER_MAP, "map")
238
239
#define draw_jit_dvbuffer_size(_gallivm, _ptr) \
240
lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_DVBUFFER_SIZE, "size")
241
242
243
/**
244
* This structure is passed directly to the generated geometry shader.
245
*
246
* It contains the derived state.
247
*
248
* Changes here must be reflected in the draw_gs_jit_context_* macros.
249
* Changes to the ordering should be avoided.
250
*
251
* Only use types with a clear size and padding here, in particular prefer the
252
* stdint.h types to the basic integer types.
253
*/
254
struct draw_gs_jit_context
255
{
256
const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
257
int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
258
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
259
struct pipe_viewport_state *viewports;
260
261
/* There two need to be exactly at DRAW_JIT_CTX_TEXTURES and
262
* DRAW_JIT_CTX_SAMPLERS positions in the struct */
263
struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
264
struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
265
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
266
267
int **prim_lengths;
268
int *emitted_vertices;
269
int *emitted_prims;
270
const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
271
int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
272
273
};
274
275
enum {
276
DRAW_GS_JIT_CTX_CONSTANTS = 0,
277
DRAW_GS_JIT_CTX_NUM_CONSTANTS = 1,
278
DRAW_GS_JIT_CTX_PLANES = 2,
279
DRAW_GS_JIT_CTX_VIEWPORT = 3,
280
/* Textures and samples are reserved for DRAW_JIT_CTX_TEXTURES
281
* and DRAW_JIT_CTX_SAMPLERS, because they both need
282
* to be at exactly the same locations as they are in the
283
* VS ctx structure for sampling to work. */
284
DRAW_GS_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
285
DRAW_GS_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
286
DRAW_GS_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
287
DRAW_GS_JIT_CTX_PRIM_LENGTHS = 7,
288
DRAW_GS_JIT_CTX_EMITTED_VERTICES = 8,
289
DRAW_GS_JIT_CTX_EMITTED_PRIMS = 9,
290
DRAW_GS_JIT_CTX_SSBOS = 10,
291
DRAW_GS_JIT_CTX_NUM_SSBOS = 11,
292
DRAW_GS_JIT_CTX_NUM_FIELDS = 12
293
};
294
295
#define draw_gs_jit_context_constants(_gallivm, _ptr) \
296
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_CONSTANTS, "constants")
297
298
#define draw_gs_jit_context_num_constants(_gallivm, _ptr) \
299
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_NUM_CONSTANTS, "num_constants")
300
301
#define draw_gs_jit_context_planes(_gallivm, _ptr) \
302
lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_PLANES, "planes")
303
304
#define draw_gs_jit_context_viewports(_gallivm, _ptr) \
305
lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_VIEWPORT, "viewports")
306
307
#define draw_gs_jit_context_textures(_gallivm, _ptr) \
308
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_TEXTURES, "textures")
309
310
#define draw_gs_jit_context_samplers(_gallivm, _ptr) \
311
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_SAMPLERS, "samplers")
312
313
#define draw_gs_jit_context_images(_gallivm, _ptr) \
314
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_IMAGES, "images")
315
316
#define draw_gs_jit_prim_lengths(_gallivm, _ptr) \
317
lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_PRIM_LENGTHS, "prim_lengths")
318
319
#define draw_gs_jit_emitted_vertices(_gallivm, _ptr) \
320
lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_EMITTED_VERTICES, "emitted_vertices")
321
322
#define draw_gs_jit_emitted_prims(_gallivm, _ptr) \
323
lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_EMITTED_PRIMS, "emitted_prims")
324
325
#define draw_gs_jit_context_ssbos(_gallivm, _ptr) \
326
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_SSBOS, "ssbos")
327
328
#define draw_gs_jit_context_num_ssbos(_gallivm, _ptr) \
329
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_NUM_SSBOS, "num_ssbos")
330
331
332
struct draw_tcs_jit_context {
333
const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
334
int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
335
336
int dummy1;
337
int dummy2;
338
/* There two need to be exactly at DRAW_JIT_CTX_TEXTURES and
339
* DRAW_JIT_CTX_SAMPLERS positions in the struct */
340
struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
341
struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
342
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
343
344
const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
345
int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
346
};
347
348
enum {
349
DRAW_TCS_JIT_CTX_CONSTANTS = 0,
350
DRAW_TCS_JIT_CTX_NUM_CONSTANTS = 1,
351
DRAW_TCS_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
352
DRAW_TCS_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
353
DRAW_TCS_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
354
DRAW_TCS_JIT_CTX_SSBOS = 7,
355
DRAW_TCS_JIT_CTX_NUM_SSBOS = 8,
356
DRAW_TCS_JIT_CTX_NUM_FIELDS = 9,
357
};
358
359
#define draw_tcs_jit_context_constants(_gallivm, _ptr) \
360
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_CONSTANTS, "constants")
361
362
#define draw_tcs_jit_context_num_constants(_gallivm, _ptr) \
363
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_NUM_CONSTANTS, "num_constants")
364
365
#define draw_tcs_jit_context_textures(_gallivm, _ptr) \
366
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_TEXTURES, "textures")
367
368
#define draw_tcs_jit_context_samplers(_gallivm, _ptr) \
369
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_SAMPLERS, "samplers")
370
371
#define draw_tcs_jit_context_images(_gallivm, _ptr) \
372
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_IMAGES, "images")
373
374
#define draw_tcs_jit_context_ssbos(_gallivm, _ptr) \
375
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_SSBOS, "ssbos")
376
377
#define draw_tcs_jit_context_num_ssbos(_gallivm, _ptr) \
378
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TCS_JIT_CTX_NUM_SSBOS, "num_ssbos")
379
380
struct draw_tes_jit_context {
381
const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
382
int num_constants[LP_MAX_TGSI_CONST_BUFFERS];
383
384
int dummy1;
385
int dummy2;
386
/* There two need to be exactly at DRAW_JIT_CTX_TEXTURES and
387
* DRAW_JIT_CTX_SAMPLERS positions in the struct */
388
struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
389
struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
390
struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
391
392
const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
393
int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
394
};
395
396
enum {
397
DRAW_TES_JIT_CTX_CONSTANTS = 0,
398
DRAW_TES_JIT_CTX_NUM_CONSTANTS = 1,
399
DRAW_TES_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
400
DRAW_TES_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
401
DRAW_TES_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
402
DRAW_TES_JIT_CTX_SSBOS = 7,
403
DRAW_TES_JIT_CTX_NUM_SSBOS = 8,
404
DRAW_TES_JIT_CTX_NUM_FIELDS = 9,
405
};
406
407
#define draw_tes_jit_context_constants(_gallivm, _ptr) \
408
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_CONSTANTS, "constants")
409
410
#define draw_tes_jit_context_num_constants(_gallivm, _ptr) \
411
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_NUM_CONSTANTS, "num_constants")
412
413
#define draw_tes_jit_context_textures(_gallivm, _ptr) \
414
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_TEXTURES, "textures")
415
416
#define draw_tes_jit_context_samplers(_gallivm, _ptr) \
417
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_SAMPLERS, "samplers")
418
419
#define draw_tes_jit_context_images(_gallivm, _ptr) \
420
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_IMAGES, "images")
421
422
#define draw_tes_jit_context_ssbos(_gallivm, _ptr) \
423
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_SSBOS, "ssbos")
424
425
#define draw_tes_jit_context_num_ssbos(_gallivm, _ptr) \
426
lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_TES_JIT_CTX_NUM_SSBOS, "num_ssbos")
427
428
typedef boolean
429
(*draw_jit_vert_func)(struct draw_jit_context *context,
430
struct vertex_header *io,
431
const struct draw_vertex_buffer vbuffers[PIPE_MAX_ATTRIBS],
432
unsigned count,
433
unsigned start_or_maxelt,
434
unsigned stride,
435
struct pipe_vertex_buffer *vertex_buffers,
436
unsigned instance_id,
437
unsigned vertex_id_offset,
438
unsigned start_instance,
439
const unsigned *fetch_elts,
440
unsigned draw_id, unsigned view_id);
441
442
443
typedef int
444
(*draw_gs_jit_func)(struct draw_gs_jit_context *context,
445
float inputs[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS],
446
struct vertex_header **output,
447
unsigned num_prims,
448
unsigned instance_id,
449
int *prim_ids,
450
unsigned invocation_id,
451
unsigned view_id);
452
453
typedef int
454
(*draw_tcs_jit_func)(struct draw_tcs_jit_context *context,
455
float inputs[32][NUM_TCS_INPUTS][TGSI_NUM_CHANNELS],
456
float outputs[32][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS],
457
uint32_t prim_id, uint32_t patch_vertices_in,
458
unsigned view_id);
459
460
typedef int
461
(*draw_tes_jit_func)(struct draw_tes_jit_context *context,
462
float inputs[32][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS],
463
struct vertex_header *io,
464
uint32_t prim_id, uint32_t num_tess_coord,
465
float *tess_coord_x, float *tess_coord_y, float *tess_outer,
466
float *tess_inner, uint32_t patch_vertices_in,
467
unsigned view_id);
468
469
470
struct draw_llvm_variant_key
471
{
472
unsigned nr_vertex_elements:8;
473
unsigned nr_samplers:8;
474
unsigned nr_sampler_views:8;
475
unsigned nr_images:8;
476
unsigned clamp_vertex_color:1;
477
unsigned clip_xy:1;
478
unsigned clip_z:1;
479
unsigned clip_user:1;
480
unsigned clip_halfz:1;
481
unsigned bypass_viewport:1;
482
unsigned need_edgeflags:1;
483
unsigned has_gs_or_tes:1;
484
unsigned num_outputs:8;
485
unsigned ucp_enable:PIPE_MAX_CLIP_PLANES;
486
/* note padding here - must use memset */
487
488
/* Variable number of vertex elements:
489
*/
490
struct pipe_vertex_element vertex_element[1];
491
492
/* Followed by variable number of samplers:
493
*/
494
/* struct draw_sampler_static_state sampler; */
495
/* Followed by variable number of images
496
*/
497
};
498
499
struct draw_gs_llvm_variant_key
500
{
501
unsigned nr_samplers:8;
502
unsigned nr_sampler_views:8;
503
unsigned nr_images:8;
504
unsigned num_outputs:8;
505
/* note padding here - must use memset */
506
507
struct draw_sampler_static_state samplers[1];
508
/* Followed by variable number of images.*/
509
};
510
511
struct draw_tcs_llvm_variant_key
512
{
513
unsigned nr_samplers:8;
514
unsigned nr_sampler_views:8;
515
unsigned nr_images:8;
516
struct draw_sampler_static_state samplers[1];
517
/* Followed by variable number of images.*/
518
};
519
520
struct draw_tes_llvm_variant_key
521
{
522
unsigned nr_samplers:8;
523
unsigned nr_sampler_views:8;
524
unsigned nr_images:8;
525
unsigned primid_output:7;
526
unsigned primid_needed:1;
527
struct draw_sampler_static_state samplers[1];
528
/* Followed by variable number of images.*/
529
};
530
531
#define DRAW_LLVM_MAX_VARIANT_KEY_SIZE \
532
(sizeof(struct draw_llvm_variant_key) + \
533
PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state) + \
534
PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
535
(PIPE_MAX_ATTRIBS-1) * sizeof(struct pipe_vertex_element))
536
537
#define DRAW_GS_LLVM_MAX_VARIANT_KEY_SIZE \
538
(sizeof(struct draw_gs_llvm_variant_key) + \
539
PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
540
PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state))
541
542
#define DRAW_TCS_LLVM_MAX_VARIANT_KEY_SIZE \
543
(sizeof(struct draw_tcs_llvm_variant_key) + \
544
PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
545
PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state))
546
547
#define DRAW_TES_LLVM_MAX_VARIANT_KEY_SIZE \
548
(sizeof(struct draw_tes_llvm_variant_key) + \
549
PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
550
PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state))
551
552
553
static inline size_t
554
draw_llvm_variant_key_size(unsigned nr_vertex_elements,
555
unsigned nr_samplers, unsigned nr_images)
556
{
557
return (sizeof(struct draw_llvm_variant_key) +
558
nr_samplers * sizeof(struct draw_sampler_static_state) +
559
nr_images * sizeof(struct draw_image_static_state) +
560
(nr_vertex_elements - 1) * sizeof(struct pipe_vertex_element));
561
}
562
563
564
static inline size_t
565
draw_gs_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images)
566
{
567
return (sizeof(struct draw_gs_llvm_variant_key) +
568
(nr_images) * sizeof(struct draw_sampler_static_state) +
569
(nr_samplers - 1) * sizeof(struct draw_sampler_static_state));
570
}
571
572
static inline size_t
573
draw_tcs_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images)
574
{
575
return (sizeof(struct draw_tcs_llvm_variant_key) +
576
(nr_images) * sizeof(struct draw_sampler_static_state) +
577
(nr_samplers - 1) * sizeof(struct draw_sampler_static_state));
578
}
579
580
static inline size_t
581
draw_tes_llvm_variant_key_size(unsigned nr_samplers, unsigned nr_images)
582
{
583
return (sizeof(struct draw_tes_llvm_variant_key) +
584
(nr_images) * sizeof(struct draw_sampler_static_state) +
585
(nr_samplers - 1) * sizeof(struct draw_sampler_static_state));
586
}
587
588
static inline struct draw_sampler_static_state *
589
draw_llvm_variant_key_samplers(struct draw_llvm_variant_key *key)
590
{
591
return (struct draw_sampler_static_state *)
592
&key->vertex_element[key->nr_vertex_elements];
593
}
594
595
static inline struct draw_image_static_state *
596
draw_llvm_variant_key_images(struct draw_llvm_variant_key *key)
597
{
598
struct draw_sampler_static_state *samplers = (struct draw_sampler_static_state *)
599
(&key->vertex_element[key->nr_vertex_elements]);
600
return (struct draw_image_static_state *)
601
&samplers[key->nr_samplers];
602
}
603
604
static inline struct draw_image_static_state *
605
draw_gs_llvm_variant_key_images(struct draw_gs_llvm_variant_key *key)
606
{
607
return (struct draw_image_static_state *)
608
&key->samplers[key->nr_samplers];
609
}
610
611
static inline struct draw_image_static_state *
612
draw_tcs_llvm_variant_key_images(struct draw_tcs_llvm_variant_key *key)
613
{
614
return (struct draw_image_static_state *)
615
&key->samplers[key->nr_samplers];
616
}
617
618
static inline struct draw_image_static_state *
619
draw_tes_llvm_variant_key_images(struct draw_tes_llvm_variant_key *key)
620
{
621
return (struct draw_image_static_state *)
622
&key->samplers[key->nr_samplers];
623
}
624
625
struct draw_llvm_variant_list_item
626
{
627
struct draw_llvm_variant *base;
628
struct draw_llvm_variant_list_item *next, *prev;
629
};
630
631
struct draw_gs_llvm_variant_list_item
632
{
633
struct draw_gs_llvm_variant *base;
634
struct draw_gs_llvm_variant_list_item *next, *prev;
635
};
636
637
struct draw_tcs_llvm_variant_list_item
638
{
639
struct draw_tcs_llvm_variant *base;
640
struct draw_tcs_llvm_variant_list_item *next, *prev;
641
};
642
643
struct draw_tes_llvm_variant_list_item
644
{
645
struct draw_tes_llvm_variant *base;
646
struct draw_tes_llvm_variant_list_item *next, *prev;
647
};
648
649
struct draw_llvm_variant
650
{
651
struct gallivm_state *gallivm;
652
653
/* LLVM JIT builder types */
654
LLVMTypeRef context_ptr_type;
655
LLVMTypeRef buffer_ptr_type;
656
LLVMTypeRef vb_ptr_type;
657
LLVMTypeRef vertex_header_ptr_type;
658
659
LLVMValueRef function;
660
draw_jit_vert_func jit_func;
661
662
struct llvm_vertex_shader *shader;
663
664
struct draw_llvm *llvm;
665
struct draw_llvm_variant_list_item list_item_global;
666
struct draw_llvm_variant_list_item list_item_local;
667
668
/* key is variable-sized, must be last */
669
struct draw_llvm_variant_key key;
670
};
671
672
673
struct draw_gs_llvm_variant
674
{
675
struct gallivm_state *gallivm;
676
677
/* LLVM JIT builder types */
678
LLVMTypeRef context_ptr_type;
679
LLVMTypeRef vertex_header_ptr_type;
680
LLVMTypeRef input_array_type;
681
682
LLVMValueRef context_ptr;
683
LLVMValueRef io_ptr;
684
LLVMValueRef num_prims;
685
LLVMValueRef function;
686
draw_gs_jit_func jit_func;
687
688
struct llvm_geometry_shader *shader;
689
690
struct draw_llvm *llvm;
691
struct draw_gs_llvm_variant_list_item list_item_global;
692
struct draw_gs_llvm_variant_list_item list_item_local;
693
694
/* key is variable-sized, must be last */
695
struct draw_gs_llvm_variant_key key;
696
};
697
698
struct draw_tcs_llvm_variant
699
{
700
struct gallivm_state *gallivm;
701
702
/* LLVM JIT builder types */
703
LLVMTypeRef context_ptr_type;
704
LLVMTypeRef input_array_type;
705
LLVMTypeRef output_array_type;
706
707
LLVMValueRef context_ptr;
708
LLVMValueRef io_ptr;
709
LLVMValueRef num_prims;
710
LLVMValueRef function;
711
draw_tcs_jit_func jit_func;
712
713
struct llvm_tess_ctrl_shader *shader;
714
715
struct draw_llvm *llvm;
716
struct draw_tcs_llvm_variant_list_item list_item_global;
717
struct draw_tcs_llvm_variant_list_item list_item_local;
718
719
/* key is variable-sized, must be last */
720
struct draw_tcs_llvm_variant_key key;
721
};
722
723
struct draw_tes_llvm_variant
724
{
725
struct gallivm_state *gallivm;
726
727
/* LLVM JIT builder types */
728
LLVMTypeRef context_ptr_type;
729
LLVMTypeRef vertex_header_ptr_type;
730
LLVMTypeRef input_array_type;
731
LLVMTypeRef patch_input_array_type;
732
733
LLVMValueRef context_ptr;
734
LLVMValueRef io_ptr;
735
LLVMValueRef num_prims;
736
LLVMValueRef function;
737
draw_tes_jit_func jit_func;
738
739
struct llvm_tess_eval_shader *shader;
740
741
struct draw_llvm *llvm;
742
struct draw_tes_llvm_variant_list_item list_item_global;
743
struct draw_tes_llvm_variant_list_item list_item_local;
744
745
/* key is variable-sized, must be last */
746
struct draw_tes_llvm_variant_key key;
747
};
748
749
struct llvm_vertex_shader {
750
struct draw_vertex_shader base;
751
752
unsigned variant_key_size;
753
struct draw_llvm_variant_list_item variants;
754
unsigned variants_created;
755
unsigned variants_cached;
756
};
757
758
struct llvm_geometry_shader {
759
struct draw_geometry_shader base;
760
761
unsigned variant_key_size;
762
struct draw_gs_llvm_variant_list_item variants;
763
unsigned variants_created;
764
unsigned variants_cached;
765
};
766
767
struct llvm_tess_ctrl_shader {
768
struct draw_tess_ctrl_shader base;
769
770
unsigned variant_key_size;
771
struct draw_tcs_llvm_variant_list_item variants;
772
unsigned variants_created;
773
unsigned variants_cached;
774
};
775
776
struct llvm_tess_eval_shader {
777
struct draw_tess_eval_shader base;
778
779
unsigned variant_key_size;
780
struct draw_tes_llvm_variant_list_item variants;
781
unsigned variants_created;
782
unsigned variants_cached;
783
};
784
785
struct draw_llvm {
786
struct draw_context *draw;
787
788
LLVMContextRef context;
789
boolean context_owned;
790
791
struct draw_jit_context jit_context;
792
struct draw_gs_jit_context gs_jit_context;
793
struct draw_tcs_jit_context tcs_jit_context;
794
struct draw_tes_jit_context tes_jit_context;
795
796
struct draw_llvm_variant_list_item vs_variants_list;
797
int nr_variants;
798
799
struct draw_gs_llvm_variant_list_item gs_variants_list;
800
int nr_gs_variants;
801
802
struct draw_tcs_llvm_variant_list_item tcs_variants_list;
803
int nr_tcs_variants;
804
805
struct draw_tes_llvm_variant_list_item tes_variants_list;
806
int nr_tes_variants;
807
};
808
809
810
static inline struct llvm_vertex_shader *
811
llvm_vertex_shader(struct draw_vertex_shader *vs)
812
{
813
return (struct llvm_vertex_shader *)vs;
814
}
815
816
static inline struct llvm_geometry_shader *
817
llvm_geometry_shader(struct draw_geometry_shader *gs)
818
{
819
return (struct llvm_geometry_shader *)gs;
820
}
821
822
static inline struct llvm_tess_ctrl_shader *
823
llvm_tess_ctrl_shader(struct draw_tess_ctrl_shader *tcs)
824
{
825
return (struct llvm_tess_ctrl_shader *)tcs;
826
}
827
828
static inline struct llvm_tess_eval_shader *
829
llvm_tess_eval_shader(struct draw_tess_eval_shader *tes)
830
{
831
return (struct llvm_tess_eval_shader *)tes;
832
}
833
834
struct draw_llvm *
835
draw_llvm_create(struct draw_context *draw, LLVMContextRef llvm_context);
836
837
void
838
draw_llvm_destroy(struct draw_llvm *llvm);
839
840
struct draw_llvm_variant *
841
draw_llvm_create_variant(struct draw_llvm *llvm,
842
unsigned num_vertex_header_attribs,
843
const struct draw_llvm_variant_key *key);
844
845
void
846
draw_llvm_destroy_variant(struct draw_llvm_variant *variant);
847
848
struct draw_llvm_variant_key *
849
draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store);
850
851
void
852
draw_llvm_dump_variant_key(struct draw_llvm_variant_key *key);
853
854
855
struct draw_gs_llvm_variant *
856
draw_gs_llvm_create_variant(struct draw_llvm *llvm,
857
unsigned num_vertex_header_attribs,
858
const struct draw_gs_llvm_variant_key *key);
859
860
void
861
draw_gs_llvm_destroy_variant(struct draw_gs_llvm_variant *variant);
862
863
struct draw_gs_llvm_variant_key *
864
draw_gs_llvm_make_variant_key(struct draw_llvm *llvm, char *store);
865
866
void
867
draw_gs_llvm_dump_variant_key(struct draw_gs_llvm_variant_key *key);
868
869
struct draw_tcs_llvm_variant *
870
draw_tcs_llvm_create_variant(struct draw_llvm *llvm,
871
unsigned num_vertex_header_attribs,
872
const struct draw_tcs_llvm_variant_key *key);
873
874
void
875
draw_tcs_llvm_destroy_variant(struct draw_tcs_llvm_variant *variant);
876
877
struct draw_tcs_llvm_variant_key *
878
draw_tcs_llvm_make_variant_key(struct draw_llvm *llvm, char *store);
879
880
void
881
draw_tcs_llvm_dump_variant_key(struct draw_tcs_llvm_variant_key *key);
882
883
struct draw_tes_llvm_variant *
884
draw_tes_llvm_create_variant(struct draw_llvm *llvm,
885
unsigned num_vertex_header_attribs,
886
const struct draw_tes_llvm_variant_key *key);
887
888
void
889
draw_tes_llvm_destroy_variant(struct draw_tes_llvm_variant *variant);
890
891
struct draw_tes_llvm_variant_key *
892
draw_tes_llvm_make_variant_key(struct draw_llvm *llvm, char *store);
893
894
void
895
draw_tes_llvm_dump_variant_key(struct draw_tes_llvm_variant_key *key);
896
897
struct lp_build_sampler_soa *
898
draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state,
899
unsigned nr_samplers);
900
901
struct lp_build_image_soa *
902
draw_llvm_image_soa_create(const struct draw_image_static_state *static_state,
903
unsigned nr_images);
904
905
void
906
draw_llvm_set_sampler_state(struct draw_context *draw,
907
enum pipe_shader_type shader_stage);
908
909
void
910
draw_llvm_set_mapped_texture(struct draw_context *draw,
911
enum pipe_shader_type shader_stage,
912
unsigned sview_idx,
913
uint32_t width, uint32_t height, uint32_t depth,
914
uint32_t first_level, uint32_t last_level,
915
uint32_t num_samples,
916
uint32_t sample_stride,
917
const void *base_ptr,
918
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
919
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
920
uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
921
922
void
923
draw_llvm_set_mapped_image(struct draw_context *draw,
924
enum pipe_shader_type shader_stage,
925
unsigned idx,
926
uint32_t width, uint32_t height, uint32_t depth,
927
const void *base_ptr,
928
uint32_t row_stride,
929
uint32_t img_stride,
930
uint32_t num_samples,
931
uint32_t sample_stride);
932
#endif
933
934