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