aboutsummaryrefslogtreecommitdiff
path: root/contrib/dxc_2025_07_14/inc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/dxc_2025_07_14/inc')
-rw-r--r--contrib/dxc_2025_07_14/inc/Support/ErrorCodes.h160
-rw-r--r--contrib/dxc_2025_07_14/inc/d3d12shader.h487
-rw-r--r--contrib/dxc_2025_07_14/inc/dxcapi.h1309
-rw-r--r--contrib/dxc_2025_07_14/inc/dxcerrors.h30
-rw-r--r--contrib/dxc_2025_07_14/inc/dxcisense.h959
-rw-r--r--contrib/dxc_2025_07_14/inc/hlsl/LICENSE.txt222
-rw-r--r--contrib/dxc_2025_07_14/inc/hlsl/README.txt7
-rw-r--r--contrib/dxc_2025_07_14/inc/hlsl/dx/linalg.h198
-rw-r--r--contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.h275
-rw-r--r--contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.impl377
-rw-r--r--contrib/dxc_2025_07_14/inc/hlsl/vk/opcode_selector.h227
-rw-r--r--contrib/dxc_2025_07_14/inc/hlsl/vk/spirv.h85
12 files changed, 4336 insertions, 0 deletions
diff --git a/contrib/dxc_2025_07_14/inc/Support/ErrorCodes.h b/contrib/dxc_2025_07_14/inc/Support/ErrorCodes.h
new file mode 100644
index 0000000..5239c81
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/Support/ErrorCodes.h
@@ -0,0 +1,160 @@
1///////////////////////////////////////////////////////////////////////////////
2// //
3// ErrorCodes.h //
4// Copyright (C) Microsoft Corporation. All rights reserved. //
5// This file is distributed under the University of Illinois Open Source //
6// License. See LICENSE.TXT for details. //
7// //
8// Provides error code values for the DirectX compiler and tools. //
9// //
10///////////////////////////////////////////////////////////////////////////////
11
12#pragma once
13
14// Redeclare some macros to not depend on winerror.h
15#define DXC_SEVERITY_ERROR 1
16#define DXC_MAKE_HRESULT(sev, fac, code) \
17 ((HRESULT)(((unsigned long)(sev) << 31) | ((unsigned long)(fac) << 16) | \
18 ((unsigned long)(code))))
19
20#define HRESULT_IS_WIN32ERR(hr) \
21 ((HRESULT)(hr & 0xFFFF0000) == \
22 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, 0))
23#define HRESULT_AS_WIN32ERR(hr) (HRESULT_CODE(hr))
24
25// Error codes from C libraries (0n150) - 0x8096xxxx
26#define FACILITY_ERRNO (0x96)
27#define HRESULT_FROM_ERRNO(x) \
28 MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_ERRNO, (x))
29
30// Error codes from DXC libraries (0n170) - 0x8013xxxx
31#define FACILITY_DXC (0xAA)
32
33// 0x00000000 - The operation succeeded.
34#define DXC_S_OK 0 // _HRESULT_TYPEDEF_(0x00000000L)
35
36// 0x80AA0001 - The operation failed because overlapping semantics were found.
37#define DXC_E_OVERLAPPING_SEMANTICS \
38 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0001))
39
40// 0x80AA0002 - The operation failed because multiple depth semantics were
41// found.
42#define DXC_E_MULTIPLE_DEPTH_SEMANTICS \
43 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0002))
44
45// 0x80AA0003 - Input file is too large.
46#define DXC_E_INPUT_FILE_TOO_LARGE \
47 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0003))
48
49// 0x80AA0004 - Error parsing DXBC container.
50#define DXC_E_INCORRECT_DXBC \
51 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0004))
52
53// 0x80AA0005 - Error parsing DXBC bytecode.
54#define DXC_E_ERROR_PARSING_DXBC_BYTECODE \
55 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0005))
56
57// 0x80AA0006 - Data is too large.
58#define DXC_E_DATA_TOO_LARGE \
59 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0006))
60
61// 0x80AA0007 - Incompatible converter options.
62#define DXC_E_INCOMPATIBLE_CONVERTER_OPTIONS \
63 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0007))
64
65// 0x80AA0008 - Irreducible control flow graph.
66#define DXC_E_IRREDUCIBLE_CFG \
67 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0008))
68
69// 0x80AA0009 - IR verification error.
70#define DXC_E_IR_VERIFICATION_FAILED \
71 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0009))
72
73// 0x80AA000A - Scope-nested control flow recovery failed.
74#define DXC_E_SCOPE_NESTED_FAILED \
75 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000A))
76
77// 0x80AA000B - Operation is not supported.
78#define DXC_E_NOT_SUPPORTED \
79 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000B))
80
81// 0x80AA000C - Unable to encode string.
82#define DXC_E_STRING_ENCODING_FAILED \
83 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000C))
84
85// 0x80AA000D - DXIL container is invalid.
86#define DXC_E_CONTAINER_INVALID \
87 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000D))
88
89// 0x80AA000E - DXIL container is missing the DXIL part.
90#define DXC_E_CONTAINER_MISSING_DXIL \
91 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000E))
92
93// 0x80AA000F - Unable to parse DxilModule metadata.
94#define DXC_E_INCORRECT_DXIL_METADATA \
95 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000F))
96
97// 0x80AA0010 - Error parsing DDI signature.
98#define DXC_E_INCORRECT_DDI_SIGNATURE \
99 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0010))
100
101// 0x80AA0011 - Duplicate part exists in dxil container.
102#define DXC_E_DUPLICATE_PART \
103 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0011))
104
105// 0x80AA0012 - Error finding part in dxil container.
106#define DXC_E_MISSING_PART \
107 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0012))
108
109// 0x80AA0013 - Malformed DXIL Container.
110#define DXC_E_MALFORMED_CONTAINER \
111 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0013))
112
113// 0x80AA0014 - Incorrect Root Signature for shader.
114#define DXC_E_INCORRECT_ROOT_SIGNATURE \
115 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0014))
116
117// 0X80AA0015 - DXIL container is missing DebugInfo part.
118#define DXC_E_CONTAINER_MISSING_DEBUG \
119 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0015))
120
121// 0X80AA0016 - Unexpected failure in macro expansion.
122#define DXC_E_MACRO_EXPANSION_FAILURE \
123 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0016))
124
125// 0X80AA0017 - DXIL optimization pass failed.
126#define DXC_E_OPTIMIZATION_FAILED \
127 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0017))
128
129// 0X80AA0018 - General internal error.
130#define DXC_E_GENERAL_INTERNAL_ERROR \
131 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0018))
132
133// 0X80AA0019 - Abort compilation error.
134#define DXC_E_ABORT_COMPILATION_ERROR \
135 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0019))
136
137// 0X80AA001A - Error in extension mechanism.
138#define DXC_E_EXTENSION_ERROR \
139 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001A))
140
141// 0X80AA001B - LLVM Fatal Error
142#define DXC_E_LLVM_FATAL_ERROR \
143 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001B))
144
145// 0X80AA001C - LLVM Unreachable code
146#define DXC_E_LLVM_UNREACHABLE \
147 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001C))
148
149// 0X80AA001D - LLVM Cast Failure
150#define DXC_E_LLVM_CAST_ERROR \
151 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001D))
152
153// 0X80AA001E - External validator (DXIL.dll) required, and missing.
154#define DXC_E_VALIDATOR_MISSING \
155 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001E))
156
157// 0X80AA001F - DXIL container Program Version mismatches Dxil module shader
158// model
159#define DXC_E_INCORRECT_PROGRAM_VERSION \
160 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001F)) \ No newline at end of file
diff --git a/contrib/dxc_2025_07_14/inc/d3d12shader.h b/contrib/dxc_2025_07_14/inc/d3d12shader.h
new file mode 100644
index 0000000..749e933
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/d3d12shader.h
@@ -0,0 +1,487 @@
1//////////////////////////////////////////////////////////////////////////////
2//
3// Copyright (c) Microsoft Corporation.
4// Licensed under the MIT license.
5//
6// File: D3D12Shader.h
7// Content: D3D12 Shader Types and APIs
8//
9//////////////////////////////////////////////////////////////////////////////
10
11#ifndef __D3D12SHADER_H__
12#define __D3D12SHADER_H__
13
14#include "d3dcommon.h"
15
16typedef enum D3D12_SHADER_VERSION_TYPE
17{
18 D3D12_SHVER_PIXEL_SHADER = 0,
19 D3D12_SHVER_VERTEX_SHADER = 1,
20 D3D12_SHVER_GEOMETRY_SHADER = 2,
21
22 // D3D11 Shaders
23 D3D12_SHVER_HULL_SHADER = 3,
24 D3D12_SHVER_DOMAIN_SHADER = 4,
25 D3D12_SHVER_COMPUTE_SHADER = 5,
26
27 // D3D12 Shaders
28 D3D12_SHVER_LIBRARY = 6,
29
30 D3D12_SHVER_RAY_GENERATION_SHADER = 7,
31 D3D12_SHVER_INTERSECTION_SHADER = 8,
32 D3D12_SHVER_ANY_HIT_SHADER = 9,
33 D3D12_SHVER_CLOSEST_HIT_SHADER = 10,
34 D3D12_SHVER_MISS_SHADER = 11,
35 D3D12_SHVER_CALLABLE_SHADER = 12,
36
37 D3D12_SHVER_MESH_SHADER = 13,
38 D3D12_SHVER_AMPLIFICATION_SHADER = 14,
39
40 D3D12_SHVER_RESERVED0 = 0xFFF0,
41} D3D12_SHADER_VERSION_TYPE;
42
43#define D3D12_SHVER_GET_TYPE(_Version) \
44 (((_Version) >> 16) & 0xffff)
45#define D3D12_SHVER_GET_MAJOR(_Version) \
46 (((_Version) >> 4) & 0xf)
47#define D3D12_SHVER_GET_MINOR(_Version) \
48 (((_Version) >> 0) & 0xf)
49
50// Slot ID for library function return
51#define D3D_RETURN_PARAMETER_INDEX (-1)
52
53typedef D3D_RESOURCE_RETURN_TYPE D3D12_RESOURCE_RETURN_TYPE;
54
55typedef D3D_CBUFFER_TYPE D3D12_CBUFFER_TYPE;
56
57
58typedef struct _D3D12_SIGNATURE_PARAMETER_DESC
59{
60 LPCSTR SemanticName; // Name of the semantic
61 UINT SemanticIndex; // Index of the semantic
62 UINT Register; // Number of member variables
63 D3D_NAME SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable
64 D3D_REGISTER_COMPONENT_TYPE ComponentType; // Scalar type (e.g. uint, float, etc.)
65 BYTE Mask; // Mask to indicate which components of the register
66 // are used (combination of D3D10_COMPONENT_MASK values)
67 BYTE ReadWriteMask; // Mask to indicate whether a given component is
68 // never written (if this is an output signature) or
69 // always read (if this is an input signature).
70 // (combination of D3D_MASK_* values)
71 UINT Stream; // Stream index
72 D3D_MIN_PRECISION MinPrecision; // Minimum desired interpolation precision
73} D3D12_SIGNATURE_PARAMETER_DESC;
74
75typedef struct _D3D12_SHADER_BUFFER_DESC
76{
77 LPCSTR Name; // Name of the constant buffer
78 D3D_CBUFFER_TYPE Type; // Indicates type of buffer content
79 UINT Variables; // Number of member variables
80 UINT Size; // Size of CB (in bytes)
81 UINT uFlags; // Buffer description flags
82} D3D12_SHADER_BUFFER_DESC;
83
84typedef struct _D3D12_SHADER_VARIABLE_DESC
85{
86 LPCSTR Name; // Name of the variable
87 UINT StartOffset; // Offset in constant buffer's backing store
88 UINT Size; // Size of variable (in bytes)
89 UINT uFlags; // Variable flags
90 LPVOID DefaultValue; // Raw pointer to default value
91 UINT StartTexture; // First texture index (or -1 if no textures used)
92 UINT TextureSize; // Number of texture slots possibly used.
93 UINT StartSampler; // First sampler index (or -1 if no textures used)
94 UINT SamplerSize; // Number of sampler slots possibly used.
95} D3D12_SHADER_VARIABLE_DESC;
96
97typedef struct _D3D12_SHADER_TYPE_DESC
98{
99 D3D_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.)
100 D3D_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.)
101 UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable)
102 UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable)
103 UINT Elements; // Number of elements (0 if not an array)
104 UINT Members; // Number of members (0 if not a structure)
105 UINT Offset; // Offset from the start of structure (0 if not a structure member)
106 LPCSTR Name; // Name of type, can be NULL
107} D3D12_SHADER_TYPE_DESC;
108
109typedef D3D_TESSELLATOR_DOMAIN D3D12_TESSELLATOR_DOMAIN;
110
111typedef D3D_TESSELLATOR_PARTITIONING D3D12_TESSELLATOR_PARTITIONING;
112
113typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D12_TESSELLATOR_OUTPUT_PRIMITIVE;
114
115typedef struct _D3D12_SHADER_DESC
116{
117 UINT Version; // Shader version
118 LPCSTR Creator; // Creator string
119 UINT Flags; // Shader compilation/parse flags
120
121 UINT ConstantBuffers; // Number of constant buffers
122 UINT BoundResources; // Number of bound resources
123 UINT InputParameters; // Number of parameters in the input signature
124 UINT OutputParameters; // Number of parameters in the output signature
125
126 UINT InstructionCount; // Number of emitted instructions
127 UINT TempRegisterCount; // Number of temporary registers used
128 UINT TempArrayCount; // Number of temporary arrays used
129 UINT DefCount; // Number of constant defines
130 UINT DclCount; // Number of declarations (input + output)
131 UINT TextureNormalInstructions; // Number of non-categorized texture instructions
132 UINT TextureLoadInstructions; // Number of texture load instructions
133 UINT TextureCompInstructions; // Number of texture comparison instructions
134 UINT TextureBiasInstructions; // Number of texture bias instructions
135 UINT TextureGradientInstructions; // Number of texture gradient instructions
136 UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
137 UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
138 UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
139 UINT StaticFlowControlCount; // Number of static flow control instructions used
140 UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
141 UINT MacroInstructionCount; // Number of macro instructions used
142 UINT ArrayInstructionCount; // Number of array instructions used
143 UINT CutInstructionCount; // Number of cut instructions used
144 UINT EmitInstructionCount; // Number of emit instructions used
145 D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology
146 UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count
147 D3D_PRIMITIVE InputPrimitive; // GS/HS input primitive
148 UINT PatchConstantParameters; // Number of parameters in the patch constant signature
149 UINT cGSInstanceCount; // Number of Geometry shader instances
150 UINT cControlPoints; // Number of control points in the HS->DS stage
151 D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; // Primitive output by the tessellator
152 D3D_TESSELLATOR_PARTITIONING HSPartitioning; // Partitioning mode of the tessellator
153 D3D_TESSELLATOR_DOMAIN TessellatorDomain; // Domain of the tessellator (quad, tri, isoline)
154 // instruction counts
155 UINT cBarrierInstructions; // Number of barrier instructions in a compute shader
156 UINT cInterlockedInstructions; // Number of interlocked instructions
157 UINT cTextureStoreInstructions; // Number of texture writes
158} D3D12_SHADER_DESC;
159
160typedef struct _D3D12_SHADER_INPUT_BIND_DESC
161{
162 LPCSTR Name; // Name of the resource
163 D3D_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.)
164 UINT BindPoint; // Starting bind point
165 UINT BindCount; // Number of contiguous bind points (for arrays)
166
167 UINT uFlags; // Input binding flags
168 D3D_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture)
169 D3D_SRV_DIMENSION Dimension; // Dimension (if texture)
170 UINT NumSamples; // Number of samples (0 if not MS texture)
171 UINT Space; // Register space
172 UINT uID; // Range ID in the bytecode
173} D3D12_SHADER_INPUT_BIND_DESC;
174
175#define D3D_SHADER_REQUIRES_DOUBLES 0x00000001
176#define D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL 0x00000002
177#define D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE 0x00000004
178#define D3D_SHADER_REQUIRES_64_UAVS 0x00000008
179#define D3D_SHADER_REQUIRES_MINIMUM_PRECISION 0x00000010
180#define D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS 0x00000020
181#define D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS 0x00000040
182#define D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING 0x00000080
183#define D3D_SHADER_REQUIRES_TILED_RESOURCES 0x00000100
184#define D3D_SHADER_REQUIRES_STENCIL_REF 0x00000200
185#define D3D_SHADER_REQUIRES_INNER_COVERAGE 0x00000400
186#define D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS 0x00000800
187#define D3D_SHADER_REQUIRES_ROVS 0x00001000
188#define D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER 0x00002000
189#define D3D_SHADER_REQUIRES_WAVE_OPS 0x00004000
190#define D3D_SHADER_REQUIRES_INT64_OPS 0x00008000
191#define D3D_SHADER_REQUIRES_VIEW_ID 0x00010000
192#define D3D_SHADER_REQUIRES_BARYCENTRICS 0x00020000
193#define D3D_SHADER_REQUIRES_NATIVE_16BIT_OPS 0x00040000
194#define D3D_SHADER_REQUIRES_SHADING_RATE 0x00080000
195#define D3D_SHADER_REQUIRES_RAYTRACING_TIER_1_1 0x00100000
196#define D3D_SHADER_REQUIRES_SAMPLER_FEEDBACK 0x00200000
197#define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_TYPED_RESOURCE 0x00400000
198#define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_GROUP_SHARED 0x00800000
199#define D3D_SHADER_REQUIRES_DERIVATIVES_IN_MESH_AND_AMPLIFICATION_SHADERS 0x01000000
200#define D3D_SHADER_REQUIRES_RESOURCE_DESCRIPTOR_HEAP_INDEXING 0x02000000
201#define D3D_SHADER_REQUIRES_SAMPLER_DESCRIPTOR_HEAP_INDEXING 0x04000000
202#define D3D_SHADER_REQUIRES_WAVE_MMA 0x08000000
203#define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE 0x10000000
204
205typedef struct _D3D12_LIBRARY_DESC
206{
207 LPCSTR Creator; // The name of the originator of the library.
208 UINT Flags; // Compilation flags.
209 UINT FunctionCount; // Number of functions exported from the library.
210} D3D12_LIBRARY_DESC;
211
212typedef struct _D3D12_FUNCTION_DESC
213{
214 UINT Version; // Shader version
215 LPCSTR Creator; // Creator string
216 UINT Flags; // Shader compilation/parse flags
217
218 UINT ConstantBuffers; // Number of constant buffers
219 UINT BoundResources; // Number of bound resources
220
221 UINT InstructionCount; // Number of emitted instructions
222 UINT TempRegisterCount; // Number of temporary registers used
223 UINT TempArrayCount; // Number of temporary arrays used
224 UINT DefCount; // Number of constant defines
225 UINT DclCount; // Number of declarations (input + output)
226 UINT TextureNormalInstructions; // Number of non-categorized texture instructions
227 UINT TextureLoadInstructions; // Number of texture load instructions
228 UINT TextureCompInstructions; // Number of texture comparison instructions
229 UINT TextureBiasInstructions; // Number of texture bias instructions
230 UINT TextureGradientInstructions; // Number of texture gradient instructions
231 UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
232 UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
233 UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
234 UINT StaticFlowControlCount; // Number of static flow control instructions used
235 UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
236 UINT MacroInstructionCount; // Number of macro instructions used
237 UINT ArrayInstructionCount; // Number of array instructions used
238 UINT MovInstructionCount; // Number of mov instructions used
239 UINT MovcInstructionCount; // Number of movc instructions used
240 UINT ConversionInstructionCount; // Number of type conversion instructions used
241 UINT BitwiseInstructionCount; // Number of bitwise arithmetic instructions used
242 D3D_FEATURE_LEVEL MinFeatureLevel; // Min target of the function byte code
243 UINT64 RequiredFeatureFlags; // Required feature flags
244
245 LPCSTR Name; // Function name
246 INT FunctionParameterCount; // Number of logical parameters in the function signature (not including return)
247 BOOL HasReturn; // TRUE, if function returns a value, false - it is a subroutine
248 BOOL Has10Level9VertexShader; // TRUE, if there is a 10L9 VS blob
249 BOOL Has10Level9PixelShader; // TRUE, if there is a 10L9 PS blob
250} D3D12_FUNCTION_DESC;
251
252typedef struct _D3D12_PARAMETER_DESC
253{
254 LPCSTR Name; // Parameter name.
255 LPCSTR SemanticName; // Parameter semantic name (+index).
256 D3D_SHADER_VARIABLE_TYPE Type; // Element type.
257 D3D_SHADER_VARIABLE_CLASS Class; // Scalar/Vector/Matrix.
258 UINT Rows; // Rows are for matrix parameters.
259 UINT Columns; // Components or Columns in matrix.
260 D3D_INTERPOLATION_MODE InterpolationMode; // Interpolation mode.
261 D3D_PARAMETER_FLAGS Flags; // Parameter modifiers.
262
263 UINT FirstInRegister; // The first input register for this parameter.
264 UINT FirstInComponent; // The first input register component for this parameter.
265 UINT FirstOutRegister; // The first output register for this parameter.
266 UINT FirstOutComponent; // The first output register component for this parameter.
267} D3D12_PARAMETER_DESC;
268
269
270//////////////////////////////////////////////////////////////////////////////
271// Interfaces ////////////////////////////////////////////////////////////////
272//////////////////////////////////////////////////////////////////////////////
273
274typedef interface ID3D12ShaderReflectionType ID3D12ShaderReflectionType;
275typedef interface ID3D12ShaderReflectionType *LPD3D12SHADERREFLECTIONTYPE;
276
277typedef interface ID3D12ShaderReflectionVariable ID3D12ShaderReflectionVariable;
278typedef interface ID3D12ShaderReflectionVariable *LPD3D12SHADERREFLECTIONVARIABLE;
279
280typedef interface ID3D12ShaderReflectionConstantBuffer ID3D12ShaderReflectionConstantBuffer;
281typedef interface ID3D12ShaderReflectionConstantBuffer *LPD3D12SHADERREFLECTIONCONSTANTBUFFER;
282
283typedef interface ID3D12ShaderReflection ID3D12ShaderReflection;
284typedef interface ID3D12ShaderReflection *LPD3D12SHADERREFLECTION;
285
286typedef interface ID3D12LibraryReflection ID3D12LibraryReflection;
287typedef interface ID3D12LibraryReflection *LPD3D12LIBRARYREFLECTION;
288
289typedef interface ID3D12FunctionReflection ID3D12FunctionReflection;
290typedef interface ID3D12FunctionReflection *LPD3D12FUNCTIONREFLECTION;
291
292typedef interface ID3D12FunctionParameterReflection ID3D12FunctionParameterReflection;
293typedef interface ID3D12FunctionParameterReflection *LPD3D12FUNCTIONPARAMETERREFLECTION;
294
295
296// {E913C351-783D-48CA-A1D1-4F306284AD56}
297interface DECLSPEC_UUID("E913C351-783D-48CA-A1D1-4F306284AD56") ID3D12ShaderReflectionType;
298DEFINE_GUID(IID_ID3D12ShaderReflectionType,
2990xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56);
300
301#undef INTERFACE
302#define INTERFACE ID3D12ShaderReflectionType
303
304DECLARE_INTERFACE(ID3D12ShaderReflectionType)
305{
306 STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_TYPE_DESC *pDesc) PURE;
307
308 STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ _In_ UINT Index) PURE;
309 STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(THIS_ _In_ LPCSTR Name) PURE;
310 STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ _In_ UINT Index) PURE;
311
312 STDMETHOD(IsEqual)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE;
313 STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS) PURE;
314 STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS) PURE;
315 STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE;
316 STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ _In_ UINT uIndex) PURE;
317 STDMETHOD(IsOfType)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE;
318 STDMETHOD(ImplementsInterface)(THIS_ _In_ ID3D12ShaderReflectionType* pBase) PURE;
319};
320
321// {8337A8A6-A216-444A-B2F4-314733A73AEA}
322interface DECLSPEC_UUID("8337A8A6-A216-444A-B2F4-314733A73AEA") ID3D12ShaderReflectionVariable;
323DEFINE_GUID(IID_ID3D12ShaderReflectionVariable,
3240x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea);
325
326#undef INTERFACE
327#define INTERFACE ID3D12ShaderReflectionVariable
328
329DECLARE_INTERFACE(ID3D12ShaderReflectionVariable)
330{
331 STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_VARIABLE_DESC *pDesc) PURE;
332
333 STDMETHOD_(ID3D12ShaderReflectionType*, GetType)(THIS) PURE;
334 STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)(THIS) PURE;
335
336 STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ _In_ UINT uArrayIndex) PURE;
337};
338
339// {C59598B4-48B3-4869-B9B1-B1618B14A8B7}
340interface DECLSPEC_UUID("C59598B4-48B3-4869-B9B1-B1618B14A8B7") ID3D12ShaderReflectionConstantBuffer;
341DEFINE_GUID(IID_ID3D12ShaderReflectionConstantBuffer,
3420xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7);
343
344#undef INTERFACE
345#define INTERFACE ID3D12ShaderReflectionConstantBuffer
346
347DECLARE_INTERFACE(ID3D12ShaderReflectionConstantBuffer)
348{
349 STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_BUFFER_DESC *pDesc) PURE;
350
351 STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(THIS_ _In_ UINT Index) PURE;
352 STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
353};
354
355// The ID3D12ShaderReflection IID may change from SDK version to SDK version
356// if the reflection API changes. This prevents new code with the new API
357// from working with an old binary. Recompiling with the new header
358// will pick up the new IID.
359
360// {5A58797D-A72C-478D-8BA2-EFC6B0EFE88E}
361interface DECLSPEC_UUID("5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") ID3D12ShaderReflection;
362DEFINE_GUID(IID_ID3D12ShaderReflection,
3630x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e);
364
365#undef INTERFACE
366#define INTERFACE ID3D12ShaderReflection
367
368DECLARE_INTERFACE_(ID3D12ShaderReflection, IUnknown)
369{
370 STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid,
371 _Out_ LPVOID *ppv) PURE;
372 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
373 STDMETHOD_(ULONG, Release)(THIS) PURE;
374
375 STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_DESC *pDesc) PURE;
376
377 STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ _In_ UINT Index) PURE;
378 STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
379
380 STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
381 _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
382
383 STDMETHOD(GetInputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
384 _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
385 STDMETHOD(GetOutputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
386 _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
387 STDMETHOD(GetPatchConstantParameterDesc)(THIS_ _In_ UINT ParameterIndex,
388 _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
389
390 STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
391
392 STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
393 _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
394
395 STDMETHOD_(UINT, GetMovInstructionCount)(THIS) PURE;
396 STDMETHOD_(UINT, GetMovcInstructionCount)(THIS) PURE;
397 STDMETHOD_(UINT, GetConversionInstructionCount)(THIS) PURE;
398 STDMETHOD_(UINT, GetBitwiseInstructionCount)(THIS) PURE;
399
400 STDMETHOD_(D3D_PRIMITIVE, GetGSInputPrimitive)(THIS) PURE;
401 STDMETHOD_(BOOL, IsSampleFrequencyShader)(THIS) PURE;
402
403 STDMETHOD_(UINT, GetNumInterfaceSlots)(THIS) PURE;
404 STDMETHOD(GetMinFeatureLevel)(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) PURE;
405
406 STDMETHOD_(UINT, GetThreadGroupSize)(THIS_
407 _Out_opt_ UINT* pSizeX,
408 _Out_opt_ UINT* pSizeY,
409 _Out_opt_ UINT* pSizeZ) PURE;
410
411 STDMETHOD_(UINT64, GetRequiresFlags)(THIS) PURE;
412};
413
414// {8E349D19-54DB-4A56-9DC9-119D87BDB804}
415interface DECLSPEC_UUID("8E349D19-54DB-4A56-9DC9-119D87BDB804") ID3D12LibraryReflection;
416DEFINE_GUID(IID_ID3D12LibraryReflection,
4170x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4);
418
419#undef INTERFACE
420#define INTERFACE ID3D12LibraryReflection
421
422DECLARE_INTERFACE_(ID3D12LibraryReflection, IUnknown)
423{
424 STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
425 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
426 STDMETHOD_(ULONG, Release)(THIS) PURE;
427
428 STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc) PURE;
429
430 STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) PURE;
431};
432
433// {1108795C-2772-4BA9-B2A8-D464DC7E2799}
434interface DECLSPEC_UUID("1108795C-2772-4BA9-B2A8-D464DC7E2799") ID3D12FunctionReflection;
435DEFINE_GUID(IID_ID3D12FunctionReflection,
4360x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99);
437
438#undef INTERFACE
439#define INTERFACE ID3D12FunctionReflection
440
441DECLARE_INTERFACE(ID3D12FunctionReflection)
442{
443 STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) PURE;
444
445 STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) PURE;
446 STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
447
448 STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
449 _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE;
450
451 STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
452
453 STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
454 _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE;
455
456 // Use D3D_RETURN_PARAMETER_INDEX to get description of the return value.
457 STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) PURE;
458};
459
460// {EC25F42D-7006-4F2B-B33E-02CC3375733F}
461interface DECLSPEC_UUID("EC25F42D-7006-4F2B-B33E-02CC3375733F") ID3D12FunctionParameterReflection;
462DEFINE_GUID(IID_ID3D12FunctionParameterReflection,
4630xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x2, 0xcc, 0x33, 0x75, 0x73, 0x3f);
464
465#undef INTERFACE
466#define INTERFACE ID3D12FunctionParameterReflection
467
468DECLARE_INTERFACE(ID3D12FunctionParameterReflection)
469{
470 STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) PURE;
471};
472
473
474//////////////////////////////////////////////////////////////////////////////
475// APIs //////////////////////////////////////////////////////////////////////
476//////////////////////////////////////////////////////////////////////////////
477
478#ifdef __cplusplus
479extern "C" {
480#endif //__cplusplus
481
482#ifdef __cplusplus
483}
484#endif //__cplusplus
485
486#endif //__D3D12SHADER_H__
487
diff --git a/contrib/dxc_2025_07_14/inc/dxcapi.h b/contrib/dxc_2025_07_14/inc/dxcapi.h
new file mode 100644
index 0000000..95cc56a
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/dxcapi.h
@@ -0,0 +1,1309 @@
1
2///////////////////////////////////////////////////////////////////////////////
3// //
4// dxcapi.h //
5// Copyright (C) Microsoft Corporation. All rights reserved. //
6// This file is distributed under the University of Illinois Open Source //
7// License. See LICENSE.TXT for details. //
8// //
9// Provides declarations for the DirectX Compiler API entry point. //
10// //
11///////////////////////////////////////////////////////////////////////////////
12
13#ifndef __DXC_API__
14#define __DXC_API__
15
16#ifdef _WIN32
17#ifndef DXC_API_IMPORT
18#define DXC_API_IMPORT __declspec(dllimport)
19#endif
20#else
21#ifndef DXC_API_IMPORT
22#define DXC_API_IMPORT __attribute__((visibility("default")))
23#endif
24#endif
25
26#ifdef _WIN32
27
28#ifndef CROSS_PLATFORM_UUIDOF
29// Warning: This macro exists in WinAdapter.h as well
30#define CROSS_PLATFORM_UUIDOF(interface, spec) \
31 struct __declspec(uuid(spec)) interface;
32#endif
33
34#else
35
36#include "WinAdapter.h"
37#include <dlfcn.h>
38#endif
39
40struct IMalloc;
41
42struct IDxcIncludeHandler;
43
44/// \brief Typedef for DxcCreateInstance function pointer.
45///
46/// This can be used with GetProcAddress to get the DxcCreateInstance function.
47typedef HRESULT(__stdcall *DxcCreateInstanceProc)(_In_ REFCLSID rclsid,
48 _In_ REFIID riid,
49 _Out_ LPVOID *ppv);
50
51/// \brief Typedef for DxcCreateInstance2 function pointer.
52///
53/// This can be used with GetProcAddress to get the DxcCreateInstance2 function.
54typedef HRESULT(__stdcall *DxcCreateInstance2Proc)(_In_ IMalloc *pMalloc,
55 _In_ REFCLSID rclsid,
56 _In_ REFIID riid,
57 _Out_ LPVOID *ppv);
58
59/// \brief Creates a single uninitialized object of the class associated with a
60/// specified CLSID.
61///
62/// \param rclsid The CLSID associated with the data and code that will be used
63/// to create the object.
64///
65/// \param riid A reference to the identifier of the interface to be used to
66/// communicate with the object.
67///
68/// \param ppv Address of pointer variable that receives the interface pointer
69/// requested in riid. Upon successful return, *ppv contains the requested
70/// interface pointer. Upon failure, *ppv contains NULL.
71///
72/// While this function is similar to CoCreateInstance, there is no COM
73/// involvement.
74extern "C" DXC_API_IMPORT
75 HRESULT __stdcall DxcCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid,
76 _Out_ LPVOID *ppv);
77
78/// \brief Version of DxcCreateInstance that takes an IMalloc interface.
79///
80/// This can be used to create an instance of the compiler with a custom memory
81/// allocator.
82extern "C" DXC_API_IMPORT
83 HRESULT __stdcall DxcCreateInstance2(_In_ IMalloc *pMalloc,
84 _In_ REFCLSID rclsid, _In_ REFIID riid,
85 _Out_ LPVOID *ppv);
86
87// For convenience, equivalent definitions to CP_UTF8 and CP_UTF16.
88#define DXC_CP_UTF8 65001
89#define DXC_CP_UTF16 1200
90#define DXC_CP_UTF32 12000
91// Use DXC_CP_ACP for: Binary; ANSI Text; Autodetect UTF with BOM
92#define DXC_CP_ACP 0
93
94/// Codepage for "wide" characters - UTF16 on Windows, UTF32 on other platforms.
95#ifdef _WIN32
96#define DXC_CP_WIDE DXC_CP_UTF16
97#else
98#define DXC_CP_WIDE DXC_CP_UTF32
99#endif
100
101/// Indicates that the shader hash was computed taking into account source
102/// information (-Zss).
103#define DXC_HASHFLAG_INCLUDES_SOURCE 1
104
105/// Hash digest type for ShaderHash.
106typedef struct DxcShaderHash {
107 UINT32 Flags; ///< DXC_HASHFLAG_*
108 BYTE HashDigest[16]; ///< The hash digest
109} DxcShaderHash;
110
111#define DXC_FOURCC(ch0, ch1, ch2, ch3) \
112 ((UINT32)(UINT8)(ch0) | (UINT32)(UINT8)(ch1) << 8 | \
113 (UINT32)(UINT8)(ch2) << 16 | (UINT32)(UINT8)(ch3) << 24)
114#define DXC_PART_PDB DXC_FOURCC('I', 'L', 'D', 'B')
115#define DXC_PART_PDB_NAME DXC_FOURCC('I', 'L', 'D', 'N')
116#define DXC_PART_PRIVATE_DATA DXC_FOURCC('P', 'R', 'I', 'V')
117#define DXC_PART_ROOT_SIGNATURE DXC_FOURCC('R', 'T', 'S', '0')
118#define DXC_PART_DXIL DXC_FOURCC('D', 'X', 'I', 'L')
119#define DXC_PART_REFLECTION_DATA DXC_FOURCC('S', 'T', 'A', 'T')
120#define DXC_PART_SHADER_HASH DXC_FOURCC('H', 'A', 'S', 'H')
121#define DXC_PART_INPUT_SIGNATURE DXC_FOURCC('I', 'S', 'G', '1')
122#define DXC_PART_OUTPUT_SIGNATURE DXC_FOURCC('O', 'S', 'G', '1')
123#define DXC_PART_PATCH_CONSTANT_SIGNATURE DXC_FOURCC('P', 'S', 'G', '1')
124
125// Some option arguments are defined here for continuity with D3DCompile
126// interface.
127#define DXC_ARG_DEBUG L"-Zi"
128#define DXC_ARG_SKIP_VALIDATION L"-Vd"
129#define DXC_ARG_SKIP_OPTIMIZATIONS L"-Od"
130#define DXC_ARG_PACK_MATRIX_ROW_MAJOR L"-Zpr"
131#define DXC_ARG_PACK_MATRIX_COLUMN_MAJOR L"-Zpc"
132#define DXC_ARG_AVOID_FLOW_CONTROL L"-Gfa"
133#define DXC_ARG_PREFER_FLOW_CONTROL L"-Gfp"
134#define DXC_ARG_ENABLE_STRICTNESS L"-Ges"
135#define DXC_ARG_ENABLE_BACKWARDS_COMPATIBILITY L"-Gec"
136#define DXC_ARG_IEEE_STRICTNESS L"-Gis"
137#define DXC_ARG_OPTIMIZATION_LEVEL0 L"-O0"
138#define DXC_ARG_OPTIMIZATION_LEVEL1 L"-O1"
139#define DXC_ARG_OPTIMIZATION_LEVEL2 L"-O2"
140#define DXC_ARG_OPTIMIZATION_LEVEL3 L"-O3"
141#define DXC_ARG_WARNINGS_ARE_ERRORS L"-WX"
142#define DXC_ARG_RESOURCES_MAY_ALIAS L"-res_may_alias"
143#define DXC_ARG_ALL_RESOURCES_BOUND L"-all_resources_bound"
144#define DXC_ARG_DEBUG_NAME_FOR_SOURCE L"-Zss"
145#define DXC_ARG_DEBUG_NAME_FOR_BINARY L"-Zsb"
146
147CROSS_PLATFORM_UUIDOF(IDxcBlob, "8BA5FB08-5195-40e2-AC58-0D989C3A0102")
148/// \brief A sized buffer that can be passed in and out of DXC APIs.
149///
150/// This is an alias of ID3D10Blob and ID3DBlob.
151struct IDxcBlob : public IUnknown {
152public:
153 /// \brief Retrieves a pointer to the blob's data.
154 virtual LPVOID STDMETHODCALLTYPE GetBufferPointer(void) = 0;
155
156 /// \brief Retrieves the size, in bytes, of the blob's data.
157 virtual SIZE_T STDMETHODCALLTYPE GetBufferSize(void) = 0;
158};
159
160CROSS_PLATFORM_UUIDOF(IDxcBlobEncoding, "7241d424-2646-4191-97c0-98e96e42fc68")
161/// \brief A blob that might have a known encoding.
162struct IDxcBlobEncoding : public IDxcBlob {
163public:
164 /// \brief Retrieve the encoding for this blob.
165 ///
166 /// \param pKnown Pointer to a variable that will be set to TRUE if the
167 /// encoding is known.
168 ///
169 /// \param pCodePage Pointer to variable that will be set to the encoding used
170 /// for this blog.
171 ///
172 /// If the encoding is not known then pCodePage will be set to CP_ACP.
173 virtual HRESULT STDMETHODCALLTYPE GetEncoding(_Out_ BOOL *pKnown,
174 _Out_ UINT32 *pCodePage) = 0;
175};
176
177CROSS_PLATFORM_UUIDOF(IDxcBlobWide, "A3F84EAB-0FAA-497E-A39C-EE6ED60B2D84")
178/// \brief A blob containing a null-terminated wide string.
179///
180/// This uses the native wide character encoding (utf16 on Windows, utf32 on
181/// Linux).
182///
183/// The value returned by GetBufferSize() is the size of the buffer, in bytes,
184/// including the null-terminator.
185///
186/// This interface is used to return output name strings DXC. Other string
187/// output blobs, such as errors/warnings, preprocessed HLSL, or other text are
188/// returned using encodings based on the -encoding option passed to the
189/// compiler.
190struct IDxcBlobWide : public IDxcBlobEncoding {
191public:
192 /// \brief Retrieves a pointer to the string stored in this blob.
193 virtual LPCWSTR STDMETHODCALLTYPE GetStringPointer(void) = 0;
194
195 /// \brief Retrieves the length of the string stored in this blob, in
196 /// characters, excluding the null-terminator.
197 virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0;
198};
199
200CROSS_PLATFORM_UUIDOF(IDxcBlobUtf8, "3DA636C9-BA71-4024-A301-30CBF125305B")
201/// \brief A blob containing a UTF-8 encoded string.
202///
203/// The value returned by GetBufferSize() is the size of the buffer, in bytes,
204/// including the null-terminator.
205///
206/// Depending on the -encoding option passed to the compiler, this interface is
207/// used to return string output blobs, such as errors/warnings, preprocessed
208/// HLSL, or other text. Output name strings always use IDxcBlobWide.
209struct IDxcBlobUtf8 : public IDxcBlobEncoding {
210public:
211 /// \brief Retrieves a pointer to the string stored in this blob.
212 virtual LPCSTR STDMETHODCALLTYPE GetStringPointer(void) = 0;
213
214 /// \brief Retrieves the length of the string stored in this blob, in
215 /// characters, excluding the null-terminator.
216 virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0;
217};
218
219#ifdef _WIN32
220/// IDxcBlobUtf16 is a legacy alias for IDxcBlobWide on Win32.
221typedef IDxcBlobWide IDxcBlobUtf16;
222#endif
223
224CROSS_PLATFORM_UUIDOF(IDxcIncludeHandler,
225 "7f61fc7d-950d-467f-b3e3-3c02fb49187c")
226/// \brief Interface for handling include directives.
227///
228/// This interface can be implemented to customize handling of include
229/// directives.
230///
231/// Use IDxcUtils::CreateDefaultIncludeHandler to create a default
232/// implementation that reads include files from the filesystem.
233///
234struct IDxcIncludeHandler : public IUnknown {
235 /// \brief Load a source file to be included by the compiler.
236 ///
237 /// \param pFilename Candidate filename.
238 ///
239 /// \param ppIncludeSource Resultant source object for included file, nullptr
240 /// if not found.
241 virtual HRESULT STDMETHODCALLTYPE
242 LoadSource(_In_z_ LPCWSTR pFilename,
243 _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource) = 0;
244};
245
246/// \brief Structure for supplying bytes or text input to Dxc APIs.
247typedef struct DxcBuffer {
248 /// \brief Pointer to the start of the buffer.
249 LPCVOID Ptr;
250
251 /// \brief Size of the buffer in bytes.
252 SIZE_T Size;
253
254 /// \brief Encoding of the buffer.
255 ///
256 /// Use Encoding = 0 for non-text bytes, ANSI text, or unknown with BOM.
257 UINT Encoding;
258} DxcText;
259
260/// \brief Structure for supplying defines to Dxc APIs.
261struct DxcDefine {
262 LPCWSTR Name; ///< The define name.
263 _Maybenull_ LPCWSTR Value; ///< Optional value for the define.
264};
265
266CROSS_PLATFORM_UUIDOF(IDxcCompilerArgs, "73EFFE2A-70DC-45F8-9690-EFF64C02429D")
267/// \brief Interface for managing arguments passed to DXC.
268///
269/// Use IDxcUtils::BuildArguments to create an instance of this interface.
270struct IDxcCompilerArgs : public IUnknown {
271 /// \brief Retrieve the array of arguments.
272 ///
273 /// This can be passed directly to the pArguments parameter of the Compile()
274 /// method.
275 virtual LPCWSTR *STDMETHODCALLTYPE GetArguments() = 0;
276
277 /// \brief Retrieve the number of arguments.
278 ///
279 /// This can be passed directly to the argCount parameter of the Compile()
280 /// method.
281 virtual UINT32 STDMETHODCALLTYPE GetCount() = 0;
282
283 /// \brief Add additional arguments to this list of compiler arguments.
284 virtual HRESULT STDMETHODCALLTYPE AddArguments(
285 _In_opt_count_(argCount)
286 LPCWSTR *pArguments, ///< Array of pointers to arguments to add.
287 _In_ UINT32 argCount ///< Number of arguments to add.
288 ) = 0;
289
290 /// \brief Add additional UTF-8 encoded arguments to this list of compiler
291 /// arguments.
292 virtual HRESULT STDMETHODCALLTYPE AddArgumentsUTF8(
293 _In_opt_count_(argCount)
294 LPCSTR *pArguments, ///< Array of pointers to UTF-8 arguments to add.
295 _In_ UINT32 argCount ///< Number of arguments to add.
296 ) = 0;
297
298 /// \brief Add additional defines to this list of compiler arguments.
299 virtual HRESULT STDMETHODCALLTYPE AddDefines(
300 _In_count_(defineCount) const DxcDefine *pDefines, ///< Array of defines.
301 _In_ UINT32 defineCount ///< Number of defines.
302 ) = 0;
303};
304
305//////////////////////////
306// Legacy Interfaces
307/////////////////////////
308
309CROSS_PLATFORM_UUIDOF(IDxcLibrary, "e5204dc7-d18c-4c3c-bdfb-851673980fe7")
310/// \deprecated IDxcUtils replaces IDxcLibrary; please use IDxcUtils insted.
311struct IDxcLibrary : public IUnknown {
312 /// \deprecated
313 virtual HRESULT STDMETHODCALLTYPE SetMalloc(_In_opt_ IMalloc *pMalloc) = 0;
314
315 /// \deprecated
316 virtual HRESULT STDMETHODCALLTYPE
317 CreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length,
318 _COM_Outptr_ IDxcBlob **ppResult) = 0;
319
320 /// \deprecated
321 virtual HRESULT STDMETHODCALLTYPE
322 CreateBlobFromFile(_In_z_ LPCWSTR pFileName, _In_opt_ UINT32 *codePage,
323 _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
324
325 /// \deprecated
326 virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingFromPinned(
327 _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,
328 _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
329
330 /// \deprecated
331 virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnHeapCopy(
332 _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,
333 _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
334
335 /// \deprecated
336 virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnMalloc(
337 _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size,
338 UINT32 codePage, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
339
340 /// \deprecated
341 virtual HRESULT STDMETHODCALLTYPE
342 CreateIncludeHandler(_COM_Outptr_ IDxcIncludeHandler **ppResult) = 0;
343
344 /// \deprecated
345 virtual HRESULT STDMETHODCALLTYPE CreateStreamFromBlobReadOnly(
346 _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0;
347
348 /// \deprecated
349 virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8(
350 _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
351
352 // Renamed from GetBlobAsUtf16 to GetBlobAsWide
353 /// \deprecated
354 virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide(
355 _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
356
357#ifdef _WIN32
358 // Alias to GetBlobAsWide on Win32
359 /// \deprecated
360 inline HRESULT GetBlobAsUtf16(_In_ IDxcBlob *pBlob,
361 _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) {
362 return this->GetBlobAsWide(pBlob, pBlobEncoding);
363 }
364#endif
365};
366
367CROSS_PLATFORM_UUIDOF(IDxcOperationResult,
368 "CEDB484A-D4E9-445A-B991-CA21CA157DC2")
369/// \brief The results of a DXC operation.
370///
371/// Note: IDxcResult replaces IDxcOperationResult and should be used wherever
372/// possible.
373struct IDxcOperationResult : public IUnknown {
374 /// \brief Retrieve the overall status of the operation.
375 virtual HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) = 0;
376
377 /// \brief Retrieve the primary output of the operation.
378 ///
379 /// This corresponds to:
380 /// * DXC_OUT_OBJECT - Compile() with shader or library target
381 /// * DXC_OUT_DISASSEMBLY - Disassemble()
382 /// * DXC_OUT_HLSL - Compile() with -P
383 /// * DXC_OUT_ROOT_SIGNATURE - Compile() with rootsig_* target
384 virtual HRESULT STDMETHODCALLTYPE
385 GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0;
386
387 /// \brief Retrieves the error buffer from the operation, if there is one.
388 ///
389 // This corresponds to calling IDxcResult::GetOutput() with DXC_OUT_ERRORS.
390 virtual HRESULT STDMETHODCALLTYPE
391 GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) = 0;
392};
393
394CROSS_PLATFORM_UUIDOF(IDxcCompiler, "8c210bf3-011f-4422-8d70-6f9acb8db617")
395/// \deprecated Please use IDxcCompiler3 instead.
396struct IDxcCompiler : public IUnknown {
397 /// \brief Compile a single entry point to the target shader model.
398 ///
399 /// \deprecated Please use IDxcCompiler3::Compile() instead.
400 virtual HRESULT STDMETHODCALLTYPE Compile(
401 _In_ IDxcBlob *pSource, // Source text to compile.
402 _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in
403 // errors and include handlers.
404 _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name.
405 _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile.
406 _In_opt_count_(argCount)
407 LPCWSTR *pArguments, // Array of pointers to arguments.
408 _In_ UINT32 argCount, // Number of arguments.
409 _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines.
410 _In_ UINT32 defineCount, // Number of defines.
411 _In_opt_ IDxcIncludeHandler
412 *pIncludeHandler, // User-provided interface to handle #include
413 // directives (optional).
414 _COM_Outptr_ IDxcOperationResult *
415 *ppResult // Compiler output status, buffer, and errors.
416 ) = 0;
417
418 /// \brief Preprocess source text.
419 ///
420 /// \deprecated Please use IDxcCompiler3::Compile() with the "-P" argument
421 /// instead.
422 virtual HRESULT STDMETHODCALLTYPE Preprocess(
423 _In_ IDxcBlob *pSource, // Source text to preprocess.
424 _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in
425 // errors and include handlers.
426 _In_opt_count_(argCount)
427 LPCWSTR *pArguments, // Array of pointers to arguments.
428 _In_ UINT32 argCount, // Number of arguments.
429 _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines.
430 _In_ UINT32 defineCount, // Number of defines.
431 _In_opt_ IDxcIncludeHandler
432 *pIncludeHandler, // user-provided interface to handle #include
433 // directives (optional).
434 _COM_Outptr_ IDxcOperationResult *
435 *ppResult // Preprocessor output status, buffer, and errors.
436 ) = 0;
437
438 /// \brief Disassemble a program.
439 ///
440 /// \deprecated Please use IDxcCompiler3::Disassemble() instead.
441 virtual HRESULT STDMETHODCALLTYPE Disassemble(
442 _In_ IDxcBlob *pSource, // Program to disassemble.
443 _COM_Outptr_ IDxcBlobEncoding **ppDisassembly // Disassembly text.
444 ) = 0;
445};
446
447CROSS_PLATFORM_UUIDOF(IDxcCompiler2, "A005A9D9-B8BB-4594-B5C9-0E633BEC4D37")
448/// \deprecated Please use IDxcCompiler3 instead.
449struct IDxcCompiler2 : public IDxcCompiler {
450 /// \brief Compile a single entry point to the target shader model with debug
451 /// information.
452 ///
453 /// \deprecated Please use IDxcCompiler3::Compile() instead.
454 virtual HRESULT STDMETHODCALLTYPE CompileWithDebug(
455 _In_ IDxcBlob *pSource, // Source text to compile.
456 _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in
457 // errors and include handlers.
458 _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name.
459 _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile.
460 _In_opt_count_(argCount)
461 LPCWSTR *pArguments, // Array of pointers to arguments.
462 _In_ UINT32 argCount, // Number of arguments.
463 _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines.
464 _In_ UINT32 defineCount, // Number of defines.
465 _In_opt_ IDxcIncludeHandler
466 *pIncludeHandler, // user-provided interface to handle #include
467 // directives (optional).
468 _COM_Outptr_ IDxcOperationResult *
469 *ppResult, // Compiler output status, buffer, and errors.
470 _Outptr_opt_result_z_ LPWSTR
471 *ppDebugBlobName, // Suggested file name for debug blob. Must be
472 // CoTaskMemFree()'d.
473 _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob.
474 ) = 0;
475};
476
477CROSS_PLATFORM_UUIDOF(IDxcLinker, "F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6")
478/// \brief DXC linker interface.
479///
480/// Use DxcCreateInstance with CLSID_DxcLinker to obtain an instance of this
481/// interface.
482struct IDxcLinker : public IUnknown {
483public:
484 /// \brief Register a library with name to reference it later.
485 virtual HRESULT
486 RegisterLibrary(_In_opt_ LPCWSTR pLibName, ///< Name of the library.
487 _In_ IDxcBlob *pLib ///< Library blob.
488 ) = 0;
489
490 /// \brief Links the shader and produces a shader blob that the Direct3D
491 /// runtime can use.
492 virtual HRESULT STDMETHODCALLTYPE Link(
493 _In_opt_ LPCWSTR pEntryName, ///< Entry point name.
494 _In_ LPCWSTR pTargetProfile, ///< shader profile to link.
495 _In_count_(libCount)
496 const LPCWSTR *pLibNames, ///< Array of library names to link.
497 _In_ UINT32 libCount, ///< Number of libraries to link.
498 _In_opt_count_(argCount)
499 const LPCWSTR *pArguments, ///< Array of pointers to arguments.
500 _In_ UINT32 argCount, ///< Number of arguments.
501 _COM_Outptr_ IDxcOperationResult *
502 *ppResult ///< Linker output status, buffer, and errors.
503 ) = 0;
504};
505
506/////////////////////////
507// Latest interfaces. Please use these.
508////////////////////////
509
510CROSS_PLATFORM_UUIDOF(IDxcUtils, "4605C4CB-2019-492A-ADA4-65F20BB7D67F")
511/// \brief Various utility functions for DXC.
512///
513/// Use DxcCreateInstance with CLSID_DxcUtils to obtain an instance of this
514/// interface.
515///
516/// IDxcUtils replaces IDxcLibrary.
517struct IDxcUtils : public IUnknown {
518 /// \brief Create a sub-blob that holds a reference to the outer blob and
519 /// points to its memory.
520 ///
521 /// \param pBlob The outer blob.
522 ///
523 /// \param offset The offset inside the outer blob.
524 ///
525 /// \param length The size, in bytes, of the buffer to reference from the
526 /// output blob.
527 ///
528 /// \param ppResult Address of the pointer that receives a pointer to the
529 /// newly created blob.
530 virtual HRESULT STDMETHODCALLTYPE
531 CreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length,
532 _COM_Outptr_ IDxcBlob **ppResult) = 0;
533
534 // For codePage, use 0 (or DXC_CP_ACP) for raw binary or ANSI code page.
535
536 /// \brief Create a blob referencing existing memory, with no copy.
537 ///
538 /// \param pData Pointer to buffer containing the contents of the new blob.
539 ///
540 /// \param size The size of the pData buffer, in bytes.
541 ///
542 /// \param codePage The code page to use if the blob contains text. Use
543 /// DXC_CP_ACP for binary or ANSI code page.
544 ///
545 /// \param ppBlobEncoding Address of the pointer that receives a pointer to
546 /// the newly created blob.
547 ///
548 /// The user must manage the memory lifetime separately.
549 ///
550 /// This replaces IDxcLibrary::CreateBlobWithEncodingFromPinned.
551 virtual HRESULT STDMETHODCALLTYPE CreateBlobFromPinned(
552 _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage,
553 _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
554
555 /// \brief Create a blob, taking ownership of memory allocated with the
556 /// supplied allocator.
557 ///
558 /// \param pData Pointer to buffer containing the contents of the new blob.
559 ///
560 /// \param pIMalloc The memory allocator to use.
561 ///
562 /// \param size The size of thee pData buffer, in bytes.
563 ///
564 /// \param codePage The code page to use if the blob contains text. Use
565 /// DXC_CP_ACP for binary or ANSI code page.
566 ///
567 /// \param ppBlobEncoding Address of the pointer that receives a pointer to
568 /// the newly created blob.
569 ///
570 /// This replaces IDxcLibrary::CreateBlobWithEncodingOnMalloc.
571 virtual HRESULT STDMETHODCALLTYPE MoveToBlob(
572 _In_bytecount_(size) LPCVOID pData, IMalloc *pIMalloc, UINT32 size,
573 UINT32 codePage, _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
574
575 /// \brief Create a blob containing a copy of the existing data.
576 ///
577 /// \param pData Pointer to buffer containing the contents of the new blob.
578 ///
579 /// \param size The size of thee pData buffer, in bytes.
580 ///
581 /// \param codePage The code page to use if the blob contains text. Use
582 /// DXC_CP_ACP for binary or ANSI code page.
583 ///
584 /// \param ppBlobEncoding Address of the pointer that receives a pointer to
585 /// the newly created blob.
586 ///
587 /// The new blob and its contents are allocated with the current allocator.
588 /// This replaces IDxcLibrary::CreateBlobWithEncodingOnHeapCopy.
589 virtual HRESULT STDMETHODCALLTYPE
590 CreateBlob(_In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage,
591 _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
592
593 /// \brief Create a blob with data loaded from a file.
594 ///
595 /// \param pFileName The name of the file to load from.
596 ///
597 /// \param pCodePage Optional code page to use if the blob contains text. Pass
598 /// NULL for binary data.
599 ///
600 /// \param ppBlobEncoding Address of the pointer that receives a pointer to
601 /// the newly created blob.
602 ///
603 /// The new blob and its contents are allocated with the current allocator.
604 /// This replaces IDxcLibrary::CreateBlobFromFile.
605 virtual HRESULT STDMETHODCALLTYPE
606 LoadFile(_In_z_ LPCWSTR pFileName, _In_opt_ UINT32 *pCodePage,
607 _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
608
609 /// \brief Create a stream that reads data from a blob.
610 ///
611 /// \param pBlob The blob to read from.
612 ///
613 /// \param ppStream Address of the pointer that receives a pointer to the
614 /// newly created stream.
615 virtual HRESULT STDMETHODCALLTYPE CreateReadOnlyStreamFromBlob(
616 _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0;
617
618 /// \brief Create default file-based include handler.
619 ///
620 /// \param ppResult Address of the pointer that receives a pointer to the
621 /// newly created include handler.
622 virtual HRESULT STDMETHODCALLTYPE
623 CreateDefaultIncludeHandler(_COM_Outptr_ IDxcIncludeHandler **ppResult) = 0;
624
625 /// \brief Convert or return matching encoded text blob as UTF-8.
626 ///
627 /// \param pBlob The blob to convert.
628 ///
629 /// \param ppBlobEncoding Address of the pointer that receives a pointer to
630 /// the newly created blob.
631 virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8(
632 _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf8 **ppBlobEncoding) = 0;
633
634 /// \brief Convert or return matching encoded text blob as UTF-16.
635 ///
636 /// \param pBlob The blob to convert.
637 ///
638 /// \param ppBlobEncoding Address of the pointer that receives a pointer to
639 /// the newly created blob.
640 virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide(
641 _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **ppBlobEncoding) = 0;
642
643#ifdef _WIN32
644 /// \brief Convert or return matching encoded text blob as UTF-16.
645 ///
646 /// \param pBlob The blob to convert.
647 ///
648 /// \param ppBlobEncoding Address of the pointer that receives a pointer to
649 /// the newly created blob.
650 ///
651 /// Alias to GetBlobAsWide on Win32.
652 inline HRESULT GetBlobAsUtf16(_In_ IDxcBlob *pBlob,
653 _COM_Outptr_ IDxcBlobWide **ppBlobEncoding) {
654 return this->GetBlobAsWide(pBlob, ppBlobEncoding);
655 }
656#endif
657
658 /// \brief Retrieve a single part from a DXIL container.
659 ///
660 /// \param pShader The shader to retrieve the part from.
661 ///
662 /// \param DxcPart The part to retrieve (eg DXC_PART_ROOT_SIGNATURE).
663 ///
664 /// \param ppPartData Address of the pointer that receives a pointer to the
665 /// part.
666 ///
667 /// \param pPartSizeInBytes Address of the pointer that receives the size of
668 /// the part.
669 ///
670 /// The returned pointer points inside the buffer passed in pShader.
671 virtual HRESULT STDMETHODCALLTYPE
672 GetDxilContainerPart(_In_ const DxcBuffer *pShader, _In_ UINT32 DxcPart,
673 _Outptr_result_nullonfailure_ void **ppPartData,
674 _Out_ UINT32 *pPartSizeInBytes) = 0;
675
676 /// \brief Create reflection interface from serialized DXIL container or the
677 /// DXC_OUT_REFLECTION blob contents.
678 ///
679 /// \param pData The source data.
680 ///
681 /// \param iid The interface ID of the reflection interface to create.
682 ///
683 /// \param ppvReflection Address of the pointer that receives a pointer to the
684 /// newly created reflection interface.
685 ///
686 /// Use this with interfaces such as ID3D12ShaderReflection.
687 virtual HRESULT STDMETHODCALLTYPE CreateReflection(
688 _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) = 0;
689
690 /// \brief Build arguments that can be passed to the Compile method.
691 virtual HRESULT STDMETHODCALLTYPE BuildArguments(
692 _In_opt_z_ LPCWSTR pSourceName, ///< Optional file name for pSource. Used
693 ///< in errors and include handlers.
694 _In_opt_z_ LPCWSTR pEntryPoint, ///< Entry point name (-E).
695 _In_z_ LPCWSTR pTargetProfile, ///< Shader profile to compile (-T).
696 _In_opt_count_(argCount)
697 LPCWSTR *pArguments, ///< Array of pointers to arguments.
698 _In_ UINT32 argCount, ///< Number of arguments.
699 _In_count_(defineCount) const DxcDefine *pDefines, ///< Array of defines.
700 _In_ UINT32 defineCount, ///< Number of defines.
701 _COM_Outptr_ IDxcCompilerArgs *
702 *ppArgs ///< Arguments you can use with Compile() method.
703 ) = 0;
704
705 /// \brief Retrieve the hash and contents of a shader PDB.
706 ///
707 /// \param pPDBBlob The blob containing the PDB.
708 ///
709 /// \param ppHash Address of the pointer that receives a pointer to the hash
710 /// blob.
711 ///
712 /// \param ppContainer Address of the pointer that receives a pointer to the
713 /// bloc containing the contents of the PDB.
714 ///
715 virtual HRESULT STDMETHODCALLTYPE
716 GetPDBContents(_In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash,
717 _COM_Outptr_ IDxcBlob **ppContainer) = 0;
718};
719
720/// \brief Specifies the kind of output to retrieve from a IDxcResult.
721///
722/// Note: text outputs returned from version 2 APIs are UTF-8 or UTF-16 based on
723/// the -encoding option passed to the compiler.
724typedef enum DXC_OUT_KIND {
725 DXC_OUT_NONE = 0, ///< No output.
726 DXC_OUT_OBJECT = 1, ///< IDxcBlob - Shader or library object.
727 DXC_OUT_ERRORS = 2, ///< IDxcBlobUtf8 or IDxcBlobWide.
728 DXC_OUT_PDB = 3, ///< IDxcBlob.
729 DXC_OUT_SHADER_HASH = 4, ///< IDxcBlob - DxcShaderHash of shader or shader
730 ///< with source info (-Zsb/-Zss).
731 DXC_OUT_DISASSEMBLY = 5, ///< IDxcBlobUtf8 or IDxcBlobWide - from Disassemble.
732 DXC_OUT_HLSL =
733 6, ///< IDxcBlobUtf8 or IDxcBlobWide - from Preprocessor or Rewriter.
734 DXC_OUT_TEXT = 7, ///< IDxcBlobUtf8 or IDxcBlobWide - other text, such as
735 ///< -ast-dump or -Odump.
736 DXC_OUT_REFLECTION = 8, ///< IDxcBlob - RDAT part with reflection data.
737 DXC_OUT_ROOT_SIGNATURE = 9, ///< IDxcBlob - Serialized root signature output.
738 DXC_OUT_EXTRA_OUTPUTS = 10, ///< IDxcExtraOutputs - Extra outputs.
739 DXC_OUT_REMARKS =
740 11, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout.
741 DXC_OUT_TIME_REPORT =
742 12, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout.
743 DXC_OUT_TIME_TRACE =
744 13, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout.
745
746 DXC_OUT_LAST = DXC_OUT_TIME_TRACE, ///< Last value for a counter.
747
748 DXC_OUT_NUM_ENUMS,
749 DXC_OUT_FORCE_DWORD = 0xFFFFFFFF
750} DXC_OUT_KIND;
751
752static_assert(DXC_OUT_NUM_ENUMS == DXC_OUT_LAST + 1,
753 "DXC_OUT_* Enum added and last value not updated.");
754
755CROSS_PLATFORM_UUIDOF(IDxcResult, "58346CDA-DDE7-4497-9461-6F87AF5E0659")
756/// \brief Result of a DXC operation.
757///
758/// DXC operations may have multiple outputs, such as a shader object and
759/// errors. This interface provides access to the outputs.
760struct IDxcResult : public IDxcOperationResult {
761 /// \brief Determines whether or not this result has the specified output.
762 ///
763 /// \param dxcOutKind The kind of output to check for.
764 virtual BOOL STDMETHODCALLTYPE HasOutput(_In_ DXC_OUT_KIND dxcOutKind) = 0;
765
766 /// \brief Retrieves the specified output.
767 ///
768 /// \param dxcOutKind The kind of output to retrieve.
769 ///
770 /// \param iid The interface ID of the output interface.
771 ///
772 /// \param ppvObject Address of the pointer that receives a pointer to the
773 /// output.
774 ///
775 /// \param ppOutputName Optional address of a pointer to receive the name
776 /// blob, if there is one.
777 virtual HRESULT STDMETHODCALLTYPE
778 GetOutput(_In_ DXC_OUT_KIND dxcOutKind, _In_ REFIID iid,
779 _COM_Outptr_opt_result_maybenull_ void **ppvObject,
780 _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputName) = 0;
781
782 /// \brief Retrieves the number of outputs available in this result.
783 virtual UINT32 GetNumOutputs() = 0;
784
785 /// \brief Retrieves the output kind at the specified index.
786 virtual DXC_OUT_KIND GetOutputByIndex(UINT32 Index) = 0;
787
788 /// \brief Retrieves the primary output kind for this result.
789 ///
790 /// See IDxcOperationResult::GetResult() for more information on the primary
791 /// output kinds.
792 virtual DXC_OUT_KIND PrimaryOutput() = 0;
793};
794
795// Special names for extra output that should get written to specific streams.
796#define DXC_EXTRA_OUTPUT_NAME_STDOUT L"*stdout*"
797#define DXC_EXTRA_OUTPUT_NAME_STDERR L"*stderr*"
798
799CROSS_PLATFORM_UUIDOF(IDxcExtraOutputs, "319b37a2-a5c2-494a-a5de-4801b2faf989")
800/// \brief Additional outputs from a DXC operation.
801///
802/// This can be used to obtain outputs that don't have an explicit DXC_OUT_KIND.
803/// Use DXC_OUT_EXTRA_OUTPUTS to obtain instances of this.
804struct IDxcExtraOutputs : public IUnknown {
805 /// \brief Retrieves the number of outputs available
806 virtual UINT32 STDMETHODCALLTYPE GetOutputCount() = 0;
807
808 /// \brief Retrieves the specified output.
809 ///
810 /// \param uIndex The index of the output to retrieve.
811 ///
812 /// \param iid The interface ID of the output interface.
813 ///
814 /// \param ppvObject Optional address of the pointer that receives a pointer
815 /// to the output if there is one.
816 ///
817 /// \param ppOutputType Optional address of the pointer that receives the
818 /// output type name blob if there is one.
819 ///
820 /// \param ppOutputName Optional address of the pointer that receives the
821 /// output name blob if there is one.
822 virtual HRESULT STDMETHODCALLTYPE
823 GetOutput(_In_ UINT32 uIndex, _In_ REFIID iid,
824 _COM_Outptr_opt_result_maybenull_ void **ppvObject,
825 _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputType,
826 _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputName) = 0;
827};
828
829CROSS_PLATFORM_UUIDOF(IDxcCompiler3, "228B4687-5A6A-4730-900C-9702B2203F54")
830/// \brief Interface to the DirectX Shader Compiler.
831///
832/// Use DxcCreateInstance with CLSID_DxcCompiler to obtain an instance of this
833/// interface.
834struct IDxcCompiler3 : public IUnknown {
835 /// \brief Compile a shader.
836 ///
837 /// IDxcUtils::BuildArguments can be used to assist building the pArguments
838 /// and argCount parameters.
839 ///
840 /// Depending on the arguments, this method can be used to:
841 ///
842 /// * Compile a single entry point to the target shader model,
843 /// * Compile a library to a library target (-T lib_*)
844 /// * Compile a root signature (-T rootsig_*),
845 /// * Preprocess HLSL source (-P).
846 virtual HRESULT STDMETHODCALLTYPE Compile(
847 _In_ const DxcBuffer *pSource, ///< Source text to compile.
848 _In_opt_count_(argCount)
849 LPCWSTR *pArguments, ///< Array of pointers to arguments.
850 _In_ UINT32 argCount, ///< Number of arguments.
851 _In_opt_ IDxcIncludeHandler
852 *pIncludeHandler, ///< user-provided interface to handle include
853 ///< directives (optional).
854 _In_ REFIID riid, ///< Interface ID for the result.
855 _Out_ LPVOID *ppResult ///< IDxcResult: status, buffer, and errors.
856 ) = 0;
857
858 /// \brief Disassemble a program.
859 virtual HRESULT STDMETHODCALLTYPE Disassemble(
860 _In_ const DxcBuffer
861 *pObject, ///< Program to disassemble: dxil container or bitcode.
862 _In_ REFIID riid, ///< Interface ID for the result.
863 _Out_ LPVOID
864 *ppResult ///< IDxcResult: status, disassembly text, and errors.
865 ) = 0;
866};
867
868static const UINT32 DxcValidatorFlags_Default = 0;
869static const UINT32 DxcValidatorFlags_InPlaceEdit =
870 1; // Validator is allowed to update shader blob in-place.
871static const UINT32 DxcValidatorFlags_RootSignatureOnly = 2;
872static const UINT32 DxcValidatorFlags_ModuleOnly = 4;
873static const UINT32 DxcValidatorFlags_ValidMask = 0x7;
874
875CROSS_PLATFORM_UUIDOF(IDxcValidator, "A6E82BD2-1FD7-4826-9811-2857E797F49A")
876/// \brief Interface to DXC shader validator.
877///
878/// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this.
879struct IDxcValidator : public IUnknown {
880 /// \brief Validate a shader.
881 virtual HRESULT STDMETHODCALLTYPE Validate(
882 _In_ IDxcBlob *pShader, ///< Shader to validate.
883 _In_ UINT32 Flags, ///< Validation flags.
884 _COM_Outptr_ IDxcOperationResult *
885 *ppResult ///< Validation output status, buffer, and errors.
886 ) = 0;
887};
888
889CROSS_PLATFORM_UUIDOF(IDxcValidator2, "458e1fd1-b1b2-4750-a6e1-9c10f03bed92")
890/// \brief Interface to DXC shader validator.
891///
892/// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this.
893struct IDxcValidator2 : public IDxcValidator {
894 /// \brief Validate a shader with optional debug bitcode.
895 virtual HRESULT STDMETHODCALLTYPE ValidateWithDebug(
896 _In_ IDxcBlob *pShader, ///< Shader to validate.
897 _In_ UINT32 Flags, ///< Validation flags.
898 _In_opt_ DxcBuffer *pOptDebugBitcode, ///< Optional debug module bitcode
899 ///< to provide line numbers.
900 _COM_Outptr_ IDxcOperationResult *
901 *ppResult ///< Validation output status, buffer, and errors.
902 ) = 0;
903};
904
905CROSS_PLATFORM_UUIDOF(IDxcContainerBuilder,
906 "334b1f50-2292-4b35-99a1-25588d8c17fe")
907/// \brief Interface to DXC container builder.
908///
909/// Use DxcCreateInstance with CLSID_DxcContainerBuilder to obtain an instance
910/// of this.
911struct IDxcContainerBuilder : public IUnknown {
912 /// \brief Load a DxilContainer to the builder.
913 virtual HRESULT STDMETHODCALLTYPE
914 Load(_In_ IDxcBlob *pDxilContainerHeader) = 0;
915
916 /// \brief Add a part to the container.
917 ///
918 /// \param fourCC The part identifier (eg DXC_PART_PDB).
919 ///
920 /// \param pSource The source blob.
921 virtual HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC,
922 _In_ IDxcBlob *pSource) = 0;
923
924 /// \brief Remove a part from the container.
925 ///
926 /// \param fourCC The part identifier (eg DXC_PART_PDB).
927 ///
928 /// \return S_OK on success, DXC_E_MISSING_PART if the part was not found, or
929 /// other standard HRESULT error code.
930 virtual HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) = 0;
931
932 /// \brief Build the container.
933 ///
934 /// \param ppResult Pointer to variable to receive the result.
935 virtual HRESULT STDMETHODCALLTYPE
936 SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0;
937};
938
939CROSS_PLATFORM_UUIDOF(IDxcAssembler, "091f7a26-1c1f-4948-904b-e6e3a8a771d5")
940/// \brief Interface to DxcAssembler.
941///
942/// Use DxcCreateInstance with CLSID_DxcAssembler to obtain an instance of this.
943struct IDxcAssembler : public IUnknown {
944 /// \brief Assemble DXIL in LL or LLVM bitcode to DXIL container.
945 virtual HRESULT STDMETHODCALLTYPE AssembleToContainer(
946 _In_ IDxcBlob *pShader, ///< Shader to assemble.
947 _COM_Outptr_ IDxcOperationResult *
948 *ppResult ///< Assembly output status, buffer, and errors.
949 ) = 0;
950};
951
952CROSS_PLATFORM_UUIDOF(IDxcContainerReflection,
953 "d2c21b26-8350-4bdc-976a-331ce6f4c54c")
954/// \brief Interface to DxcContainerReflection.
955///
956/// Use DxcCreateInstance with CLSID_DxcContainerReflection to obtain an
957/// instance of this.
958struct IDxcContainerReflection : public IUnknown {
959 /// \brief Choose the container to perform reflection on
960 ///
961 /// \param pContainer The container to load. If null is passed then this
962 /// instance will release any held resources.
963 virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) = 0;
964
965 /// \brief Retrieves the number of parts in the container.
966 ///
967 /// \param pResult Pointer to variable to receive the result.
968 ///
969 /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
970 /// loaded using Load(), or other standard HRESULT error codes.
971 virtual HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) = 0;
972
973 /// \brief Retrieve the kind of a specified part.
974 ///
975 /// \param idx The index of the part to retrieve the kind of.
976 ///
977 /// \param pResult Pointer to variable to receive the result.
978 ///
979 /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
980 /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard
981 /// HRESULT error codes.
982 virtual HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx,
983 _Out_ UINT32 *pResult) = 0;
984
985 /// \brief Retrieve the content of a specified part.
986 ///
987 /// \param idx The index of the part to retrieve.
988 ///
989 /// \param ppResult Pointer to variable to receive the result.
990 ///
991 /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
992 /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard
993 /// HRESULT error codes.
994 virtual HRESULT STDMETHODCALLTYPE
995 GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) = 0;
996
997 /// \brief Retrieve the index of the first part with the specified kind.
998 ///
999 /// \param kind The kind to search for.
1000 ///
1001 /// \param pResult Pointer to variable to receive the index of the matching
1002 /// part.
1003 ///
1004 /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
1005 /// loaded using Load(), HRESULT_FROM_WIN32(ERROR_NOT_FOUND) if there is no
1006 /// part with the specified kind, or other standard HRESULT error codes.
1007 virtual HRESULT STDMETHODCALLTYPE
1008 FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) = 0;
1009
1010 /// \brief Retrieve the reflection interface for a specified part.
1011 ///
1012 /// \param idx The index of the part to retrieve the reflection interface of.
1013 ///
1014 /// \param iid The IID of the interface to retrieve.
1015 ///
1016 /// \param ppvObject Pointer to variable to receive the result.
1017 ///
1018 /// Use this with interfaces such as ID3D12ShaderReflection.
1019 ///
1020 /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
1021 /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard
1022 /// HRESULT error codes.
1023 virtual HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid,
1024 void **ppvObject) = 0;
1025};
1026
1027CROSS_PLATFORM_UUIDOF(IDxcOptimizerPass, "AE2CD79F-CC22-453F-9B6B-B124E7A5204C")
1028/// \brief An optimizer pass.
1029///
1030/// Instances of this can be obtained via IDxcOptimizer::GetAvailablePass.
1031struct IDxcOptimizerPass : public IUnknown {
1032 virtual HRESULT STDMETHODCALLTYPE
1033 GetOptionName(_COM_Outptr_ LPWSTR *ppResult) = 0;
1034 virtual HRESULT STDMETHODCALLTYPE
1035 GetDescription(_COM_Outptr_ LPWSTR *ppResult) = 0;
1036 virtual HRESULT STDMETHODCALLTYPE GetOptionArgCount(_Out_ UINT32 *pCount) = 0;
1037 virtual HRESULT STDMETHODCALLTYPE
1038 GetOptionArgName(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;
1039 virtual HRESULT STDMETHODCALLTYPE
1040 GetOptionArgDescription(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;
1041};
1042
1043CROSS_PLATFORM_UUIDOF(IDxcOptimizer, "25740E2E-9CBA-401B-9119-4FB42F39F270")
1044/// \brief Interface to DxcOptimizer.
1045///
1046/// Use DxcCreateInstance with CLSID_DxcOptimizer to obtain an instance of this.
1047struct IDxcOptimizer : public IUnknown {
1048 virtual HRESULT STDMETHODCALLTYPE
1049 GetAvailablePassCount(_Out_ UINT32 *pCount) = 0;
1050 virtual HRESULT STDMETHODCALLTYPE
1051 GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass **ppResult) = 0;
1052 virtual HRESULT STDMETHODCALLTYPE
1053 RunOptimizer(IDxcBlob *pBlob, _In_count_(optionCount) LPCWSTR *ppOptions,
1054 UINT32 optionCount, _COM_Outptr_ IDxcBlob **pOutputModule,
1055 _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) = 0;
1056};
1057
1058static const UINT32 DxcVersionInfoFlags_None = 0;
1059static const UINT32 DxcVersionInfoFlags_Debug = 1; // Matches VS_FF_DEBUG
1060static const UINT32 DxcVersionInfoFlags_Internal =
1061 2; // Internal Validator (non-signing)
1062
1063CROSS_PLATFORM_UUIDOF(IDxcVersionInfo, "b04f5b50-2059-4f12-a8ff-a1e0cde1cc7e")
1064/// \brief PDB Version information.
1065///
1066/// Use IDxcPdbUtils2::GetVersionInfo to obtain an instance of this.
1067struct IDxcVersionInfo : public IUnknown {
1068 virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor,
1069 _Out_ UINT32 *pMinor) = 0;
1070 virtual HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) = 0;
1071};
1072
1073CROSS_PLATFORM_UUIDOF(IDxcVersionInfo2, "fb6904c4-42f0-4b62-9c46-983af7da7c83")
1074/// \brief PDB Version Information.
1075///
1076/// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and
1077/// then use QueryInterface to obtain an instance of this interface from it.
1078struct IDxcVersionInfo2 : public IDxcVersionInfo {
1079 virtual HRESULT STDMETHODCALLTYPE GetCommitInfo(
1080 _Out_ UINT32 *pCommitCount, ///< The total number commits.
1081 _Outptr_result_z_ char **pCommitHash ///< The SHA of the latest commit.
1082 ///< Must be CoTaskMemFree()'d.
1083 ) = 0;
1084};
1085
1086CROSS_PLATFORM_UUIDOF(IDxcVersionInfo3, "5e13e843-9d25-473c-9ad2-03b2d0b44b1e")
1087/// \brief PDB Version Information.
1088///
1089/// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and
1090/// then use QueryInterface to obtain an instance of this interface from it.
1091struct IDxcVersionInfo3 : public IUnknown {
1092 virtual HRESULT STDMETHODCALLTYPE GetCustomVersionString(
1093 _Outptr_result_z_ char *
1094 *pVersionString ///< Custom version string for compiler. Must be
1095 ///< CoTaskMemFree()'d.
1096 ) = 0;
1097};
1098
1099struct DxcArgPair {
1100 const WCHAR *pName;
1101 const WCHAR *pValue;
1102};
1103
1104CROSS_PLATFORM_UUIDOF(IDxcPdbUtils, "E6C9647E-9D6A-4C3B-B94C-524B5A6C343D")
1105/// \deprecated Please use IDxcPdbUtils2 instead.
1106struct IDxcPdbUtils : public IUnknown {
1107 virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0;
1108
1109 virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0;
1110 virtual HRESULT STDMETHODCALLTYPE
1111 GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0;
1112 virtual HRESULT STDMETHODCALLTYPE
1113 GetSourceName(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0;
1114
1115 virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0;
1116 virtual HRESULT STDMETHODCALLTYPE
1117 GetFlag(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0;
1118
1119 virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0;
1120 virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex,
1121 _Outptr_result_z_ BSTR *pResult) = 0;
1122
1123 virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0;
1124 virtual HRESULT STDMETHODCALLTYPE
1125 GetArgPair(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pName,
1126 _Outptr_result_z_ BSTR *pValue) = 0;
1127
1128 virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0;
1129 virtual HRESULT STDMETHODCALLTYPE
1130 GetDefine(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0;
1131
1132 virtual HRESULT STDMETHODCALLTYPE
1133 GetTargetProfile(_Outptr_result_z_ BSTR *pResult) = 0;
1134 virtual HRESULT STDMETHODCALLTYPE
1135 GetEntryPoint(_Outptr_result_z_ BSTR *pResult) = 0;
1136 virtual HRESULT STDMETHODCALLTYPE
1137 GetMainFileName(_Outptr_result_z_ BSTR *pResult) = 0;
1138
1139 virtual HRESULT STDMETHODCALLTYPE
1140 GetHash(_COM_Outptr_ IDxcBlob **ppResult) = 0;
1141 virtual HRESULT STDMETHODCALLTYPE
1142 GetName(_Outptr_result_z_ BSTR *pResult) = 0;
1143
1144 virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0;
1145 virtual HRESULT STDMETHODCALLTYPE
1146 GetFullPDB(_COM_Outptr_ IDxcBlob **ppFullPDB) = 0;
1147
1148 virtual HRESULT STDMETHODCALLTYPE
1149 GetVersionInfo(_COM_Outptr_ IDxcVersionInfo **ppVersionInfo) = 0;
1150
1151 virtual HRESULT STDMETHODCALLTYPE
1152 SetCompiler(_In_ IDxcCompiler3 *pCompiler) = 0;
1153 virtual HRESULT STDMETHODCALLTYPE
1154 CompileForFullPDB(_COM_Outptr_ IDxcResult **ppResult) = 0;
1155 virtual HRESULT STDMETHODCALLTYPE OverrideArgs(_In_ DxcArgPair *pArgPairs,
1156 UINT32 uNumArgPairs) = 0;
1157 virtual HRESULT STDMETHODCALLTYPE
1158 OverrideRootSignature(_In_ const WCHAR *pRootSignature) = 0;
1159};
1160
1161CROSS_PLATFORM_UUIDOF(IDxcPdbUtils2, "4315D938-F369-4F93-95A2-252017CC3807")
1162/// \brief DxcPdbUtils interface.
1163///
1164/// Use DxcCreateInstance with CLSID_DxcPdbUtils to create an instance of this.
1165struct IDxcPdbUtils2 : public IUnknown {
1166 virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0;
1167
1168 virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0;
1169 virtual HRESULT STDMETHODCALLTYPE
1170 GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0;
1171 virtual HRESULT STDMETHODCALLTYPE
1172 GetSourceName(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
1173
1174 virtual HRESULT STDMETHODCALLTYPE GetLibraryPDBCount(UINT32 *pCount) = 0;
1175 virtual HRESULT STDMETHODCALLTYPE GetLibraryPDB(
1176 _In_ UINT32 uIndex, _COM_Outptr_ IDxcPdbUtils2 **ppOutPdbUtils,
1177 _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppLibraryName) = 0;
1178
1179 virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0;
1180 virtual HRESULT STDMETHODCALLTYPE
1181 GetFlag(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
1182
1183 virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0;
1184 virtual HRESULT STDMETHODCALLTYPE
1185 GetArg(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
1186
1187 virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0;
1188 virtual HRESULT STDMETHODCALLTYPE GetArgPair(
1189 _In_ UINT32 uIndex, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppName,
1190 _COM_Outptr_result_maybenull_ IDxcBlobWide **ppValue) = 0;
1191
1192 virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0;
1193 virtual HRESULT STDMETHODCALLTYPE
1194 GetDefine(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
1195
1196 virtual HRESULT STDMETHODCALLTYPE
1197 GetTargetProfile(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
1198 virtual HRESULT STDMETHODCALLTYPE
1199 GetEntryPoint(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
1200 virtual HRESULT STDMETHODCALLTYPE
1201 GetMainFileName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
1202
1203 virtual HRESULT STDMETHODCALLTYPE
1204 GetHash(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0;
1205 virtual HRESULT STDMETHODCALLTYPE
1206 GetName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
1207
1208 virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(
1209 _COM_Outptr_result_maybenull_ IDxcVersionInfo **ppVersionInfo) = 0;
1210
1211 virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainID(_Out_ UINT32 *pID) = 0;
1212 virtual HRESULT STDMETHODCALLTYPE
1213 GetCustomToolchainData(_COM_Outptr_result_maybenull_ IDxcBlob **ppBlob) = 0;
1214
1215 virtual HRESULT STDMETHODCALLTYPE
1216 GetWholeDxil(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0;
1217
1218 virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0;
1219 virtual BOOL STDMETHODCALLTYPE IsPDBRef() = 0;
1220};
1221
1222// Note: __declspec(selectany) requires 'extern'
1223// On Linux __declspec(selectany) is removed and using 'extern' results in link
1224// error.
1225#ifdef _MSC_VER
1226#define CLSID_SCOPE __declspec(selectany) extern
1227#else
1228#define CLSID_SCOPE
1229#endif
1230
1231CLSID_SCOPE const CLSID CLSID_DxcCompiler = {
1232 0x73e22d93,
1233 0xe6ce,
1234 0x47f3,
1235 {0xb5, 0xbf, 0xf0, 0x66, 0x4f, 0x39, 0xc1, 0xb0}};
1236
1237// {EF6A8087-B0EA-4D56-9E45-D07E1A8B7806}
1238CLSID_SCOPE const GUID CLSID_DxcLinker = {
1239 0xef6a8087,
1240 0xb0ea,
1241 0x4d56,
1242 {0x9e, 0x45, 0xd0, 0x7e, 0x1a, 0x8b, 0x78, 0x6}};
1243
1244// {CD1F6B73-2AB0-484D-8EDC-EBE7A43CA09F}
1245CLSID_SCOPE const CLSID CLSID_DxcDiaDataSource = {
1246 0xcd1f6b73,
1247 0x2ab0,
1248 0x484d,
1249 {0x8e, 0xdc, 0xeb, 0xe7, 0xa4, 0x3c, 0xa0, 0x9f}};
1250
1251// {3E56AE82-224D-470F-A1A1-FE3016EE9F9D}
1252CLSID_SCOPE const CLSID CLSID_DxcCompilerArgs = {
1253 0x3e56ae82,
1254 0x224d,
1255 0x470f,
1256 {0xa1, 0xa1, 0xfe, 0x30, 0x16, 0xee, 0x9f, 0x9d}};
1257
1258// {6245D6AF-66E0-48FD-80B4-4D271796748C}
1259CLSID_SCOPE const GUID CLSID_DxcLibrary = {
1260 0x6245d6af,
1261 0x66e0,
1262 0x48fd,
1263 {0x80, 0xb4, 0x4d, 0x27, 0x17, 0x96, 0x74, 0x8c}};
1264
1265CLSID_SCOPE const GUID CLSID_DxcUtils = CLSID_DxcLibrary;
1266
1267// {8CA3E215-F728-4CF3-8CDD-88AF917587A1}
1268CLSID_SCOPE const GUID CLSID_DxcValidator = {
1269 0x8ca3e215,
1270 0xf728,
1271 0x4cf3,
1272 {0x8c, 0xdd, 0x88, 0xaf, 0x91, 0x75, 0x87, 0xa1}};
1273
1274// {D728DB68-F903-4F80-94CD-DCCF76EC7151}
1275CLSID_SCOPE const GUID CLSID_DxcAssembler = {
1276 0xd728db68,
1277 0xf903,
1278 0x4f80,
1279 {0x94, 0xcd, 0xdc, 0xcf, 0x76, 0xec, 0x71, 0x51}};
1280
1281// {b9f54489-55b8-400c-ba3a-1675e4728b91}
1282CLSID_SCOPE const GUID CLSID_DxcContainerReflection = {
1283 0xb9f54489,
1284 0x55b8,
1285 0x400c,
1286 {0xba, 0x3a, 0x16, 0x75, 0xe4, 0x72, 0x8b, 0x91}};
1287
1288// {AE2CD79F-CC22-453F-9B6B-B124E7A5204C}
1289CLSID_SCOPE const GUID CLSID_DxcOptimizer = {
1290 0xae2cd79f,
1291 0xcc22,
1292 0x453f,
1293 {0x9b, 0x6b, 0xb1, 0x24, 0xe7, 0xa5, 0x20, 0x4c}};
1294
1295// {94134294-411f-4574-b4d0-8741e25240d2}
1296CLSID_SCOPE const GUID CLSID_DxcContainerBuilder = {
1297 0x94134294,
1298 0x411f,
1299 0x4574,
1300 {0xb4, 0xd0, 0x87, 0x41, 0xe2, 0x52, 0x40, 0xd2}};
1301
1302// {54621dfb-f2ce-457e-ae8c-ec355faeec7c}
1303CLSID_SCOPE const GUID CLSID_DxcPdbUtils = {
1304 0x54621dfb,
1305 0xf2ce,
1306 0x457e,
1307 {0xae, 0x8c, 0xec, 0x35, 0x5f, 0xae, 0xec, 0x7c}};
1308
1309#endif
diff --git a/contrib/dxc_2025_07_14/inc/dxcerrors.h b/contrib/dxc_2025_07_14/inc/dxcerrors.h
new file mode 100644
index 0000000..ce50b83
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/dxcerrors.h
@@ -0,0 +1,30 @@
1///////////////////////////////////////////////////////////////////////////////
2// //
3// dxcerror.h //
4// Copyright (C) Microsoft Corporation. All rights reserved. //
5// This file is distributed under the University of Illinois Open Source //
6// License. See LICENSE.TXT for details. //
7// //
8// Provides definition of error codes. //
9// //
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef __DXC_ERRORS__
13#define __DXC_ERRORS__
14
15#ifndef FACILITY_GRAPHICS
16#define FACILITY_GRAPHICS 36
17#endif
18
19#define DXC_EXCEPTION_CODE(name, status) \
20 static constexpr DWORD EXCEPTION_##name = \
21 (0xc0000000u | (FACILITY_GRAPHICS << 16) | \
22 (0xff00u | (status & 0xffu)));
23
24DXC_EXCEPTION_CODE(LOAD_LIBRARY_FAILED, 0x00u)
25DXC_EXCEPTION_CODE(NO_HMODULE, 0x01u)
26DXC_EXCEPTION_CODE(GET_PROC_FAILED, 0x02u)
27
28#undef DXC_EXCEPTION_CODE
29
30#endif
diff --git a/contrib/dxc_2025_07_14/inc/dxcisense.h b/contrib/dxc_2025_07_14/inc/dxcisense.h
new file mode 100644
index 0000000..661de16
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/dxcisense.h
@@ -0,0 +1,959 @@
1///////////////////////////////////////////////////////////////////////////////
2// //
3// dxcisense.h //
4// Copyright (C) Microsoft Corporation. All rights reserved. //
5// This file is distributed under the University of Illinois Open Source //
6// License. See LICENSE.TXT for details. //
7// //
8// Provides declarations for the DirectX Compiler IntelliSense component. //
9// //
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef __DXC_ISENSE__
13#define __DXC_ISENSE__
14
15#include "dxcapi.h"
16#ifndef _WIN32
17#include "WinAdapter.h"
18#endif
19
20typedef enum DxcGlobalOptions {
21 DxcGlobalOpt_None = 0x0,
22 DxcGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
23 DxcGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
24 DxcGlobalOpt_ThreadBackgroundPriorityForAll =
25 DxcGlobalOpt_ThreadBackgroundPriorityForIndexing |
26 DxcGlobalOpt_ThreadBackgroundPriorityForEditing
27} DxcGlobalOptions;
28
29typedef enum DxcTokenKind {
30 DxcTokenKind_Punctuation =
31 0, // A token that contains some kind of punctuation.
32 DxcTokenKind_Keyword = 1, // A language keyword.
33 DxcTokenKind_Identifier = 2, // An identifier (that is not a keyword).
34 DxcTokenKind_Literal = 3, // A numeric, string, or character literal.
35 DxcTokenKind_Comment = 4, // A comment.
36 DxcTokenKind_Unknown =
37 5, // An unknown token (possibly known to a future version).
38 DxcTokenKind_BuiltInType = 6, // A built-in type like int, void or float3.
39} DxcTokenKind;
40
41typedef enum DxcTypeKind {
42 DxcTypeKind_Invalid =
43 0, // Reprents an invalid type (e.g., where no type is available).
44 DxcTypeKind_Unexposed =
45 1, // A type whose specific kind is not exposed via this interface.
46 // Builtin types
47 DxcTypeKind_Void = 2,
48 DxcTypeKind_Bool = 3,
49 DxcTypeKind_Char_U = 4,
50 DxcTypeKind_UChar = 5,
51 DxcTypeKind_Char16 = 6,
52 DxcTypeKind_Char32 = 7,
53 DxcTypeKind_UShort = 8,
54 DxcTypeKind_UInt = 9,
55 DxcTypeKind_ULong = 10,
56 DxcTypeKind_ULongLong = 11,
57 DxcTypeKind_UInt128 = 12,
58 DxcTypeKind_Char_S = 13,
59 DxcTypeKind_SChar = 14,
60 DxcTypeKind_WChar = 15,
61 DxcTypeKind_Short = 16,
62 DxcTypeKind_Int = 17,
63 DxcTypeKind_Long = 18,
64 DxcTypeKind_LongLong = 19,
65 DxcTypeKind_Int128 = 20,
66 DxcTypeKind_Float = 21,
67 DxcTypeKind_Double = 22,
68 DxcTypeKind_LongDouble = 23,
69 DxcTypeKind_NullPtr = 24,
70 DxcTypeKind_Overload = 25,
71 DxcTypeKind_Dependent = 26,
72 DxcTypeKind_ObjCId = 27,
73 DxcTypeKind_ObjCClass = 28,
74 DxcTypeKind_ObjCSel = 29,
75 DxcTypeKind_FirstBuiltin = DxcTypeKind_Void,
76 DxcTypeKind_LastBuiltin = DxcTypeKind_ObjCSel,
77
78 DxcTypeKind_Complex = 100,
79 DxcTypeKind_Pointer = 101,
80 DxcTypeKind_BlockPointer = 102,
81 DxcTypeKind_LValueReference = 103,
82 DxcTypeKind_RValueReference = 104,
83 DxcTypeKind_Record = 105,
84 DxcTypeKind_Enum = 106,
85 DxcTypeKind_Typedef = 107,
86 DxcTypeKind_ObjCInterface = 108,
87 DxcTypeKind_ObjCObjectPointer = 109,
88 DxcTypeKind_FunctionNoProto = 110,
89 DxcTypeKind_FunctionProto = 111,
90 DxcTypeKind_ConstantArray = 112,
91 DxcTypeKind_Vector = 113,
92 DxcTypeKind_IncompleteArray = 114,
93 DxcTypeKind_VariableArray = 115,
94 DxcTypeKind_DependentSizedArray = 116,
95 DxcTypeKind_MemberPointer = 117
96} DxcTypeKind;
97
98// Describes the severity of a particular diagnostic.
99typedef enum DxcDiagnosticSeverity {
100 // A diagnostic that has been suppressed, e.g., by a command-line option.
101 DxcDiagnostic_Ignored = 0,
102
103 // This diagnostic is a note that should be attached to the previous
104 // (non-note) diagnostic.
105 DxcDiagnostic_Note = 1,
106
107 // This diagnostic indicates suspicious code that may not be wrong.
108 DxcDiagnostic_Warning = 2,
109
110 // This diagnostic indicates that the code is ill-formed.
111 DxcDiagnostic_Error = 3,
112
113 // This diagnostic indicates that the code is ill-formed such that future
114 // parser rec unlikely to produce useful results.
115 DxcDiagnostic_Fatal = 4
116
117} DxcDiagnosticSeverity;
118
119// Options to control the display of diagnostics.
120typedef enum DxcDiagnosticDisplayOptions {
121 // Display the source-location information where the diagnostic was located.
122 DxcDiagnostic_DisplaySourceLocation = 0x01,
123
124 // If displaying the source-location information of the diagnostic,
125 // also include the column number.
126 DxcDiagnostic_DisplayColumn = 0x02,
127
128 // If displaying the source-location information of the diagnostic,
129 // also include information about source ranges in a machine-parsable format.
130 DxcDiagnostic_DisplaySourceRanges = 0x04,
131
132 // Display the option name associated with this diagnostic, if any.
133 DxcDiagnostic_DisplayOption = 0x08,
134
135 // Display the category number associated with this diagnostic, if any.
136 DxcDiagnostic_DisplayCategoryId = 0x10,
137
138 // Display the category name associated with this diagnostic, if any.
139 DxcDiagnostic_DisplayCategoryName = 0x20,
140
141 // Display the severity of the diagnostic message.
142 DxcDiagnostic_DisplaySeverity = 0x200
143} DxcDiagnosticDisplayOptions;
144
145typedef enum DxcTranslationUnitFlags {
146 // Used to indicate that no special translation-unit options are needed.
147 DxcTranslationUnitFlags_None = 0x0,
148
149 // Used to indicate that the parser should construct a "detailed"
150 // preprocessing record, including all macro definitions and instantiations.
151 DxcTranslationUnitFlags_DetailedPreprocessingRecord = 0x01,
152
153 // Used to indicate that the translation unit is incomplete.
154 DxcTranslationUnitFlags_Incomplete = 0x02,
155
156 // Used to indicate that the translation unit should be built with an
157 // implicit precompiled header for the preamble.
158 DxcTranslationUnitFlags_PrecompiledPreamble = 0x04,
159
160 // Used to indicate that the translation unit should cache some
161 // code-completion results with each reparse of the source file.
162 DxcTranslationUnitFlags_CacheCompletionResults = 0x08,
163
164 // Used to indicate that the translation unit will be serialized with
165 // SaveTranslationUnit.
166 DxcTranslationUnitFlags_ForSerialization = 0x10,
167
168 // DEPRECATED
169 DxcTranslationUnitFlags_CXXChainedPCH = 0x20,
170
171 // Used to indicate that function/method bodies should be skipped while
172 // parsing.
173 DxcTranslationUnitFlags_SkipFunctionBodies = 0x40,
174
175 // Used to indicate that brief documentation comments should be
176 // included into the set of code completions returned from this translation
177 // unit.
178 DxcTranslationUnitFlags_IncludeBriefCommentsInCodeCompletion = 0x80,
179
180 // Used to indicate that compilation should occur on the caller's thread.
181 DxcTranslationUnitFlags_UseCallerThread = 0x800
182} DxcTranslationUnitFlags;
183
184typedef enum DxcCursorFormatting {
185 DxcCursorFormatting_Default =
186 0x0, // Default rules, language-insensitive formatting.
187 DxcCursorFormatting_UseLanguageOptions =
188 0x1, // Language-sensitive formatting.
189 DxcCursorFormatting_SuppressSpecifiers = 0x2, // Supresses type specifiers.
190 DxcCursorFormatting_SuppressTagKeyword =
191 0x4, // Suppressed tag keyword (eg, 'class').
192 DxcCursorFormatting_IncludeNamespaceKeyword =
193 0x8, // Include namespace keyword.
194} DxcCursorFormatting;
195
196enum DxcCursorKind {
197 /* Declarations */
198 DxcCursor_UnexposedDecl =
199 1, // A declaration whose specific kind is not exposed via this interface.
200 DxcCursor_StructDecl = 2, // A C or C++ struct.
201 DxcCursor_UnionDecl = 3, // A C or C++ union.
202 DxcCursor_ClassDecl = 4, // A C++ class.
203 DxcCursor_EnumDecl = 5, // An enumeration.
204 DxcCursor_FieldDecl = 6, // A field (in C) or non-static data member (in C++)
205 // in a struct, union, or C++ class.
206 DxcCursor_EnumConstantDecl = 7, // An enumerator constant.
207 DxcCursor_FunctionDecl = 8, // A function.
208 DxcCursor_VarDecl = 9, // A variable.
209 DxcCursor_ParmDecl = 10, // A function or method parameter.
210 DxcCursor_ObjCInterfaceDecl = 11, // An Objective-C interface.
211 DxcCursor_ObjCCategoryDecl = 12, // An Objective-C interface for a category.
212 DxcCursor_ObjCProtocolDecl = 13, // An Objective-C protocol declaration.
213 DxcCursor_ObjCPropertyDecl = 14, // An Objective-C property declaration.
214 DxcCursor_ObjCIvarDecl = 15, // An Objective-C instance variable.
215 DxcCursor_ObjCInstanceMethodDecl = 16, // An Objective-C instance method.
216 DxcCursor_ObjCClassMethodDecl = 17, // An Objective-C class method.
217 DxcCursor_ObjCImplementationDecl = 18, // An Objective-C \@implementation.
218 DxcCursor_ObjCCategoryImplDecl =
219 19, // An Objective-C \@implementation for a category.
220 DxcCursor_TypedefDecl = 20, // A typedef
221 DxcCursor_CXXMethod = 21, // A C++ class method.
222 DxcCursor_Namespace = 22, // A C++ namespace.
223 DxcCursor_LinkageSpec = 23, // A linkage specification, e.g. 'extern "C"'.
224 DxcCursor_Constructor = 24, // A C++ constructor.
225 DxcCursor_Destructor = 25, // A C++ destructor.
226 DxcCursor_ConversionFunction = 26, // A C++ conversion function.
227 DxcCursor_TemplateTypeParameter = 27, // A C++ template type parameter.
228 DxcCursor_NonTypeTemplateParameter = 28, // A C++ non-type template parameter.
229 DxcCursor_TemplateTemplateParameter =
230 29, // A C++ template template parameter.
231 DxcCursor_FunctionTemplate = 30, // A C++ function template.
232 DxcCursor_ClassTemplate = 31, // A C++ class template.
233 DxcCursor_ClassTemplatePartialSpecialization =
234 32, // A C++ class template partial specialization.
235 DxcCursor_NamespaceAlias = 33, // A C++ namespace alias declaration.
236 DxcCursor_UsingDirective = 34, // A C++ using directive.
237 DxcCursor_UsingDeclaration = 35, // A C++ using declaration.
238 DxcCursor_TypeAliasDecl = 36, // A C++ alias declaration
239 DxcCursor_ObjCSynthesizeDecl = 37, // An Objective-C \@synthesize definition.
240 DxcCursor_ObjCDynamicDecl = 38, // An Objective-C \@dynamic definition.
241 DxcCursor_CXXAccessSpecifier = 39, // An access specifier.
242
243 DxcCursor_FirstDecl = DxcCursor_UnexposedDecl,
244 DxcCursor_LastDecl = DxcCursor_CXXAccessSpecifier,
245
246 /* References */
247 DxcCursor_FirstRef = 40, /* Decl references */
248 DxcCursor_ObjCSuperClassRef = 40,
249 DxcCursor_ObjCProtocolRef = 41,
250 DxcCursor_ObjCClassRef = 42,
251 /**
252 * \brief A reference to a type declaration.
253 *
254 * A type reference occurs anywhere where a type is named but not
255 * declared. For example, given:
256 *
257 * \code
258 * typedef unsigned size_type;
259 * size_type size;
260 * \endcode
261 *
262 * The typedef is a declaration of size_type (DxcCursor_TypedefDecl),
263 * while the type of the variable "size" is referenced. The cursor
264 * referenced by the type of size is the typedef for size_type.
265 */
266 DxcCursor_TypeRef = 43, // A reference to a type declaration.
267 DxcCursor_CXXBaseSpecifier = 44,
268 DxcCursor_TemplateRef =
269 45, // A reference to a class template, function template, template
270 // template parameter, or class template partial specialization.
271 DxcCursor_NamespaceRef = 46, // A reference to a namespace or namespace alias.
272 DxcCursor_MemberRef =
273 47, // A reference to a member of a struct, union, or class that occurs in
274 // some non-expression context, e.g., a designated initializer.
275 /**
276 * \brief A reference to a labeled statement.
277 *
278 * This cursor kind is used to describe the jump to "start_over" in the
279 * goto statement in the following example:
280 *
281 * \code
282 * start_over:
283 * ++counter;
284 *
285 * goto start_over;
286 * \endcode
287 *
288 * A label reference cursor refers to a label statement.
289 */
290 DxcCursor_LabelRef = 48, // A reference to a labeled statement.
291
292 // A reference to a set of overloaded functions or function templates
293 // that has not yet been resolved to a specific function or function template.
294 //
295 // An overloaded declaration reference cursor occurs in C++ templates where
296 // a dependent name refers to a function.
297 DxcCursor_OverloadedDeclRef = 49,
298 DxcCursor_VariableRef =
299 50, // A reference to a variable that occurs in some non-expression
300 // context, e.g., a C++ lambda capture list.
301
302 DxcCursor_LastRef = DxcCursor_VariableRef,
303
304 /* Error conditions */
305 DxcCursor_FirstInvalid = 70,
306 DxcCursor_InvalidFile = 70,
307 DxcCursor_NoDeclFound = 71,
308 DxcCursor_NotImplemented = 72,
309 DxcCursor_InvalidCode = 73,
310 DxcCursor_LastInvalid = DxcCursor_InvalidCode,
311
312 /* Expressions */
313 DxcCursor_FirstExpr = 100,
314
315 /**
316 * \brief An expression whose specific kind is not exposed via this
317 * interface.
318 *
319 * Unexposed expressions have the same operations as any other kind
320 * of expression; one can extract their location information,
321 * spelling, children, etc. However, the specific kind of the
322 * expression is not reported.
323 */
324 DxcCursor_UnexposedExpr = 100, // An expression whose specific kind is not
325 // exposed via this interface.
326 DxcCursor_DeclRefExpr =
327 101, // An expression that refers to some value declaration, such as a
328 // function, varible, or enumerator.
329 DxcCursor_MemberRefExpr =
330 102, // An expression that refers to a member of a struct, union, class,
331 // Objective-C class, etc.
332 DxcCursor_CallExpr = 103, // An expression that calls a function.
333 DxcCursor_ObjCMessageExpr = 104, // An expression that sends a message to an
334 // Objective-C object or class.
335 DxcCursor_BlockExpr = 105, // An expression that represents a block literal.
336 DxcCursor_IntegerLiteral = 106, // An integer literal.
337 DxcCursor_FloatingLiteral = 107, // A floating point number literal.
338 DxcCursor_ImaginaryLiteral = 108, // An imaginary number literal.
339 DxcCursor_StringLiteral = 109, // A string literal.
340 DxcCursor_CharacterLiteral = 110, // A character literal.
341 DxcCursor_ParenExpr =
342 111, // A parenthesized expression, e.g. "(1)". This AST node is only
343 // formed if full location information is requested.
344 DxcCursor_UnaryOperator = 112, // This represents the unary-expression's
345 // (except sizeof and alignof).
346 DxcCursor_ArraySubscriptExpr = 113, // [C99 6.5.2.1] Array Subscripting.
347 DxcCursor_BinaryOperator =
348 114, // A builtin binary operation expression such as "x + y" or "x <= y".
349 DxcCursor_CompoundAssignOperator = 115, // Compound assignment such as "+=".
350 DxcCursor_ConditionalOperator = 116, // The ?: ternary operator.
351 DxcCursor_CStyleCastExpr =
352 117, // An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++
353 // [expr.cast]), which uses the syntax (Type)expr, eg: (int)f.
354 DxcCursor_CompoundLiteralExpr = 118, // [C99 6.5.2.5]
355 DxcCursor_InitListExpr = 119, // Describes an C or C++ initializer list.
356 DxcCursor_AddrLabelExpr =
357 120, // The GNU address of label extension, representing &&label.
358 DxcCursor_StmtExpr =
359 121, // This is the GNU Statement Expression extension: ({int X=4; X;})
360 DxcCursor_GenericSelectionExpr = 122, // Represents a C11 generic selection.
361
362 /** \brief Implements the GNU __null extension, which is a name for a null
363 * pointer constant that has integral type (e.g., int or long) and is the same
364 * size and alignment as a pointer.
365 *
366 * The __null extension is typically only used by system headers, which define
367 * NULL as __null in C++ rather than using 0 (which is an integer that may not
368 * match the size of a pointer).
369 */
370 DxcCursor_GNUNullExpr = 123,
371 DxcCursor_CXXStaticCastExpr = 124, // C++'s static_cast<> expression.
372 DxcCursor_CXXDynamicCastExpr = 125, // C++'s dynamic_cast<> expression.
373 DxcCursor_CXXReinterpretCastExpr =
374 126, // C++'s reinterpret_cast<> expression.
375 DxcCursor_CXXConstCastExpr = 127, // C++'s const_cast<> expression.
376
377 /** \brief Represents an explicit C++ type conversion that uses "functional"
378 * notion (C++ [expr.type.conv]).
379 *
380 * Example:
381 * \code
382 * x = int(0.5);
383 * \endcode
384 */
385 DxcCursor_CXXFunctionalCastExpr = 128,
386 DxcCursor_CXXTypeidExpr = 129, // A C++ typeid expression (C++ [expr.typeid]).
387 DxcCursor_CXXBoolLiteralExpr = 130, // [C++ 2.13.5] C++ Boolean Literal.
388 DxcCursor_CXXNullPtrLiteralExpr = 131, // [C++0x 2.14.7] C++ Pointer Literal.
389 DxcCursor_CXXThisExpr = 132, // Represents the "this" expression in C++
390 DxcCursor_CXXThrowExpr = 133, // [C++ 15] C++ Throw Expression, both 'throw'
391 // and 'throw' assignment-expression.
392 DxcCursor_CXXNewExpr = 134, // A new expression for memory allocation and
393 // constructor calls, e.g: "new CXXNewExpr(foo)".
394 DxcCursor_CXXDeleteExpr =
395 135, // A delete expression for memory deallocation and destructor calls,
396 // e.g. "delete[] pArray".
397 DxcCursor_UnaryExpr = 136, // A unary expression.
398 DxcCursor_ObjCStringLiteral =
399 137, // An Objective-C string literal i.e. @"foo".
400 DxcCursor_ObjCEncodeExpr = 138, // An Objective-C \@encode expression.
401 DxcCursor_ObjCSelectorExpr = 139, // An Objective-C \@selector expression.
402 DxcCursor_ObjCProtocolExpr = 140, // An Objective-C \@protocol expression.
403
404 /** \brief An Objective-C "bridged" cast expression, which casts between
405 * Objective-C pointers and C pointers, transferring ownership in the process.
406 *
407 * \code
408 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
409 * \endcode
410 */
411 DxcCursor_ObjCBridgedCastExpr = 141,
412
413 /** \brief Represents a C++0x pack expansion that produces a sequence of
414 * expressions.
415 *
416 * A pack expansion expression contains a pattern (which itself is an
417 * expression) followed by an ellipsis. For example:
418 *
419 * \code
420 * template<typename F, typename ...Types>
421 * void forward(F f, Types &&...args) {
422 * f(static_cast<Types&&>(args)...);
423 * }
424 * \endcode
425 */
426 DxcCursor_PackExpansionExpr = 142,
427
428 /** \brief Represents an expression that computes the length of a parameter
429 * pack.
430 *
431 * \code
432 * template<typename ...Types>
433 * struct count {
434 * static const unsigned value = sizeof...(Types);
435 * };
436 * \endcode
437 */
438 DxcCursor_SizeOfPackExpr = 143,
439
440 /* \brief Represents a C++ lambda expression that produces a local function
441 * object.
442 *
443 * \code
444 * void abssort(float *x, unsigned N) {
445 * std::sort(x, x + N,
446 * [](float a, float b) {
447 * return std::abs(a) < std::abs(b);
448 * });
449 * }
450 * \endcode
451 */
452 DxcCursor_LambdaExpr = 144,
453 DxcCursor_ObjCBoolLiteralExpr = 145, // Objective-c Boolean Literal.
454 DxcCursor_ObjCSelfExpr =
455 146, // Represents the "self" expression in a ObjC method.
456 DxcCursor_LastExpr = DxcCursor_ObjCSelfExpr,
457
458 /* Statements */
459 DxcCursor_FirstStmt = 200,
460 /**
461 * \brief A statement whose specific kind is not exposed via this
462 * interface.
463 *
464 * Unexposed statements have the same operations as any other kind of
465 * statement; one can extract their location information, spelling,
466 * children, etc. However, the specific kind of the statement is not
467 * reported.
468 */
469 DxcCursor_UnexposedStmt = 200,
470
471 /** \brief A labelled statement in a function.
472 *
473 * This cursor kind is used to describe the "start_over:" label statement in
474 * the following example:
475 *
476 * \code
477 * start_over:
478 * ++counter;
479 * \endcode
480 *
481 */
482 DxcCursor_LabelStmt = 201,
483 DxcCursor_CompoundStmt =
484 202, // A group of statements like { stmt stmt }. This cursor kind is used
485 // to describe compound statements, e.g. function bodies.
486 DxcCursor_CaseStmt = 203, // A case statement.
487 DxcCursor_DefaultStmt = 204, // A default statement.
488 DxcCursor_IfStmt = 205, // An if statement
489 DxcCursor_SwitchStmt = 206, // A switch statement.
490 DxcCursor_WhileStmt = 207, // A while statement.
491 DxcCursor_DoStmt = 208, // A do statement.
492 DxcCursor_ForStmt = 209, // A for statement.
493 DxcCursor_GotoStmt = 210, // A goto statement.
494 DxcCursor_IndirectGotoStmt = 211, // An indirect goto statement.
495 DxcCursor_ContinueStmt = 212, // A continue statement.
496 DxcCursor_BreakStmt = 213, // A break statement.
497 DxcCursor_ReturnStmt = 214, // A return statement.
498 DxcCursor_GCCAsmStmt = 215, // A GCC inline assembly statement extension.
499 DxcCursor_AsmStmt = DxcCursor_GCCAsmStmt,
500
501 DxcCursor_ObjCAtTryStmt =
502 216, // Objective-C's overall \@try-\@catch-\@finally statement.
503 DxcCursor_ObjCAtCatchStmt = 217, // Objective-C's \@catch statement.
504 DxcCursor_ObjCAtFinallyStmt = 218, // Objective-C's \@finally statement.
505 DxcCursor_ObjCAtThrowStmt = 219, // Objective-C's \@throw statement.
506 DxcCursor_ObjCAtSynchronizedStmt =
507 220, // Objective-C's \@synchronized statement.
508 DxcCursor_ObjCAutoreleasePoolStmt =
509 221, // Objective-C's autorelease pool statement.
510 DxcCursor_ObjCForCollectionStmt = 222, // Objective-C's collection statement.
511
512 DxcCursor_CXXCatchStmt = 223, // C++'s catch statement.
513 DxcCursor_CXXTryStmt = 224, // C++'s try statement.
514 DxcCursor_CXXForRangeStmt = 225, // C++'s for (* : *) statement.
515
516 DxcCursor_SEHTryStmt =
517 226, // Windows Structured Exception Handling's try statement.
518 DxcCursor_SEHExceptStmt =
519 227, // Windows Structured Exception Handling's except statement.
520 DxcCursor_SEHFinallyStmt =
521 228, // Windows Structured Exception Handling's finally statement.
522
523 DxcCursor_MSAsmStmt = 229, // A MS inline assembly statement extension.
524 DxcCursor_NullStmt = 230, // The null satement ";": C99 6.8.3p3.
525 DxcCursor_DeclStmt = 231, // Adaptor class for mixing declarations with
526 // statements and expressions.
527 DxcCursor_OMPParallelDirective = 232, // OpenMP parallel directive.
528 DxcCursor_OMPSimdDirective = 233, // OpenMP SIMD directive.
529 DxcCursor_OMPForDirective = 234, // OpenMP for directive.
530 DxcCursor_OMPSectionsDirective = 235, // OpenMP sections directive.
531 DxcCursor_OMPSectionDirective = 236, // OpenMP section directive.
532 DxcCursor_OMPSingleDirective = 237, // OpenMP single directive.
533 DxcCursor_OMPParallelForDirective = 238, // OpenMP parallel for directive.
534 DxcCursor_OMPParallelSectionsDirective =
535 239, // OpenMP parallel sections directive.
536 DxcCursor_OMPTaskDirective = 240, // OpenMP task directive.
537 DxcCursor_OMPMasterDirective = 241, // OpenMP master directive.
538 DxcCursor_OMPCriticalDirective = 242, // OpenMP critical directive.
539 DxcCursor_OMPTaskyieldDirective = 243, // OpenMP taskyield directive.
540 DxcCursor_OMPBarrierDirective = 244, // OpenMP barrier directive.
541 DxcCursor_OMPTaskwaitDirective = 245, // OpenMP taskwait directive.
542 DxcCursor_OMPFlushDirective = 246, // OpenMP flush directive.
543 DxcCursor_SEHLeaveStmt =
544 247, // Windows Structured Exception Handling's leave statement.
545 DxcCursor_OMPOrderedDirective = 248, // OpenMP ordered directive.
546 DxcCursor_OMPAtomicDirective = 249, // OpenMP atomic directive.
547 DxcCursor_OMPForSimdDirective = 250, // OpenMP for SIMD directive.
548 DxcCursor_OMPParallelForSimdDirective =
549 251, // OpenMP parallel for SIMD directive.
550 DxcCursor_OMPTargetDirective = 252, // OpenMP target directive.
551 DxcCursor_OMPTeamsDirective = 253, // OpenMP teams directive.
552 DxcCursor_OMPTaskgroupDirective = 254, // OpenMP taskgroup directive.
553 DxcCursor_OMPCancellationPointDirective =
554 255, // OpenMP cancellation point directive.
555 DxcCursor_OMPCancelDirective = 256, // OpenMP cancel directive.
556 DxcCursor_LastStmt = DxcCursor_OMPCancelDirective,
557
558 DxcCursor_TranslationUnit =
559 300, // Cursor that represents the translation unit itself.
560
561 /* Attributes */
562 DxcCursor_FirstAttr = 400,
563 /**
564 * \brief An attribute whose specific kind is not exposed via this
565 * interface.
566 */
567 DxcCursor_UnexposedAttr = 400,
568
569 DxcCursor_IBActionAttr = 401,
570 DxcCursor_IBOutletAttr = 402,
571 DxcCursor_IBOutletCollectionAttr = 403,
572 DxcCursor_CXXFinalAttr = 404,
573 DxcCursor_CXXOverrideAttr = 405,
574 DxcCursor_AnnotateAttr = 406,
575 DxcCursor_AsmLabelAttr = 407,
576 DxcCursor_PackedAttr = 408,
577 DxcCursor_PureAttr = 409,
578 DxcCursor_ConstAttr = 410,
579 DxcCursor_NoDuplicateAttr = 411,
580 DxcCursor_CUDAConstantAttr = 412,
581 DxcCursor_CUDADeviceAttr = 413,
582 DxcCursor_CUDAGlobalAttr = 414,
583 DxcCursor_CUDAHostAttr = 415,
584 DxcCursor_CUDASharedAttr = 416,
585 DxcCursor_LastAttr = DxcCursor_CUDASharedAttr,
586
587 /* Preprocessing */
588 DxcCursor_PreprocessingDirective = 500,
589 DxcCursor_MacroDefinition = 501,
590 DxcCursor_MacroExpansion = 502,
591 DxcCursor_MacroInstantiation = DxcCursor_MacroExpansion,
592 DxcCursor_InclusionDirective = 503,
593 DxcCursor_FirstPreprocessing = DxcCursor_PreprocessingDirective,
594 DxcCursor_LastPreprocessing = DxcCursor_InclusionDirective,
595
596 /* Extra Declarations */
597 /**
598 * \brief A module import declaration.
599 */
600 DxcCursor_ModuleImportDecl = 600,
601 DxcCursor_FirstExtraDecl = DxcCursor_ModuleImportDecl,
602 DxcCursor_LastExtraDecl = DxcCursor_ModuleImportDecl
603};
604
605enum DxcCursorKindFlags {
606 DxcCursorKind_None = 0,
607 DxcCursorKind_Declaration = 0x1,
608 DxcCursorKind_Reference = 0x2,
609 DxcCursorKind_Expression = 0x4,
610 DxcCursorKind_Statement = 0x8,
611 DxcCursorKind_Attribute = 0x10,
612 DxcCursorKind_Invalid = 0x20,
613 DxcCursorKind_TranslationUnit = 0x40,
614 DxcCursorKind_Preprocessing = 0x80,
615 DxcCursorKind_Unexposed = 0x100,
616};
617
618enum DxcCodeCompleteFlags {
619 DxcCodeCompleteFlags_None = 0,
620 DxcCodeCompleteFlags_IncludeMacros = 0x1,
621 DxcCodeCompleteFlags_IncludeCodePatterns = 0x2,
622 DxcCodeCompleteFlags_IncludeBriefComments = 0x4,
623};
624
625enum DxcCompletionChunkKind {
626 DxcCompletionChunk_Optional = 0,
627 DxcCompletionChunk_TypedText = 1,
628 DxcCompletionChunk_Text = 2,
629 DxcCompletionChunk_Placeholder = 3,
630 DxcCompletionChunk_Informative = 4,
631 DxcCompletionChunk_CurrentParameter = 5,
632 DxcCompletionChunk_LeftParen = 6,
633 DxcCompletionChunk_RightParen = 7,
634 DxcCompletionChunk_LeftBracket = 8,
635 DxcCompletionChunk_RightBracket = 9,
636 DxcCompletionChunk_LeftBrace = 10,
637 DxcCompletionChunk_RightBrace = 11,
638 DxcCompletionChunk_LeftAngle = 12,
639 DxcCompletionChunk_RightAngle = 13,
640 DxcCompletionChunk_Comma = 14,
641 DxcCompletionChunk_ResultType = 15,
642 DxcCompletionChunk_Colon = 16,
643 DxcCompletionChunk_SemiColon = 17,
644 DxcCompletionChunk_Equal = 18,
645 DxcCompletionChunk_HorizontalSpace = 19,
646 DxcCompletionChunk_VerticalSpace = 20,
647};
648
649struct IDxcCursor;
650struct IDxcDiagnostic;
651struct IDxcFile;
652struct IDxcInclusion;
653struct IDxcIntelliSense;
654struct IDxcIndex;
655struct IDxcSourceLocation;
656struct IDxcSourceRange;
657struct IDxcToken;
658struct IDxcTranslationUnit;
659struct IDxcType;
660struct IDxcUnsavedFile;
661struct IDxcCodeCompleteResults;
662struct IDxcCompletionResult;
663struct IDxcCompletionString;
664
665CROSS_PLATFORM_UUIDOF(IDxcCursor, "1467b985-288d-4d2a-80c1-ef89c42c40bc")
666struct IDxcCursor : public IUnknown {
667 virtual HRESULT STDMETHODCALLTYPE
668 GetExtent(_Outptr_result_nullonfailure_ IDxcSourceRange **pRange) = 0;
669 virtual HRESULT STDMETHODCALLTYPE
670 GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
671 virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcCursorKind *pResult) = 0;
672 virtual HRESULT STDMETHODCALLTYPE
673 GetKindFlags(_Out_ DxcCursorKindFlags *pResult) = 0;
674 virtual HRESULT STDMETHODCALLTYPE
675 GetSemanticParent(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
676 virtual HRESULT STDMETHODCALLTYPE
677 GetLexicalParent(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
678 virtual HRESULT STDMETHODCALLTYPE
679 GetCursorType(_Outptr_result_nullonfailure_ IDxcType **pResult) = 0;
680 virtual HRESULT STDMETHODCALLTYPE GetNumArguments(_Out_ int *pResult) = 0;
681 virtual HRESULT STDMETHODCALLTYPE GetArgumentAt(
682 int index, _Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
683 virtual HRESULT STDMETHODCALLTYPE
684 GetReferencedCursor(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
685 /// <summary>For a cursor that is either a reference to or a declaration of
686 /// some entity, retrieve a cursor that describes the definition of that
687 /// entity.</summary> <remarks>Some entities can be declared multiple times
688 /// within a translation unit, but only one of those declarations can also be
689 /// a definition.</remarks> <returns>A cursor to the definition of this
690 /// entity; nullptr if there is no definition in this translation
691 /// unit.</returns>
692 virtual HRESULT STDMETHODCALLTYPE
693 GetDefinitionCursor(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
694 virtual HRESULT STDMETHODCALLTYPE
695 FindReferencesInFile(_In_ IDxcFile *file, unsigned skip, unsigned top,
696 _Out_ unsigned *pResultLength,
697 _Outptr_result_buffer_maybenull_(*pResultLength)
698 IDxcCursor ***pResult) = 0;
699 /// <summary>Gets the name for the entity references by the cursor, e.g. foo
700 /// for an 'int foo' variable.</summary>
701 virtual HRESULT STDMETHODCALLTYPE
702 GetSpelling(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
703 virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcCursor *other,
704 _Out_ BOOL *pResult) = 0;
705 virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pResult) = 0;
706 virtual HRESULT STDMETHODCALLTYPE IsDefinition(_Out_ BOOL *pResult) = 0;
707 /// <summary>Gets the display name for the cursor, including e.g. parameter
708 /// types for a function.</summary>
709 virtual HRESULT STDMETHODCALLTYPE GetDisplayName(_Out_ BSTR *pResult) = 0;
710 /// <summary>Gets the qualified name for the symbol the cursor refers
711 /// to.</summary>
712 virtual HRESULT STDMETHODCALLTYPE GetQualifiedName(
713 BOOL includeTemplateArgs, _Outptr_result_maybenull_ BSTR *pResult) = 0;
714 /// <summary>Gets a name for the cursor, applying the specified formatting
715 /// flags.</summary>
716 virtual HRESULT STDMETHODCALLTYPE
717 GetFormattedName(DxcCursorFormatting formatting,
718 _Outptr_result_maybenull_ BSTR *pResult) = 0;
719 /// <summary>Gets children in pResult up to top elements.</summary>
720 virtual HRESULT STDMETHODCALLTYPE
721 GetChildren(unsigned skip, unsigned top, _Out_ unsigned *pResultLength,
722 _Outptr_result_buffer_maybenull_(*pResultLength)
723 IDxcCursor ***pResult) = 0;
724 /// <summary>Gets the cursor following a location within a compound
725 /// cursor.</summary>
726 virtual HRESULT STDMETHODCALLTYPE
727 GetSnappedChild(_In_ IDxcSourceLocation *location,
728 _Outptr_result_maybenull_ IDxcCursor **pResult) = 0;
729};
730
731CROSS_PLATFORM_UUIDOF(IDxcDiagnostic, "4f76b234-3659-4d33-99b0-3b0db994b564")
732struct IDxcDiagnostic : public IUnknown {
733 virtual HRESULT STDMETHODCALLTYPE
734 FormatDiagnostic(DxcDiagnosticDisplayOptions options,
735 _Outptr_result_maybenull_ LPSTR *pResult) = 0;
736 virtual HRESULT STDMETHODCALLTYPE
737 GetSeverity(_Out_ DxcDiagnosticSeverity *pResult) = 0;
738 virtual HRESULT STDMETHODCALLTYPE
739 GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
740 virtual HRESULT STDMETHODCALLTYPE
741 GetSpelling(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
742 virtual HRESULT STDMETHODCALLTYPE
743 GetCategoryText(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
744 virtual HRESULT STDMETHODCALLTYPE GetNumRanges(_Out_ unsigned *pResult) = 0;
745 virtual HRESULT STDMETHODCALLTYPE
746 GetRangeAt(unsigned index,
747 _Outptr_result_nullonfailure_ IDxcSourceRange **pResult) = 0;
748 virtual HRESULT STDMETHODCALLTYPE GetNumFixIts(_Out_ unsigned *pResult) = 0;
749 virtual HRESULT STDMETHODCALLTYPE
750 GetFixItAt(unsigned index,
751 _Outptr_result_nullonfailure_ IDxcSourceRange **pReplacementRange,
752 _Outptr_result_maybenull_ LPSTR *pText) = 0;
753};
754
755CROSS_PLATFORM_UUIDOF(IDxcFile, "bb2fca9e-1478-47ba-b08c-2c502ada4895")
756struct IDxcFile : public IUnknown {
757 /// <summary>Gets the file name for this file.</summary>
758 virtual HRESULT STDMETHODCALLTYPE
759 GetName(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
760 /// <summary>Checks whether this file is equal to the other specified
761 /// file.</summary>
762 virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcFile *other,
763 _Out_ BOOL *pResult) = 0;
764};
765
766CROSS_PLATFORM_UUIDOF(IDxcInclusion, "0c364d65-df44-4412-888e-4e552fc5e3d6")
767struct IDxcInclusion : public IUnknown {
768 virtual HRESULT STDMETHODCALLTYPE
769 GetIncludedFile(_Outptr_result_nullonfailure_ IDxcFile **pResult) = 0;
770 virtual HRESULT STDMETHODCALLTYPE GetStackLength(_Out_ unsigned *pResult) = 0;
771 virtual HRESULT STDMETHODCALLTYPE
772 GetStackItem(unsigned index,
773 _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
774};
775
776CROSS_PLATFORM_UUIDOF(IDxcIntelliSense, "b1f99513-46d6-4112-8169-dd0d6053f17d")
777struct IDxcIntelliSense : public IUnknown {
778 virtual HRESULT STDMETHODCALLTYPE
779 CreateIndex(_Outptr_result_nullonfailure_ IDxcIndex **index) = 0;
780 virtual HRESULT STDMETHODCALLTYPE GetNullLocation(
781 _Outptr_result_nullonfailure_ IDxcSourceLocation **location) = 0;
782 virtual HRESULT STDMETHODCALLTYPE
783 GetNullRange(_Outptr_result_nullonfailure_ IDxcSourceRange **location) = 0;
784 virtual HRESULT STDMETHODCALLTYPE
785 GetRange(_In_ IDxcSourceLocation *start, _In_ IDxcSourceLocation *end,
786 _Outptr_result_nullonfailure_ IDxcSourceRange **location) = 0;
787 virtual HRESULT STDMETHODCALLTYPE GetDefaultDiagnosticDisplayOptions(
788 _Out_ DxcDiagnosticDisplayOptions *pValue) = 0;
789 virtual HRESULT STDMETHODCALLTYPE
790 GetDefaultEditingTUOptions(_Out_ DxcTranslationUnitFlags *pValue) = 0;
791 virtual HRESULT STDMETHODCALLTYPE CreateUnsavedFile(
792 _In_ LPCSTR fileName, _In_ LPCSTR contents, unsigned contentLength,
793 _Outptr_result_nullonfailure_ IDxcUnsavedFile **pResult) = 0;
794};
795
796CROSS_PLATFORM_UUIDOF(IDxcIndex, "937824a0-7f5a-4815-9ba7-7fc0424f4173")
797struct IDxcIndex : public IUnknown {
798 virtual HRESULT STDMETHODCALLTYPE
799 SetGlobalOptions(DxcGlobalOptions options) = 0;
800 virtual HRESULT STDMETHODCALLTYPE
801 GetGlobalOptions(_Out_ DxcGlobalOptions *options) = 0;
802 virtual HRESULT STDMETHODCALLTYPE ParseTranslationUnit(
803 _In_z_ const char *source_filename,
804 _In_count_(num_command_line_args) const char *const *command_line_args,
805 int num_command_line_args,
806 _In_count_(num_unsaved_files) IDxcUnsavedFile **unsaved_files,
807 unsigned num_unsaved_files, DxcTranslationUnitFlags options,
808 _Out_ IDxcTranslationUnit **pTranslationUnit) = 0;
809};
810
811CROSS_PLATFORM_UUIDOF(IDxcSourceLocation,
812 "8e7ddf1c-d7d3-4d69-b286-85fccba1e0cf")
813struct IDxcSourceLocation : public IUnknown {
814 virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcSourceLocation *other,
815 _Out_ BOOL *pResult) = 0;
816 virtual HRESULT STDMETHODCALLTYPE GetSpellingLocation(
817 _Outptr_opt_ IDxcFile **pFile, _Out_opt_ unsigned *pLine,
818 _Out_opt_ unsigned *pCol, _Out_opt_ unsigned *pOffset) = 0;
819 virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pResult) = 0;
820 virtual HRESULT STDMETHODCALLTYPE
821 GetPresumedLocation(_Outptr_opt_ LPSTR *pFilename, _Out_opt_ unsigned *pLine,
822 _Out_opt_ unsigned *pCol) = 0;
823};
824
825CROSS_PLATFORM_UUIDOF(IDxcSourceRange, "f1359b36-a53f-4e81-b514-b6b84122a13f")
826struct IDxcSourceRange : public IUnknown {
827 virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pValue) = 0;
828 virtual HRESULT STDMETHODCALLTYPE
829 GetStart(_Out_ IDxcSourceLocation **pValue) = 0;
830 virtual HRESULT STDMETHODCALLTYPE
831 GetEnd(_Out_ IDxcSourceLocation **pValue) = 0;
832 virtual HRESULT STDMETHODCALLTYPE GetOffsets(_Out_ unsigned *startOffset,
833 _Out_ unsigned *endOffset) = 0;
834};
835
836CROSS_PLATFORM_UUIDOF(IDxcToken, "7f90b9ff-a275-4932-97d8-3cfd234482a2")
837struct IDxcToken : public IUnknown {
838 virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTokenKind *pValue) = 0;
839 virtual HRESULT STDMETHODCALLTYPE
840 GetLocation(_Out_ IDxcSourceLocation **pValue) = 0;
841 virtual HRESULT STDMETHODCALLTYPE
842 GetExtent(_Out_ IDxcSourceRange **pValue) = 0;
843 virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Out_ LPSTR *pValue) = 0;
844};
845
846CROSS_PLATFORM_UUIDOF(IDxcTranslationUnit,
847 "9677dee0-c0e5-46a1-8b40-3db3168be63d")
848struct IDxcTranslationUnit : public IUnknown {
849 virtual HRESULT STDMETHODCALLTYPE GetCursor(_Out_ IDxcCursor **pCursor) = 0;
850 virtual HRESULT STDMETHODCALLTYPE
851 Tokenize(_In_ IDxcSourceRange *range,
852 _Outptr_result_buffer_maybenull_(*pTokenCount) IDxcToken ***pTokens,
853 _Out_ unsigned *pTokenCount) = 0;
854 virtual HRESULT STDMETHODCALLTYPE
855 GetLocation(_In_ IDxcFile *file, unsigned line, unsigned column,
856 _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
857 virtual HRESULT STDMETHODCALLTYPE
858 GetNumDiagnostics(_Out_ unsigned *pValue) = 0;
859 virtual HRESULT STDMETHODCALLTYPE
860 GetDiagnostic(unsigned index,
861 _Outptr_result_nullonfailure_ IDxcDiagnostic **pValue) = 0;
862 virtual HRESULT STDMETHODCALLTYPE
863 GetFile(_In_ const char *name,
864 _Outptr_result_nullonfailure_ IDxcFile **pResult) = 0;
865 virtual HRESULT STDMETHODCALLTYPE
866 GetFileName(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
867 virtual HRESULT STDMETHODCALLTYPE Reparse(_In_count_(num_unsaved_files)
868 IDxcUnsavedFile **unsaved_files,
869 unsigned num_unsaved_files) = 0;
870 virtual HRESULT STDMETHODCALLTYPE
871 GetCursorForLocation(_In_ IDxcSourceLocation *location,
872 _Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
873 virtual HRESULT STDMETHODCALLTYPE GetLocationForOffset(
874 _In_ IDxcFile *file, unsigned offset,
875 _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
876 virtual HRESULT STDMETHODCALLTYPE GetSkippedRanges(
877 _In_ IDxcFile *file, _Out_ unsigned *pResultCount,
878 _Outptr_result_buffer_(*pResultCount) IDxcSourceRange ***pResult) = 0;
879 virtual HRESULT STDMETHODCALLTYPE
880 GetDiagnosticDetails(unsigned index, DxcDiagnosticDisplayOptions options,
881 _Out_ unsigned *errorCode, _Out_ unsigned *errorLine,
882 _Out_ unsigned *errorColumn, _Out_ BSTR *errorFile,
883 _Out_ unsigned *errorOffset, _Out_ unsigned *errorLength,
884 _Out_ BSTR *errorMessage) = 0;
885 virtual HRESULT STDMETHODCALLTYPE GetInclusionList(
886 _Out_ unsigned *pResultCount,
887 _Outptr_result_buffer_(*pResultCount) IDxcInclusion ***pResult) = 0;
888 virtual HRESULT STDMETHODCALLTYPE CodeCompleteAt(
889 _In_ const char *fileName, unsigned line, unsigned column,
890 _In_ IDxcUnsavedFile **pUnsavedFiles, unsigned numUnsavedFiles,
891 _In_ DxcCodeCompleteFlags options,
892 _Outptr_result_nullonfailure_ IDxcCodeCompleteResults **pResult) = 0;
893};
894
895CROSS_PLATFORM_UUIDOF(IDxcType, "2ec912fd-b144-4a15-ad0d-1c5439c81e46")
896struct IDxcType : public IUnknown {
897 virtual HRESULT STDMETHODCALLTYPE
898 GetSpelling(_Outptr_result_z_ LPSTR *pResult) = 0;
899 virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcType *other,
900 _Out_ BOOL *pResult) = 0;
901 virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTypeKind *pResult) = 0;
902};
903
904CROSS_PLATFORM_UUIDOF(IDxcUnsavedFile, "8ec00f98-07d0-4e60-9d7c-5a50b5b0017f")
905struct IDxcUnsavedFile : public IUnknown {
906 virtual HRESULT STDMETHODCALLTYPE
907 GetFileName(_Outptr_result_z_ LPSTR *pFileName) = 0;
908 virtual HRESULT STDMETHODCALLTYPE
909 GetContents(_Outptr_result_z_ LPSTR *pContents) = 0;
910 virtual HRESULT STDMETHODCALLTYPE GetLength(_Out_ unsigned *pLength) = 0;
911};
912
913CROSS_PLATFORM_UUIDOF(IDxcCodeCompleteResults,
914 "1E06466A-FD8B-45F3-A78F-8A3F76EBB552")
915struct IDxcCodeCompleteResults : public IUnknown {
916 virtual HRESULT STDMETHODCALLTYPE GetNumResults(_Out_ unsigned *pResult) = 0;
917 virtual HRESULT STDMETHODCALLTYPE
918 GetResultAt(unsigned index,
919 _Outptr_result_nullonfailure_ IDxcCompletionResult **pResult) = 0;
920};
921
922CROSS_PLATFORM_UUIDOF(IDxcCompletionResult,
923 "943C0588-22D0-4784-86FC-701F802AC2B6")
924struct IDxcCompletionResult : public IUnknown {
925 virtual HRESULT STDMETHODCALLTYPE
926 GetCursorKind(_Out_ DxcCursorKind *pResult) = 0;
927 virtual HRESULT STDMETHODCALLTYPE GetCompletionString(
928 _Outptr_result_nullonfailure_ IDxcCompletionString **pResult) = 0;
929};
930
931CROSS_PLATFORM_UUIDOF(IDxcCompletionString,
932 "06B51E0F-A605-4C69-A110-CD6E14B58EEC")
933struct IDxcCompletionString : public IUnknown {
934 virtual HRESULT STDMETHODCALLTYPE
935 GetNumCompletionChunks(_Out_ unsigned *pResult) = 0;
936 virtual HRESULT STDMETHODCALLTYPE GetCompletionChunkKind(
937 unsigned chunkNumber, _Out_ DxcCompletionChunkKind *pResult) = 0;
938 virtual HRESULT STDMETHODCALLTYPE
939 GetCompletionChunkText(unsigned chunkNumber, _Out_ LPSTR *pResult) = 0;
940};
941
942// Fun fact: 'extern' is required because const is by default static in C++, so
943// CLSID_DxcIntelliSense is not visible externally (this is OK in C, since const
944// is not by default static in C)
945
946#ifdef _MSC_VER
947#define CLSID_SCOPE __declspec(selectany) extern
948#else
949#define CLSID_SCOPE
950#endif
951
952CLSID_SCOPE const CLSID
953 CLSID_DxcIntelliSense = {/* 3047833c-d1c0-4b8e-9d40-102878605985 */
954 0x3047833c,
955 0xd1c0,
956 0x4b8e,
957 {0x9d, 0x40, 0x10, 0x28, 0x78, 0x60, 0x59, 0x85}};
958
959#endif
diff --git a/contrib/dxc_2025_07_14/inc/hlsl/LICENSE.txt b/contrib/dxc_2025_07_14/inc/hlsl/LICENSE.txt
new file mode 100644
index 0000000..94472c3
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/hlsl/LICENSE.txt
@@ -0,0 +1,222 @@
1==============================================================================
2The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
3==============================================================================
4
5 Apache License
6 Version 2.0, January 2004
7 http://www.apache.org/licenses/
8
9 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
10
11 1. Definitions.
12
13 "License" shall mean the terms and conditions for use, reproduction,
14 and distribution as defined by Sections 1 through 9 of this document.
15
16 "Licensor" shall mean the copyright owner or entity authorized by
17 the copyright owner that is granting the License.
18
19 "Legal Entity" shall mean the union of the acting entity and all
20 other entities that control, are controlled by, or are under common
21 control with that entity. For the purposes of this definition,
22 "control" means (i) the power, direct or indirect, to cause the
23 direction or management of such entity, whether by contract or
24 otherwise, or (ii) ownership of fifty percent (50%) or more of the
25 outstanding shares, or (iii) beneficial ownership of such entity.
26
27 "You" (or "Your") shall mean an individual or Legal Entity
28 exercising permissions granted by this License.
29
30 "Source" form shall mean the preferred form for making modifications,
31 including but not limited to software source code, documentation
32 source, and configuration files.
33
34 "Object" form shall mean any form resulting from mechanical
35 transformation or translation of a Source form, including but
36 not limited to compiled object code, generated documentation,
37 and conversions to other media types.
38
39 "Work" shall mean the work of authorship, whether in Source or
40 Object form, made available under the License, as indicated by a
41 copyright notice that is included in or attached to the work
42 (an example is provided in the Appendix below).
43
44 "Derivative Works" shall mean any work, whether in Source or Object
45 form, that is based on (or derived from) the Work and for which the
46 editorial revisions, annotations, elaborations, or other modifications
47 represent, as a whole, an original work of authorship. For the purposes
48 of this License, Derivative Works shall not include works that remain
49 separable from, or merely link (or bind by name) to the interfaces of,
50 the Work and Derivative Works thereof.
51
52 "Contribution" shall mean any work of authorship, including
53 the original version of the Work and any modifications or additions
54 to that Work or Derivative Works thereof, that is intentionally
55 submitted to Licensor for inclusion in the Work by the copyright owner
56 or by an individual or Legal Entity authorized to submit on behalf of
57 the copyright owner. For the purposes of this definition, "submitted"
58 means any form of electronic, verbal, or written communication sent
59 to the Licensor or its representatives, including but not limited to
60 communication on electronic mailing lists, source code control systems,
61 and issue tracking systems that are managed by, or on behalf of, the
62 Licensor for the purpose of discussing and improving the Work, but
63 excluding communication that is conspicuously marked or otherwise
64 designated in writing by the copyright owner as "Not a Contribution."
65
66 "Contributor" shall mean Licensor and any individual or Legal Entity
67 on behalf of whom a Contribution has been received by Licensor and
68 subsequently incorporated within the Work.
69
70 2. Grant of Copyright License. Subject to the terms and conditions of
71 this License, each Contributor hereby grants to You a perpetual,
72 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73 copyright license to reproduce, prepare Derivative Works of,
74 publicly display, publicly perform, sublicense, and distribute the
75 Work and such Derivative Works in Source or Object form.
76
77 3. Grant of Patent License. Subject to the terms and conditions of
78 this License, each Contributor hereby grants to You a perpetual,
79 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80 (except as stated in this section) patent license to make, have made,
81 use, offer to sell, sell, import, and otherwise transfer the Work,
82 where such license applies only to those patent claims licensable
83 by such Contributor that are necessarily infringed by their
84 Contribution(s) alone or by combination of their Contribution(s)
85 with the Work to which such Contribution(s) was submitted. If You
86 institute patent litigation against any entity (including a
87 cross-claim or counterclaim in a lawsuit) alleging that the Work
88 or a Contribution incorporated within the Work constitutes direct
89 or contributory patent infringement, then any patent licenses
90 granted to You under this License for that Work shall terminate
91 as of the date such litigation is filed.
92
93 4. Redistribution. You may reproduce and distribute copies of the
94 Work or Derivative Works thereof in any medium, with or without
95 modifications, and in Source or Object form, provided that You
96 meet the following conditions:
97
98 (a) You must give any other recipients of the Work or
99 Derivative Works a copy of this License; and
100
101 (b) You must cause any modified files to carry prominent notices
102 stating that You changed the files; and
103
104 (c) You must retain, in the Source form of any Derivative Works
105 that You distribute, all copyright, patent, trademark, and
106 attribution notices from the Source form of the Work,
107 excluding those notices that do not pertain to any part of
108 the Derivative Works; and
109
110 (d) If the Work includes a "NOTICE" text file as part of its
111 distribution, then any Derivative Works that You distribute must
112 include a readable copy of the attribution notices contained
113 within such NOTICE file, excluding those notices that do not
114 pertain to any part of the Derivative Works, in at least one
115 of the following places: within a NOTICE text file distributed
116 as part of the Derivative Works; within the Source form or
117 documentation, if provided along with the Derivative Works; or,
118 within a display generated by the Derivative Works, if and
119 wherever such third-party notices normally appear. The contents
120 of the NOTICE file are for informational purposes only and
121 do not modify the License. You may add Your own attribution
122 notices within Derivative Works that You distribute, alongside
123 or as an addendum to the NOTICE text from the Work, provided
124 that such additional attribution notices cannot be construed
125 as modifying the License.
126
127 You may add Your own copyright statement to Your modifications and
128 may provide additional or different license terms and conditions
129 for use, reproduction, or distribution of Your modifications, or
130 for any such Derivative Works as a whole, provided Your use,
131 reproduction, and distribution of the Work otherwise complies with
132 the conditions stated in this License.
133
134 5. Submission of Contributions. Unless You explicitly state otherwise,
135 any Contribution intentionally submitted for inclusion in the Work
136 by You to the Licensor shall be under the terms and conditions of
137 this License, without any additional terms or conditions.
138 Notwithstanding the above, nothing herein shall supersede or modify
139 the terms of any separate license agreement you may have executed
140 with Licensor regarding such Contributions.
141
142 6. Trademarks. This License does not grant permission to use the trade
143 names, trademarks, service marks, or product names of the Licensor,
144 except as required for reasonable and customary use in describing the
145 origin of the Work and reproducing the content of the NOTICE file.
146
147 7. Disclaimer of Warranty. Unless required by applicable law or
148 agreed to in writing, Licensor provides the Work (and each
149 Contributor provides its Contributions) on an "AS IS" BASIS,
150 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
151 implied, including, without limitation, any warranties or conditions
152 of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
153 PARTICULAR PURPOSE. You are solely responsible for determining the
154 appropriateness of using or redistributing the Work and assume any
155 risks associated with Your exercise of permissions under this License.
156
157 8. Limitation of Liability. In no event and under no legal theory,
158 whether in tort (including negligence), contract, or otherwise,
159 unless required by applicable law (such as deliberate and grossly
160 negligent acts) or agreed to in writing, shall any Contributor be
161 liable to You for damages, including any direct, indirect, special,
162 incidental, or consequential damages of any character arising as a
163 result of this License or out of the use or inability to use the
164 Work (including but not limited to damages for loss of goodwill,
165 work stoppage, computer failure or malfunction, or any and all
166 other commercial damages or losses), even if such Contributor
167 has been advised of the possibility of such damages.
168
169 9. Accepting Warranty or Additional Liability. While redistributing
170 the Work or Derivative Works thereof, You may choose to offer,
171 and charge a fee for, acceptance of support, warranty, indemnity,
172 or other liability obligations and/or rights consistent with this
173 License. However, in accepting such obligations, You may act only
174 on Your own behalf and on Your sole responsibility, not on behalf
175 of any other Contributor, and only if You agree to indemnify,
176 defend, and hold each Contributor harmless for any liability
177 incurred by, or claims asserted against, such Contributor by reason
178 of your accepting any such warranty or additional liability.
179
180 END OF TERMS AND CONDITIONS
181
182 APPENDIX: How to apply the Apache License to your work.
183
184 To apply the Apache License to your work, attach the following
185 boilerplate notice, with the fields enclosed by brackets "[]"
186 replaced with your own identifying information. (Don't include
187 the brackets!) The text should be enclosed in the appropriate
188 comment syntax for the file format. We also recommend that a
189 file or class name and description of purpose be included on the
190 same "printed page" as the copyright notice for easier
191 identification within third-party archives.
192
193 Copyright [yyyy] [name of copyright owner]
194
195 Licensed under the Apache License, Version 2.0 (the "License");
196 you may not use this file except in compliance with the License.
197 You may obtain a copy of the License at
198
199 http://www.apache.org/licenses/LICENSE-2.0
200
201 Unless required by applicable law or agreed to in writing, software
202 distributed under the License is distributed on an "AS IS" BASIS,
203 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
204 See the License for the specific language governing permissions and
205 limitations under the License.
206
207
208---- LLVM Exceptions to the Apache 2.0 License ----
209
210As an exception, if, as a result of your compiling your source code, portions
211of this Software are embedded into an Object form of such source code, you
212may redistribute such embedded portions in such Object form without complying
213with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
214
215In addition, if you combine or link compiled forms of this Software with
216software that is licensed under the GPLv2 ("Combined Software") and if a
217court of competent jurisdiction determines that the patent provision (Section
2183), the indemnity provision (Section 9) or other Section of the License
219conflicts with the conditions of the GPLv2, you may retroactively and
220prospectively choose to deem waived or otherwise exclude such Section(s) of
221the License, but only in their entirety and only with respect to the Combined
222Software.
diff --git a/contrib/dxc_2025_07_14/inc/hlsl/README.txt b/contrib/dxc_2025_07_14/inc/hlsl/README.txt
new file mode 100644
index 0000000..a760bb9
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/hlsl/README.txt
@@ -0,0 +1,7 @@
1HLSL Standard Header Library
2============================
3
4The contents of this directory and subdirectories are the HLSL Standard Header
5library. These headers are open source software. You may freely distribute all
6or parts of these headers under the terms of the license agreement found in
7LICENSE.txt.
diff --git a/contrib/dxc_2025_07_14/inc/hlsl/dx/linalg.h b/contrib/dxc_2025_07_14/inc/hlsl/dx/linalg.h
new file mode 100644
index 0000000..4f5e620
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/hlsl/dx/linalg.h
@@ -0,0 +1,198 @@
1// Header for linear algebra APIs.
2
3#if __spirv__
4#error "Cooperative vectors not (yet) supported for SPIRV"
5#endif
6
7#if ((__SHADER_TARGET_MAJOR > 6) || \
8 (__SHADER_TARGET_MAJOR == 6 && __SHADER_TARGET_MINOR >= 9)) && \
9 (__HLSL_VERSION >= 2021)
10
11namespace dx {
12namespace linalg {
13
14// NOTE: can't be an enum class because we get this error:
15// error: non-type template argument of type 'dx::linalg::DataType' is not
16// an integral constant expression
17//
18enum DataType {
19 DATA_TYPE_SINT16 = 2, // ComponentType::I16
20 DATA_TYPE_UINT16 = 3, // ComponentType::U16
21 DATA_TYPE_SINT32 = 4, // ComponentType::I32
22 DATA_TYPE_UINT32 = 5, // ComponentType::U32
23 DATA_TYPE_FLOAT16 = 8, // ComponentType::F16
24 DATA_TYPE_FLOAT32 = 9, // ComponentType::F32
25 DATA_TYPE_SINT8_T4_PACKED = 17, // ComponentType::PackedS8x32
26 DATA_TYPE_UINT8_T4_PACKED = 18, // ComponentType::PackedU8x32
27 DATA_TYPE_UINT8 = 19, // ComponentType::U8
28 DATA_TYPE_SINT8 = 20, // ComponentType::I8
29 DATA_TYPE_FLOAT8_E4M3 = 21, // ComponentType::F8_E4M3
30 // (1 sign, 4 exp, 3 mantissa bits)
31 DATA_TYPE_FLOAT8_E5M2 = 22, // ComponentType::F8_E5M2
32 // (1 sign, 5 exp, 2 mantissa bits)
33};
34
35enum MatrixLayout {
36 MATRIX_LAYOUT_ROW_MAJOR = 0,
37 MATRIX_LAYOUT_COLUMN_MAJOR = 1,
38 MATRIX_LAYOUT_MUL_OPTIMAL = 2,
39 MATRIX_LAYOUT_OUTER_PRODUCT_OPTIMAL = 3
40};
41
42//
43// Helper for signedness
44//
45namespace details {
46
47template <typename T> struct IsUnsigned {};
48
49#define _SPECIALIZE_ISUNSIGNED(type, value) \
50 template <> struct IsUnsigned<type> { \
51 static const bool Value = value; \
52 }
53
54_SPECIALIZE_ISUNSIGNED(uint8_t4_packed, true);
55_SPECIALIZE_ISUNSIGNED(int8_t4_packed, true);
56_SPECIALIZE_ISUNSIGNED(uint32_t, true);
57_SPECIALIZE_ISUNSIGNED(int32_t, false);
58_SPECIALIZE_ISUNSIGNED(float32_t, false);
59
60#ifdef __HLSL_ENABLE_16_BIT
61_SPECIALIZE_ISUNSIGNED(uint16_t, true);
62_SPECIALIZE_ISUNSIGNED(int16_t, false);
63_SPECIALIZE_ISUNSIGNED(float16_t, false);
64#else // //__HLSL_ENABLE_16_BIT
65_SPECIALIZE_ISUNSIGNED(half, false);
66#endif //__HLSL_ENABLE_16_BIT
67
68#undef _SPECIALIZE_ISUNSIGNED
69
70} // namespace details
71
72//
73// (RW)MatrixRef
74//
75
76template <typename BufferTy, DataType DT, uint M, uint K, MatrixLayout ML,
77 bool Transpose>
78struct MatrixRefImpl {
79 BufferTy Buffer;
80 uint StartOffset;
81 uint Stride;
82};
83
84template <DataType DT, uint M, uint K, MatrixLayout ML, bool Transpose = false>
85using MatrixRef = MatrixRefImpl<ByteAddressBuffer, DT, M, K, ML, Transpose>;
86
87template <DataType DT, uint M, uint K, MatrixLayout ML, bool Transpose = false>
88using RWMatrixRef = MatrixRefImpl<RWByteAddressBuffer, DT, M, K, ML, Transpose>;
89
90//
91// (RW)VectorRef
92//
93
94template <typename BufferTy, DataType DT> struct VectorRefImpl {
95 BufferTy Buffer;
96 uint StartOffset;
97};
98
99template <DataType DT> using VectorRef = VectorRefImpl<ByteAddressBuffer, DT>;
100
101template <DataType DT>
102using RWVectorRef = VectorRefImpl<RWByteAddressBuffer, DT>;
103
104//
105// Vector
106//
107
108template <typename T, int N, DataType DT> struct InterpretedVector {
109 vector<T, N> Data;
110};
111
112template <DataType DT, typename T, int N>
113InterpretedVector<T, N, DT> MakeInterpretedVector(vector<T, N> Vec) {
114 InterpretedVector<T, N, DT> IV = {Vec};
115 return IV;
116}
117
118//
119// Mul
120//
121
122template <typename OutputElTy, typename InputElTy, int InputElCount,
123 typename MatrixBufferTy, DataType InputDT, DataType MatrixDT,
124 uint MatrixM, uint MatrixK, MatrixLayout MatrixLayout,
125 bool MatrixTranspose>
126vector<OutputElTy, MatrixM>
127Mul(MatrixRefImpl<MatrixBufferTy, MatrixDT, MatrixM, MatrixK, MatrixLayout,
128 MatrixTranspose>
129 Matrix,
130 InterpretedVector<InputElTy, InputElCount, InputDT> InputVector) {
131
132 vector<OutputElTy, MatrixM> OutputVector;
133
134 __builtin_MatVecMul(
135 /*out*/ OutputVector, details::IsUnsigned<OutputElTy>::Value,
136 InputVector.Data, details::IsUnsigned<InputElTy>::Value, InputDT,
137 Matrix.Buffer, Matrix.StartOffset, MatrixDT, MatrixM, MatrixK,
138 MatrixLayout, MatrixTranspose, Matrix.Stride);
139
140 return OutputVector;
141}
142
143//
144// MulAdd
145//
146
147template <typename OutputElTy, typename InputElTy, int InputElCount,
148 typename MatrixBufferTy, DataType InputDT, DataType MatrixDT,
149 uint MatrixM, uint MatrixK, MatrixLayout MatrixLayout,
150 bool MatrixTranspose, typename BiasVectorBufferTy,
151 DataType BiasVectorDT>
152vector<OutputElTy, MatrixM>
153MulAdd(MatrixRefImpl<MatrixBufferTy, MatrixDT, MatrixM, MatrixK, MatrixLayout,
154 MatrixTranspose>
155 Matrix,
156 InterpretedVector<InputElTy, InputElCount, InputDT> InputVector,
157 VectorRefImpl<BiasVectorBufferTy, BiasVectorDT> BiasVector) {
158
159 vector<OutputElTy, MatrixM> OutputVector;
160
161 __builtin_MatVecMulAdd(
162 /*out*/ OutputVector, details::IsUnsigned<OutputElTy>::Value,
163 InputVector.Data, details::IsUnsigned<InputElTy>::Value, InputDT,
164 Matrix.Buffer, Matrix.StartOffset, MatrixDT, MatrixM, MatrixK,
165 MatrixLayout, MatrixTranspose, Matrix.Stride, BiasVector.Buffer,
166 BiasVector.StartOffset, BiasVectorDT);
167
168 return OutputVector;
169}
170
171//
172// OuterProductAccumulate
173//
174
175template <typename ElTy, int MatrixM, int MatrixN, DataType MatrixDT,
176 MatrixLayout MatrixLayout>
177void OuterProductAccumulate(
178 vector<ElTy, MatrixM> InputVector1, vector<ElTy, MatrixN> InputVector2,
179 RWMatrixRef<MatrixDT, MatrixM, MatrixN, MatrixLayout, false> Matrix) {
180 __builtin_OuterProductAccumulate(InputVector1, InputVector2, Matrix.Buffer,
181 Matrix.StartOffset, MatrixDT, MatrixLayout,
182 Matrix.Stride);
183}
184
185//
186// VectorAccumulate
187//
188
189template <typename ElTy, int ElCount>
190void VectorAccumulate(vector<ElTy, ElCount> InputVector,
191 RWByteAddressBuffer Buffer, uint Offset) {
192 __builtin_VectorAccumulate(InputVector, Buffer, Offset);
193}
194
195} // namespace linalg
196} // namespace dx
197
198#endif // SM 6.9 check and HV version check
diff --git a/contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.h b/contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.h
new file mode 100644
index 0000000..a53ab4c
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.h
@@ -0,0 +1,275 @@
1// Copyright (c) 2024 Google LLC
2//
3// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7#ifndef _HLSL_VK_KHR_COOPERATIVE_MATRIX_H_
8#define _HLSL_VK_KHR_COOPERATIVE_MATRIX_H_
9
10#if __SPIRV_MAJOR_VERSION__ == 1 && __SPIRV_MINOR_VERSION__ < 6
11#error "CooperativeMatrix requires a minimum of SPIR-V 1.6"
12#endif
13
14#include "vk/spirv.h"
15
16namespace vk {
17namespace khr {
18
19// The base cooperative matrix class. The template arguments correspond to the
20// operands in the OpTypeCooperativeMatrixKHR instruction.
21template <typename ComponentType, Scope scope, uint rows, uint columns,
22 CooperativeMatrixUse use>
23class CooperativeMatrix {
24 template <class NewComponentType>
25 CooperativeMatrix<NewComponentType, scope, rows, columns, use> cast();
26
27 // Apply OpSNegate or OFNegate, depending on ComponentType, in a element by
28 // element manner.
29 CooperativeMatrix negate();
30
31 // Apply OpIAdd or OFAdd, depending on ComponentType, in a element by element
32 // manner.
33 CooperativeMatrix operator+(CooperativeMatrix other);
34
35 // Apply OpISub or OFSub, depending on ComponentType, in a element by element
36 // manner.
37 CooperativeMatrix operator-(CooperativeMatrix other);
38
39 // Apply OpIMul or OFMul, depending on ComponentType, in a element by element
40 // manner.
41 CooperativeMatrix operator*(CooperativeMatrix other);
42
43 // Apply OpSDiv, OpUDiv or OFDiv, depending on ComponentType, in a element by
44 // element manner.
45 CooperativeMatrix operator/(CooperativeMatrix other);
46
47 // Apply OpMatrixTimesScalar in a element by element manner.
48 CooperativeMatrix operator*(ComponentType scalar);
49
50 // Store the cooperative matrix using OpCooperativeMatrixStoreKHR to
51 // data using the given memory layout, stride, and memory access operands.
52 // `NonPrivatePointer` and `MakePointerAvailable` with the workgroup scope
53 // will be added to the memory access operands to make the memory coherent.
54 //
55 // This function uses a SPIR-V pointer because HLSL does not allow groupshared
56 // memory object to be passed by reference. The pointer is a hack to get
57 // around that.
58 //
59 // The layout and stride will be passed to the SPIR-V instruction as is. The
60 // precise meaning can be found in the specification for
61 // SPV_KHR_cooperative_matrix.
62 template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
63 class Type>
64 void Store(WorkgroupSpirvPointer<Type> data, uint32_t stride);
65
66 // Same as above, but uses MemoryAccessMaskNone for the memory access
67 // operands.
68 template <CooperativeMatrixLayout layout, class Type>
69 void Store(WorkgroupSpirvPointer<Type> data, uint32_t stride) {
70 Store<MemoryAccessMaskNone, layout>(data, stride);
71 }
72
73 // Store the cooperative matrix using OpCooperativeMatrixStoreKHR to
74 // data[index] using the given memory layout, stride, and memory access
75 // operands. The layout and stride will be passed to the SPIR-V instruction as
76 // is. The precise meaning can be found in the specification for
77 // SPV_KHR_cooperative_matrix.
78 template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
79 class Type>
80 void Store(RWStructuredBuffer<Type> data, uint32_t index, uint32_t stride);
81
82 // Same as above, but uses MemoryAccessMaskNone for the memory access
83 // operands.
84 template <CooperativeMatrixLayout layout, class Type>
85 void Store(RWStructuredBuffer<Type> data, uint32_t index, uint32_t stride) {
86 Store<MemoryAccessMaskNone, layout>(data, index, stride);
87 }
88
89 // Store the cooperative matrix using OpCooperativeMatrixStoreKHR to
90 // data[index] using the given memory layout, stride, and memory access
91 // operands. `NonPrivatePointer` and `MakePointerAvailable` with the
92 // QueueFamily scope will be added to the memory access operands to make the
93 // memory coherent.
94 //
95 // The layout and stride will be passed to the SPIR-V instruction as is. The
96 // precise meaning can be found in the specification for
97 // SPV_KHR_cooperative_matrix.
98 template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
99 class Type>
100 void CoherentStore(globallycoherent RWStructuredBuffer<Type> data,
101 uint32_t index, uint32_t stride);
102
103 // Same as above, but uses MemoryAccessMaskNone for the memory access operands
104 // template argument.
105 template <CooperativeMatrixLayout layout, class Type>
106 void CoherentStore(globallycoherent RWStructuredBuffer<Type> data,
107 uint32_t index, uint32_t stride) {
108 CoherentStore<MemoryAccessMaskNone, layout>(data, index, stride);
109 }
110
111 // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
112 // data using the given memory layout, stride, and memory access operands.
113 // `NonPrivatePointer` and `MakePointerVisible` with the workgroup scope
114 // will be added to the memory access operands to make the memory coherent.
115 //
116 // This function uses a SPIR-V pointer because HLSL does not allow groupshared
117 // memory object to be passed by reference. The pointer is a hack to get
118 // around that.
119 //
120 // The layout and stride will be passed to the SPIR-V instruction as is. The
121 // precise meaning can be found in the specification for
122 // SPV_KHR_cooperative_matrix.
123 template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
124 class Type>
125 static CooperativeMatrix Load(WorkgroupSpirvPointer<Type> data,
126 uint32_t stride);
127
128 // Same as above, but uses MemoryAccessMaskNone for the memory access
129 // operands.
130 template <CooperativeMatrixLayout layout, class Type>
131 static CooperativeMatrix Load(WorkgroupSpirvPointer<Type> data,
132 uint32_t stride) {
133 return Load<MemoryAccessMaskNone, layout>(data, stride);
134 }
135
136 // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
137 // data[index] using the given memory layout, stride, and memory access
138 // operands.
139 //
140 // The layout and stride will be passed to the SPIR-V instruction as is. The
141 // precise meaning can be found in the specification for
142 // SPV_KHR_cooperative_matrix.
143 template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
144 class Type>
145 static CooperativeMatrix Load(RWStructuredBuffer<Type> data, uint32_t index,
146 uint32_t stride);
147
148 // Same as above, but uses MemoryAccessMaskNone for the memory access
149 // operands.
150 template <CooperativeMatrixLayout layout, class Type>
151 static CooperativeMatrix Load(RWStructuredBuffer<Type> data, uint32_t index,
152 uint32_t stride) {
153 return Load<MemoryAccessMaskNone, layout>(data, index, stride);
154 }
155
156 // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
157 // data[index] using the given memory layout, stride, and memory access
158 // operands. `NonPrivatePointer` and `MakePointerVisible` with the QueueFamily
159 // scope will be added to the memory access operands to make the memory
160 // coherent.
161 //
162 //
163 // The layout and stride will be passed to the SPIR-V instruction as is. The
164 // precise meaning can be found in the specification for
165 // SPV_KHR_cooperative_matrix.
166 template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
167 class Type>
168 static CooperativeMatrix
169 CoherentLoad(globallycoherent RWStructuredBuffer<Type> data, uint32_t index,
170 uint32_t stride);
171
172 // Same as above, but uses MemoryAccessMaskNone for the memory access operands
173 // template argument.
174 template <CooperativeMatrixLayout layout, class Type>
175 static CooperativeMatrix
176 CoherentLoad(globallycoherent RWStructuredBuffer<Type> data, uint32_t index,
177 uint32_t stride) {
178 return CoherentLoad<MemoryAccessMaskNone, layout>(data, index, stride);
179 }
180
181 // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
182 // data[index] using the given memory layout, stride, and memory access
183 // operands. No memory access bits are added to the operands. Since the memory
184 // is readonly, there should be no need.
185 //
186 // The layout and stride will be passed to the SPIR-V instruction as is. The
187 // precise meaning can be found in the specification for
188 // SPV_KHR_cooperative_matrix.
189 template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
190 class Type>
191 static CooperativeMatrix Load(StructuredBuffer<Type> data, uint32_t index,
192 uint32_t stride);
193
194 // Same as above, but uses MemoryAccessMaskNone for the memory access
195 // operands.
196 template <CooperativeMatrixLayout layout, class Type>
197 static CooperativeMatrix Load(StructuredBuffer<Type> data, uint32_t index,
198 uint32_t stride) {
199 return Load<MemoryAccessMaskNone, layout>(data, index, stride);
200 }
201
202 // Constructs a cooperative matrix with all values initialized to v. Note that
203 // all threads in scope must have the same value for v.
204 static CooperativeMatrix Splat(ComponentType v);
205
206 // Returns the result of OpCooperativeMatrixLengthKHR on the current type.
207 static uint32_t GetLength();
208
209 // Functions to access the elements of the cooperative matrix. The index must
210 // be less than GetLength().
211 void Set(ComponentType value, uint32_t index);
212 ComponentType Get(uint32_t index);
213
214 static const bool hasSignedIntegerComponentType =
215 (ComponentType(0) - ComponentType(1) < ComponentType(0));
216
217 // clang-format off
218 using SpirvMatrixType = vk::SpirvOpaqueType<
219 /* OpTypeCooperativeMatrixKHR */ 4456, ComponentType,
220 vk::integral_constant<uint, scope>, vk::integral_constant<uint, rows>,
221 vk::integral_constant<uint, columns>, vk::integral_constant<uint, use> >;
222
223 [[vk::ext_extension("SPV_KHR_cooperative_matrix")]]
224 [[vk::ext_capability(/* CooperativeMatrixKHRCapability */ 6022)]]
225 [[vk::ext_capability(/* VulkanMemoryModel */ 5345)]]
226 SpirvMatrixType _matrix;
227 // clang-format on
228};
229
230// Cooperative matrix that can be used in the "a" position of a multiply add
231// instruction (r = (a * b) + c).
232template <typename ComponentType, Scope scope, uint rows, uint columns>
233using CooperativeMatrixA =
234 CooperativeMatrix<ComponentType, scope, rows, columns,
235 CooperativeMatrixUseMatrixAKHR>;
236
237// Cooperative matrix that can be used in the "b" position of a multiply add
238// instruction (r = (a * b) + c).
239template <typename ComponentType, Scope scope, uint rows, uint columns>
240using CooperativeMatrixB =
241 CooperativeMatrix<ComponentType, scope, rows, columns,
242 CooperativeMatrixUseMatrixBKHR>;
243
244// Cooperative matrix that can be used in the "r" and "c" position of a multiply
245// add instruction (r = (a * b) + c).
246template <typename ComponentType, Scope scope, uint rows, uint columns>
247using CooperativeMatrixAccumulator =
248 CooperativeMatrix<ComponentType, scope, rows, columns,
249 CooperativeMatrixUseMatrixAccumulatorKHR>;
250
251// Returns the result of OpCooperativeMatrixMulAddKHR when applied to a, b, and
252// c. The cooperative matrix operands are inferred, with the
253// SaturatingAccumulationKHR bit not set.
254template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
255CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
256cooperativeMatrixMultiplyAdd(
257 CooperativeMatrixA<ComponentType, scope, rows, K> a,
258 CooperativeMatrixB<ComponentType, scope, K, columns> b,
259 CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c);
260
261// Returns the result of OpCooperativeMatrixMulAddKHR when applied to a, b, and
262// c. The cooperative matrix operands are inferred, with the
263// SaturatingAccumulationKHR bit set.
264template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
265CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
266cooperativeMatrixSaturatingMultiplyAdd(
267 CooperativeMatrixA<ComponentType, scope, rows, K> a,
268 CooperativeMatrixB<ComponentType, scope, K, columns> b,
269 CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c);
270
271} // namespace khr
272} // namespace vk
273
274#include "cooperative_matrix.impl"
275#endif // _HLSL_VK_KHR_COOPERATIVE_MATRIX_H_
diff --git a/contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.impl b/contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.impl
new file mode 100644
index 0000000..2acae8e
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/hlsl/vk/khr/cooperative_matrix.impl
@@ -0,0 +1,377 @@
1// Copyright (c) 2024 Google LLC
2//
3// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7#include "vk/opcode_selector.h"
8
9template <typename ResultType, typename ComponentType>
10[[vk::ext_instruction(/* OpMatrixTimesScalar */ 143)]] ResultType
11__builtin_spv_MatrixTimesScalar(ResultType a, ComponentType b);
12
13template <typename ComponentType, vk::Scope scope, uint rows, uint columns,
14 vk::CooperativeMatrixUse use>
15[[vk::ext_instruction(/* OpCompositeExtract */ 81)]] ComponentType
16__builtin_spv_ExtractFromCooperativeMatrix(
17 typename vk::khr::CooperativeMatrix<ComponentType, scope, rows, columns,
18 use>::SpirvMatrixType matrix,
19 uint32_t index);
20
21template <typename CoopMatrixType, typename ComponentType>
22[[vk::ext_instruction(/* OpCompositeConstruct */ 80)]] CoopMatrixType
23__builtin_spv_ConstructCooperativeMatrix(ComponentType value);
24
25template <class ResultPointerType, class BaseType>
26[[vk::ext_instruction(/* OpAccessChain */ 65)]] ResultPointerType
27__builtin_spv_AccessChain([[vk::ext_reference]] BaseType base, uint32_t index);
28
29template <class ObjectType, class PointerType>
30[[vk::ext_instruction(/* OpLoad */ 61)]] ObjectType
31__builtin_spv_LoadPointer(PointerType base);
32
33template <class PointerType, class ObjectType>
34[[vk::ext_instruction(/* OpLoad */ 62)]] void
35__builtin_spv_StorePointer(PointerType base, ObjectType object);
36
37template <typename ComponentType, vk::Scope scope, uint rows, uint columns,
38 vk::CooperativeMatrixUse use>
39[[vk::ext_instruction(/* OpCompositeInsert */ 82)]]
40typename vk::khr::CooperativeMatrix<ComponentType, scope, rows, columns,
41 use>::SpirvMatrixType
42__builtin_spv_InsertIntoCooperativeMatrix(
43 ComponentType value,
44 typename vk::khr::CooperativeMatrix<ComponentType, scope, rows, columns,
45 use>::SpirvMatrixType matrix,
46 uint32_t index);
47
48// Define the load and store instructions
49template <typename ResultType, typename PointerType>
50[[vk::ext_instruction(/* OpCooperativeMatrixLoadKHR */ 4457)]] ResultType
51__builtin_spv_CooperativeMatrixLoadKHR(
52 [[vk::ext_reference]] PointerType pointer,
53 vk::CooperativeMatrixLayout memory_layout, uint stride,
54 [[vk::ext_literal]] uint32_t memory_operand);
55
56template <typename ResultType, typename PointerType>
57[[vk::ext_instruction(/* OpCooperativeMatrixLoadKHR */ 4457)]] ResultType
58__builtin_spv_CooperativeMatrixLoadKHR(
59 [[vk::ext_reference]] PointerType pointer,
60 vk::CooperativeMatrixLayout memory_layout, uint stride,
61 [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
62
63template <typename ResultType, typename PointerType>
64[[vk::ext_instruction(/* OpCooperativeMatrixLoadKHR */ 4457)]] ResultType
65__builtin_spv_CooperativeMatrixWorkgroupLoadKHR(
66 vk::WorkgroupSpirvPointer<PointerType> pointer,
67 vk::CooperativeMatrixLayout memory_layout, uint stride,
68 [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
69
70template <typename ObjectType, typename PointerType>
71[[vk::ext_instruction(/* OpCooperativeMatrixStoreKHR */ 4458)]] void
72__builtin_spv_CooperativeMatrixStoreKHR(
73 [[vk::ext_reference]] PointerType pointer, ObjectType object,
74 vk::CooperativeMatrixLayout memory_layout, uint stride,
75 [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
76
77template <typename ObjectType, typename PointerType>
78[[vk::ext_instruction(/* OpCooperativeMatrixStoreKHR */ 4458)]] void
79__builtin_spv_CooperativeMatrixStoreKHR(
80 [[vk::ext_reference]] PointerType pointer, ObjectType object,
81 vk::CooperativeMatrixLayout memory_layout, uint stride,
82 [[vk::ext_literal]] uint32_t memory_operand);
83
84template <typename ObjectType, typename PointerType>
85[[vk::ext_instruction(/* OpCooperativeMatrixStoreKHR */ 4458)]] void
86__builtin_spv_CooperativeMatrixWorkgroupStoreKHR(
87 vk::WorkgroupSpirvPointer<PointerType> pointer, ObjectType object,
88 vk::CooperativeMatrixLayout memory_layout, uint stride,
89 [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
90
91// We cannot define `OpCooperativeMatrixLengthKHR` using ext_instruction because
92// one of the operands is a type id. This builtin will have specific code in the
93// compiler to expand it.
94template <class MatrixType> uint __builtin_spv_CooperativeMatrixLengthKHR();
95
96// Arithmetic Instructions
97template <typename ResultType, typename MatrixTypeA, typename MatrixTypeB,
98 typename MatrixTypeC>
99[[vk::ext_instruction(/* OpCooperativeMatrixMulAddKHR */ 4459)]] ResultType
100__builtin_spv_CooperativeMatrixMulAddKHR(MatrixTypeA a, MatrixTypeB b,
101 MatrixTypeC c,
102 [[vk::ext_literal]] int operands);
103namespace vk {
104namespace khr {
105
106template <class ComponentType, Scope scope, uint rows, uint columns,
107 CooperativeMatrixUse use>
108template <class NewComponentType>
109CooperativeMatrix<NewComponentType, scope, rows, columns, use>
110CooperativeMatrix<ComponentType, scope, rows, columns, use>::cast() {
111 using ResultType =
112 CooperativeMatrix<NewComponentType, scope, rows, columns, use>;
113 ResultType result;
114 result._matrix = util::ConversionSelector<ComponentType, NewComponentType>::
115 template Convert<typename ResultType::SpirvMatrixType>(_matrix);
116 return result;
117}
118
119template <class ComponentType, Scope scope, uint rows, uint columns,
120 CooperativeMatrixUse use>
121CooperativeMatrix<ComponentType, scope, rows, columns, use>
122CooperativeMatrix<ComponentType, scope, rows, columns, use>::negate() {
123 CooperativeMatrix result;
124 result._matrix = util::ArithmeticSelector<ComponentType>::Negate(_matrix);
125 return result;
126}
127
128template <class ComponentType, Scope scope, uint rows, uint columns,
129 CooperativeMatrixUse use>
130CooperativeMatrix<ComponentType, scope, rows, columns, use>
131CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator+(
132 CooperativeMatrix other) {
133 CooperativeMatrix result;
134 result._matrix =
135 util::ArithmeticSelector<ComponentType>::Add(_matrix, other._matrix);
136 return result;
137}
138
139template <class ComponentType, Scope scope, uint rows, uint columns,
140 CooperativeMatrixUse use>
141CooperativeMatrix<ComponentType, scope, rows, columns, use>
142CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator-(
143 CooperativeMatrix other) {
144 CooperativeMatrix result;
145 result._matrix =
146 util::ArithmeticSelector<ComponentType>::Sub(_matrix, other._matrix);
147 return result;
148}
149
150template <class ComponentType, Scope scope, uint rows, uint columns,
151 CooperativeMatrixUse use>
152CooperativeMatrix<ComponentType, scope, rows, columns, use>
153CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator*(
154 CooperativeMatrix other) {
155 CooperativeMatrix result;
156 result._matrix =
157 util::ArithmeticSelector<ComponentType>::Mul(_matrix, other._matrix);
158 return result;
159}
160
161template <class ComponentType, Scope scope, uint rows, uint columns,
162 CooperativeMatrixUse use>
163CooperativeMatrix<ComponentType, scope, rows, columns, use>
164CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator/(
165 CooperativeMatrix other) {
166 CooperativeMatrix result;
167 result._matrix =
168 util::ArithmeticSelector<ComponentType>::Div(_matrix, other._matrix);
169 return result;
170}
171
172template <class ComponentType, Scope scope, uint rows, uint columns,
173 CooperativeMatrixUse use>
174CooperativeMatrix<ComponentType, scope, rows, columns, use>
175CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator*(
176 ComponentType scalar) {
177 CooperativeMatrix result;
178 result._matrix = __builtin_spv_MatrixTimesScalar(_matrix, scalar);
179 return result;
180}
181
182template <class ComponentType, Scope scope, uint rows, uint columns,
183 CooperativeMatrixUse use>
184template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
185 class Type>
186void CooperativeMatrix<ComponentType, scope, rows, columns, use>::Store(
187 WorkgroupSpirvPointer<Type> data, uint32_t stride) {
188 __builtin_spv_CooperativeMatrixWorkgroupStoreKHR(
189 data, _matrix, layout, stride,
190 memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
191 MemoryAccessMakePointerAvailableMask,
192 ScopeWorkgroup);
193}
194
195template <class ComponentType, Scope scope, uint rows, uint columns,
196 CooperativeMatrixUse use>
197template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
198 class Type>
199void CooperativeMatrix<ComponentType, scope, rows, columns, use>::Store(
200 RWStructuredBuffer<Type> data, uint32_t index, uint32_t stride) {
201 __builtin_spv_CooperativeMatrixStoreKHR(data[index], _matrix, layout, stride,
202 memoryAccessOperands);
203}
204
205template <class ComponentType, Scope scope, uint rows, uint columns,
206 CooperativeMatrixUse use>
207template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
208 class Type>
209void CooperativeMatrix<ComponentType, scope, rows, columns, use>::CoherentStore(
210 globallycoherent RWStructuredBuffer<Type> data, uint32_t index,
211 uint32_t stride) {
212 __builtin_spv_CooperativeMatrixStoreKHR(
213 data[index], _matrix, layout, stride,
214 memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
215 MemoryAccessMakePointerAvailableMask,
216 ScopeQueueFamily);
217}
218
219template <class ComponentType, Scope scope, uint rows, uint columns,
220 CooperativeMatrixUse use>
221template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
222 class Type>
223CooperativeMatrix<ComponentType, scope, rows, columns, use>
224CooperativeMatrix<ComponentType, scope, rows, columns, use>::Load(
225 vk::WorkgroupSpirvPointer<Type> buffer, uint32_t stride) {
226 CooperativeMatrix result;
227 result._matrix =
228 __builtin_spv_CooperativeMatrixWorkgroupLoadKHR<SpirvMatrixType>(
229 buffer, layout, stride,
230 memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
231 MemoryAccessMakePointerVisibleMask,
232 ScopeWorkgroup);
233 return result;
234}
235
236template <class ComponentType, Scope scope, uint rows, uint columns,
237 CooperativeMatrixUse use>
238template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
239 class Type>
240CooperativeMatrix<ComponentType, scope, rows, columns, use>
241CooperativeMatrix<ComponentType, scope, rows, columns, use>::Load(
242 RWStructuredBuffer<Type> buffer, uint32_t index, uint32_t stride) {
243 CooperativeMatrix result;
244 result._matrix = __builtin_spv_CooperativeMatrixLoadKHR<SpirvMatrixType>(
245 buffer[index], layout, stride, memoryAccessOperands);
246 return result;
247}
248
249template <class ComponentType, Scope scope, uint rows, uint columns,
250 CooperativeMatrixUse use>
251template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
252 class Type>
253CooperativeMatrix<ComponentType, scope, rows, columns, use>
254CooperativeMatrix<ComponentType, scope, rows, columns, use>::CoherentLoad(
255 RWStructuredBuffer<Type> buffer, uint32_t index, uint32_t stride) {
256 CooperativeMatrix result;
257 result._matrix = __builtin_spv_CooperativeMatrixLoadKHR<SpirvMatrixType>(
258 buffer[index], layout, stride,
259 memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
260 MemoryAccessMakePointerVisibleMask,
261 ScopeQueueFamily);
262 return result;
263}
264
265template <class ComponentType, Scope scope, uint rows, uint columns,
266 CooperativeMatrixUse use>
267template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
268 class Type>
269CooperativeMatrix<ComponentType, scope, rows, columns, use>
270CooperativeMatrix<ComponentType, scope, rows, columns, use>::Load(
271 StructuredBuffer<Type> buffer, uint32_t index, uint32_t stride) {
272 CooperativeMatrix result;
273 result._matrix = __builtin_spv_CooperativeMatrixLoadKHR<SpirvMatrixType>(
274 buffer[index], layout, stride, MemoryAccessMaskNone);
275 return result;
276}
277
278template <class ComponentType, Scope scope, uint rows, uint columns,
279 CooperativeMatrixUse use>
280CooperativeMatrix<ComponentType, scope, rows, columns, use>
281CooperativeMatrix<ComponentType, scope, rows, columns, use>::Splat(
282 ComponentType v) {
283 CooperativeMatrix result;
284 result._matrix = __builtin_spv_ConstructCooperativeMatrix<SpirvMatrixType>(v);
285 return result;
286}
287
288template <class ComponentType, Scope scope, uint rows, uint columns,
289 CooperativeMatrixUse use>
290uint CooperativeMatrix<ComponentType, scope, rows, columns, use>::GetLength() {
291 return __builtin_spv_CooperativeMatrixLengthKHR<SpirvMatrixType>();
292}
293
294template <class ComponentType, Scope scope, uint rows, uint columns,
295 CooperativeMatrixUse use>
296ComponentType CooperativeMatrix<ComponentType, scope, rows, columns, use>::Get(
297 uint32_t index) {
298 // clang-format off
299 using ComponentPtr = vk::SpirvOpaqueType<
300 /* OpTypePointer */ 32,
301 /* function storage class */ vk::Literal<vk::integral_constant<uint, 7> >,
302 ComponentType>;
303 // clang-format on
304 ComponentPtr ptr = __builtin_spv_AccessChain<ComponentPtr>(_matrix, index);
305 return __builtin_spv_LoadPointer<ComponentType>(ptr);
306}
307
308template <class ComponentType, Scope scope, uint rows, uint columns,
309 CooperativeMatrixUse use>
310void CooperativeMatrix<ComponentType, scope, rows, columns, use>::Set(
311 ComponentType value, uint32_t index) {
312 // clang-format off
313 using ComponentPtr = vk::SpirvOpaqueType<
314 /* OpTypePointer */ 32,
315 /* function storage class */ vk::Literal<vk::integral_constant<uint, 7> >,
316 ComponentType>;
317 // clang-format on
318 ComponentPtr ptr = __builtin_spv_AccessChain<ComponentPtr>(_matrix, index);
319 return __builtin_spv_StorePointer(ptr, value);
320}
321
322template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
323CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
324cooperativeMatrixMultiplyAdd(
325 CooperativeMatrixA<ComponentType, scope, rows, K> a,
326 CooperativeMatrixB<ComponentType, scope, K, columns> b,
327 CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c) {
328
329 const vk::CooperativeMatrixOperandsMask allSignedComponents =
330 vk::CooperativeMatrixOperandsMatrixASignedComponentsKHRMask |
331 vk::CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask |
332 vk::CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask |
333 vk::CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask;
334
335 const vk::CooperativeMatrixOperandsMask operands =
336 (vk::CooperativeMatrixOperandsMask)(
337 a.hasSignedIntegerComponentType
338 ? allSignedComponents
339 : vk::CooperativeMatrixOperandsMaskNone);
340
341 CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> result;
342 result._matrix = __builtin_spv_CooperativeMatrixMulAddKHR<
343 typename CooperativeMatrixAccumulator<ComponentType, scope, rows,
344 columns>::SpirvMatrixType>(
345 a._matrix, b._matrix, c._matrix, operands);
346 return result;
347}
348
349template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
350CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
351cooperativeMatrixSaturatingMultiplyAdd(
352 CooperativeMatrixA<ComponentType, scope, rows, K> a,
353 CooperativeMatrixB<ComponentType, scope, K, columns> b,
354 CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c) {
355
356 const vk::CooperativeMatrixOperandsMask allSignedComponents =
357 vk::CooperativeMatrixOperandsMatrixASignedComponentsKHRMask |
358 vk::CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask |
359 vk::CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask |
360 vk::CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask |
361 vk::CooperativeMatrixOperandsSaturatingAccumulationKHRMask;
362
363 const vk::CooperativeMatrixOperandsMask operands =
364 (vk::CooperativeMatrixOperandsMask)(
365 a.hasSignedIntegerComponentType
366 ? allSignedComponents
367 : vk::CooperativeMatrixOperandsSaturatingAccumulationKHRMask);
368 CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> result;
369 result._matrix = __builtin_spv_CooperativeMatrixMulAddKHR<
370 typename CooperativeMatrixAccumulator<ComponentType, scope, rows,
371 columns>::SpirvMatrixType>(
372 a._matrix, b._matrix, c._matrix, operands);
373 return result;
374}
375
376} // namespace khr
377} // namespace vk
diff --git a/contrib/dxc_2025_07_14/inc/hlsl/vk/opcode_selector.h b/contrib/dxc_2025_07_14/inc/hlsl/vk/opcode_selector.h
new file mode 100644
index 0000000..bc8672c
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/hlsl/vk/opcode_selector.h
@@ -0,0 +1,227 @@
1// Copyright (c) 2024 Google LLC
2//
3// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7#ifndef _HLSL_VK_KHR_OPCODE_SELECTOR_H_
8#define _HLSL_VK_KHR_OPCODE_SELECTOR_H_
9
10#define DECLARE_UNARY_OP(name, opcode) \
11 template <typename ResultType> \
12 [[vk::ext_instruction(opcode)]] ResultType __builtin_spv_##name( \
13 ResultType a)
14
15DECLARE_UNARY_OP(CopyObject, 83);
16DECLARE_UNARY_OP(SNegate, 126);
17DECLARE_UNARY_OP(FNegate, 127);
18
19#define DECLARE_CONVERSION_OP(name, opcode) \
20 template <typename ResultType, typename OperandType> \
21 [[vk::ext_instruction(opcode)]] ResultType __builtin_spv_##name( \
22 OperandType a)
23
24DECLARE_CONVERSION_OP(ConvertFtoU, 109);
25DECLARE_CONVERSION_OP(ConvertFtoS, 110);
26DECLARE_CONVERSION_OP(ConvertSToF, 111);
27DECLARE_CONVERSION_OP(ConvertUToF, 112);
28DECLARE_CONVERSION_OP(UConvert, 113);
29DECLARE_CONVERSION_OP(SConvert, 114);
30DECLARE_CONVERSION_OP(FConvert, 115);
31DECLARE_CONVERSION_OP(Bitcast, 124);
32
33#undef DECLARY_UNARY_OP
34
35#define DECLARE_BINOP(name, opcode) \
36 template <typename ResultType> \
37 [[vk::ext_instruction(opcode)]] ResultType __builtin_spv_##name( \
38 ResultType a, ResultType b)
39
40DECLARE_BINOP(IAdd, 128);
41DECLARE_BINOP(FAdd, 129);
42DECLARE_BINOP(ISub, 130);
43DECLARE_BINOP(FSub, 131);
44DECLARE_BINOP(IMul, 132);
45DECLARE_BINOP(FMul, 133);
46DECLARE_BINOP(UDiv, 134);
47DECLARE_BINOP(SDiv, 135);
48DECLARE_BINOP(FDiv, 136);
49
50#undef DECLARE_BINOP
51namespace vk {
52namespace util {
53
54template <class ComponentType> class ArithmeticSelector;
55
56#define ARITHMETIC_SELECTOR(BaseType, OpNegate, OpAdd, OpSub, OpMul, OpDiv, \
57 SIGNED_INTEGER_TYPE) \
58 template <> class ArithmeticSelector<BaseType> { \
59 template <class T> static T Negate(T a) { return OpNegate(a); } \
60 template <class T> static T Add(T a, T b) { return OpAdd(a, b); } \
61 template <class T> static T Sub(T a, T b) { return OpSub(a, b); } \
62 template <class T> static T Mul(T a, T b) { return OpMul(a, b); } \
63 template <class T> static T Div(T a, T b) { return OpDiv(a, b); } \
64 };
65
66ARITHMETIC_SELECTOR(half, __builtin_spv_FNegate, __builtin_spv_FAdd,
67 __builtin_spv_FSub, __builtin_spv_FMul, __builtin_spv_FDiv,
68 false);
69ARITHMETIC_SELECTOR(float, __builtin_spv_FNegate, __builtin_spv_FAdd,
70 __builtin_spv_FSub, __builtin_spv_FMul, __builtin_spv_FDiv,
71 false);
72ARITHMETIC_SELECTOR(double, __builtin_spv_FNegate, __builtin_spv_FAdd,
73 __builtin_spv_FSub, __builtin_spv_FMul, __builtin_spv_FDiv,
74 false);
75
76#if __HLSL_ENABLE_16_BIT
77ARITHMETIC_SELECTOR(int16_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
78 __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_SDiv,
79 true);
80ARITHMETIC_SELECTOR(uint16_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
81 __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_UDiv,
82 false);
83#endif // __HLSL_ENABLE_16_BIT
84
85ARITHMETIC_SELECTOR(int32_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
86 __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_SDiv,
87 true);
88ARITHMETIC_SELECTOR(int64_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
89 __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_SDiv,
90 true);
91ARITHMETIC_SELECTOR(uint32_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
92 __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_UDiv,
93 false);
94ARITHMETIC_SELECTOR(uint64_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
95 __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_UDiv,
96 false);
97
98// The conversion selector is will be used to convert one type to another
99// using the SPIR-V conversion instructions. See
100// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_conversion_instructions.
101// SourceType and TargetType must be integer or floating point scalar type.
102
103// ConversionSelector::Convert converts an object of type S to an object of type
104// T. S must be SourceType, a vector of SourceType, or a cooperative matrix of
105// SourceType. T must be TargetType, a vector of TargetType, or a cooperative
106// matrix of TargetType. T must have the same number of components as S. T is a
107// cooperative matrix if and only if S is a cooperative matrix.
108template <class SourceType, class TargetType> class ConversionSelector;
109
110#define CONVERSION_SELECTOR(SourceType, TargetType, OpConvert) \
111 template <> class ConversionSelector<SourceType, TargetType> { \
112 template <class T, class S> static T Convert(S a) { \
113 return OpConvert<T>(a); \
114 } \
115 };
116
117#if __HLSL_ENABLE_16_BIT
118CONVERSION_SELECTOR(uint16_t, uint16_t, __builtin_spv_CopyObject);
119CONVERSION_SELECTOR(uint16_t, int16_t, __builtin_spv_Bitcast);
120CONVERSION_SELECTOR(uint16_t, uint32_t, __builtin_spv_UConvert);
121CONVERSION_SELECTOR(uint16_t, int32_t, __builtin_spv_SConvert);
122CONVERSION_SELECTOR(uint16_t, uint64_t, __builtin_spv_UConvert);
123CONVERSION_SELECTOR(uint16_t, int64_t, __builtin_spv_SConvert);
124CONVERSION_SELECTOR(uint16_t, half, __builtin_spv_ConvertUToF);
125CONVERSION_SELECTOR(uint16_t, float, __builtin_spv_ConvertUToF);
126CONVERSION_SELECTOR(uint16_t, double, __builtin_spv_ConvertUToF);
127
128CONVERSION_SELECTOR(int16_t, uint16_t, __builtin_spv_Bitcast);
129CONVERSION_SELECTOR(int16_t, int16_t, __builtin_spv_CopyObject);
130CONVERSION_SELECTOR(int16_t, uint32_t, __builtin_spv_UConvert);
131CONVERSION_SELECTOR(int16_t, int32_t, __builtin_spv_SConvert);
132CONVERSION_SELECTOR(int16_t, uint64_t, __builtin_spv_UConvert);
133CONVERSION_SELECTOR(int16_t, int64_t, __builtin_spv_SConvert);
134CONVERSION_SELECTOR(int16_t, half, __builtin_spv_ConvertSToF);
135CONVERSION_SELECTOR(int16_t, float, __builtin_spv_ConvertSToF);
136CONVERSION_SELECTOR(int16_t, double, __builtin_spv_ConvertSToF);
137
138CONVERSION_SELECTOR(uint32_t, uint16_t, __builtin_spv_UConvert);
139CONVERSION_SELECTOR(uint32_t, int16_t, __builtin_spv_SConvert);
140
141CONVERSION_SELECTOR(int32_t, uint16_t, __builtin_spv_UConvert);
142CONVERSION_SELECTOR(int32_t, int16_t, __builtin_spv_SConvert);
143
144CONVERSION_SELECTOR(uint64_t, uint16_t, __builtin_spv_UConvert);
145CONVERSION_SELECTOR(uint64_t, int16_t, __builtin_spv_SConvert);
146
147CONVERSION_SELECTOR(int64_t, uint16_t, __builtin_spv_UConvert);
148CONVERSION_SELECTOR(int64_t, int16_t, __builtin_spv_SConvert);
149
150CONVERSION_SELECTOR(half, uint16_t, __builtin_spv_ConvertFtoU);
151CONVERSION_SELECTOR(half, int16_t, __builtin_spv_ConvertFtoS);
152
153CONVERSION_SELECTOR(float, uint16_t, __builtin_spv_ConvertFtoU);
154CONVERSION_SELECTOR(float, int16_t, __builtin_spv_ConvertFtoS);
155
156CONVERSION_SELECTOR(double, uint16_t, __builtin_spv_ConvertFtoU);
157CONVERSION_SELECTOR(double, int16_t, __builtin_spv_ConvertFtoS);
158#endif
159
160CONVERSION_SELECTOR(uint32_t, uint32_t, __builtin_spv_CopyObject);
161CONVERSION_SELECTOR(uint32_t, int32_t, __builtin_spv_Bitcast);
162CONVERSION_SELECTOR(uint32_t, uint64_t, __builtin_spv_UConvert);
163CONVERSION_SELECTOR(uint32_t, int64_t, __builtin_spv_SConvert);
164CONVERSION_SELECTOR(uint32_t, half, __builtin_spv_ConvertUToF);
165CONVERSION_SELECTOR(uint32_t, float, __builtin_spv_ConvertUToF);
166CONVERSION_SELECTOR(uint32_t, double, __builtin_spv_ConvertUToF);
167
168CONVERSION_SELECTOR(int32_t, uint32_t, __builtin_spv_Bitcast);
169CONVERSION_SELECTOR(int32_t, int32_t, __builtin_spv_CopyObject);
170CONVERSION_SELECTOR(int32_t, uint64_t, __builtin_spv_UConvert);
171CONVERSION_SELECTOR(int32_t, int64_t, __builtin_spv_SConvert);
172CONVERSION_SELECTOR(int32_t, half, __builtin_spv_ConvertSToF);
173CONVERSION_SELECTOR(int32_t, float, __builtin_spv_ConvertSToF);
174CONVERSION_SELECTOR(int32_t, double, __builtin_spv_ConvertSToF);
175
176CONVERSION_SELECTOR(uint64_t, uint32_t, __builtin_spv_UConvert);
177CONVERSION_SELECTOR(uint64_t, int32_t, __builtin_spv_SConvert);
178CONVERSION_SELECTOR(uint64_t, uint64_t, __builtin_spv_Bitcast);
179CONVERSION_SELECTOR(uint64_t, int64_t, __builtin_spv_CopyObject);
180CONVERSION_SELECTOR(uint64_t, half, __builtin_spv_ConvertUToF);
181CONVERSION_SELECTOR(uint64_t, float, __builtin_spv_ConvertUToF);
182CONVERSION_SELECTOR(uint64_t, double, __builtin_spv_ConvertUToF);
183
184CONVERSION_SELECTOR(int64_t, uint32_t, __builtin_spv_UConvert);
185CONVERSION_SELECTOR(int64_t, int32_t, __builtin_spv_SConvert);
186CONVERSION_SELECTOR(int64_t, uint64_t, __builtin_spv_Bitcast);
187CONVERSION_SELECTOR(int64_t, int64_t, __builtin_spv_CopyObject);
188CONVERSION_SELECTOR(int64_t, half, __builtin_spv_ConvertSToF);
189CONVERSION_SELECTOR(int64_t, float, __builtin_spv_ConvertSToF);
190CONVERSION_SELECTOR(int64_t, double, __builtin_spv_ConvertSToF);
191
192CONVERSION_SELECTOR(half, uint32_t, __builtin_spv_ConvertFtoU);
193CONVERSION_SELECTOR(half, int32_t, __builtin_spv_ConvertFtoS);
194CONVERSION_SELECTOR(half, uint64_t, __builtin_spv_ConvertFtoU);
195CONVERSION_SELECTOR(half, int64_t, __builtin_spv_ConvertFtoS);
196CONVERSION_SELECTOR(half, half, __builtin_spv_CopyObject);
197#if __HLSL_ENABLE_16_BIT
198CONVERSION_SELECTOR(half, float, __builtin_spv_FConvert);
199#else
200CONVERSION_SELECTOR(half, float, __builtin_spv_CopyObject);
201#endif
202
203CONVERSION_SELECTOR(half, double, __builtin_spv_FConvert);
204
205CONVERSION_SELECTOR(float, uint32_t, __builtin_spv_ConvertFtoU);
206CONVERSION_SELECTOR(float, int32_t, __builtin_spv_ConvertFtoS);
207CONVERSION_SELECTOR(float, uint64_t, __builtin_spv_ConvertFtoU);
208CONVERSION_SELECTOR(float, int64_t, __builtin_spv_ConvertFtoS);
209#if __HLSL_ENABLE_16_BIT
210CONVERSION_SELECTOR(float, half, __builtin_spv_FConvert);
211#else
212CONVERSION_SELECTOR(float, half, __builtin_spv_CopyObject);
213#endif
214CONVERSION_SELECTOR(float, float, __builtin_spv_CopyObject);
215CONVERSION_SELECTOR(float, double, __builtin_spv_FConvert);
216
217CONVERSION_SELECTOR(double, uint32_t, __builtin_spv_ConvertFtoU);
218CONVERSION_SELECTOR(double, int32_t, __builtin_spv_ConvertFtoS);
219CONVERSION_SELECTOR(double, uint64_t, __builtin_spv_ConvertFtoU);
220CONVERSION_SELECTOR(double, int64_t, __builtin_spv_ConvertFtoS);
221CONVERSION_SELECTOR(double, half, __builtin_spv_FConvert);
222CONVERSION_SELECTOR(double, float, __builtin_spv_FConvert);
223CONVERSION_SELECTOR(double, double, __builtin_spv_CopyObject);
224}; // namespace util
225} // namespace vk
226
227#endif // _HLSL_VK_KHR_OPCODE_SELECTOR_H_
diff --git a/contrib/dxc_2025_07_14/inc/hlsl/vk/spirv.h b/contrib/dxc_2025_07_14/inc/hlsl/vk/spirv.h
new file mode 100644
index 0000000..69bb53b
--- /dev/null
+++ b/contrib/dxc_2025_07_14/inc/hlsl/vk/spirv.h
@@ -0,0 +1,85 @@
1// Copyright (c) 2024 Google LLC
2//
3// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7#ifndef _HLSL_VK_SPIRV_H_
8#define _HLSL_VK_SPIRV_H_
9
10namespace vk {
11
12enum CooperativeMatrixUse {
13 CooperativeMatrixUseMatrixAKHR = 0,
14 CooperativeMatrixUseMatrixBKHR = 1,
15 CooperativeMatrixUseMatrixAccumulatorKHR = 2,
16 CooperativeMatrixUseMax = 0x7fffffff,
17};
18
19enum CooperativeMatrixLayout {
20 CooperativeMatrixLayoutRowMajorKHR = 0,
21 CooperativeMatrixLayoutColumnMajorKHR = 1,
22 CooperativeMatrixLayoutRowBlockedInterleavedARM = 4202,
23 CooperativeMatrixLayoutColumnBlockedInterleavedARM = 4203,
24 CooperativeMatrixLayoutMax = 0x7fffffff,
25};
26
27enum CooperativeMatrixOperandsMask {
28 CooperativeMatrixOperandsMaskNone = 0,
29 CooperativeMatrixOperandsMatrixASignedComponentsKHRMask = 0x00000001,
30 CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask = 0x00000002,
31 CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask = 0x00000004,
32 CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask = 0x00000008,
33 CooperativeMatrixOperandsSaturatingAccumulationKHRMask = 0x00000010,
34};
35
36enum MemoryAccessMask {
37 MemoryAccessMaskNone = 0,
38 MemoryAccessVolatileMask = 0x00000001,
39 MemoryAccessAlignedMask = 0x00000002,
40 MemoryAccessNontemporalMask = 0x00000004,
41 MemoryAccessMakePointerAvailableMask = 0x00000008,
42 MemoryAccessMakePointerAvailableKHRMask = 0x00000008,
43 MemoryAccessMakePointerVisibleMask = 0x00000010,
44 MemoryAccessMakePointerVisibleKHRMask = 0x00000010,
45 MemoryAccessNonPrivatePointerMask = 0x00000020,
46 MemoryAccessNonPrivatePointerKHRMask = 0x00000020,
47 MemoryAccessAliasScopeINTELMaskMask = 0x00010000,
48 MemoryAccessNoAliasINTELMaskMask = 0x00020000,
49};
50
51enum Scope {
52 ScopeCrossDevice = 0,
53 ScopeDevice = 1,
54 ScopeWorkgroup = 2,
55 ScopeSubgroup = 3,
56 ScopeInvocation = 4,
57 ScopeQueueFamily = 5,
58 ScopeQueueFamilyKHR = 5,
59 ScopeShaderCallKHR = 6,
60 ScopeMax = 0x7fffffff,
61};
62
63enum StorageClass {
64 StorageClassWorkgroup = 4,
65};
66
67// An opaque type to represent a Spir-V pointer to the workgroup storage class.
68// clang-format off
69template <typename PointeeType>
70using WorkgroupSpirvPointer = const vk::SpirvOpaqueType<
71 /* OpTypePointer */ 32,
72 vk::Literal<vk::integral_constant<uint, StorageClassWorkgroup> >,
73 PointeeType>;
74// clang-format on
75
76// Returns an opaque Spir-V pointer to v. The memory object v's storage class
77// modifier must be groupshared. If the incorrect storage class is used, then
78// there will be a validation error, and it will not show the correct
79template <typename T>
80[[vk::ext_instruction(/* OpCopyObject */ 83)]] WorkgroupSpirvPointer<T>
81GetGroupSharedAddress([[vk::ext_reference]] T v);
82
83} // namespace vk
84
85#endif // _HLSL_VK_SPIRV_H_