Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/vkd3d/include/vkd3d_shader.h
8765 views
1
/*
2
* Copyright 2017-2019 Józef Kucia for CodeWeavers
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17
*/
18
19
#ifndef __VKD3D_SHADER_H
20
#define __VKD3D_SHADER_H
21
22
#include <stdbool.h>
23
#include <stdint.h>
24
#include <stddef.h>
25
#include <vkd3d_types.h>
26
27
#ifdef __cplusplus
28
extern "C" {
29
#endif /* __cplusplus */
30
31
/**
32
* \file vkd3d_shader.h
33
*
34
* This file contains definitions for the vkd3d-shader library.
35
*
36
* The vkd3d-shader library provides multiple utilities related to the
37
* compilation, transformation, and reflection of GPU shaders.
38
*
39
* \since 1.2
40
*/
41
42
/** \since 1.3 */
43
enum vkd3d_shader_api_version
44
{
45
VKD3D_SHADER_API_VERSION_1_0,
46
VKD3D_SHADER_API_VERSION_1_1,
47
VKD3D_SHADER_API_VERSION_1_2,
48
VKD3D_SHADER_API_VERSION_1_3,
49
VKD3D_SHADER_API_VERSION_1_4,
50
VKD3D_SHADER_API_VERSION_1_5,
51
VKD3D_SHADER_API_VERSION_1_6,
52
VKD3D_SHADER_API_VERSION_1_7,
53
VKD3D_SHADER_API_VERSION_1_8,
54
VKD3D_SHADER_API_VERSION_1_9,
55
VKD3D_SHADER_API_VERSION_1_10,
56
VKD3D_SHADER_API_VERSION_1_11,
57
VKD3D_SHADER_API_VERSION_1_12,
58
VKD3D_SHADER_API_VERSION_1_13,
59
VKD3D_SHADER_API_VERSION_1_14,
60
VKD3D_SHADER_API_VERSION_1_15,
61
VKD3D_SHADER_API_VERSION_1_16,
62
VKD3D_SHADER_API_VERSION_1_17,
63
VKD3D_SHADER_API_VERSION_1_18,
64
65
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_API_VERSION),
66
};
67
68
/** The type of a chained structure. */
69
enum vkd3d_shader_structure_type
70
{
71
/** The structure is a vkd3d_shader_compile_info structure. */
72
VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO,
73
/** The structure is a vkd3d_shader_interface_info structure. */
74
VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO,
75
/** The structure is a vkd3d_shader_scan_descriptor_info structure. */
76
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO,
77
/** The structure is a vkd3d_shader_spirv_domain_shader_target_info structure. */
78
VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_DOMAIN_SHADER_TARGET_INFO,
79
/** The structure is a vkd3d_shader_spirv_target_info structure. */
80
VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_TARGET_INFO,
81
/** The structure is a vkd3d_shader_transform_feedback_info structure. */
82
VKD3D_SHADER_STRUCTURE_TYPE_TRANSFORM_FEEDBACK_INFO,
83
84
/**
85
* The structure is a vkd3d_shader_hlsl_source_info structure.
86
* \since 1.3
87
*/
88
VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO,
89
/**
90
* The structure is a vkd3d_shader_preprocess_info structure.
91
* \since 1.3
92
*/
93
VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO,
94
/**
95
* The structure is a vkd3d_shader_descriptor_offset_info structure.
96
* \since 1.3
97
*/
98
VKD3D_SHADER_STRUCTURE_TYPE_DESCRIPTOR_OFFSET_INFO,
99
/**
100
* The structure is a vkd3d_shader_scan_signature_info structure.
101
* \since 1.9
102
*/
103
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_SIGNATURE_INFO,
104
/**
105
* The structure is a vkd3d_shader_varying_map_info structure.
106
* \since 1.9
107
*/
108
VKD3D_SHADER_STRUCTURE_TYPE_VARYING_MAP_INFO,
109
/**
110
* The structure is a vkd3d_shader_scan_combined_resource_sampler_info structure.
111
* \since 1.10
112
*/
113
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO,
114
/**
115
* The structure is a vkd3d_shader_parameter_info structure.
116
* \since 1.13
117
*/
118
VKD3D_SHADER_STRUCTURE_TYPE_PARAMETER_INFO,
119
/**
120
* The structure is a vkd3d_shader_scan_hull_shader_tessellation_info structure.
121
* \since 1.15
122
*/
123
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_HULL_SHADER_TESSELLATION_INFO,
124
/**
125
* The structure is a vkd3d_shader_scan_thread_group_size_info structure.
126
* \since 1.18
127
*/
128
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_THREAD_GROUP_SIZE_INFO,
129
/**
130
* The structure is a vkd3d_shader_d3dbc_source_info structure.
131
* \since 1.18
132
*/
133
VKD3D_SHADER_STRUCTURE_TYPE_D3DBC_SOURCE_INFO,
134
135
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE),
136
};
137
138
/**
139
* Determines how buffer UAVs are stored.
140
*
141
* This also affects UAV counters in Vulkan environments. In OpenGL
142
* environments, atomic counter buffers are always used for UAV counters.
143
*/
144
enum vkd3d_shader_compile_option_buffer_uav
145
{
146
/** Use buffer textures for buffer UAVs. This is the default value. */
147
VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV_STORAGE_TEXEL_BUFFER = 0x00000000,
148
/** Use storage buffers for buffer UAVs. */
149
VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV_STORAGE_BUFFER = 0x00000001,
150
151
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV),
152
};
153
154
/**
155
* Determines how typed UAVs are declared.
156
* \since 1.5
157
*/
158
enum vkd3d_shader_compile_option_typed_uav
159
{
160
/** Use R32(u)i/R32f format for UAVs which are read from. This is the default value. */
161
VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_R32 = 0x00000000,
162
/**
163
* Use Unknown format for UAVs which are read from. This should only be set if
164
* shaderStorageImageReadWithoutFormat is enabled in the target environment.
165
*/
166
VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_UNKNOWN = 0x00000001,
167
168
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV),
169
};
170
171
enum vkd3d_shader_compile_option_formatting_flags
172
{
173
VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NONE = 0x00000000,
174
VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR = 0x00000001,
175
VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT = 0x00000002,
176
VKD3D_SHADER_COMPILE_OPTION_FORMATTING_OFFSETS = 0x00000004,
177
VKD3D_SHADER_COMPILE_OPTION_FORMATTING_HEADER = 0x00000008,
178
VKD3D_SHADER_COMPILE_OPTION_FORMATTING_RAW_IDS = 0x00000010,
179
/**
180
* Emit the signatures when disassembling a shader.
181
*
182
* \since 1.12
183
*/
184
VKD3D_SHADER_COMPILE_OPTION_FORMATTING_IO_SIGNATURES = 0x00000020,
185
186
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FLAGS),
187
};
188
189
/** Determines how matrices are stored. \since 1.9 */
190
enum vkd3d_shader_compile_option_pack_matrix_order
191
{
192
VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR = 0x00000001,
193
VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR = 0x00000002,
194
195
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER),
196
};
197
198
/** Individual options to enable various backward compatibility features. \since 1.10 */
199
enum vkd3d_shader_compile_option_backward_compatibility
200
{
201
/**
202
* Causes compiler to convert SM1-3 semantics to corresponding System Value semantics,
203
* when compiling HLSL sources for SM4+ targets.
204
*
205
* This option does the following conversions:
206
*
207
* - POSITION to SV_Position for vertex shader outputs, pixel shader inputs,
208
* and geometry shader inputs and outputs;
209
* - COLORN to SV_TargetN for pixel shader outputs;
210
* - DEPTH to SV_Depth for pixel shader outputs.
211
*/
212
VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES = 0x00000001,
213
/**
214
* Causes 'double' to behave as an alias for 'float'. This option only
215
* applies to HLSL sources with shader model 1-3 target profiles. Without
216
* this option using the 'double' type produces compilation errors in
217
* these target profiles.
218
*
219
* This option is disabled by default.
220
*
221
* \since 1.14
222
*/
223
VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS = 0x00000002,
224
225
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY),
226
};
227
228
/**
229
* Determines the origin of fragment coordinates.
230
*
231
* \since 1.10
232
*/
233
enum vkd3d_shader_compile_option_fragment_coordinate_origin
234
{
235
/** Fragment coordinates originate from the upper-left. This is the
236
* default; it's also the only value supported by Vulkan environments. */
237
VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN_UPPER_LEFT = 0x00000000,
238
/** Fragment coordinates originate from the lower-left. This matches the
239
* traditional behaviour of OpenGL environments. */
240
VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN_LOWER_LEFT = 0x00000001,
241
242
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN),
243
};
244
245
/** Advertises feature availability. \since 1.11 */
246
enum vkd3d_shader_compile_option_feature_flags
247
{
248
/** The SPIR-V target environment supports 64-bit integer types. This
249
* corresponds to the "shaderInt64" feature in the Vulkan API, and the
250
* "GL_ARB_gpu_shader_int64" extension in the OpenGL API. */
251
VKD3D_SHADER_COMPILE_OPTION_FEATURE_INT64 = 0x00000001,
252
/** The SPIR-V target environment supports 64-bit floating-point types.
253
* This corresponds to the "shaderFloat64" feature in the Vulkan API, and
254
* the "GL_ARB_gpu_shader_fp64" extension in the OpenGL API. */
255
VKD3D_SHADER_COMPILE_OPTION_FEATURE_FLOAT64 = 0x00000002,
256
/** The SPIR-V target environment supports wave operations.
257
* This flag is valid only in VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_1
258
* or greater, and corresponds to the following minimum requirements in
259
* VkPhysicalDeviceSubgroupProperties:
260
* - subgroupSize >= 4.
261
* - supportedOperations has BASIC, VOTE, ARITHMETIC, BALLOT, SHUFFLE and
262
* QUAD bits set.
263
* - supportedStages include COMPUTE and FRAGMENT. \since 1.12 */
264
VKD3D_SHADER_COMPILE_OPTION_FEATURE_WAVE_OPS = 0x00000004,
265
/** The SPIR-V target environment supports zero-initializing workgroup
266
* memory. This corresponds to the "shaderZeroInitializeWorkgroupMemory"
267
* Vulkan feature. \since 1.16 */
268
VKD3D_SHADER_COMPILE_OPTION_FEATURE_ZERO_INITIALIZE_WORKGROUP_MEMORY = 0x00000008,
269
270
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FEATURE_FLAGS),
271
};
272
273
/**
274
* Flags for vkd3d_shader_parse_dxbc().
275
*
276
* \since 1.12
277
*/
278
enum vkd3d_shader_parse_dxbc_flags
279
{
280
/** Ignore the checksum and continue parsing even if it is
281
* incorrect. */
282
VKD3D_SHADER_PARSE_DXBC_IGNORE_CHECKSUM = 0x00000001,
283
284
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARSE_DXBC_FLAGS),
285
};
286
287
enum vkd3d_shader_compile_option_name
288
{
289
/**
290
* If \a value is nonzero, do not include debug information in the
291
* compiled shader. The default value is zero.
292
*
293
* This option is supported by vkd3d_shader_compile(). However, not all
294
* compilers support generating debug information.
295
*/
296
VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG = 0x00000001,
297
/** \a value is a member of enum vkd3d_shader_compile_option_buffer_uav. */
298
VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV = 0x00000002,
299
/** \a value is a member of enum vkd3d_shader_compile_option_formatting_flags. */
300
VKD3D_SHADER_COMPILE_OPTION_FORMATTING = 0x00000003,
301
/** \a value is a member of enum vkd3d_shader_api_version. \since 1.3 */
302
VKD3D_SHADER_COMPILE_OPTION_API_VERSION = 0x00000004,
303
/** \a value is a member of enum vkd3d_shader_compile_option_typed_uav. \since 1.5 */
304
VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV = 0x00000005,
305
/**
306
* If \a value is nonzero, write the point size for Vulkan tessellation and
307
* geometry shaders. This option should be enabled if and only if the
308
* shaderTessellationAndGeometryPointSize feature is enabled. The default
309
* value is nonzero, i.e. write the point size.
310
*
311
* This option is supported by vkd3d_shader_compile() for the SPIR-V target
312
* type and Vulkan targets; it should not be enabled otherwise.
313
*
314
* \since 1.7
315
*/
316
VKD3D_SHADER_COMPILE_OPTION_WRITE_TESS_GEOM_POINT_SIZE = 0x00000006,
317
/**
318
* This option specifies default matrix packing order for HLSL sources.
319
* Explicit variable modifiers or pragmas will take precedence.
320
*
321
* \a value is a member of enum vkd3d_shader_compile_option_pack_matrix_order.
322
*
323
* \since 1.9
324
*/
325
VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER = 0x00000007,
326
/**
327
* This option is used to enable various backward compatibility features.
328
*
329
* \a value is a mask of values from enum vkd3d_shader_compile_option_backward_compatibility.
330
*
331
* \since 1.10
332
*/
333
VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY = 0x00000008,
334
/**
335
* This option specifies the origin of fragment coordinates for SPIR-V
336
* targets.
337
*
338
* \a value is a member of enum
339
* vkd3d_shader_compile_option_fragment_coordinate_origin.
340
*
341
* \since 1.10
342
*/
343
VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN = 0x00000009,
344
/**
345
* This option specifies the shader features available in the target
346
* environment. These are not extensions, i.e. they are always supported
347
* by the driver, but may not be supported by the available hardware.
348
*
349
* \a value is a member of enum vkd3d_shader_compile_option_feature_flags.
350
*
351
* \since 1.11
352
*/
353
VKD3D_SHADER_COMPILE_OPTION_FEATURE = 0x0000000a,
354
/**
355
* If \a value is non-zero compilation will produce a child effect using
356
* shared object descriptions, as instructed by the "shared" modifier.
357
* Child effects are supported with fx_4_0, and fx_4_1 profiles. This option
358
* and "shared" modifiers are ignored for the fx_5_0 profile and non-fx profiles.
359
* The fx_2_0 profile does not have a separate concept of child effects, variables
360
* marked with "shared" modifier will be marked as such in a binary.
361
*
362
* \since 1.12
363
*/
364
VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT = 0x0000000b,
365
/**
366
* If \a value is nonzero, emit a compile warning warn when vectors or
367
* matrices are truncated in an implicit conversion.
368
* If warnings are disabled, this option has no effect.
369
* This option has no effects for targets other than HLSL.
370
*
371
* The default value is nonzero, i.e. enable implicit truncation warnings.
372
*
373
* \since 1.12
374
*/
375
VKD3D_SHADER_COMPILE_OPTION_WARN_IMPLICIT_TRUNCATION = 0x0000000c,
376
/**
377
* If \a value is nonzero, empty constant buffers descriptions are
378
* written out in the output effect binary. This option applies only
379
* to fx_4_0 and fx_4_1 profiles and is otherwise ignored.
380
*
381
* \since 1.12
382
*/
383
VKD3D_SHADER_COMPILE_OPTION_INCLUDE_EMPTY_BUFFERS_IN_EFFECTS = 0x0000000d,
384
385
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME),
386
};
387
388
/**
389
* Various settings which may affect shader compilation or scanning, passed as
390
* part of struct vkd3d_shader_compile_info. For more details, see the
391
* documentation for individual options.
392
*/
393
struct vkd3d_shader_compile_option
394
{
395
/** Name of the option. */
396
enum vkd3d_shader_compile_option_name name;
397
/**
398
* A value associated with the option. The type and interpretation of the
399
* value depends on the option in question.
400
*/
401
unsigned int value;
402
};
403
404
/** Describes which shader stages a resource is visible to. */
405
enum vkd3d_shader_visibility
406
{
407
/** The resource is visible to all shader stages. */
408
VKD3D_SHADER_VISIBILITY_ALL = 0,
409
/** The resource is visible only to the vertex shader. */
410
VKD3D_SHADER_VISIBILITY_VERTEX = 1,
411
/** The resource is visible only to the hull shader. */
412
VKD3D_SHADER_VISIBILITY_HULL = 2,
413
/** The resource is visible only to the domain shader. */
414
VKD3D_SHADER_VISIBILITY_DOMAIN = 3,
415
/** The resource is visible only to the geometry shader. */
416
VKD3D_SHADER_VISIBILITY_GEOMETRY = 4,
417
/** The resource is visible only to the pixel shader. */
418
VKD3D_SHADER_VISIBILITY_PIXEL = 5,
419
420
/** The resource is visible only to the compute shader. */
421
VKD3D_SHADER_VISIBILITY_COMPUTE = 1000000000,
422
423
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_VISIBILITY),
424
};
425
426
/** A generic structure containing a GPU shader, in text or byte-code format. */
427
struct vkd3d_shader_code
428
{
429
/**
430
* Pointer to the code. Note that textual formats are not null-terminated.
431
* Therefore \a size should not include a null terminator when this
432
* structure is passed as input to a vkd3d-shader function, and \a size
433
* will not include a null terminator when this structure is used as
434
* output.
435
*
436
* For convenience, vkd3d_shader_preprocess() and vkd3d_shader_compile()
437
* will append a null terminator past the end of their output when
438
* outputting textual formats like VKD3D_SHADER_TARGET_D3D_ASM. This makes
439
* it safe to call functions like strlen() on \a code for such output,
440
* although doing so will obviously not account for any embedded null
441
* characters that may be present.
442
*/
443
const void *code;
444
/** Size of \a code, in bytes. */
445
size_t size;
446
};
447
448
/** The type of a shader resource descriptor. */
449
enum vkd3d_shader_descriptor_type
450
{
451
/**
452
* The descriptor is a shader resource view. In Direct3D assembly, this is
453
* bound to a t# register.
454
*/
455
VKD3D_SHADER_DESCRIPTOR_TYPE_SRV = 0x0,
456
/**
457
* The descriptor is an unordered access view. In Direct3D assembly, this is
458
* bound to a u# register.
459
*/
460
VKD3D_SHADER_DESCRIPTOR_TYPE_UAV = 0x1,
461
/**
462
* The descriptor is a constant buffer view. In Direct3D assembly, this is
463
* bound to a cb# register.
464
*/
465
VKD3D_SHADER_DESCRIPTOR_TYPE_CBV = 0x2,
466
/**
467
* The descriptor is a sampler. In Direct3D assembly, this is bound to an s#
468
* register.
469
*/
470
VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER = 0x3,
471
472
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_TYPE),
473
};
474
475
/**
476
* A common structure describing the bind point of a descriptor or descriptor
477
* array in the target environment.
478
*/
479
struct vkd3d_shader_descriptor_binding
480
{
481
/**
482
* The set of the descriptor. If the target environment does not support
483
* descriptor sets, this value must be set to 0.
484
*/
485
unsigned int set;
486
/** The binding index of the descriptor. */
487
unsigned int binding;
488
/**
489
* The size of this descriptor array. If an offset is specified for this
490
* binding by the vkd3d_shader_descriptor_offset_info structure, counting
491
* starts at that offset.
492
*/
493
unsigned int count;
494
};
495
496
enum vkd3d_shader_binding_flag
497
{
498
VKD3D_SHADER_BINDING_FLAG_BUFFER = 0x00000001,
499
VKD3D_SHADER_BINDING_FLAG_IMAGE = 0x00000002,
500
501
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_BINDING_FLAG),
502
};
503
504
/**
505
* The factor used to interpolate the fragment output colour with fog.
506
*
507
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for specification of the
508
* interpolation factor as defined here.
509
*
510
* The following variables may be used to determine the interpolation factor:
511
*
512
* c = The fog coordinate value output from the vertex shader. This is an
513
* inter-stage varying with the semantic name "FOG" and semantic index 0.
514
* It may be modified by VKD3D_SHADER_PARAMETER_NAME_FOG_SOURCE.
515
* E = The value of VKD3D_SHADER_PARAMETER_NAME_FOG_END.
516
* k = The value of VKD3D_SHADER_PARAMETER_NAME_FOG_SCALE.
517
*
518
* \since 1.15
519
*/
520
enum vkd3d_shader_fog_fragment_mode
521
{
522
/**
523
* No fog interpolation is applied;
524
* the output colour is passed through unmodified.
525
* Equivalently, the fog interpolation factor is 1.
526
*/
527
VKD3D_SHADER_FOG_FRAGMENT_NONE = 0x0,
528
/**
529
* The fog interpolation factor is 2^-(k * c).
530
*
531
* In order to implement traditional exponential fog, as present in
532
* Direct3D and OpenGL, i.e.
533
*
534
* e^-(density * c)
535
*
536
* set
537
*
538
* k = density * logâ‚‚(e)
539
*/
540
VKD3D_SHADER_FOG_FRAGMENT_EXP = 0x1,
541
/**
542
* The fog interpolation factor is 2^-((k * c)²).
543
*
544
* In order to implement traditional square-exponential fog, as present in
545
* Direct3D and OpenGL, i.e.
546
*
547
* e^-((density * c)²)
548
*
549
* set
550
*
551
* k = density * √log₂(e)
552
*/
553
VKD3D_SHADER_FOG_FRAGMENT_EXP2 = 0x2,
554
/**
555
* The fog interpolation factor is (E - c) * k.
556
*
557
* In order to implement traditional linear fog, as present in Direct3D and
558
* OpenGL, i.e.
559
*
560
* (end - c) / (end - start)
561
*
562
* set
563
*
564
* E = end
565
* k = 1 / (end - start)
566
*/
567
VKD3D_SHADER_FOG_FRAGMENT_LINEAR = 0x3,
568
569
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_FOG_FRAGMENT_MODE),
570
};
571
572
/**
573
* The source of the fog varying output by a pre-rasterization shader.
574
* The fog varying is defined as the output varying with the semantic name "FOG"
575
* and semantic index 0.
576
*
577
* See VKD3D_SHADER_PARAMETER_NAME_FOG_SOURCE for further documentation of this
578
* parameter.
579
*
580
* \since 1.15
581
*/
582
enum vkd3d_shader_fog_source
583
{
584
/**
585
* The source shader is not modified. That is, the fog varying in the target
586
* shader is the original fog varying if and only if present.
587
*/
588
VKD3D_SHADER_FOG_SOURCE_FOG = 0x0,
589
/**
590
* If the source shader has a fog varying, it is not modified.
591
* Otherwise, if the source shader outputs a varying with semantic name
592
* "COLOR" and semantic index 1 whose index includes a W component,
593
* said W component is output as fog varying.
594
* Otherwise, no fog varying is output.
595
*/
596
VKD3D_SHADER_FOG_SOURCE_FOG_OR_SPECULAR_W = 0x1,
597
/**
598
* The fog source is the Z component of the position output by the vertex
599
* shader.
600
*/
601
VKD3D_SHADER_FOG_SOURCE_Z = 0x2,
602
/**
603
* The fog source is the W component of the position output by the vertex
604
* shader.
605
*/
606
VKD3D_SHADER_FOG_SOURCE_W = 0x3,
607
608
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_FOG_SOURCE),
609
};
610
611
/**
612
* The manner in which a parameter value is provided to the shader, used in
613
* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.
614
*/
615
enum vkd3d_shader_parameter_type
616
{
617
VKD3D_SHADER_PARAMETER_TYPE_UNKNOWN,
618
/** The parameter value is embedded directly in the shader. */
619
VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT,
620
/**
621
* The parameter value is provided to the shader via specialization
622
* constants. This value is only supported for the SPIR-V target type.
623
*/
624
VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT,
625
/**
626
* The parameter value is provided to the shader as part of a uniform
627
* buffer.
628
*
629
* \since 1.13
630
*/
631
VKD3D_SHADER_PARAMETER_TYPE_BUFFER,
632
633
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARAMETER_TYPE),
634
};
635
636
/**
637
* The format of data provided to the shader, used in
638
* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.
639
*/
640
enum vkd3d_shader_parameter_data_type
641
{
642
VKD3D_SHADER_PARAMETER_DATA_TYPE_UNKNOWN,
643
/** The parameter is provided as a 32-bit unsigned integer. */
644
VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32,
645
/** The parameter is provided as a 32-bit float. \since 1.13 */
646
VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32,
647
/**
648
* The parameter is provided as a 4-dimensional vector of 32-bit floats.
649
* This parameter must be used with struct vkd3d_shader_parameter1;
650
* it cannot be used with struct vkd3d_shader_parameter.
651
* \since 1.14
652
*/
653
VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4,
654
655
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARAMETER_DATA_TYPE),
656
};
657
658
/**
659
* Names a specific shader parameter, used in
660
* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.
661
*/
662
enum vkd3d_shader_parameter_name
663
{
664
VKD3D_SHADER_PARAMETER_NAME_UNKNOWN,
665
/**
666
* The sample count of the framebuffer, as returned by the HLSL function
667
* GetRenderTargetSampleCount() or the GLSL builtin gl_NumSamples.
668
*
669
* This parameter should be specified when compiling to SPIR-V, which
670
* provides no builtin ability to query this information from the shader.
671
*
672
* The default value is 1.
673
*
674
* The data type for this parameter must be
675
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
676
*/
677
VKD3D_SHADER_PARAMETER_NAME_RASTERIZER_SAMPLE_COUNT,
678
/**
679
* Alpha test comparison function. When this parameter is provided, if the
680
* alpha component of the pixel shader colour output at location 0 fails the
681
* test, as defined by this function and the reference value provided by
682
* VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_REF, the fragment will be
683
* discarded.
684
*
685
* This parameter, along with VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_REF,
686
* can be used to implement fixed function alpha test, as present in
687
* Direct3D versions up to 9, if the target environment does not support
688
* alpha test as part of its own fixed-function API (as Vulkan and core
689
* OpenGL).
690
*
691
* The default value is VKD3D_SHADER_COMPARISON_FUNC_ALWAYS.
692
*
693
* The data type for this parameter must be
694
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32. The value specified must be
695
* a member of enum vkd3d_shader_comparison_func.
696
*
697
* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this
698
* version of vkd3d-shader.
699
*
700
* \since 1.13
701
*/
702
VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_FUNC,
703
/**
704
* Alpha test reference value.
705
* See VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_FUNC for documentation of
706
* alpha test.
707
*
708
* The default value is zero.
709
*
710
* \since 1.13
711
*/
712
VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_REF,
713
/**
714
* Whether to use flat interpolation for fragment shader colour inputs.
715
* If the value is nonzero, inputs whose semantic usage is COLOR will use
716
* flat interpolation instead of linear.
717
* This parameter is ignored if the shader model is 4 or greater, since only
718
* shader model 3 and below do not specify the interpolation mode in the
719
* shader bytecode.
720
*
721
* This parameter can be used to implement fixed function shade mode, as
722
* present in Direct3D versions up to 9, if the target environment does not
723
* support shade mode as part of its own fixed-function API (as Vulkan and
724
* core OpenGL).
725
*
726
* The data type for this parameter must be
727
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
728
*
729
* The default value is zero, i.e. use linear interpolation.
730
*
731
* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this
732
* version of vkd3d-shader.
733
*
734
* \since 1.13
735
*/
736
VKD3D_SHADER_PARAMETER_NAME_FLAT_INTERPOLATION,
737
/**
738
* A mask of enabled clip planes.
739
*
740
* When this parameter is provided to a vertex shader, for each nonzero bit
741
* of this mask, a user clip distance will be generated from vertex position
742
* in clip space, and the clip plane defined by the indexed vector, taken
743
* from the VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_# parameter.
744
*
745
* Regardless of the specific clip planes which are enabled, the clip
746
* distances which are output are a contiguous array starting from clip
747
* distance 0. This affects the interface of OpenGL. For example, if only
748
* clip planes 1 and 3 are enabled (and so the value of the mask is 0xa),
749
* the user should enable only GL_CLIP_DISTANCE0 and GL_CLIP_DISTANCE1.
750
*
751
* The default value is zero, i.e. do not enable any clip planes.
752
*
753
* The data type for this parameter must be
754
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
755
*
756
* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this
757
* version of vkd3d-shader.
758
*
759
* If the source shader writes clip distances and this parameter is nonzero,
760
* compilation fails.
761
*
762
* \since 1.14
763
*/
764
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_MASK,
765
/**
766
* Clip plane values.
767
* See VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_MASK for documentation of
768
* clip planes.
769
*
770
* These enum values are contiguous and arithmetic may safely be performed
771
* on them. That is, VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_[n] is
772
* VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_0 plus n.
773
*
774
* The data type for each parameter must be
775
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.
776
*
777
* The default value for each plane is a (0, 0, 0, 0) vector.
778
*
779
* \since 1.14
780
*/
781
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_0,
782
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_1,
783
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_2,
784
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_3,
785
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_4,
786
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_5,
787
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_6,
788
VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_7,
789
/**
790
* Point size.
791
*
792
* When this parameter is provided to a vertex, tessellation, or geometry
793
* shader, and the source shader does not write point size, it specifies a
794
* uniform value which will be written to point size.
795
* If the source shader writes point size, this parameter is ignored.
796
*
797
* This parameter can be used to implement fixed function point size, as
798
* present in Direct3D versions 8 and 9, if the target environment does not
799
* support point size as part of its own fixed-function API (as Vulkan and
800
* core OpenGL).
801
*
802
* The data type for this parameter must be
803
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
804
*
805
* \since 1.14
806
*/
807
VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE,
808
/**
809
* Minimum point size.
810
*
811
* When this parameter is provided to a vertex, tessellation, or geometry
812
* shader, and the source shader writes point size or uses the
813
* VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE parameter, the point size will
814
* be clamped to the provided minimum value.
815
* If point size is not written in one of these ways,
816
* this parameter is ignored.
817
* If this parameter is not provided, the point size will not be clamped
818
* to a minimum size by vkd3d-shader.
819
*
820
* This parameter can be used to implement fixed function point size, as
821
* present in Direct3D versions 8 and 9, if the target environment does not
822
* support point size as part of its own fixed-function API (as Vulkan and
823
* core OpenGL).
824
*
825
* The data type for this parameter must be
826
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
827
*
828
* \since 1.14
829
*/
830
VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MIN,
831
/**
832
* Maximum point size.
833
*
834
* This parameter has identical behaviour to
835
* VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MIN, except that it provides
836
* the maximum size rather than the minimum.
837
*
838
* \since 1.14
839
*/
840
VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MAX,
841
/**
842
* Whether texture coordinate inputs should take their values from the
843
* point coordinate.
844
*
845
* When this parameter is provided to a pixel shader, and the value is
846
* nonzero, any fragment shader input with the semantic name "TEXCOORD"
847
* takes its value from the point coordinates instead of from the previous
848
* shader. The point coordinates here are defined as a four-component vector
849
* whose X and Y components are the X and Y coordinates of the fragment
850
* within a point being rasterized, and whose Z and W components are zero.
851
*
852
* In GLSL, the X and Y components are drawn from gl_PointCoord; in SPIR-V,
853
* they are drawn from a variable with the BuiltinPointCoord decoration.
854
*
855
* This includes t# fragment shader inputs in shader model 2 shaders,
856
* as well as texture sampling in shader model 1 shaders.
857
*
858
* This parameter can be used to implement fixed function point sprite, as
859
* present in Direct3D versions 8 and 9, if the target environment does not
860
* support point sprite as part of its own fixed-function API (as Vulkan and
861
* core OpenGL).
862
*
863
* The data type for this parameter must be
864
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
865
*
866
* The default value is zero, i.e. use the original varyings.
867
*
868
* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this
869
* version of vkd3d-shader.
870
*
871
* \since 1.14
872
*/
873
VKD3D_SHADER_PARAMETER_NAME_POINT_SPRITE,
874
/**
875
* Fog mode used in fragment shaders.
876
*
877
* The value specified by this parameter must be a member of
878
* enum vkd3d_shader_fog_fragment_mode.
879
*
880
* If not VKD3D_SHADER_FOG_FRAGMENT_NONE, the pixel shader colour output at
881
* location 0 is linearly interpolated with the fog colour defined by
882
* VKD3D_SHADER_PARAMETER_NAME_FOG_COLOUR. The interpolation factor is
883
* defined according to the enumerant selected by this parameter.
884
* The interpolated value is then outputted instead of the original value at
885
* location 0.
886
*
887
* An interpolation factor of 0 specifies to use the fog colour; a factor of
888
* 1 specifies to use the original colour output. The interpolation factor
889
* is clamped to the [0, 1] range before interpolating.
890
*
891
* The default value is VKD3D_SHADER_FOG_FRAGMENT_NONE.
892
*
893
* The data type for this parameter must be
894
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
895
*
896
* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this
897
* version of vkd3d-shader.
898
*
899
* \since 1.15
900
*/
901
VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE,
902
/**
903
* Fog colour.
904
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of
905
* fog.
906
*
907
* The data type for this parameter must be
908
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.
909
*
910
* The default value is transparent black, i.e. the vector {0, 0, 0, 0}.
911
*
912
* \since 1.15
913
*/
914
VKD3D_SHADER_PARAMETER_NAME_FOG_COLOUR,
915
/**
916
* End coordinate for linear fog.
917
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of
918
* fog.
919
*
920
* The data type for this parameter must be
921
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
922
*
923
* The default value is 1.0.
924
*
925
* \since 1.15
926
*/
927
VKD3D_SHADER_PARAMETER_NAME_FOG_END,
928
/**
929
* Scale value for fog.
930
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of
931
* fog.
932
*
933
* The data type for this parameter must be
934
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
935
*
936
* The default value is 1.0.
937
*
938
* \since 1.15
939
*/
940
VKD3D_SHADER_PARAMETER_NAME_FOG_SCALE,
941
/**
942
* Fog source. The value specified by this parameter must be a member of
943
* enum vkd3d_shader_fog_source.
944
*
945
* This parameter replaces or suppletes the fog varying output by a
946
* pre-rasterization shader. The fog varying is defined as the output
947
* varying with the semantic name "FOG" and semantic index 0.
948
*
949
* Together with other fog parameters, this parameter can be used to
950
* implement fixed function fog, as present in Direct3D versions up to 9,
951
* if the target environment does not support fog as part of its own
952
* fixed-function API (as Vulkan and core OpenGL).
953
*
954
* The default value is VKD3D_SHADER_FOG_SOURCE_FOG.
955
*
956
* The data type for this parameter must be
957
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
958
*
959
* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this
960
* version of vkd3d-shader.
961
*
962
* \since 1.15
963
*/
964
VKD3D_SHADER_PARAMETER_NAME_FOG_SOURCE,
965
/**
966
* Bump-mapping matrix. This parameter is used in the evaluation of the
967
* Shader Model 1.x instructions BEM, TEXBEM, and TEXBEML.
968
*
969
* This parameter specifies a 2x2 matrix, packed into a vector in the order
970
* [00, 01, 10, 11], where "01" specifies the component at column 0 and row
971
* 1. These coordinates correspond to the Direct3D notation.
972
*
973
* To use this parameter to implement Direct3D bump mapping, pass the values
974
* of the texture stage states D3DTSS_BUMPENVMAT00, D3DTSS_BUMPENVMAT01,
975
* D3DTSS_BUMPENVMAT10, and D3DTSS_BUMPENVMAT11, in that order.
976
*
977
* These enum values are contiguous and arithmetic may safely be performed
978
* on them. That is, VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_[n] is
979
* VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_0 plus n.
980
*
981
* The data type for each parameter must be
982
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.
983
*
984
* The default value for each parameter is the zero matrix [0, 0; 0, 0].
985
*
986
* \since 1.18
987
*/
988
VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_0,
989
VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_1,
990
VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_2,
991
VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_3,
992
VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_4,
993
VKD3D_SHADER_PARAMETER_NAME_BUMP_MATRIX_5,
994
/**
995
* Bump-mapping luminance scale factor. This parameter is used in the
996
* evaluation of the Shader Model 1.x instruction TEXBEML.
997
*
998
* To use this parameter to implement Direct3D bump mapping, pass the value
999
* of the texture stage state D3DTSS_BUMPENVLSCALE.
1000
*
1001
* These enum values are contiguous and arithmetic may safely be performed
1002
* on them. That is, VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_[n] is
1003
* VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_0 plus n.
1004
*
1005
* The data type for each parameter must be
1006
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
1007
*
1008
* The default value for each parameter is 0.0.
1009
*
1010
* \since 1.18
1011
*/
1012
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_0,
1013
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_1,
1014
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_2,
1015
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_3,
1016
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_4,
1017
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_SCALE_5,
1018
/**
1019
* Bump-mapping luminance offset. This parameter is used in the
1020
* evaluation of the Shader Model 1.x instruction TEXBEML.
1021
*
1022
* To use this parameter to implement Direct3D bump mapping, pass the value
1023
* of the texture stage state D3DTSS_BUMPENVLOFFSET.
1024
*
1025
* These enum values are contiguous and arithmetic may safely be performed
1026
* on them. That is, VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_[n] is
1027
* VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_0 plus n.
1028
*
1029
* The data type for each parameter must be
1030
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
1031
*
1032
* The default value for each parameter is 0.0.
1033
*
1034
* \since 1.18
1035
*/
1036
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_0,
1037
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_1,
1038
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_2,
1039
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_3,
1040
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_4,
1041
VKD3D_SHADER_PARAMETER_NAME_BUMP_LUMINANCE_OFFSET_5,
1042
1043
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARAMETER_NAME),
1044
};
1045
1046
/**
1047
* The value of an immediate constant parameter, used in
1048
* struct vkd3d_shader_parameter.
1049
*/
1050
struct vkd3d_shader_parameter_immediate_constant
1051
{
1052
union
1053
{
1054
/**
1055
* The value if the parameter's data type is
1056
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
1057
*/
1058
uint32_t u32;
1059
/**
1060
* The value if the parameter's data type is
1061
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
1062
*
1063
* \since 1.13
1064
*/
1065
float f32;
1066
} u;
1067
};
1068
1069
/**
1070
* The value of an immediate constant parameter, used in
1071
* struct vkd3d_shader_parameter1.
1072
*
1073
* \since 1.13
1074
*/
1075
struct vkd3d_shader_parameter_immediate_constant1
1076
{
1077
union
1078
{
1079
/**
1080
* The value if the parameter's data type is
1081
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
1082
*/
1083
uint32_t u32;
1084
/**
1085
* The value if the parameter's data type is
1086
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
1087
*/
1088
float f32;
1089
/**
1090
* A pointer to the value if the parameter's data type is
1091
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.
1092
*
1093
* \since 1.14
1094
*/
1095
float f32_vec4[4];
1096
void *_pointer_pad;
1097
uint32_t _pad[4];
1098
} u;
1099
};
1100
1101
/**
1102
* The linkage of a specialization constant parameter, used in
1103
* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.
1104
*/
1105
struct vkd3d_shader_parameter_specialization_constant
1106
{
1107
/**
1108
* The ID of the specialization constant.
1109
* If the type comprises more than one constant, such as
1110
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4, then a contiguous
1111
* array of specialization constants should be used, one for each component,
1112
* and this ID should point to the first component.
1113
*/
1114
uint32_t id;
1115
};
1116
1117
/**
1118
* The linkage of a parameter specified through a uniform buffer, used in
1119
* struct vkd3d_shader_parameter1.
1120
*/
1121
struct vkd3d_shader_parameter_buffer
1122
{
1123
/**
1124
* The set of the uniform buffer descriptor. If the target environment does
1125
* not support descriptor sets, this value must be set to 0.
1126
*/
1127
unsigned int set;
1128
/** The binding index of the uniform buffer descriptor. */
1129
unsigned int binding;
1130
/** The byte offset of the parameter within the buffer. */
1131
uint32_t offset;
1132
};
1133
1134
/**
1135
* An individual shader parameter.
1136
*
1137
* This structure is an earlier version of struct vkd3d_shader_parameter1
1138
* which supports fewer parameter types;
1139
* refer to that structure for usage information.
1140
*
1141
* Only the following types may be used with this structure:
1142
*
1143
* - VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT
1144
* - VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT
1145
*/
1146
struct vkd3d_shader_parameter
1147
{
1148
enum vkd3d_shader_parameter_name name;
1149
enum vkd3d_shader_parameter_type type;
1150
enum vkd3d_shader_parameter_data_type data_type;
1151
union
1152
{
1153
struct vkd3d_shader_parameter_immediate_constant immediate_constant;
1154
struct vkd3d_shader_parameter_specialization_constant specialization_constant;
1155
} u;
1156
};
1157
1158
/**
1159
* An individual shader parameter.
1160
*
1161
* This structure is used in struct vkd3d_shader_parameter_info; see there for
1162
* explanation of shader parameters.
1163
*
1164
* For example, to specify the rasterizer sample count to the shader via an
1165
* unsigned integer specialization constant with ID 3,
1166
* set the following members:
1167
*
1168
* - \a name = VKD3D_SHADER_PARAMETER_NAME_RASTERIZER_SAMPLE_COUNT
1169
* - \a type = VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT
1170
* - \a data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32
1171
* - \a u.specialization_constant.id = 3
1172
*
1173
* This structure is an extended version of struct vkd3d_shader_parameter.
1174
*/
1175
struct vkd3d_shader_parameter1
1176
{
1177
/** The builtin parameter to be mapped. */
1178
enum vkd3d_shader_parameter_name name;
1179
/** How the parameter will be provided to the shader. */
1180
enum vkd3d_shader_parameter_type type;
1181
/**
1182
* The data type of the supplied parameter, which determines how it is to
1183
* be interpreted.
1184
*/
1185
enum vkd3d_shader_parameter_data_type data_type;
1186
union
1187
{
1188
/**
1189
* Additional information if \a type is
1190
* VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT.
1191
*/
1192
struct vkd3d_shader_parameter_immediate_constant1 immediate_constant;
1193
/**
1194
* Additional information if \a type is
1195
* VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT.
1196
*/
1197
struct vkd3d_shader_parameter_specialization_constant specialization_constant;
1198
/**
1199
* Additional information if \a type is
1200
* VKD3D_SHADER_PARAMETER_TYPE_BUFFER.
1201
*/
1202
struct vkd3d_shader_parameter_buffer buffer;
1203
void *_pointer_pad;
1204
uint32_t _pad[4];
1205
} u;
1206
};
1207
1208
/**
1209
* Symbolic register indices for mapping uniform constant register sets in
1210
* legacy Direct3D bytecode to constant buffer views in the target environment.
1211
*
1212
* Members of this enumeration are used in
1213
* \ref vkd3d_shader_resource_binding.register_index.
1214
*
1215
* \since 1.9
1216
*/
1217
enum vkd3d_shader_d3dbc_constant_register
1218
{
1219
/** The float constant register set, c# in Direct3D assembly. */
1220
VKD3D_SHADER_D3DBC_FLOAT_CONSTANT_REGISTER = 0x0,
1221
/** The integer constant register set, i# in Direct3D assembly. */
1222
VKD3D_SHADER_D3DBC_INT_CONSTANT_REGISTER = 0x1,
1223
/** The boolean constant register set, b# in Direct3D assembly. */
1224
VKD3D_SHADER_D3DBC_BOOL_CONSTANT_REGISTER = 0x2,
1225
1226
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_D3DBC_CONSTANT_REGISTER),
1227
};
1228
1229
/**
1230
* Describes the mapping of a single resource or resource array to its binding
1231
* point in the target environment.
1232
*
1233
* For example, to map a Direct3D SRV with register space 2, register "t3" to
1234
* a Vulkan descriptor in set 4 and with binding 5, set the following members:
1235
* - \a type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV
1236
* - \a register_space = 2
1237
* - \a register_index = 3
1238
* - \a binding.set = 4
1239
* - \a binding.binding = 5
1240
* - \a binding.count = 1
1241
*
1242
* This structure is used in struct vkd3d_shader_interface_info.
1243
*/
1244
struct vkd3d_shader_resource_binding
1245
{
1246
/** The type of this descriptor. */
1247
enum vkd3d_shader_descriptor_type type;
1248
/**
1249
* Register space of the Direct3D resource. If the source format does not
1250
* support multiple register spaces, this parameter must be set to 0.
1251
*/
1252
unsigned int register_space;
1253
/**
1254
* Register index of the Direct3D resource.
1255
*
1256
* For legacy Direct3D shaders, vkd3d-shader maps each constant register
1257
* set to a single constant buffer view. This parameter names the register
1258
* set to map, and must be a member of
1259
* enum vkd3d_shader_d3dbc_constant_register.
1260
*/
1261
unsigned int register_index;
1262
/** Shader stage(s) to which the resource is visible. */
1263
enum vkd3d_shader_visibility shader_visibility;
1264
/** A combination of zero or more elements of vkd3d_shader_binding_flag. */
1265
unsigned int flags;
1266
1267
/** The binding in the target environment. */
1268
struct vkd3d_shader_descriptor_binding binding;
1269
};
1270
1271
#define VKD3D_SHADER_DUMMY_SAMPLER_INDEX ~0u
1272
1273
/**
1274
* Describes the mapping of a Direct3D resource-sampler pair to a combined
1275
* sampler (i.e. sampled image).
1276
*
1277
* This structure is used in struct vkd3d_shader_interface_info.
1278
*/
1279
struct vkd3d_shader_combined_resource_sampler
1280
{
1281
/**
1282
* Register space of the Direct3D resource. If the source format does not
1283
* support multiple register spaces, this parameter must be set to 0.
1284
*/
1285
unsigned int resource_space;
1286
/** Register index of the Direct3D resource. */
1287
unsigned int resource_index;
1288
/**
1289
* Register space of the Direct3D sampler. If the source format does not
1290
* support multiple register spaces, this parameter must be set to 0.
1291
*/
1292
unsigned int sampler_space;
1293
/** Register index of the Direct3D sampler. */
1294
unsigned int sampler_index;
1295
/** Shader stage(s) to which the resource is visible. */
1296
enum vkd3d_shader_visibility shader_visibility;
1297
/** A combination of zero or more elements of vkd3d_shader_binding_flag. */
1298
unsigned int flags;
1299
1300
/** The binding in the target environment. */
1301
struct vkd3d_shader_descriptor_binding binding;
1302
};
1303
1304
/**
1305
* Describes the mapping of a single Direct3D UAV counter.
1306
*
1307
* This structure is used in struct vkd3d_shader_interface_info.
1308
*/
1309
struct vkd3d_shader_uav_counter_binding
1310
{
1311
/**
1312
* Register space of the Direct3D UAV descriptor. If the source format does
1313
* not support multiple register spaces, this parameter must be set to 0.
1314
*/
1315
unsigned int register_space;
1316
/** Register index of the Direct3D UAV descriptor. */
1317
unsigned int register_index;
1318
/** Shader stage(s) to which the UAV counter is visible. */
1319
enum vkd3d_shader_visibility shader_visibility;
1320
1321
/** The binding in the target environment. */
1322
struct vkd3d_shader_descriptor_binding binding;
1323
unsigned int offset;
1324
};
1325
1326
/**
1327
* Describes the mapping of a Direct3D constant buffer to a range of push
1328
* constants in the target environment.
1329
*
1330
* This structure is used in struct vkd3d_shader_interface_info.
1331
*/
1332
struct vkd3d_shader_push_constant_buffer
1333
{
1334
/**
1335
* Register space of the Direct3D resource. If the source format does not
1336
* support multiple register spaces, this parameter must be set to 0.
1337
*/
1338
unsigned int register_space;
1339
/** Register index of the Direct3D resource. */
1340
unsigned int register_index;
1341
/** Shader stage(s) to which the resource is visible. */
1342
enum vkd3d_shader_visibility shader_visibility;
1343
1344
/** Offset, in bytes, of the target push constants. */
1345
unsigned int offset;
1346
/** Size, in bytes, of the target push constants. */
1347
unsigned int size;
1348
};
1349
1350
/**
1351
* A chained structure describing the interface between a compiled shader and
1352
* the target environment.
1353
*
1354
* For example, when compiling Direct3D shader byte code to SPIR-V, this
1355
* structure contains mappings from Direct3D descriptor registers to SPIR-V
1356
* descriptor bindings.
1357
*
1358
* This structure is optional. If omitted, vkd3d_shader_compile() will use a
1359
* default mapping, in which resources are mapped to sequential bindings in
1360
* register set 0.
1361
*
1362
* This structure extends vkd3d_shader_compile_info.
1363
*
1364
* This structure contains only input parameters.
1365
*/
1366
struct vkd3d_shader_interface_info
1367
{
1368
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO. */
1369
enum vkd3d_shader_structure_type type;
1370
/** Optional pointer to a structure containing further parameters. */
1371
const void *next;
1372
1373
/** Pointer to an array of bindings for shader resource descriptors. */
1374
const struct vkd3d_shader_resource_binding *bindings;
1375
/** Size, in elements, of \ref bindings. */
1376
unsigned int binding_count;
1377
1378
/** Pointer to an array of bindings for push constant buffers. */
1379
const struct vkd3d_shader_push_constant_buffer *push_constant_buffers;
1380
/** Size, in elements, of \ref push_constant_buffers. */
1381
unsigned int push_constant_buffer_count;
1382
1383
/** Pointer to an array of bindings for combined samplers. */
1384
const struct vkd3d_shader_combined_resource_sampler *combined_samplers;
1385
/** Size, in elements, of \ref combined_samplers. */
1386
unsigned int combined_sampler_count;
1387
1388
/** Pointer to an array of bindings for UAV counters. */
1389
const struct vkd3d_shader_uav_counter_binding *uav_counters;
1390
/** Size, in elements, of \ref uav_counters. */
1391
unsigned int uav_counter_count;
1392
};
1393
1394
struct vkd3d_shader_transform_feedback_element
1395
{
1396
unsigned int stream_index;
1397
const char *semantic_name;
1398
unsigned int semantic_index;
1399
uint8_t component_index;
1400
uint8_t component_count;
1401
uint8_t output_slot;
1402
};
1403
1404
/* Extends vkd3d_shader_interface_info. */
1405
struct vkd3d_shader_transform_feedback_info
1406
{
1407
enum vkd3d_shader_structure_type type;
1408
const void *next;
1409
1410
const struct vkd3d_shader_transform_feedback_element *elements;
1411
unsigned int element_count;
1412
const unsigned int *buffer_strides;
1413
unsigned int buffer_stride_count;
1414
};
1415
1416
struct vkd3d_shader_descriptor_offset
1417
{
1418
unsigned int static_offset;
1419
unsigned int dynamic_offset_index;
1420
};
1421
1422
/**
1423
* A chained structure containing descriptor offsets.
1424
*
1425
* This structure is optional.
1426
*
1427
* This structure extends vkd3d_shader_interface_info.
1428
*
1429
* This structure contains only input parameters.
1430
*
1431
* \since 1.3
1432
*/
1433
struct vkd3d_shader_descriptor_offset_info
1434
{
1435
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_DESCRIPTOR_OFFSET_INFO. */
1436
enum vkd3d_shader_structure_type type;
1437
/** Optional pointer to a structure containing further parameters. */
1438
const void *next;
1439
1440
/**
1441
* Byte offset within the push constants of an array of 32-bit
1442
* descriptor array offsets. See the description of 'binding_offsets'
1443
* below.
1444
*/
1445
unsigned int descriptor_table_offset;
1446
/** Size, in elements, of the descriptor table push constant array. */
1447
unsigned int descriptor_table_count;
1448
1449
/**
1450
* Pointer to an array of struct vkd3d_shader_descriptor_offset objects.
1451
* The 'static_offset' field contains an offset into the descriptor arrays
1452
* referenced by the 'bindings' array in struct vkd3d_shader_interface_info.
1453
* This allows mapping multiple shader resource arrays to a single binding
1454
* point in the target environment.
1455
*
1456
* 'dynamic_offset_index' in struct vkd3d_shader_descriptor_offset allows
1457
* offsets to be set at runtime. The 32-bit descriptor table push constant
1458
* at this index will be added to 'static_offset' to calculate the final
1459
* binding offset.
1460
*
1461
* If runtime offsets are not required, set all 'dynamic_offset_index'
1462
* values to \c ~0u and 'descriptor_table_count' to zero.
1463
*
1464
* For example, to map Direct3D constant buffer registers 'cb0[0:3]' and
1465
* 'cb1[6:7]' to descriptors 8-12 and 4-5 in the Vulkan descriptor array in
1466
* descriptor set 3 and with binding 2, set the following values in the
1467
* 'bindings' array in struct vkd3d_shader_interface_info:
1468
*
1469
* \code
1470
* type = VKD3D_SHADER_DESCRIPTOR_TYPE_CBV
1471
* register_space = 0
1472
* register_index = 0
1473
* binding.set = 3
1474
* binding.binding = 2
1475
* binding.count = 4
1476
*
1477
* type = VKD3D_SHADER_DESCRIPTOR_TYPE_CBV
1478
* register_space = 0
1479
* register_index = 6
1480
* binding.set = 3
1481
* binding.binding = 2
1482
* binding.count = 2
1483
* \endcode
1484
*
1485
* and then pass \c {8, \c 4} as static binding offsets here.
1486
*
1487
* This field may be NULL, in which case the corresponding offsets are
1488
* specified to be 0.
1489
*/
1490
const struct vkd3d_shader_descriptor_offset *binding_offsets;
1491
1492
/**
1493
* Pointer to an array of offsets into the descriptor arrays referenced by
1494
* the 'uav_counters' array in struct vkd3d_shader_interface_info. This
1495
* works the same way as \ref binding_offsets above.
1496
*/
1497
const struct vkd3d_shader_descriptor_offset *uav_counter_offsets;
1498
};
1499
1500
/** The format of a shader to be compiled or scanned. */
1501
enum vkd3d_shader_source_type
1502
{
1503
/**
1504
* The shader has no type or is to be ignored. This is not a valid value
1505
* for vkd3d_shader_compile() or vkd3d_shader_scan().
1506
*/
1507
VKD3D_SHADER_SOURCE_NONE,
1508
/**
1509
* A 'Tokenized Program Format' shader embedded in a DXBC container. This is
1510
* the format used for Direct3D shader model 4 and 5 shaders.
1511
*/
1512
VKD3D_SHADER_SOURCE_DXBC_TPF,
1513
/** High-Level Shader Language source code. \since 1.3 */
1514
VKD3D_SHADER_SOURCE_HLSL,
1515
/**
1516
* Legacy Direct3D byte-code. This is the format used for Direct3D shader
1517
* model 1, 2, and 3 shaders. \since 1.3
1518
*/
1519
VKD3D_SHADER_SOURCE_D3D_BYTECODE,
1520
/**
1521
* A 'DirectX Intermediate Language' shader embedded in a DXBC container. This is
1522
* the format used for Direct3D shader model 6 shaders. \since 1.9
1523
*/
1524
VKD3D_SHADER_SOURCE_DXBC_DXIL,
1525
/**
1526
* Binary format used by Direct3D 9/10.x/11 effects.
1527
* Input is a raw FX section without container. \since 1.14
1528
*/
1529
VKD3D_SHADER_SOURCE_FX,
1530
/**
1531
* A D3DX texture shader. This is the format used for the 'tx_1_0' HLSL
1532
* target profile. \since 1.17
1533
*/
1534
VKD3D_SHADER_SOURCE_TX,
1535
1536
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SOURCE_TYPE),
1537
};
1538
1539
/** The output format of a compiled shader. */
1540
enum vkd3d_shader_target_type
1541
{
1542
/**
1543
* The shader has no type or is to be ignored. This is not a valid value
1544
* for vkd3d_shader_compile().
1545
*/
1546
VKD3D_SHADER_TARGET_NONE,
1547
/**
1548
* A SPIR-V shader in binary form. This is the format used for Vulkan
1549
* shaders.
1550
*/
1551
VKD3D_SHADER_TARGET_SPIRV_BINARY,
1552
VKD3D_SHADER_TARGET_SPIRV_TEXT,
1553
/**
1554
* Direct3D shader assembly. \since 1.3
1555
*/
1556
VKD3D_SHADER_TARGET_D3D_ASM,
1557
/**
1558
* Legacy Direct3D byte-code. This is the format used for Direct3D shader
1559
* model 1, 2, and 3 shaders. \since 1.3
1560
*/
1561
VKD3D_SHADER_TARGET_D3D_BYTECODE,
1562
/**
1563
* A 'Tokenized Program Format' shader embedded in a DXBC container. This is
1564
* the format used for Direct3D shader model 4 and 5 shaders. \since 1.3
1565
*/
1566
VKD3D_SHADER_TARGET_DXBC_TPF,
1567
/**
1568
* An 'OpenGL Shading Language' shader. \since 1.3
1569
*/
1570
VKD3D_SHADER_TARGET_GLSL,
1571
/**
1572
* Binary format used by Direct3D 9/10.x/11 effects profiles.
1573
* Output is a raw FX section without container. \since 1.11
1574
*/
1575
VKD3D_SHADER_TARGET_FX,
1576
/**
1577
* A 'Metal Shading Language' shader. \since 1.14
1578
*/
1579
VKD3D_SHADER_TARGET_MSL,
1580
1581
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TARGET_TYPE),
1582
};
1583
1584
/**
1585
* Describes the minimum severity of compilation messages returned by
1586
* vkd3d_shader_compile() and similar functions.
1587
*/
1588
enum vkd3d_shader_log_level
1589
{
1590
/** No messages will be returned. */
1591
VKD3D_SHADER_LOG_NONE,
1592
/** Only fatal errors which prevent successful compilation will be returned. */
1593
VKD3D_SHADER_LOG_ERROR,
1594
/** Non-fatal warnings and fatal errors will be returned. */
1595
VKD3D_SHADER_LOG_WARNING,
1596
/**
1597
* All messages, including general informational messages, will be returned.
1598
*/
1599
VKD3D_SHADER_LOG_INFO,
1600
1601
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_LOG_LEVEL),
1602
};
1603
1604
/**
1605
* A chained structure containing compilation parameters.
1606
*/
1607
struct vkd3d_shader_compile_info
1608
{
1609
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO. */
1610
enum vkd3d_shader_structure_type type;
1611
/**
1612
* Optional pointer to a structure containing further parameters. For a list
1613
* of valid structures, refer to the respective function documentation. If
1614
* no further parameters are needed, this field should be set to NULL.
1615
*/
1616
const void *next;
1617
1618
/** Input source code or byte code. */
1619
struct vkd3d_shader_code source;
1620
1621
/** Format of the input code passed in \ref source. */
1622
enum vkd3d_shader_source_type source_type;
1623
/** Desired output format. */
1624
enum vkd3d_shader_target_type target_type;
1625
1626
/**
1627
* Pointer to an array of compilation options. This field is ignored if
1628
* \ref option_count is zero, but must be valid otherwise.
1629
*
1630
* If the same option is specified multiple times, only the last value is
1631
* used.
1632
*
1633
* Options not relevant to or not supported by a particular shader compiler
1634
* or scanner will be ignored.
1635
*/
1636
const struct vkd3d_shader_compile_option *options;
1637
/** Size, in elements, of \ref options. */
1638
unsigned int option_count;
1639
1640
/** Minimum severity of messages returned from the shader function. */
1641
enum vkd3d_shader_log_level log_level;
1642
/**
1643
* Name of the initial source file, which may be used in error messages or
1644
* debug information. This parameter is optional and may be NULL.
1645
*/
1646
const char *source_name;
1647
};
1648
1649
enum vkd3d_shader_spirv_environment
1650
{
1651
VKD3D_SHADER_SPIRV_ENVIRONMENT_NONE,
1652
VKD3D_SHADER_SPIRV_ENVIRONMENT_OPENGL_4_5,
1653
VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_0, /* default target */
1654
/** \since 1.12 */
1655
VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_1,
1656
1657
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SPIRV_ENVIRONMENT),
1658
};
1659
1660
enum vkd3d_shader_spirv_extension
1661
{
1662
VKD3D_SHADER_SPIRV_EXTENSION_NONE,
1663
VKD3D_SHADER_SPIRV_EXTENSION_EXT_DEMOTE_TO_HELPER_INVOCATION,
1664
/** \since 1.3 */
1665
VKD3D_SHADER_SPIRV_EXTENSION_EXT_DESCRIPTOR_INDEXING,
1666
/** \since 1.3 */
1667
VKD3D_SHADER_SPIRV_EXTENSION_EXT_STENCIL_EXPORT,
1668
/** \since 1.11 */
1669
VKD3D_SHADER_SPIRV_EXTENSION_EXT_VIEWPORT_INDEX_LAYER,
1670
/** \since 1.12 */
1671
VKD3D_SHADER_SPIRV_EXTENSION_EXT_FRAGMENT_SHADER_INTERLOCK,
1672
1673
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SPIRV_EXTENSION),
1674
};
1675
1676
/* Extends vkd3d_shader_compile_info. */
1677
struct vkd3d_shader_spirv_target_info
1678
{
1679
enum vkd3d_shader_structure_type type;
1680
const void *next;
1681
1682
const char *entry_point; /* "main" if NULL. */
1683
1684
enum vkd3d_shader_spirv_environment environment;
1685
1686
const enum vkd3d_shader_spirv_extension *extensions;
1687
unsigned int extension_count;
1688
1689
const struct vkd3d_shader_parameter *parameters;
1690
unsigned int parameter_count;
1691
1692
bool dual_source_blending;
1693
const unsigned int *output_swizzles;
1694
unsigned int output_swizzle_count;
1695
};
1696
1697
enum vkd3d_shader_tessellator_output_primitive
1698
{
1699
VKD3D_SHADER_TESSELLATOR_OUTPUT_POINT = 0x1,
1700
VKD3D_SHADER_TESSELLATOR_OUTPUT_LINE = 0x2,
1701
VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CW = 0x3,
1702
VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 0x4,
1703
1704
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TESSELLATOR_OUTPUT_PRIMITIVE),
1705
};
1706
1707
enum vkd3d_shader_tessellator_partitioning
1708
{
1709
VKD3D_SHADER_TESSELLATOR_PARTITIONING_INTEGER = 0x1,
1710
VKD3D_SHADER_TESSELLATOR_PARTITIONING_POW2 = 0x2,
1711
VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 0x3,
1712
VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 0x4,
1713
1714
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TESSELLATOR_PARTITIONING),
1715
};
1716
1717
/* Extends vkd3d_shader_spirv_target_info. */
1718
struct vkd3d_shader_spirv_domain_shader_target_info
1719
{
1720
enum vkd3d_shader_structure_type type;
1721
const void *next;
1722
1723
enum vkd3d_shader_tessellator_output_primitive output_primitive;
1724
enum vkd3d_shader_tessellator_partitioning partitioning;
1725
};
1726
1727
/**
1728
* A single preprocessor macro, passed as part of struct
1729
* vkd3d_shader_preprocess_info.
1730
*/
1731
struct vkd3d_shader_macro
1732
{
1733
/**
1734
* Pointer to a null-terminated string containing the name of a macro. This
1735
* macro must not be a parameterized (i.e. function-like) macro. If this
1736
* field is not a valid macro identifier, this macro will be ignored.
1737
*/
1738
const char *name;
1739
/**
1740
* Optional pointer to a null-terminated string containing the expansion of
1741
* the macro. This field may be set to NULL, in which case the macro has an
1742
* empty expansion.
1743
*/
1744
const char *value;
1745
};
1746
1747
/**
1748
* Type of a callback function which will be used to open preprocessor includes.
1749
*
1750
* This callback function is passed as part of struct
1751
* vkd3d_shader_preprocess_info.
1752
*
1753
* If this function fails, vkd3d-shader will emit a compilation error, and the
1754
* \a pfn_close_include callback will not be called.
1755
*
1756
* \param filename Unquoted string used as an argument to the \#include
1757
* directive.
1758
*
1759
* \param local Whether the \#include directive is requesting a local (i.e.
1760
* double-quoted) or system (i.e. angle-bracketed) include.
1761
*
1762
* \param parent_data Unprocessed source code of the file in which this
1763
* \#include directive is evaluated. This parameter may be NULL.
1764
*
1765
* \param context The user-defined pointer passed to struct
1766
* vkd3d_shader_preprocess_info.
1767
*
1768
* \param out Output location for the full contents of the included file. The
1769
* code need not be allocated using standard vkd3d functions, but must remain
1770
* valid until the corresponding call to \a pfn_close_include. If this function
1771
* fails, the contents of this parameter are ignored.
1772
*
1773
* \return A member of \ref vkd3d_result.
1774
*/
1775
typedef int (*PFN_vkd3d_shader_open_include)(const char *filename, bool local,
1776
const char *parent_data, void *context, struct vkd3d_shader_code *out);
1777
/**
1778
* Type of a callback function which will be used to close preprocessor
1779
* includes.
1780
*
1781
* This callback function is passed as part of struct
1782
* vkd3d_shader_preprocess_info.
1783
*
1784
* \param code Contents of the included file, which were allocated by the
1785
* vkd3d_shader_preprocess_info.pfn_open_include callback.
1786
* The user must free them.
1787
*
1788
* \param context The user-defined pointer passed to struct
1789
* vkd3d_shader_preprocess_info.
1790
*/
1791
typedef void (*PFN_vkd3d_shader_close_include)(const struct vkd3d_shader_code *code, void *context);
1792
1793
/**
1794
* A chained structure containing preprocessing parameters.
1795
*
1796
* This structure is optional.
1797
*
1798
* This structure extends vkd3d_shader_compile_info.
1799
*
1800
* This structure contains only input parameters.
1801
*
1802
* \since 1.3
1803
*/
1804
struct vkd3d_shader_preprocess_info
1805
{
1806
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO. */
1807
enum vkd3d_shader_structure_type type;
1808
/** Optional pointer to a structure containing further parameters. */
1809
const void *next;
1810
1811
/**
1812
* Pointer to an array of predefined macros. Each macro in this array will
1813
* be expanded as if a corresponding \#define statement were prepended to
1814
* the source code.
1815
*
1816
* If the same macro is specified multiple times, only the last value is
1817
* used.
1818
*/
1819
const struct vkd3d_shader_macro *macros;
1820
/** Size, in elements, of \ref macros. */
1821
unsigned int macro_count;
1822
1823
/**
1824
* Optional pointer to a callback function, which will be called in order to
1825
* evaluate \#include directives. The function receives parameters
1826
* corresponding to the directive's arguments, and should return the
1827
* complete text of the included file.
1828
*
1829
* If this field is set to NULL, or if this structure is omitted,
1830
* vkd3d-shader will attempt to open included files using POSIX file APIs.
1831
*
1832
* If this field is set to NULL, the \ref pfn_close_include field must also
1833
* be set to NULL.
1834
*/
1835
PFN_vkd3d_shader_open_include pfn_open_include;
1836
/**
1837
* Optional pointer to a callback function, which will be called whenever an
1838
* included file is closed. This function will be called exactly once for
1839
* each successful call to \ref pfn_open_include, and should be used to free
1840
* any resources allocated thereby.
1841
*
1842
* If this field is set to NULL, the \ref pfn_open_include field must also
1843
* be set to NULL.
1844
*/
1845
PFN_vkd3d_shader_close_include pfn_close_include;
1846
/**
1847
* User-defined pointer which will be passed unmodified to the
1848
* \ref pfn_open_include and \ref pfn_close_include callbacks.
1849
*/
1850
void *include_context;
1851
};
1852
1853
/**
1854
* A chained structure containing HLSL compilation parameters.
1855
*
1856
* This structure is optional.
1857
*
1858
* This structure extends vkd3d_shader_compile_info.
1859
*
1860
* This structure contains only input parameters.
1861
*
1862
* \since 1.3
1863
*/
1864
struct vkd3d_shader_hlsl_source_info
1865
{
1866
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO. */
1867
enum vkd3d_shader_structure_type type;
1868
/** Optional pointer to a structure containing further parameters. */
1869
const void *next;
1870
1871
/**
1872
* Optional pointer to a null-terminated string containing the shader entry
1873
* point.
1874
*
1875
* If this parameter is NULL, vkd3d-shader uses the entry point "main".
1876
*/
1877
const char *entry_point;
1878
struct vkd3d_shader_code secondary_code;
1879
/**
1880
* Pointer to a null-terminated string containing the target shader
1881
* profile.
1882
*/
1883
const char *profile;
1884
};
1885
1886
/* root signature 1.0 */
1887
enum vkd3d_shader_filter
1888
{
1889
VKD3D_SHADER_FILTER_MIN_MAG_MIP_POINT = 0x000,
1890
VKD3D_SHADER_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x001,
1891
VKD3D_SHADER_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x004,
1892
VKD3D_SHADER_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x005,
1893
VKD3D_SHADER_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x010,
1894
VKD3D_SHADER_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x011,
1895
VKD3D_SHADER_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x014,
1896
VKD3D_SHADER_FILTER_MIN_MAG_MIP_LINEAR = 0x015,
1897
VKD3D_SHADER_FILTER_ANISOTROPIC = 0x055,
1898
VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x080,
1899
VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x081,
1900
VKD3D_SHADER_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x084,
1901
VKD3D_SHADER_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x085,
1902
VKD3D_SHADER_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x090,
1903
VKD3D_SHADER_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x091,
1904
VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x094,
1905
VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x095,
1906
VKD3D_SHADER_FILTER_COMPARISON_ANISOTROPIC = 0x0d5,
1907
VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100,
1908
VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101,
1909
VKD3D_SHADER_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104,
1910
VKD3D_SHADER_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105,
1911
VKD3D_SHADER_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110,
1912
VKD3D_SHADER_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111,
1913
VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114,
1914
VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115,
1915
VKD3D_SHADER_FILTER_MINIMUM_ANISOTROPIC = 0x155,
1916
VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180,
1917
VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181,
1918
VKD3D_SHADER_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184,
1919
VKD3D_SHADER_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185,
1920
VKD3D_SHADER_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190,
1921
VKD3D_SHADER_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191,
1922
VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194,
1923
VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195,
1924
VKD3D_SHADER_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5,
1925
1926
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_FILTER),
1927
};
1928
1929
enum vkd3d_shader_texture_address_mode
1930
{
1931
VKD3D_SHADER_TEXTURE_ADDRESS_MODE_WRAP = 0x1,
1932
VKD3D_SHADER_TEXTURE_ADDRESS_MODE_MIRROR = 0x2,
1933
VKD3D_SHADER_TEXTURE_ADDRESS_MODE_CLAMP = 0x3,
1934
VKD3D_SHADER_TEXTURE_ADDRESS_MODE_BORDER = 0x4,
1935
VKD3D_SHADER_TEXTURE_ADDRESS_MODE_MIRROR_ONCE = 0x5,
1936
1937
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TEXTURE_ADDRESS_MODE),
1938
};
1939
1940
enum vkd3d_shader_comparison_func
1941
{
1942
VKD3D_SHADER_COMPARISON_FUNC_NEVER = 0x1,
1943
VKD3D_SHADER_COMPARISON_FUNC_LESS = 0x2,
1944
VKD3D_SHADER_COMPARISON_FUNC_EQUAL = 0x3,
1945
VKD3D_SHADER_COMPARISON_FUNC_LESS_EQUAL = 0x4,
1946
VKD3D_SHADER_COMPARISON_FUNC_GREATER = 0x5,
1947
VKD3D_SHADER_COMPARISON_FUNC_NOT_EQUAL = 0x6,
1948
VKD3D_SHADER_COMPARISON_FUNC_GREATER_EQUAL = 0x7,
1949
VKD3D_SHADER_COMPARISON_FUNC_ALWAYS = 0x8,
1950
1951
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPARISON_FUNC),
1952
};
1953
1954
enum vkd3d_shader_static_border_colour
1955
{
1956
VKD3D_SHADER_STATIC_BORDER_COLOUR_TRANSPARENT_BLACK = 0x0,
1957
VKD3D_SHADER_STATIC_BORDER_COLOUR_OPAQUE_BLACK = 0x1,
1958
VKD3D_SHADER_STATIC_BORDER_COLOUR_OPAQUE_WHITE = 0x2,
1959
1960
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STATIC_BORDER_COLOUR),
1961
};
1962
1963
struct vkd3d_shader_static_sampler_desc
1964
{
1965
enum vkd3d_shader_filter filter;
1966
enum vkd3d_shader_texture_address_mode address_u;
1967
enum vkd3d_shader_texture_address_mode address_v;
1968
enum vkd3d_shader_texture_address_mode address_w;
1969
float mip_lod_bias;
1970
unsigned int max_anisotropy;
1971
enum vkd3d_shader_comparison_func comparison_func;
1972
enum vkd3d_shader_static_border_colour border_colour;
1973
float min_lod;
1974
float max_lod;
1975
unsigned int shader_register;
1976
unsigned int register_space;
1977
enum vkd3d_shader_visibility shader_visibility;
1978
};
1979
1980
struct vkd3d_shader_descriptor_range
1981
{
1982
enum vkd3d_shader_descriptor_type range_type;
1983
unsigned int descriptor_count;
1984
unsigned int base_shader_register;
1985
unsigned int register_space;
1986
unsigned int descriptor_table_offset;
1987
};
1988
1989
struct vkd3d_shader_root_descriptor_table
1990
{
1991
unsigned int descriptor_range_count;
1992
const struct vkd3d_shader_descriptor_range *descriptor_ranges;
1993
};
1994
1995
struct vkd3d_shader_root_constants
1996
{
1997
unsigned int shader_register;
1998
unsigned int register_space;
1999
unsigned int value_count;
2000
};
2001
2002
struct vkd3d_shader_root_descriptor
2003
{
2004
unsigned int shader_register;
2005
unsigned int register_space;
2006
};
2007
2008
enum vkd3d_shader_root_parameter_type
2009
{
2010
VKD3D_SHADER_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE = 0x0,
2011
VKD3D_SHADER_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS = 0x1,
2012
VKD3D_SHADER_ROOT_PARAMETER_TYPE_CBV = 0x2,
2013
VKD3D_SHADER_ROOT_PARAMETER_TYPE_SRV = 0x3,
2014
VKD3D_SHADER_ROOT_PARAMETER_TYPE_UAV = 0x4,
2015
2016
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_PARAMETER_TYPE),
2017
};
2018
2019
struct vkd3d_shader_root_parameter
2020
{
2021
enum vkd3d_shader_root_parameter_type parameter_type;
2022
union
2023
{
2024
struct vkd3d_shader_root_descriptor_table descriptor_table;
2025
struct vkd3d_shader_root_constants constants;
2026
struct vkd3d_shader_root_descriptor descriptor;
2027
} u;
2028
enum vkd3d_shader_visibility shader_visibility;
2029
};
2030
2031
enum vkd3d_shader_root_signature_flags
2032
{
2033
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_NONE = 0x00,
2034
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x01,
2035
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS = 0x02,
2036
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS = 0x04,
2037
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS = 0x08,
2038
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS = 0x10,
2039
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS = 0x20,
2040
VKD3D_SHADER_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT = 0x40,
2041
2042
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_SIGNATURE_FLAGS),
2043
};
2044
2045
struct vkd3d_shader_root_signature_desc
2046
{
2047
unsigned int parameter_count;
2048
const struct vkd3d_shader_root_parameter *parameters;
2049
unsigned int static_sampler_count;
2050
const struct vkd3d_shader_static_sampler_desc *static_samplers;
2051
enum vkd3d_shader_root_signature_flags flags;
2052
};
2053
2054
/* root signature 1.1 */
2055
enum vkd3d_shader_root_descriptor_flags
2056
{
2057
VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_NONE = 0x0,
2058
VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE = 0x2,
2059
VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4,
2060
VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_DATA_STATIC = 0x8,
2061
2062
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_DESCRIPTOR_FLAGS),
2063
};
2064
2065
enum vkd3d_shader_descriptor_range_flags
2066
{
2067
VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_NONE = 0x0,
2068
VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE = 0x1,
2069
VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE = 0x2,
2070
VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4,
2071
VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DATA_STATIC = 0x8,
2072
/** \since 1.11 */
2073
VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS = 0x10000,
2074
2075
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_RANGE_FLAGS),
2076
};
2077
2078
struct vkd3d_shader_descriptor_range1
2079
{
2080
enum vkd3d_shader_descriptor_type range_type;
2081
unsigned int descriptor_count;
2082
unsigned int base_shader_register;
2083
unsigned int register_space;
2084
enum vkd3d_shader_descriptor_range_flags flags;
2085
unsigned int descriptor_table_offset;
2086
};
2087
2088
struct vkd3d_shader_root_descriptor_table1
2089
{
2090
unsigned int descriptor_range_count;
2091
const struct vkd3d_shader_descriptor_range1 *descriptor_ranges;
2092
};
2093
2094
struct vkd3d_shader_root_descriptor1
2095
{
2096
unsigned int shader_register;
2097
unsigned int register_space;
2098
enum vkd3d_shader_root_descriptor_flags flags;
2099
};
2100
2101
struct vkd3d_shader_root_parameter1
2102
{
2103
enum vkd3d_shader_root_parameter_type parameter_type;
2104
union
2105
{
2106
struct vkd3d_shader_root_descriptor_table1 descriptor_table;
2107
struct vkd3d_shader_root_constants constants;
2108
struct vkd3d_shader_root_descriptor1 descriptor;
2109
} u;
2110
enum vkd3d_shader_visibility shader_visibility;
2111
};
2112
2113
struct vkd3d_shader_root_signature_desc1
2114
{
2115
unsigned int parameter_count;
2116
const struct vkd3d_shader_root_parameter1 *parameters;
2117
unsigned int static_sampler_count;
2118
const struct vkd3d_shader_static_sampler_desc *static_samplers;
2119
enum vkd3d_shader_root_signature_flags flags;
2120
};
2121
2122
enum vkd3d_shader_root_signature_version
2123
{
2124
VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_0 = 0x1,
2125
VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_1 = 0x2,
2126
2127
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_SIGNATURE_VERSION),
2128
};
2129
2130
struct vkd3d_shader_versioned_root_signature_desc
2131
{
2132
enum vkd3d_shader_root_signature_version version;
2133
union
2134
{
2135
struct vkd3d_shader_root_signature_desc v_1_0;
2136
struct vkd3d_shader_root_signature_desc1 v_1_1;
2137
} u;
2138
};
2139
2140
/**
2141
* The type of a shader resource, returned as part of struct
2142
* vkd3d_shader_descriptor_info.
2143
*/
2144
enum vkd3d_shader_resource_type
2145
{
2146
/**
2147
* The type is invalid or not applicable for this descriptor. This value is
2148
* returned for samplers.
2149
*/
2150
VKD3D_SHADER_RESOURCE_NONE = 0x0,
2151
/** Dimensionless buffer. */
2152
VKD3D_SHADER_RESOURCE_BUFFER = 0x1,
2153
/** 1-dimensional texture. */
2154
VKD3D_SHADER_RESOURCE_TEXTURE_1D = 0x2,
2155
/** 2-dimensional texture. */
2156
VKD3D_SHADER_RESOURCE_TEXTURE_2D = 0x3,
2157
/** Multisampled 2-dimensional texture. */
2158
VKD3D_SHADER_RESOURCE_TEXTURE_2DMS = 0x4,
2159
/** 3-dimensional texture. */
2160
VKD3D_SHADER_RESOURCE_TEXTURE_3D = 0x5,
2161
/** Cubemap texture. */
2162
VKD3D_SHADER_RESOURCE_TEXTURE_CUBE = 0x6,
2163
/** 1-dimensional array texture. */
2164
VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY = 0x7,
2165
/** 2-dimensional array texture. */
2166
VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY = 0x8,
2167
/** Multisampled 2-dimensional array texture. */
2168
VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY = 0x9,
2169
/** Cubemap array texture. */
2170
VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY = 0xa,
2171
2172
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_TYPE),
2173
};
2174
2175
/**
2176
* The type of the data contained in a shader resource, returned as part of
2177
* struct vkd3d_shader_descriptor_info. All formats are 32-bit.
2178
*/
2179
enum vkd3d_shader_resource_data_type
2180
{
2181
/**
2182
* The descriptor has no relevant data type. This value is returned for
2183
* samplers. \since 1.16
2184
*/
2185
VKD3D_SHADER_RESOURCE_DATA_NONE = 0x0,
2186
/** Unsigned normalized integer. */
2187
VKD3D_SHADER_RESOURCE_DATA_UNORM = 0x1,
2188
/** Signed normalized integer. */
2189
VKD3D_SHADER_RESOURCE_DATA_SNORM = 0x2,
2190
/** Signed integer. */
2191
VKD3D_SHADER_RESOURCE_DATA_INT = 0x3,
2192
/** Unsigned integer. */
2193
VKD3D_SHADER_RESOURCE_DATA_UINT = 0x4,
2194
/** IEEE single-precision floating-point. */
2195
VKD3D_SHADER_RESOURCE_DATA_FLOAT = 0x5,
2196
/** Undefined/type-less. \since 1.3 */
2197
VKD3D_SHADER_RESOURCE_DATA_MIXED = 0x6,
2198
/** IEEE double-precision floating-point. \since 1.3 */
2199
VKD3D_SHADER_RESOURCE_DATA_DOUBLE = 0x7,
2200
/** Continuation of the previous component. For example, 64-bit
2201
* double-precision floating-point data may be returned as two 32-bit
2202
* components, with the first component (containing the LSB) specified as
2203
* VKD3D_SHADER_RESOURCE_DATA_DOUBLE, and the second component specified
2204
* as VKD3D_SHADER_RESOURCE_DATA_CONTINUED. \since 1.3 */
2205
VKD3D_SHADER_RESOURCE_DATA_CONTINUED = 0x8,
2206
2207
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_DATA_TYPE),
2208
};
2209
2210
/**
2211
* Additional flags describing a shader descriptor, returned as part of struct
2212
* vkd3d_shader_descriptor_info.
2213
*/
2214
enum vkd3d_shader_descriptor_info_flag
2215
{
2216
/**
2217
* The descriptor is a UAV resource, whose counter is read from or written
2218
* to by the shader.
2219
*/
2220
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER = 0x00000001,
2221
/** The descriptor is a UAV resource, which is read from by the shader. */
2222
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002,
2223
/** The descriptor is a comparison sampler. */
2224
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE = 0x00000004,
2225
/** The descriptor is a UAV resource, on which the shader performs
2226
* atomic ops. \since 1.6 */
2227
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_ATOMICS = 0x00000008,
2228
/** The descriptor is a raw (byte-addressed) buffer. \since 1.9 */
2229
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER = 0x00000010,
2230
2231
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_INFO_FLAG),
2232
};
2233
2234
/**
2235
* Describes a single shader descriptor; returned as part of
2236
* struct vkd3d_shader_scan_descriptor_info.
2237
*/
2238
struct vkd3d_shader_descriptor_info
2239
{
2240
/** Type of the descriptor (for example, SRV, CBV, UAV, or sampler). */
2241
enum vkd3d_shader_descriptor_type type;
2242
/**
2243
* Register space of the resource, or 0 if the shader does not
2244
* support multiple register spaces.
2245
*/
2246
unsigned int register_space;
2247
/** Register index of the descriptor. */
2248
unsigned int register_index;
2249
/** Resource type, if applicable, including its dimension. */
2250
enum vkd3d_shader_resource_type resource_type;
2251
/** Data type contained in the resource (for example, float or integer). */
2252
enum vkd3d_shader_resource_data_type resource_data_type;
2253
/**
2254
* Bitwise combination of zero or more members of
2255
* \ref vkd3d_shader_descriptor_info_flag.
2256
*/
2257
unsigned int flags;
2258
/**
2259
* Size of this descriptor array, or 1 if a single descriptor.
2260
* For an unbounded array this value is ~0u.
2261
*/
2262
unsigned int count;
2263
};
2264
2265
/**
2266
* A chained structure enumerating the descriptors declared by a shader.
2267
*
2268
* This structure extends vkd3d_shader_compile_info.
2269
*
2270
* When scanning a legacy Direct3D shader, vkd3d-shader enumerates descriptors
2271
* as follows:
2272
*
2273
* - Each constant register set used by the shader is scanned as a single
2274
* constant buffer descriptor.
2275
* There may therefore be up to three such descriptors, one for each register
2276
* set used by the shader: float, integer, and boolean.
2277
* The fields are set as follows:
2278
* * The \ref vkd3d_shader_descriptor_info.type field is set to
2279
* VKD3D_SHADER_DESCRIPTOR_TYPE_CBV.
2280
* * The \ref vkd3d_shader_descriptor_info.register_space field is set to zero.
2281
* * The \ref vkd3d_shader_descriptor_info.register_index field is set to a
2282
* member of enum vkd3d_shader_d3dbc_constant_register denoting which set
2283
* is used.
2284
* * The \ref vkd3d_shader_descriptor_info.count field is set to one.
2285
* - Each sampler used by the shader is scanned as two separate descriptors,
2286
* one representing the texture, and one representing the sampler state.
2287
* If desired, these may be mapped back into a single combined sampler using
2288
* struct vkd3d_shader_combined_resource_sampler.
2289
* The fields are set as follows:
2290
* * The \ref vkd3d_shader_descriptor_info.type field is set to
2291
* VKD3D_SHADER_DESCRIPTOR_TYPE_SRV and VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER
2292
* respectively.
2293
* * The \ref vkd3d_shader_descriptor_info.register_space field is set to zero.
2294
* * The \ref vkd3d_shader_descriptor_info.register_index field is set to the
2295
* binding index of the original sampler, for both descriptors.
2296
* * The \ref vkd3d_shader_descriptor_info.count field is set to one.
2297
*/
2298
struct vkd3d_shader_scan_descriptor_info
2299
{
2300
/**
2301
* Input; must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO.
2302
*/
2303
enum vkd3d_shader_structure_type type;
2304
/** Input; optional pointer to a structure containing further parameters. */
2305
const void *next;
2306
2307
/** Output; returns a pointer to an array of descriptors. */
2308
struct vkd3d_shader_descriptor_info *descriptors;
2309
/** Output; size, in elements, of \ref descriptors. */
2310
unsigned int descriptor_count;
2311
};
2312
2313
/**
2314
* This structure describes a single resource-sampler pair. It is returned as
2315
* part of struct vkd3d_shader_scan_combined_resource_sampler_info.
2316
*
2317
* \since 1.10
2318
*/
2319
struct vkd3d_shader_combined_resource_sampler_info
2320
{
2321
unsigned int resource_space;
2322
unsigned int resource_index;
2323
unsigned int sampler_space;
2324
unsigned int sampler_index;
2325
};
2326
2327
/**
2328
* A chained structure describing the resource-sampler pairs used by a shader.
2329
*
2330
* This structure extends vkd3d_shader_compile_info.
2331
*
2332
* The information returned in this structure can be used to populate the
2333
* \ref vkd3d_shader_interface_info.combined_samplers field. This is
2334
* particularly useful when targeting environments without separate binding
2335
* points for samplers and resources, like OpenGL.
2336
*
2337
* No resource-sampler pairs are returned for dynamic accesses to
2338
* resource/sampler descriptor arrays, as can occur in Direct3D shader model
2339
* 5.1 shaders.
2340
*
2341
* Members of this structure are allocated by vkd3d-shader and should be freed
2342
* with vkd3d_shader_free_scan_combined_resource_sampler_info() when no longer
2343
* needed.
2344
*
2345
* \since 1.10
2346
*/
2347
struct vkd3d_shader_scan_combined_resource_sampler_info
2348
{
2349
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO. */
2350
enum vkd3d_shader_structure_type type;
2351
/** Optional pointer to a structure containing further parameters. */
2352
const void *next;
2353
2354
/** Pointer to an array of resource-sampler pairs. */
2355
struct vkd3d_shader_combined_resource_sampler_info *combined_samplers;
2356
/** The number of resource-sampler pairs in \ref combined_samplers. */
2357
unsigned int combined_sampler_count;
2358
};
2359
2360
/**
2361
* A chained structure describing the tessellation information in a hull shader.
2362
*
2363
* This structure extends vkd3d_shader_compile_info.
2364
*
2365
* \since 1.15
2366
*/
2367
struct vkd3d_shader_scan_hull_shader_tessellation_info
2368
{
2369
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_HULL_SHADER_TESSELLATION_INFO. */
2370
enum vkd3d_shader_structure_type type;
2371
/** Optional pointer to a structure containing further parameters. */
2372
const void *next;
2373
2374
/** The tessellation output primitive. */
2375
enum vkd3d_shader_tessellator_output_primitive output_primitive;
2376
/** The tessellation partitioning mode. */
2377
enum vkd3d_shader_tessellator_partitioning partitioning;
2378
};
2379
2380
/**
2381
* A chained structure describing the thread group size in a compute shader.
2382
*
2383
* This structure extends vkd3d_shader_compile_info.
2384
*
2385
* \since 1.18
2386
*/
2387
struct vkd3d_shader_scan_thread_group_size_info
2388
{
2389
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_THREAD_GROUP_SIZE_INFO. */
2390
enum vkd3d_shader_structure_type type;
2391
/** Optional pointer to a structure containing further parameters. */
2392
const void *next;
2393
2394
/** The thread group size in the x/y/z direction. */
2395
unsigned int x, y, z;
2396
};
2397
2398
/**
2399
* A chained structure containing legacy Direct3D bytecode compilation parameters.
2400
* This structure specifies some information about the source environment that
2401
* is not specified in the source shader format, but may be necessary for the
2402
* target format.
2403
*
2404
* This structure is optional.
2405
*
2406
* This structure extends vkd3d_shader_compile_info.
2407
*
2408
* This structure contains only input parameters.
2409
*
2410
* \since 1.18
2411
*/
2412
struct vkd3d_shader_d3dbc_source_info
2413
{
2414
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_D3DBC_SOURCE_INFO. */
2415
enum vkd3d_shader_structure_type type;
2416
/** Optional pointer to a structure containing further parameters. */
2417
const void *next;
2418
2419
/**
2420
* The dimension of each texture bound to the shader.
2421
*
2422
* If this structure is not specified, the dimension for all textures will
2423
* be VKD3D_SHADER_RESOURCE_TEXTURE_2D.
2424
*
2425
* The dimension of textures in this array not used by the shader will be
2426
* ignored.
2427
*
2428
* This field is ignored for shader models 2 and higher.
2429
*/
2430
enum vkd3d_shader_resource_type texture_dimensions[6];
2431
2432
/**
2433
* A mask indicating which samplers should be shadow (i.e. comparison-mode)
2434
* samplers. When legacy Direct3D shaders are used with the Direct3D 8 and 9
2435
* APIs, this is implied by the format of the sampled resource; e.g. a
2436
* D3DFMT_D24S8 texture implies shadow sampling, while a D3DFMT_A8R8G8B8
2437
* or D3DFMT_INTZ texture does not.
2438
* This information is necessary when converting to other formats
2439
* (e.g. SPIR-V, GLSL) which specify this in the shader.
2440
*
2441
* For example, if bit 1 is set (so the value is 0x2), this indicates that
2442
* the sampler at bind point 1 (and no others) should be a shadow sampler.
2443
*
2444
* Bits in this mask corresponding to textures not used by the shader will
2445
* be ignored.
2446
*
2447
* If this structure is not specified, no samplers will be considered to
2448
* be shadow samplers.
2449
*/
2450
uint32_t shadow_samplers;
2451
};
2452
2453
/**
2454
* Data type of a shader varying, returned as part of struct
2455
* vkd3d_shader_signature_element.
2456
*/
2457
enum vkd3d_shader_component_type
2458
{
2459
/** The varying has no type. */
2460
VKD3D_SHADER_COMPONENT_VOID = 0x0,
2461
/** 32-bit unsigned integer. */
2462
VKD3D_SHADER_COMPONENT_UINT = 0x1,
2463
/** 32-bit signed integer. */
2464
VKD3D_SHADER_COMPONENT_INT = 0x2,
2465
/** 32-bit IEEE floating-point. */
2466
VKD3D_SHADER_COMPONENT_FLOAT = 0x3,
2467
/** Boolean. */
2468
VKD3D_SHADER_COMPONENT_BOOL = 0x4,
2469
/** 64-bit IEEE floating-point. */
2470
VKD3D_SHADER_COMPONENT_DOUBLE = 0x5,
2471
/** 64-bit unsigned integer. \since 1.11 */
2472
VKD3D_SHADER_COMPONENT_UINT64 = 0x6,
2473
/** 64-bit signed integer. \since 1.16 */
2474
VKD3D_SHADER_COMPONENT_INT64 = 0x7,
2475
/** 16-bit IEEE floating-point. \since 1.16 */
2476
VKD3D_SHADER_COMPONENT_FLOAT16 = 0x8,
2477
/** 16-bit unsigned integer. \since 1.16 */
2478
VKD3D_SHADER_COMPONENT_UINT16 = 0x9,
2479
/** 16-bit signed integer. \since 1.16 */
2480
VKD3D_SHADER_COMPONENT_INT16 = 0xa,
2481
2482
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPONENT_TYPE),
2483
};
2484
2485
/** System value semantic, returned as part of struct vkd3d_shader_signature. */
2486
enum vkd3d_shader_sysval_semantic
2487
{
2488
/** No system value. */
2489
VKD3D_SHADER_SV_NONE = 0x00,
2490
/** Vertex position; SV_Position in Direct3D. */
2491
VKD3D_SHADER_SV_POSITION = 0x01,
2492
/** Clip distance; SV_ClipDistance in Direct3D. */
2493
VKD3D_SHADER_SV_CLIP_DISTANCE = 0x02,
2494
/** Cull distance; SV_CullDistance in Direct3D. */
2495
VKD3D_SHADER_SV_CULL_DISTANCE = 0x03,
2496
/** Render target layer; SV_RenderTargetArrayIndex in Direct3D. */
2497
VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX = 0x04,
2498
/** Viewport index; SV_ViewportArrayIndex in Direct3D. */
2499
VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX = 0x05,
2500
/** Vertex ID; SV_VertexID in Direct3D. */
2501
VKD3D_SHADER_SV_VERTEX_ID = 0x06,
2502
/** Primitive ID; SV_PrimitiveID in Direct3D. */
2503
VKD3D_SHADER_SV_PRIMITIVE_ID = 0x07,
2504
/** Instance ID; SV_InstanceID in Direct3D. */
2505
VKD3D_SHADER_SV_INSTANCE_ID = 0x08,
2506
/** Whether the triangle is front-facing; SV_IsFrontFace in Direct3D. */
2507
VKD3D_SHADER_SV_IS_FRONT_FACE = 0x09,
2508
/** Sample index; SV_SampleIndex in Direct3D. */
2509
VKD3D_SHADER_SV_SAMPLE_INDEX = 0x0a,
2510
VKD3D_SHADER_SV_TESS_FACTOR_QUADEDGE = 0x0b,
2511
VKD3D_SHADER_SV_TESS_FACTOR_QUADINT = 0x0c,
2512
VKD3D_SHADER_SV_TESS_FACTOR_TRIEDGE = 0x0d,
2513
VKD3D_SHADER_SV_TESS_FACTOR_TRIINT = 0x0e,
2514
VKD3D_SHADER_SV_TESS_FACTOR_LINEDET = 0x0f,
2515
VKD3D_SHADER_SV_TESS_FACTOR_LINEDEN = 0x10,
2516
/** Render target; SV_Target in Direct3D. \since 1.9 */
2517
VKD3D_SHADER_SV_TARGET = 0x40,
2518
/** Depth; SV_Depth in Direct3D. \since 1.9 */
2519
VKD3D_SHADER_SV_DEPTH = 0x41,
2520
/** Sample mask; SV_Coverage in Direct3D. \since 1.9 */
2521
VKD3D_SHADER_SV_COVERAGE = 0x42,
2522
/**
2523
* Depth, which is guaranteed to be greater than or equal to the current
2524
* depth; SV_DepthGreaterEqual in Direct3D. \since 1.9
2525
*/
2526
VKD3D_SHADER_SV_DEPTH_GREATER_EQUAL = 0x43,
2527
/**
2528
* Depth, which is guaranteed to be less than or equal to the current
2529
* depth; SV_DepthLessEqual in Direct3D. \since 1.9
2530
*/
2531
VKD3D_SHADER_SV_DEPTH_LESS_EQUAL = 0x44,
2532
/** Stencil reference; SV_StencilRef in Direct3D. \since 1.9 */
2533
VKD3D_SHADER_SV_STENCIL_REF = 0x45,
2534
2535
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SYSVAL_SEMANTIC),
2536
};
2537
2538
/**
2539
* Minimum interpolation precision of a shader varying, returned as part of
2540
* struct vkd3d_shader_signature_element.
2541
*/
2542
enum vkd3d_shader_minimum_precision
2543
{
2544
VKD3D_SHADER_MINIMUM_PRECISION_NONE = 0,
2545
/** 16-bit floating-point. */
2546
VKD3D_SHADER_MINIMUM_PRECISION_FLOAT_16 = 1,
2547
/** 10-bit fixed point (2 integer and 8 fractional bits). */
2548
VKD3D_SHADER_MINIMUM_PRECISION_FIXED_8_2 = 2,
2549
/** 16-bit signed integer. */
2550
VKD3D_SHADER_MINIMUM_PRECISION_INT_16 = 4,
2551
/** 16-bit unsigned integer. */
2552
VKD3D_SHADER_MINIMUM_PRECISION_UINT_16 = 5,
2553
2554
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_MINIMUM_PRECISION),
2555
};
2556
2557
/**
2558
* A single shader varying, returned as part of struct vkd3d_shader_signature.
2559
*/
2560
struct vkd3d_shader_signature_element
2561
{
2562
/** Semantic name. */
2563
const char *semantic_name;
2564
/** Semantic index, or 0 if the semantic is not indexed. */
2565
unsigned int semantic_index;
2566
/**
2567
* Stream index of a geometry shader output semantic. If the signature is
2568
* not a geometry shader output signature, this field will be set to 0.
2569
*/
2570
unsigned int stream_index;
2571
/**
2572
* System value semantic. If the varying is not a system value, this field
2573
* will be set to VKD3D_SHADER_SV_NONE.
2574
*/
2575
enum vkd3d_shader_sysval_semantic sysval_semantic;
2576
/** Data type. */
2577
enum vkd3d_shader_component_type component_type;
2578
/** Register index. */
2579
unsigned int register_index;
2580
/** Mask of the register components allocated to this varying. */
2581
unsigned int mask;
2582
/**
2583
* Subset of \ref mask which the shader reads from or writes to. Unlike
2584
* Direct3D shader bytecode, the mask for output and tessellation signatures
2585
* is not inverted, i.e. bits set in this field denote components which are
2586
* written to.
2587
*/
2588
unsigned int used_mask;
2589
/** Minimum interpolation precision. */
2590
enum vkd3d_shader_minimum_precision min_precision;
2591
};
2592
2593
/**
2594
* Description of a shader input or output signature. This structure is
2595
* populated by vkd3d_shader_parse_input_signature().
2596
*
2597
* The helper function vkd3d_shader_find_signature_element() will look up a
2598
* varying element by its semantic name, semantic index, and stream index.
2599
*/
2600
struct vkd3d_shader_signature
2601
{
2602
/** Pointer to an array of varyings. */
2603
struct vkd3d_shader_signature_element *elements;
2604
/** Size, in elements, of \ref elements. */
2605
unsigned int element_count;
2606
};
2607
2608
/** Possible values for a single component of a vkd3d-shader swizzle. */
2609
enum vkd3d_shader_swizzle_component
2610
{
2611
VKD3D_SHADER_SWIZZLE_X = 0x0,
2612
VKD3D_SHADER_SWIZZLE_Y = 0x1,
2613
VKD3D_SHADER_SWIZZLE_Z = 0x2,
2614
VKD3D_SHADER_SWIZZLE_W = 0x3,
2615
2616
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SWIZZLE_COMPONENT),
2617
};
2618
2619
/**
2620
* A description of a DXBC section.
2621
*
2622
* \since 1.7
2623
*/
2624
struct vkd3d_shader_dxbc_section_desc
2625
{
2626
/** The section tag. */
2627
uint32_t tag;
2628
/** The contents of the section. */
2629
struct vkd3d_shader_code data;
2630
};
2631
2632
/**
2633
* A description of a DXBC blob, as returned by vkd3d_shader_parse_dxbc().
2634
*
2635
* \since 1.7
2636
*/
2637
struct vkd3d_shader_dxbc_desc
2638
{
2639
/**
2640
* The DXBC tag. This will always be "DXBC" in structures returned by
2641
* this version of vkd3d-shader.
2642
*/
2643
uint32_t tag;
2644
/** A checksum of the DXBC contents. */
2645
uint32_t checksum[4];
2646
/**
2647
* The DXBC version. This will always be 1 in structures returned by this
2648
* version of vkd3d-shader.
2649
*/
2650
unsigned int version;
2651
/** The total size of the DXBC blob. */
2652
size_t size;
2653
/** The number of sections contained in the DXBC. */
2654
size_t section_count;
2655
/** Descriptions of the sections contained in the DXBC. */
2656
struct vkd3d_shader_dxbc_section_desc *sections;
2657
};
2658
2659
/**
2660
* A mask selecting one component from a vkd3d-shader swizzle. The component has
2661
* type \ref vkd3d_shader_swizzle_component.
2662
*/
2663
#define VKD3D_SHADER_SWIZZLE_MASK (0xffu)
2664
/** The offset, in bits, of the nth parameter of a vkd3d-shader swizzle. */
2665
#define VKD3D_SHADER_SWIZZLE_SHIFT(idx) (8u * (idx))
2666
2667
/**
2668
* A helper macro which returns a vkd3d-shader swizzle with the given
2669
* components. The components are specified as the suffixes to members of
2670
* \ref vkd3d_shader_swizzle_component. For example, the swizzle ".xwyy" can be
2671
* represented as:
2672
* \code
2673
* VKD3D_SHADER_SWIZZLE(X, W, Y, Y)
2674
* \endcode
2675
*/
2676
#define VKD3D_SHADER_SWIZZLE(x, y, z, w) \
2677
(VKD3D_SHADER_SWIZZLE_ ## x << VKD3D_SHADER_SWIZZLE_SHIFT(0) \
2678
| VKD3D_SHADER_SWIZZLE_ ## y << VKD3D_SHADER_SWIZZLE_SHIFT(1) \
2679
| VKD3D_SHADER_SWIZZLE_ ## z << VKD3D_SHADER_SWIZZLE_SHIFT(2) \
2680
| VKD3D_SHADER_SWIZZLE_ ## w << VKD3D_SHADER_SWIZZLE_SHIFT(3))
2681
2682
/** The identity swizzle ".xyzw". */
2683
#define VKD3D_SHADER_NO_SWIZZLE VKD3D_SHADER_SWIZZLE(X, Y, Z, W)
2684
2685
/** Build a vkd3d-shader swizzle with the given components. */
2686
static inline uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_component x,
2687
enum vkd3d_shader_swizzle_component y, enum vkd3d_shader_swizzle_component z,
2688
enum vkd3d_shader_swizzle_component w)
2689
{
2690
return ((x & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(0))
2691
| ((y & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(1))
2692
| ((z & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(2))
2693
| ((w & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(3));
2694
}
2695
2696
/**
2697
* A chained structure containing descriptions of shader inputs and outputs.
2698
*
2699
* This structure is currently implemented only for DXBC and legacy D3D bytecode
2700
* source types.
2701
* For DXBC shaders, the returned information is parsed directly from the
2702
* signatures embedded in the DXBC shader.
2703
* For legacy D3D shaders, the returned information is synthesized based on
2704
* registers declared or used by shader instructions.
2705
* For all other shader types, the structure is zeroed.
2706
*
2707
* All members (except for \ref type and \ref next) are output-only.
2708
*
2709
* This structure is passed to vkd3d_shader_scan() and extends
2710
* vkd3d_shader_compile_info.
2711
*
2712
* Members of this structure are allocated by vkd3d-shader and should be freed
2713
* with vkd3d_shader_free_scan_signature_info() when no longer needed.
2714
*
2715
* All signatures may contain pointers into the input shader, and should only
2716
* be accessed while the input shader remains valid.
2717
*
2718
* Signature elements are synthesized from legacy Direct3D bytecode as follows:
2719
* - The \ref vkd3d_shader_signature_element.semantic_name field is set to an
2720
* uppercase string corresponding to the HLSL name for the usage, e.g.
2721
* "POSITION", "BLENDWEIGHT", "COLOR", "PSIZE", etc.
2722
* - The \ref vkd3d_shader_signature_element.semantic_index field is set to the
2723
* usage index.
2724
* - The \ref vkd3d_shader_signature_element.stream_index is always 0.
2725
*
2726
* Signature elements are synthesized for any input or output register declared
2727
* or used in a legacy Direct3D bytecode shader, including the following:
2728
* - Shader model 1 and 2 colour and texture coordinate registers.
2729
* - The shader model 1 pixel shader output register.
2730
* - Shader model 1 and 2 vertex shader output registers (position, fog, and
2731
* point size).
2732
* - Shader model 3 pixel shader system value input registers (pixel position
2733
* and face).
2734
*
2735
* \since 1.9
2736
*/
2737
struct vkd3d_shader_scan_signature_info
2738
{
2739
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_SIGNATURE_INFO. */
2740
enum vkd3d_shader_structure_type type;
2741
/** Optional pointer to a structure containing further parameters. */
2742
const void *next;
2743
2744
/** The shader input varyings. */
2745
struct vkd3d_shader_signature input;
2746
2747
/** The shader output varyings. */
2748
struct vkd3d_shader_signature output;
2749
2750
/** The shader patch constant varyings. */
2751
struct vkd3d_shader_signature patch_constant;
2752
};
2753
2754
/**
2755
* Describes the mapping of a output varying register in a shader stage,
2756
* to an input varying register in the following shader stage.
2757
*
2758
* This structure is used in struct vkd3d_shader_varying_map_info.
2759
*/
2760
struct vkd3d_shader_varying_map
2761
{
2762
/**
2763
* The signature index (in the output signature) of the output varying.
2764
* If greater than or equal to the number of elements in the output
2765
* signature, signifies that the varying is consumed by the next stage but
2766
* not written by this one.
2767
*/
2768
unsigned int output_signature_index;
2769
/** The register index of the input varying to map this register to. */
2770
unsigned int input_register_index;
2771
/** The mask consumed by the destination register. */
2772
unsigned int input_mask;
2773
};
2774
2775
/**
2776
* A chained structure which describes how output varyings in this shader stage
2777
* should be mapped to input varyings in the next stage.
2778
*
2779
* This structure is optional. It should not be provided if there is no shader
2780
* stage.
2781
* However, depending on the input and output formats, this structure may be
2782
* necessary in order to generate shaders which correctly match each other.
2783
*
2784
* If this structure is absent, vkd3d-shader will map varyings from one stage
2785
* to another based on their register index.
2786
* For Direct3D shader model 3.0, such a default mapping will be incorrect
2787
* unless the registers are allocated in the same order, and hence this
2788
* field is necessary to correctly match inter-stage varyings.
2789
* This mapping may also be necessary under other circumstances where the
2790
* varying interface does not match exactly.
2791
*
2792
* This structure is passed to vkd3d_shader_compile() and extends
2793
* vkd3d_shader_compile_info.
2794
*
2795
* This structure contains only input parameters.
2796
*
2797
* \since 1.9
2798
*/
2799
struct vkd3d_shader_varying_map_info
2800
{
2801
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_VARYING_MAP_INFO. */
2802
enum vkd3d_shader_structure_type type;
2803
/** Optional pointer to a structure containing further parameters. */
2804
const void *next;
2805
2806
/**
2807
* A mapping of output varyings in this shader stage to input varyings
2808
* in the next shader stage.
2809
*
2810
* This mapping should include exactly one element for each varying
2811
* consumed by the next shader stage.
2812
* If this shader stage outputs a varying that is not consumed by the next
2813
* shader stage, that varying should be absent from this array.
2814
*
2815
* This mapping may be constructed by vkd3d_shader_build_varying_map().
2816
*/
2817
const struct vkd3d_shader_varying_map *varying_map;
2818
/** The number of registers provided in \ref varying_map. */
2819
unsigned int varying_count;
2820
};
2821
2822
/**
2823
* Interface information regarding a builtin shader parameter.
2824
*
2825
* Like compile options specified with struct vkd3d_shader_compile_option,
2826
* parameters are used to specify certain values which are not part of the
2827
* source shader bytecode but which need to be specified in the shader bytecode
2828
* in the target format.
2829
* Unlike struct vkd3d_shader_compile_option, however, this structure allows
2830
* parameters to be specified in a variety of different ways, as described by
2831
* enum vkd3d_shader_parameter_type.
2832
*
2833
* This structure is an extended version of struct vkd3d_shader_parameter as
2834
* used in struct vkd3d_shader_spirv_target_info, which allows more parameter
2835
* types to be used, and also allows specifying parameters when compiling
2836
* shaders to target types other than SPIR-V. If this structure is chained
2837
* along with vkd3d_shader_spirv_target_info, any parameters specified in the
2838
* latter structure are ignored.
2839
*
2840
* This structure is passed to vkd3d_shader_compile() and extends
2841
* vkd3d_shader_compile_info.
2842
*
2843
* This structure contains only input parameters.
2844
*
2845
* \since 1.13
2846
*/
2847
struct vkd3d_shader_parameter_info
2848
{
2849
/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_PARAMETER_INFO. */
2850
enum vkd3d_shader_structure_type type;
2851
/** Optional pointer to a structure containing further parameters. */
2852
const void *next;
2853
2854
/** Pointer to an array of dynamic parameters for this shader instance. */
2855
const struct vkd3d_shader_parameter1 *parameters;
2856
/** Size, in elements, of \ref parameters. */
2857
unsigned int parameter_count;
2858
};
2859
2860
#ifdef LIBVKD3D_SHADER_SOURCE
2861
# define VKD3D_SHADER_API VKD3D_EXPORT
2862
#else
2863
# define VKD3D_SHADER_API VKD3D_IMPORT
2864
#endif
2865
2866
#ifndef VKD3D_SHADER_NO_PROTOTYPES
2867
2868
/**
2869
* Returns the current version of this library.
2870
*
2871
* \param major Output location for the major version of this library.
2872
*
2873
* \param minor Output location for the minor version of this library.
2874
*
2875
* \return A human-readable string describing the library name and version. This
2876
* string is null-terminated and UTF-8 encoded. This may be a pointer to static
2877
* data in libvkd3d-shader; it should not be freed.
2878
*/
2879
VKD3D_SHADER_API const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor);
2880
/**
2881
* Returns the source types supported, with any target type, by
2882
* vkd3d_shader_compile(). Future versions of the library may introduce
2883
* additional source types; callers should ignore unrecognised source types.
2884
*
2885
* Use vkd3d_shader_get_supported_target_types() to determine which target types
2886
* are supported for each source type.
2887
*
2888
* \param count Output location for the size, in elements, of the returned
2889
* array.
2890
*
2891
* \return Pointer to an array of source types supported by this version of
2892
* vkd3d-shader. This array may be a pointer to static data in libvkd3d-shader;
2893
* it should not be freed.
2894
*/
2895
VKD3D_SHADER_API const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(unsigned int *count);
2896
/**
2897
* Returns the target types supported, with the given source type, by
2898
* vkd3d_shader_compile(). Future versions of the library may introduce
2899
* additional target types; callers should ignore unrecognised target types.
2900
*
2901
* \param source_type Source type for which to enumerate supported target types.
2902
*
2903
* \param count Output location for the size, in elements, of the returned
2904
* array.
2905
*
2906
* \return Pointer to an array of target types supported by this version of
2907
* vkd3d-shader. This array may be a pointer to static data in libvkd3d-shader;
2908
* it should not be freed.
2909
*/
2910
VKD3D_SHADER_API const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types(
2911
enum vkd3d_shader_source_type source_type, unsigned int *count);
2912
2913
/**
2914
* Transform a form of GPU shader source code or byte code into another form of
2915
* source code or byte code.
2916
*
2917
* This version of vkd3d-shader supports the following transformations:
2918
* - VKD3D_SHADER_SOURCE_DXBC_DXIL to VKD3D_SHADER_TARGET_SPIRV_BINARY
2919
* - VKD3D_SHADER_SOURCE_DXBC_DXIL to VKD3D_SHADER_TARGET_SPIRV_TEXT
2920
* (if vkd3d was compiled with SPIRV-Tools)
2921
* - VKD3D_SHADER_SOURCE_DXBC_DXIL to VKD3D_SHADER_TARGET_D3D_ASM
2922
* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_SPIRV_BINARY
2923
* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_SPIRV_TEXT
2924
* (if vkd3d was compiled with SPIRV-Tools)
2925
* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_D3D_ASM
2926
* - VKD3D_SHADER_SOURCE_D3D_BYTECODE to VKD3D_SHADER_TARGET_SPIRV_BINARY
2927
* - VKD3D_SHADER_SOURCE_D3D_BYTECODE to VKD3D_SHADER_TARGET_SPIRV_TEXT
2928
* (if vkd3d was compiled with SPIRV-Tools)
2929
* - VKD3D_SHADER_SOURCE_D3D_BYTECODE to VKD3D_SHADER_TARGET_D3D_ASM
2930
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_SPIRV_BINARY
2931
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_SPIRV_TEXT
2932
* (if vkd3d was compiled with SPIRV-Tools)
2933
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_D3D_ASM
2934
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_D3D_BYTECODE
2935
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_DXBC_TPF
2936
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_FX
2937
* - VKD3D_SHADER_SOURCE_FX to VKD3D_SHADER_TARGET_D3D_ASM
2938
* - VKD3D_SHADER_SOURCE_TX to VKD3D_SHADER_TARGET_D3D_ASM
2939
*
2940
* Supported transformations can also be detected at runtime with the functions
2941
* vkd3d_shader_get_supported_source_types() and
2942
* vkd3d_shader_get_supported_target_types().
2943
*
2944
* Depending on the source and target types, this function may support the
2945
* following chained structures:
2946
* - vkd3d_shader_d3dbc_source_info
2947
* - vkd3d_shader_descriptor_offset_info
2948
* - vkd3d_shader_hlsl_source_info
2949
* - vkd3d_shader_interface_info
2950
* - vkd3d_shader_parameter_info
2951
* - vkd3d_shader_preprocess_info
2952
* - vkd3d_shader_scan_combined_resource_sampler_info
2953
* - vkd3d_shader_scan_descriptor_info
2954
* - vkd3d_shader_scan_hull_shader_tessellation_info
2955
* - vkd3d_shader_scan_signature_info
2956
* - vkd3d_shader_scan_thread_group_size_info
2957
* - vkd3d_shader_spirv_domain_shader_target_info
2958
* - vkd3d_shader_spirv_target_info
2959
* - vkd3d_shader_transform_feedback_info
2960
* - vkd3d_shader_varying_map_info
2961
*
2962
* \param compile_info A chained structure containing compilation parameters.
2963
*
2964
* \param out A pointer to a vkd3d_shader_code structure in which the compiled
2965
* code will be stored.
2966
* \n
2967
* The compiled shader is allocated by vkd3d-shader and should be freed with
2968
* vkd3d_shader_free_shader_code() when no longer needed.
2969
*
2970
* \param messages Optional output location for error or informational messages
2971
* produced by the compiler.
2972
* \n
2973
* This string is null-terminated and UTF-8 encoded.
2974
* \n
2975
* The messages are allocated by vkd3d-shader and should be freed with
2976
* vkd3d_shader_free_messages() when no longer needed.
2977
* \n
2978
* The messages returned can be regulated with the \a log_level member of struct
2979
* vkd3d_shader_compile_info. Regardless of the requested level, if this
2980
* parameter is NULL, no compilation messages will be returned.
2981
* \n
2982
* If no messages are produced by the compiler, this parameter may
2983
* receive NULL instead of a valid string pointer.
2984
*
2985
* \return A member of \ref vkd3d_result.
2986
*/
2987
VKD3D_SHADER_API int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
2988
struct vkd3d_shader_code *out, char **messages);
2989
/**
2990
* Free shader messages allocated by another vkd3d-shader function, such as
2991
* vkd3d_shader_compile().
2992
*
2993
* \param messages Messages to free. This pointer is optional and may be NULL,
2994
* in which case no action will be taken.
2995
*/
2996
VKD3D_SHADER_API void vkd3d_shader_free_messages(char *messages);
2997
/**
2998
* Free shader code allocated by another vkd3d-shader function, such as
2999
* vkd3d_shader_compile().
3000
*
3001
* This function frees the \ref vkd3d_shader_code.code member, but does not free
3002
* the structure itself.
3003
*
3004
* \param code Code to free.
3005
*/
3006
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
3007
3008
/**
3009
* Convert a byte code description of a shader root signature to a structural
3010
* description which can be easily parsed by C code.
3011
*
3012
* This function corresponds to
3013
* ID3D12VersionedRootSignatureDeserializer::GetUnconvertedRootSignatureDesc().
3014
*
3015
* This function performs the reverse transformation of
3016
* vkd3d_shader_serialize_root_signature().
3017
*
3018
* This function parses a standalone root signature, and should not be confused
3019
* with vkd3d_shader_parse_input_signature().
3020
*
3021
* \param dxbc Compiled byte code, in DXBC format.
3022
*
3023
* \param root_signature Output location in which the decompiled root signature
3024
* will be stored.
3025
* \n
3026
* Members of \a root_signature may be allocated by vkd3d-shader. The signature
3027
* should be freed with vkd3d_shader_free_root_signature() when no longer
3028
* needed.
3029
*
3030
* \param messages Optional output location for error or informational messages
3031
* produced by the parser.
3032
* \n
3033
* This string is null-terminated and UTF-8 encoded.
3034
* \n
3035
* The messages are allocated by vkd3d-shader and should be freed with
3036
* vkd3d_shader_free_messages() when no longer needed.
3037
* \n
3038
* If no messages are produced by the parser, this parameter may
3039
* receive NULL instead of a valid string pointer.
3040
*
3041
* \return A member of \ref vkd3d_result.
3042
*/
3043
VKD3D_SHADER_API int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
3044
struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages);
3045
/**
3046
* Free a structural representation of a shader root signature allocated by
3047
* vkd3d_shader_convert_root_signature() or vkd3d_shader_parse_root_signature().
3048
*
3049
* This function may free members of struct
3050
* vkd3d_shader_versioned_root_signature_desc, but does not free the structure
3051
* itself.
3052
*
3053
* \param root_signature Signature description to free.
3054
*/
3055
VKD3D_SHADER_API void vkd3d_shader_free_root_signature(
3056
struct vkd3d_shader_versioned_root_signature_desc *root_signature);
3057
3058
/**
3059
* Convert a structural description of a shader root signature to a byte code
3060
* format capable of being read by ID3D12Device::CreateRootSignature. The
3061
* compiled signature is compatible with Microsoft D3D 12.
3062
*
3063
* This function corresponds to D3D12SerializeVersionedRootSignature().
3064
*
3065
* \param root_signature Description of the root signature.
3066
*
3067
* \param dxbc A pointer to a vkd3d_shader_code structure in which the compiled
3068
* code will be stored.
3069
* \n
3070
* The compiled signature is allocated by vkd3d-shader and should be freed with
3071
* vkd3d_shader_free_shader_code() when no longer needed.
3072
*
3073
* \param messages Optional output location for error or informational messages
3074
* produced by the serializer.
3075
* \n
3076
* This string is null-terminated and UTF-8 encoded.
3077
* \n
3078
* The messages are allocated by vkd3d-shader and should be freed with
3079
* vkd3d_shader_free_messages() when no longer needed.
3080
* \n
3081
* If no messages are produced by the serializer, this parameter may
3082
* receive NULL instead of a valid string pointer.
3083
*
3084
* \return A member of \ref vkd3d_result.
3085
*/
3086
VKD3D_SHADER_API int vkd3d_shader_serialize_root_signature(
3087
const struct vkd3d_shader_versioned_root_signature_desc *root_signature,
3088
struct vkd3d_shader_code *dxbc, char **messages);
3089
/**
3090
* Convert a structural representation of a root signature to a different
3091
* version of structural representation.
3092
*
3093
* This function corresponds to
3094
* ID3D12VersionedRootSignatureDeserializer::GetRootSignatureDescAtVersion().
3095
*
3096
* \param dst A pointer to a vkd3d_shader_versioned_root_signature_desc
3097
* structure in which the converted signature will be stored.
3098
* \n
3099
* Members of \a dst may be allocated by vkd3d-shader. The signature should be
3100
* freed with vkd3d_shader_free_root_signature() when no longer needed.
3101
*
3102
* \param version The desired version to convert \a src to. This version must
3103
* not be equal to \a src->version.
3104
*
3105
* \param src Input root signature description.
3106
*
3107
* \return A member of \ref vkd3d_result.
3108
*/
3109
VKD3D_SHADER_API int vkd3d_shader_convert_root_signature(struct vkd3d_shader_versioned_root_signature_desc *dst,
3110
enum vkd3d_shader_root_signature_version version, const struct vkd3d_shader_versioned_root_signature_desc *src);
3111
3112
/**
3113
* Parse shader source code or byte code, returning various types of requested
3114
* information.
3115
*
3116
* The \a source_type member of \a compile_info must be set to the type of the
3117
* shader.
3118
*
3119
* The \a target_type member may be set to VKD3D_SHADER_TARGET_NONE, in which
3120
* case vkd3d_shader_scan() will return information about the shader in
3121
* isolation. Alternatively, it may be set to a valid compilation target for the
3122
* shader, in which case vkd3d_shader_scan() will return information that
3123
* reflects the interface for a shader as it will be compiled to that target.
3124
* In this case other chained structures may be appended to \a compile_info as
3125
* they would be passed to vkd3d_shader_compile(), and interpreted accordingly,
3126
* such as vkd3d_shader_spirv_target_info.
3127
*
3128
* (For a hypothetical example, suppose the source shader distinguishes float
3129
* and integer texture data, but the target environment does not support integer
3130
* textures. In this case vkd3d_shader_compile() might translate integer
3131
* operations to float. Accordingly using VKD3D_SHADER_TARGET_NONE would
3132
* accurately report whether the texture expects integer or float data, but
3133
* using the relevant specific target type would report
3134
* VKD3D_SHADER_RESOURCE_DATA_FLOAT.)
3135
*
3136
* Currently this function supports the following code types:
3137
* - VKD3D_SHADER_SOURCE_DXBC_DXIL
3138
* - VKD3D_SHADER_SOURCE_DXBC_TPF
3139
* - VKD3D_SHADER_SOURCE_D3D_BYTECODE
3140
* - VKD3D_SHADER_SOURCE_HLSL
3141
*
3142
* \param compile_info A chained structure containing scan parameters.
3143
* \n
3144
* The scanner supports the following chained structures:
3145
* - vkd3d_shader_d3dbc_source_info
3146
* - vkd3d_shader_descriptor_offset_info
3147
* - vkd3d_shader_hlsl_source_info
3148
* - vkd3d_shader_interface_info
3149
* - vkd3d_shader_parameter_info
3150
* - vkd3d_shader_preprocess_info
3151
* - vkd3d_shader_scan_combined_resource_sampler_info
3152
* - vkd3d_shader_scan_descriptor_info
3153
* - vkd3d_shader_scan_hull_shader_tessellation_info
3154
* - vkd3d_shader_scan_signature_info
3155
* - vkd3d_shader_scan_thread_group_size_info
3156
* - vkd3d_shader_spirv_domain_shader_target_info
3157
* - vkd3d_shader_spirv_target_info
3158
* - vkd3d_shader_transform_feedback_info
3159
* - vkd3d_shader_varying_map_info
3160
* \n
3161
* Although the \a compile_info parameter is read-only, chained structures
3162
* passed to this function need not be, and may serve as output parameters,
3163
* depending on their structure type.
3164
*
3165
* \param messages Optional output location for error or informational messages
3166
* produced by the parser.
3167
* \n
3168
* This string is null-terminated and UTF-8 encoded.
3169
* \n
3170
* The messages are allocated by vkd3d-shader and should be freed with
3171
* vkd3d_shader_free_messages() when no longer needed.
3172
* \n
3173
* The messages returned can be regulated with the \a log_level member of struct
3174
* vkd3d_shader_compile_info. Regardless of the requested level, if this
3175
* parameter is NULL, no compilation messages will be returned.
3176
* \n
3177
* If no messages are produced by the parser, this parameter may
3178
* receive NULL instead of a valid string pointer.
3179
*
3180
* \return A member of \ref vkd3d_result.
3181
*/
3182
VKD3D_SHADER_API int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages);
3183
/**
3184
* Free members of struct vkd3d_shader_scan_descriptor_info() allocated by
3185
* vkd3d_shader_scan().
3186
*
3187
* This function may free members of vkd3d_shader_scan_descriptor_info, but
3188
* does not free the structure itself.
3189
*
3190
* \param scan_descriptor_info Descriptor information to free.
3191
*/
3192
VKD3D_SHADER_API void vkd3d_shader_free_scan_descriptor_info(
3193
struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);
3194
3195
/**
3196
* Read the input signature of a compiled DXBC shader, returning a structural
3197
* description which can be easily parsed by C code.
3198
*
3199
* This function parses a compiled shader. To parse a standalone root signature,
3200
* use vkd3d_shader_parse_root_signature().
3201
*
3202
* This function only parses DXBC shaders, and only retrieves the input
3203
* signature. To retrieve signatures from other shader types, or other signature
3204
* types, use vkd3d_shader_scan() and struct vkd3d_shader_scan_signature_info.
3205
* This function returns the same input signature that is returned in
3206
* struct vkd3d_shader_scan_signature_info for dxbc-tpf shaders, but may return
3207
* different information for dxbc-dxil shaders.
3208
*
3209
* \param dxbc Compiled byte code, in DXBC format.
3210
*
3211
* \param signature Output location in which the parsed root signature will be
3212
* stored.
3213
* \n
3214
* Members of \a signature may be allocated by vkd3d-shader. The signature
3215
* should be freed with vkd3d_shader_free_shader_signature() when no longer
3216
* needed.
3217
* \n
3218
* The signature may contain pointers into the input shader, and should only be
3219
* accessed while the input shader remains valid.
3220
*
3221
* \param messages Optional output location for error or informational messages
3222
* produced by the parser.
3223
* \n
3224
* This string is null-terminated and UTF-8 encoded.
3225
* \n
3226
* The messages are allocated by vkd3d-shader and should be freed with
3227
* vkd3d_shader_free_messages() when no longer needed.
3228
* \n
3229
* If no messages are produced by the parser, this parameter may
3230
* receive NULL instead of a valid string pointer.
3231
*
3232
* \return A member of \ref vkd3d_result.
3233
*/
3234
VKD3D_SHADER_API int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
3235
struct vkd3d_shader_signature *signature, char **messages);
3236
/**
3237
* Find a single element of a parsed input signature.
3238
*
3239
* \param signature The parsed input signature. This structure is normally
3240
* populated by vkd3d_shader_parse_input_signature().
3241
*
3242
* \param semantic_name Semantic name of the desired element. This function
3243
* performs a case-insensitive comparison with respect to the ASCII plane.
3244
*
3245
* \param semantic_index Semantic index of the desired element.
3246
*
3247
* \param stream_index Geometry shader stream index of the desired element. If
3248
* the signature is not a geometry shader output signature, this parameter must
3249
* be set to 0.
3250
*
3251
* \return A description of the element matching the requested parameters, or
3252
* NULL if no such element was found. If not NULL, the return value points into
3253
* the \a signature parameter and should not be explicitly freed.
3254
*/
3255
VKD3D_SHADER_API struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
3256
const struct vkd3d_shader_signature *signature, const char *semantic_name,
3257
unsigned int semantic_index, unsigned int stream_index);
3258
/**
3259
* Free a structural representation of a shader input signature allocated by
3260
* vkd3d_shader_parse_input_signature().
3261
*
3262
* This function may free members of struct vkd3d_shader_signature, but does not
3263
* free the structure itself.
3264
*
3265
* \param signature Signature description to free.
3266
*/
3267
VKD3D_SHADER_API void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature);
3268
3269
/* 1.3 */
3270
3271
/**
3272
* Preprocess the given source code.
3273
*
3274
* This function supports the following chained structures:
3275
* - vkd3d_shader_preprocess_info
3276
*
3277
* \param compile_info A chained structure containing compilation parameters.
3278
*
3279
* \param out A pointer to a vkd3d_shader_code structure in which the
3280
* preprocessed code will be stored.
3281
* \n
3282
* The preprocessed shader is allocated by vkd3d-shader and should be freed with
3283
* vkd3d_shader_free_shader_code() when no longer needed.
3284
*
3285
* \param messages Optional output location for error or informational messages
3286
* produced by the preprocessor.
3287
* \n
3288
* This string is null-terminated and UTF-8 encoded.
3289
* \n
3290
* The messages are allocated by vkd3d-shader and should be freed with
3291
* vkd3d_shader_free_messages() when no longer needed.
3292
* \n
3293
* The messages returned can be regulated with the \a log_level member of struct
3294
* vkd3d_shader_compile_info. Regardless of the requested level, if this
3295
* parameter is NULL, no compilation messages will be returned.
3296
* \n
3297
* If no messages are produced by the preprocessor, this parameter may
3298
* receive NULL instead of a valid string pointer.
3299
*
3300
* \return A member of \ref vkd3d_result.
3301
*
3302
* \since 1.3
3303
*/
3304
VKD3D_SHADER_API int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info,
3305
struct vkd3d_shader_code *out, char **messages);
3306
3307
/**
3308
* Set a callback to be called when vkd3d-shader outputs debug logging.
3309
*
3310
* If NULL, or if this function has not been called, libvkd3d-shader will print
3311
* all enabled log output to stderr.
3312
*
3313
* \param callback Callback function to set.
3314
*
3315
* \since 1.4
3316
*/
3317
VKD3D_SHADER_API void vkd3d_shader_set_log_callback(PFN_vkd3d_log callback);
3318
3319
/**
3320
* Free the contents of a vkd3d_shader_dxbc_desc structure allocated by
3321
* another vkd3d-shader function, such as vkd3d_shader_parse_dxbc().
3322
*
3323
* This function may free the \ref vkd3d_shader_dxbc_desc.sections member, but
3324
* does not free the structure itself.
3325
*
3326
* \param dxbc The vkd3d_shader_dxbc_desc structure to free.
3327
*
3328
* \since 1.7
3329
*/
3330
VKD3D_SHADER_API void vkd3d_shader_free_dxbc(struct vkd3d_shader_dxbc_desc *dxbc);
3331
3332
/**
3333
* Parse a DXBC blob contained in a vkd3d_shader_code structure.
3334
*
3335
* \param dxbc A vkd3d_shader_code structure containing the DXBC blob to parse.
3336
*
3337
* \param flags A combination of zero or more elements of enum
3338
* vkd3d_shader_parse_dxbc_flags.
3339
*
3340
* \param desc A vkd3d_shader_dxbc_desc structure describing the contents of
3341
* the DXBC blob. Its vkd3d_shader_dxbc_section_desc structures will contain
3342
* pointers into the input blob; its contents are only valid while the input
3343
* blob is valid. The contents of this structure should be freed with
3344
* vkd3d_shader_free_dxbc() when no longer needed.
3345
*
3346
* \param messages Optional output location for error or informational messages
3347
* produced by the parser.
3348
* \n
3349
* This string is null-terminated and UTF-8 encoded.
3350
* \n
3351
* The messages are allocated by vkd3d-shader and should be freed with
3352
* vkd3d_shader_free_messages() when no longer needed.
3353
* \n
3354
* If no messages are produced by the parser, this parameter may
3355
* receive NULL instead of a valid string pointer.
3356
*
3357
* \return A member of \ref vkd3d_result.
3358
*
3359
* \since 1.7
3360
*/
3361
VKD3D_SHADER_API int vkd3d_shader_parse_dxbc(const struct vkd3d_shader_code *dxbc,
3362
uint32_t flags, struct vkd3d_shader_dxbc_desc *desc, char **messages);
3363
3364
/**
3365
* Serialize a DXBC description into a blob stored in a vkd3d_shader_code
3366
* structure.
3367
*
3368
* \param section_count The number of DXBC sections to serialize.
3369
*
3370
* \param sections An array of vkd3d_shader_dxbc_section_desc structures
3371
* to serialize.
3372
*
3373
* \param dxbc A pointer to a vkd3d_shader_code structure in which the
3374
* serialized blob will be stored.
3375
* \n
3376
* The output blob is allocated by vkd3d-shader and should be freed with
3377
* vkd3d_shader_free_shader_code() when no longer needed.
3378
*
3379
* \param messages Optional output location for error or informational messages
3380
* produced by the serializer.
3381
* \n
3382
* This string is null-terminated and UTF-8 encoded.
3383
* \n
3384
* The messages are allocated by vkd3d-shader and should be freed with
3385
* vkd3d_shader_free_messages() when no longer needed.
3386
* \n
3387
* If no messages are produced by the serializer, this parameter may
3388
* receive NULL instead of a valid string pointer.
3389
*
3390
* \return A member of \ref vkd3d_result.
3391
*
3392
* \since 1.7
3393
*/
3394
VKD3D_SHADER_API int vkd3d_shader_serialize_dxbc(size_t section_count,
3395
const struct vkd3d_shader_dxbc_section_desc *sections, struct vkd3d_shader_code *dxbc, char **messages);
3396
3397
/**
3398
* Free members of struct vkd3d_shader_scan_signature_info allocated by
3399
* vkd3d_shader_scan().
3400
*
3401
* This function may free members of vkd3d_shader_scan_signature_info, but
3402
* does not free the structure itself.
3403
*
3404
* \param info Scan information to free.
3405
*
3406
* \since 1.9
3407
*/
3408
VKD3D_SHADER_API void vkd3d_shader_free_scan_signature_info(struct vkd3d_shader_scan_signature_info *info);
3409
3410
/**
3411
* Build a mapping of output varyings in a shader stage to input varyings in
3412
* the following shader stage.
3413
*
3414
* This mapping should be used in struct vkd3d_shader_varying_map_info to
3415
* compile the first shader.
3416
*
3417
* \param output_signature The output signature of the first shader.
3418
*
3419
* \param input_signature The input signature of the second shader.
3420
*
3421
* \param count On output, contains the number of entries written into
3422
* "varyings".
3423
*
3424
* \param varyings Pointer to an output array of varyings.
3425
* This must point to space for N varyings, where N is the number of elements
3426
* in the input signature.
3427
*
3428
* \remark Valid legacy Direct3D pixel shaders have at most 12 varying inputs:
3429
* 10 inter-stage varyings, face, and position.
3430
* Therefore, in practice, it is safe to call this function with a
3431
* pre-allocated array with a fixed size of 12.
3432
*
3433
* \since 1.9
3434
*/
3435
VKD3D_SHADER_API void vkd3d_shader_build_varying_map(const struct vkd3d_shader_signature *output_signature,
3436
const struct vkd3d_shader_signature *input_signature,
3437
unsigned int *count, struct vkd3d_shader_varying_map *varyings);
3438
3439
/**
3440
* Free members of struct vkd3d_shader_scan_combined_resource_sampler_info
3441
* allocated by vkd3d_shader_scan().
3442
*
3443
* This function may free members of
3444
* vkd3d_shader_scan_combined_resource_sampler_info, but does not free the
3445
* structure itself.
3446
*
3447
* \param info Combined resource-sampler information to free.
3448
*
3449
* \since 1.10
3450
*/
3451
VKD3D_SHADER_API void vkd3d_shader_free_scan_combined_resource_sampler_info(
3452
struct vkd3d_shader_scan_combined_resource_sampler_info *info);
3453
3454
#endif /* VKD3D_SHADER_NO_PROTOTYPES */
3455
3456
/** Type of vkd3d_shader_get_version(). */
3457
typedef const char *(*PFN_vkd3d_shader_get_version)(unsigned int *major, unsigned int *minor);
3458
/** Type of vkd3d_shader_get_supported_source_types(). */
3459
typedef const enum vkd3d_shader_source_type *(*PFN_vkd3d_shader_get_supported_source_types)(unsigned int *count);
3460
/** Type of vkd3d_shader_get_supported_target_types(). */
3461
typedef const enum vkd3d_shader_target_type *(*PFN_vkd3d_shader_get_supported_target_types)(
3462
enum vkd3d_shader_source_type source_type, unsigned int *count);
3463
3464
/** Type of vkd3d_shader_compile(). */
3465
typedef int (*PFN_vkd3d_shader_compile)(const struct vkd3d_shader_compile_info *compile_info,
3466
struct vkd3d_shader_code *out, char **messages);
3467
/** Type of vkd3d_shader_free_messages(). */
3468
typedef void (*PFN_vkd3d_shader_free_messages)(char *messages);
3469
/** Type of vkd3d_shader_free_shader_code(). */
3470
typedef void (*PFN_vkd3d_shader_free_shader_code)(struct vkd3d_shader_code *code);
3471
3472
/** Type of vkd3d_shader_parse_root_signature(). */
3473
typedef int (*PFN_vkd3d_shader_parse_root_signature)(const struct vkd3d_shader_code *dxbc,
3474
struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages);
3475
/** Type of vkd3d_shader_free_root_signature(). */
3476
typedef void (*PFN_vkd3d_shader_free_root_signature)(struct vkd3d_shader_versioned_root_signature_desc *root_signature);
3477
3478
/** Type of vkd3d_shader_serialize_root_signature(). */
3479
typedef int (*PFN_vkd3d_shader_serialize_root_signature)(
3480
const struct vkd3d_shader_versioned_root_signature_desc *root_signature,
3481
struct vkd3d_shader_code *dxbc, char **messages);
3482
3483
/** Type of vkd3d_shader_convert_root_signature(). */
3484
typedef int (*PFN_vkd3d_shader_convert_root_signature)(struct vkd3d_shader_versioned_root_signature_desc *dst,
3485
enum vkd3d_shader_root_signature_version version, const struct vkd3d_shader_versioned_root_signature_desc *src);
3486
3487
/** Type of vkd3d_shader_scan(). */
3488
typedef int (*PFN_vkd3d_shader_scan)(const struct vkd3d_shader_compile_info *compile_info, char **messages);
3489
/** Type of vkd3d_shader_free_scan_descriptor_info(). */
3490
typedef void (*PFN_vkd3d_shader_free_scan_descriptor_info)(
3491
struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);
3492
3493
/** Type of vkd3d_shader_parse_input_signature(). */
3494
typedef int (*PFN_vkd3d_shader_parse_input_signature)(const struct vkd3d_shader_code *dxbc,
3495
struct vkd3d_shader_signature *signature, char **messages);
3496
/** Type of vkd3d_shader_find_signature_element(). */
3497
typedef struct vkd3d_shader_signature_element * (*PFN_vkd3d_shader_find_signature_element)(
3498
const struct vkd3d_shader_signature *signature, const char *semantic_name,
3499
unsigned int semantic_index, unsigned int stream_index);
3500
/** Type of vkd3d_shader_free_shader_signature(). */
3501
typedef void (*PFN_vkd3d_shader_free_shader_signature)(struct vkd3d_shader_signature *signature);
3502
3503
/** Type of vkd3d_shader_preprocess(). \since 1.3 */
3504
typedef void (*PFN_vkd3d_shader_preprocess)(struct vkd3d_shader_compile_info *compile_info,
3505
struct vkd3d_shader_code *out, char **messages);
3506
3507
/** Type of vkd3d_shader_set_log_callback(). \since 1.4 */
3508
typedef void (*PFN_vkd3d_shader_set_log_callback)(PFN_vkd3d_log callback);
3509
3510
/** Type of vkd3d_shader_free_dxbc(). \since 1.7 */
3511
typedef void (*PFN_vkd3d_shader_free_dxbc)(struct vkd3d_shader_dxbc_desc *dxbc);
3512
/** Type of vkd3d_shader_parse_dxbc(). \since 1.7 */
3513
typedef int (*PFN_vkd3d_shader_parse_dxbc)(const struct vkd3d_shader_code *dxbc,
3514
uint32_t flags, struct vkd3d_shader_dxbc_desc *desc, char **messages);
3515
/** Type of vkd3d_shader_serialize_dxbc(). \since 1.7 */
3516
typedef int (*PFN_vkd3d_shader_serialize_dxbc)(size_t section_count,
3517
const struct vkd3d_shader_dxbc_section_desc *sections, struct vkd3d_shader_code *dxbc, char **messages);
3518
3519
/** Type of vkd3d_shader_build_varying_map(). \since 1.9 */
3520
typedef void (*PFN_vkd3d_shader_build_varying_map)(const struct vkd3d_shader_signature *output_signature,
3521
const struct vkd3d_shader_signature *input_signature,
3522
unsigned int *count, struct vkd3d_shader_varying_map *varyings);
3523
/** Type of vkd3d_shader_free_scan_signature_info(). \since 1.9 */
3524
typedef void (*PFN_vkd3d_shader_free_scan_signature_info)(struct vkd3d_shader_scan_signature_info *info);
3525
3526
/** Type of vkd3d_shader_free_scan_combined_resource_sampler_info(). \since 1.10 */
3527
typedef void (*PFN_vkd3d_shader_free_scan_combined_resource_sampler_info)(
3528
struct vkd3d_shader_scan_combined_resource_sampler_info *info);
3529
3530
#ifdef __cplusplus
3531
}
3532
#endif /* __cplusplus */
3533
3534
#endif /* __VKD3D_SHADER_H */
3535
3536