Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/compiler/shader_info.h
4545 views
1
/*
2
* Copyright © 2016 Intel Corporation
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* IN THE SOFTWARE.
22
*
23
*/
24
25
#ifndef SHADER_INFO_H
26
#define SHADER_INFO_H
27
28
#include "util/bitset.h"
29
#include "shader_enums.h"
30
#include <stdint.h>
31
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
36
#define MAX_INLINABLE_UNIFORMS 4
37
38
struct spirv_supported_capabilities {
39
bool address;
40
bool atomic_storage;
41
bool demote_to_helper_invocation;
42
bool derivative_group;
43
bool descriptor_array_dynamic_indexing;
44
bool descriptor_array_non_uniform_indexing;
45
bool descriptor_indexing;
46
bool device_group;
47
bool draw_parameters;
48
bool float16_atomic_min_max;
49
bool float32_atomic_add;
50
bool float32_atomic_min_max;
51
bool float64;
52
bool float64_atomic_add;
53
bool float64_atomic_min_max;
54
bool fragment_shader_sample_interlock;
55
bool fragment_shader_pixel_interlock;
56
bool fragment_shading_rate;
57
bool generic_pointers;
58
bool geometry_streams;
59
bool image_ms_array;
60
bool image_read_without_format;
61
bool image_write_without_format;
62
bool image_atomic_int64;
63
bool int8;
64
bool int16;
65
bool int64;
66
bool int64_atomics;
67
bool integer_functions2;
68
bool kernel;
69
bool kernel_image;
70
bool kernel_image_read_write;
71
bool literal_sampler;
72
bool min_lod;
73
bool multiview;
74
bool physical_storage_buffer_address;
75
bool post_depth_coverage;
76
bool printf;
77
bool ray_tracing;
78
bool ray_query;
79
bool ray_traversal_primitive_culling;
80
bool runtime_descriptor_array;
81
bool float_controls;
82
bool shader_clock;
83
bool shader_viewport_index_layer;
84
bool sparse_residency;
85
bool stencil_export;
86
bool storage_8bit;
87
bool storage_16bit;
88
bool storage_image_ms;
89
bool subgroup_arithmetic;
90
bool subgroup_ballot;
91
bool subgroup_basic;
92
bool subgroup_quad;
93
bool subgroup_shuffle;
94
bool subgroup_uniform_control_flow;
95
bool subgroup_vote;
96
bool tessellation;
97
bool transform_feedback;
98
bool variable_pointers;
99
bool vk_memory_model;
100
bool vk_memory_model_device_scope;
101
bool workgroup_memory_explicit_layout;
102
bool float16;
103
bool amd_fragment_mask;
104
bool amd_gcn_shader;
105
bool amd_shader_ballot;
106
bool amd_trinary_minmax;
107
bool amd_image_read_write_lod;
108
bool amd_shader_explicit_vertex_parameter;
109
bool amd_image_gather_bias_lod;
110
111
bool intel_subgroup_shuffle;
112
bool intel_subgroup_buffer_block_io;
113
};
114
115
typedef struct shader_info {
116
const char *name;
117
118
/* Descriptive name provided by the client; may be NULL */
119
const char *label;
120
121
/* Shader is internal, and should be ignored by things like NIR_PRINT */
122
bool internal;
123
124
/** The shader stage, such as MESA_SHADER_VERTEX. */
125
gl_shader_stage stage:8;
126
127
/** The shader stage in a non SSO linked program that follows this stage,
128
* such as MESA_SHADER_FRAGMENT.
129
*/
130
gl_shader_stage next_stage:8;
131
132
/* Number of textures used by this shader */
133
uint8_t num_textures;
134
/* Number of uniform buffers used by this shader */
135
uint8_t num_ubos;
136
/* Number of atomic buffers used by this shader */
137
uint8_t num_abos;
138
/* Number of shader storage buffers (max .driver_location + 1) used by this
139
* shader. In the case of nir_lower_atomics_to_ssbo being used, this will
140
* be the number of actual SSBOs in gl_program->info, and the lowered SSBOs
141
* and atomic counters in nir_shader->info.
142
*/
143
uint8_t num_ssbos;
144
/* Number of images used by this shader */
145
uint8_t num_images;
146
147
/* Which inputs are actually read */
148
uint64_t inputs_read;
149
/* Which outputs are actually written */
150
uint64_t outputs_written;
151
/* Which outputs are actually read */
152
uint64_t outputs_read;
153
/* Which system values are actually read */
154
BITSET_DECLARE(system_values_read, SYSTEM_VALUE_MAX);
155
156
/* Which 16-bit inputs and outputs are used corresponding to
157
* VARYING_SLOT_VARn_16BIT.
158
*/
159
uint16_t inputs_read_16bit;
160
uint16_t outputs_written_16bit;
161
uint16_t outputs_read_16bit;
162
uint16_t inputs_read_indirectly_16bit;
163
uint16_t outputs_accessed_indirectly_16bit;
164
165
/* Which patch inputs are actually read */
166
uint32_t patch_inputs_read;
167
/* Which patch outputs are actually written */
168
uint32_t patch_outputs_written;
169
/* Which patch outputs are read */
170
uint32_t patch_outputs_read;
171
172
/* Which inputs are read indirectly (subset of inputs_read) */
173
uint64_t inputs_read_indirectly;
174
/* Which outputs are read or written indirectly */
175
uint64_t outputs_accessed_indirectly;
176
/* Which patch inputs are read indirectly (subset of patch_inputs_read) */
177
uint64_t patch_inputs_read_indirectly;
178
/* Which patch outputs are read or written indirectly */
179
uint64_t patch_outputs_accessed_indirectly;
180
181
/** Bitfield of which textures are used */
182
BITSET_DECLARE(textures_used, 32);
183
184
/** Bitfield of which textures are used by texelFetch() */
185
BITSET_DECLARE(textures_used_by_txf, 32);
186
187
/** Bitfield of which images are used */
188
uint32_t images_used;
189
/** Bitfield of which images are buffers. */
190
uint32_t image_buffers;
191
/** Bitfield of which images are MSAA. */
192
uint32_t msaa_images;
193
194
/* SPV_KHR_float_controls: execution mode for floating point ops */
195
uint16_t float_controls_execution_mode;
196
197
/**
198
* Size of shared variables accessed by compute/task/mesh shaders.
199
*/
200
unsigned shared_size;
201
202
/**
203
* Local workgroup size used by compute/task/mesh shaders.
204
*/
205
uint16_t workgroup_size[3];
206
207
uint16_t inlinable_uniform_dw_offsets[MAX_INLINABLE_UNIFORMS];
208
uint8_t num_inlinable_uniforms:4;
209
210
/* The size of the gl_ClipDistance[] array, if declared. */
211
uint8_t clip_distance_array_size:4;
212
213
/* The size of the gl_CullDistance[] array, if declared. */
214
uint8_t cull_distance_array_size:4;
215
216
/* Whether or not this shader ever uses textureGather() */
217
bool uses_texture_gather:1;
218
219
/**
220
* True if this shader uses the fddx/fddy opcodes.
221
*
222
* Note that this does not include the "fine" and "coarse" variants.
223
*/
224
bool uses_fddx_fddy:1;
225
226
/* Bitmask of bit-sizes used with ALU instructions. */
227
uint8_t bit_sizes_float;
228
uint8_t bit_sizes_int;
229
230
/* Whether the first UBO is the default uniform buffer, i.e. uniforms. */
231
bool first_ubo_is_default_ubo:1;
232
233
/* Whether or not separate shader objects were used */
234
bool separate_shader:1;
235
236
/** Was this shader linked with any transform feedback varyings? */
237
bool has_transform_feedback_varyings:1;
238
239
/* Whether flrp has been lowered. */
240
bool flrp_lowered:1;
241
242
/* Whether nir_lower_io has been called to lower derefs.
243
* nir_variables for inputs and outputs might not be present in the IR.
244
*/
245
bool io_lowered:1;
246
247
/* Whether the shader writes memory, including transform feedback. */
248
bool writes_memory:1;
249
250
/* Whether gl_Layer is viewport-relative */
251
bool layer_viewport_relative:1;
252
253
/* Whether explicit barriers are used */
254
bool uses_control_barrier : 1;
255
bool uses_memory_barrier : 1;
256
257
/**
258
* Shared memory types have explicit layout set. Used for
259
* SPV_KHR_workgroup_storage_explicit_layout.
260
*/
261
bool shared_memory_explicit_layout:1;
262
263
/**
264
* Used for VK_KHR_zero_initialize_workgroup_memory.
265
*/
266
bool zero_initialize_shared_memory:1;
267
268
/**
269
* Used for ARB_compute_variable_group_size.
270
*/
271
bool workgroup_size_variable:1;
272
273
union {
274
struct {
275
/* Which inputs are doubles */
276
uint64_t double_inputs;
277
278
/* For AMD-specific driver-internal shaders. It replaces vertex
279
* buffer loads with code generating VS inputs from scalar registers.
280
*
281
* Valid values: SI_VS_BLIT_SGPRS_POS_*
282
*/
283
uint8_t blit_sgprs_amd:4;
284
285
/* True if the shader writes position in window space coordinates pre-transform */
286
bool window_space_position:1;
287
} vs;
288
289
struct {
290
/** The output primitive type (GL enum value) */
291
uint16_t output_primitive;
292
293
/** The input primitive type (GL enum value) */
294
uint16_t input_primitive;
295
296
/** The maximum number of vertices the geometry shader might write. */
297
uint16_t vertices_out;
298
299
/** 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS */
300
uint8_t invocations;
301
302
/** The number of vertices received per input primitive (max. 6) */
303
uint8_t vertices_in:3;
304
305
/** Whether or not this shader uses EndPrimitive */
306
bool uses_end_primitive:1;
307
308
/** The streams used in this shaders (max. 4) */
309
uint8_t active_stream_mask:4;
310
} gs;
311
312
struct {
313
bool uses_discard:1;
314
bool uses_demote:1;
315
bool uses_fbfetch_output:1;
316
bool color_is_dual_source:1;
317
318
/**
319
* True if this fragment shader requires helper invocations. This
320
* can be caused by the use of ALU derivative ops, texture
321
* instructions which do implicit derivatives, and the use of quad
322
* subgroup operations.
323
*/
324
bool needs_quad_helper_invocations:1;
325
326
/**
327
* True if this fragment shader requires helper invocations for
328
* all subgroup operations, not just quad ops and derivatives.
329
*/
330
bool needs_all_helper_invocations:1;
331
332
/**
333
* Whether any inputs are declared with the "sample" qualifier.
334
*/
335
bool uses_sample_qualifier:1;
336
337
/**
338
* Whether sample shading is used.
339
*/
340
bool uses_sample_shading:1;
341
342
/**
343
* Whether early fragment tests are enabled as defined by
344
* ARB_shader_image_load_store.
345
*/
346
bool early_fragment_tests:1;
347
348
/**
349
* Defined by INTEL_conservative_rasterization.
350
*/
351
bool inner_coverage:1;
352
353
bool post_depth_coverage:1;
354
355
/**
356
* \name ARB_fragment_coord_conventions
357
* @{
358
*/
359
bool pixel_center_integer:1;
360
bool origin_upper_left:1;
361
/*@}*/
362
363
bool pixel_interlock_ordered:1;
364
bool pixel_interlock_unordered:1;
365
bool sample_interlock_ordered:1;
366
bool sample_interlock_unordered:1;
367
368
/**
369
* Flags whether NIR's base types on the FS color outputs should be
370
* ignored.
371
*
372
* GLSL requires that fragment shader output base types match the
373
* render target's base types for the behavior to be defined. From
374
* the GL 4.6 spec:
375
*
376
* "If the values written by the fragment shader do not match the
377
* format(s) of the corresponding color buffer(s), the result is
378
* undefined."
379
*
380
* However, for NIR shaders translated from TGSI, we don't have the
381
* output types any more, so the driver will need to do whatever
382
* fixups are necessary to handle effectively untyped data being
383
* output from the FS.
384
*/
385
bool untyped_color_outputs:1;
386
387
/** gl_FragDepth layout for ARB_conservative_depth. */
388
enum gl_frag_depth_layout depth_layout:3;
389
390
/**
391
* Interpolation qualifiers for drivers that lowers color inputs
392
* to system values.
393
*/
394
unsigned color0_interp:3; /* glsl_interp_mode */
395
bool color0_sample:1;
396
bool color0_centroid:1;
397
unsigned color1_interp:3; /* glsl_interp_mode */
398
bool color1_sample:1;
399
bool color1_centroid:1;
400
} fs;
401
402
struct {
403
uint16_t workgroup_size_hint[3];
404
405
uint8_t user_data_components_amd:3;
406
407
/*
408
* Arrangement of invocations used to calculate derivatives in a compute
409
* shader. From NV_compute_shader_derivatives.
410
*/
411
enum gl_derivative_group derivative_group:2;
412
413
/**
414
* pointer size is:
415
* AddressingModelLogical: 0 (default)
416
* AddressingModelPhysical32: 32
417
* AddressingModelPhysical64: 64
418
*/
419
unsigned ptr_size;
420
421
/**
422
* Uses subgroup intrinsics which can communicate across a quad.
423
*/
424
bool uses_wide_subgroup_intrinsics;
425
} cs;
426
427
/* Applies to both TCS and TES. */
428
struct {
429
uint16_t primitive_mode; /* GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
430
431
/** The number of vertices in the TCS output patch. */
432
uint8_t tcs_vertices_out;
433
enum gl_tess_spacing spacing:2;
434
435
/** Is the vertex order counterclockwise? */
436
bool ccw:1;
437
bool point_mode:1;
438
439
/* Bit mask of TCS per-vertex inputs (VS outputs) that are used
440
* with a vertex index that is NOT the invocation id
441
*/
442
uint64_t tcs_cross_invocation_inputs_read;
443
444
/* Bit mask of TCS per-vertex outputs that are used
445
* with a vertex index that is NOT the invocation id
446
*/
447
uint64_t tcs_cross_invocation_outputs_read;
448
} tess;
449
};
450
} shader_info;
451
452
#ifdef __cplusplus
453
}
454
#endif
455
456
#endif /* SHADER_INFO_H */
457
458