diff options
Diffstat (limited to 'contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_root_signature.h')
| -rw-r--r-- | contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_root_signature.h | 1227 |
1 files changed, 1227 insertions, 0 deletions
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_root_signature.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_root_signature.h new file mode 100644 index 0000000..e194d30 --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_root_signature.h | |||
| @@ -0,0 +1,1227 @@ | |||
| 1 | //********************************************************* | ||
| 2 | // | ||
| 3 | // Copyright (c) Microsoft Corporation. | ||
| 4 | // Licensed under the MIT License (MIT). | ||
| 5 | // | ||
| 6 | //********************************************************* | ||
| 7 | |||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #ifndef __cplusplus | ||
| 11 | #error D3DX12 requires C++ | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #include "d3d12.h" | ||
| 15 | #include "d3dx12_default.h" | ||
| 16 | |||
| 17 | //------------------------------------------------------------------------------------------------ | ||
| 18 | struct CD3DX12_DESCRIPTOR_RANGE : public D3D12_DESCRIPTOR_RANGE | ||
| 19 | { | ||
| 20 | CD3DX12_DESCRIPTOR_RANGE() = default; | ||
| 21 | explicit CD3DX12_DESCRIPTOR_RANGE(const D3D12_DESCRIPTOR_RANGE &o) noexcept : | ||
| 22 | D3D12_DESCRIPTOR_RANGE(o) | ||
| 23 | {} | ||
| 24 | CD3DX12_DESCRIPTOR_RANGE( | ||
| 25 | D3D12_DESCRIPTOR_RANGE_TYPE rangeType, | ||
| 26 | UINT numDescriptors, | ||
| 27 | UINT baseShaderRegister, | ||
| 28 | UINT registerSpace = 0, | ||
| 29 | UINT offsetInDescriptorsFromTableStart = | ||
| 30 | D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept | ||
| 31 | { | ||
| 32 | Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); | ||
| 33 | } | ||
| 34 | |||
| 35 | inline void Init( | ||
| 36 | D3D12_DESCRIPTOR_RANGE_TYPE rangeType, | ||
| 37 | UINT numDescriptors, | ||
| 38 | UINT baseShaderRegister, | ||
| 39 | UINT registerSpace = 0, | ||
| 40 | UINT offsetInDescriptorsFromTableStart = | ||
| 41 | D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept | ||
| 42 | { | ||
| 43 | Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); | ||
| 44 | } | ||
| 45 | |||
| 46 | static inline void Init( | ||
| 47 | _Out_ D3D12_DESCRIPTOR_RANGE &range, | ||
| 48 | D3D12_DESCRIPTOR_RANGE_TYPE rangeType, | ||
| 49 | UINT numDescriptors, | ||
| 50 | UINT baseShaderRegister, | ||
| 51 | UINT registerSpace = 0, | ||
| 52 | UINT offsetInDescriptorsFromTableStart = | ||
| 53 | D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept | ||
| 54 | { | ||
| 55 | range.RangeType = rangeType; | ||
| 56 | range.NumDescriptors = numDescriptors; | ||
| 57 | range.BaseShaderRegister = baseShaderRegister; | ||
| 58 | range.RegisterSpace = registerSpace; | ||
| 59 | range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; | ||
| 60 | } | ||
| 61 | }; | ||
| 62 | |||
| 63 | //------------------------------------------------------------------------------------------------ | ||
| 64 | struct CD3DX12_ROOT_DESCRIPTOR_TABLE : public D3D12_ROOT_DESCRIPTOR_TABLE | ||
| 65 | { | ||
| 66 | CD3DX12_ROOT_DESCRIPTOR_TABLE() = default; | ||
| 67 | explicit CD3DX12_ROOT_DESCRIPTOR_TABLE(const D3D12_ROOT_DESCRIPTOR_TABLE &o) noexcept : | ||
| 68 | D3D12_ROOT_DESCRIPTOR_TABLE(o) | ||
| 69 | {} | ||
| 70 | CD3DX12_ROOT_DESCRIPTOR_TABLE( | ||
| 71 | UINT numDescriptorRanges, | ||
| 72 | _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept | ||
| 73 | { | ||
| 74 | Init(numDescriptorRanges, _pDescriptorRanges); | ||
| 75 | } | ||
| 76 | |||
| 77 | inline void Init( | ||
| 78 | UINT numDescriptorRanges, | ||
| 79 | _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept | ||
| 80 | { | ||
| 81 | Init(*this, numDescriptorRanges, _pDescriptorRanges); | ||
| 82 | } | ||
| 83 | |||
| 84 | static inline void Init( | ||
| 85 | _Out_ D3D12_ROOT_DESCRIPTOR_TABLE &rootDescriptorTable, | ||
| 86 | UINT numDescriptorRanges, | ||
| 87 | _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept | ||
| 88 | { | ||
| 89 | rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; | ||
| 90 | rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | |||
| 94 | //------------------------------------------------------------------------------------------------ | ||
| 95 | struct CD3DX12_ROOT_CONSTANTS : public D3D12_ROOT_CONSTANTS | ||
| 96 | { | ||
| 97 | CD3DX12_ROOT_CONSTANTS() = default; | ||
| 98 | explicit CD3DX12_ROOT_CONSTANTS(const D3D12_ROOT_CONSTANTS &o) noexcept : | ||
| 99 | D3D12_ROOT_CONSTANTS(o) | ||
| 100 | {} | ||
| 101 | CD3DX12_ROOT_CONSTANTS( | ||
| 102 | UINT num32BitValues, | ||
| 103 | UINT shaderRegister, | ||
| 104 | UINT registerSpace = 0) noexcept | ||
| 105 | { | ||
| 106 | Init(num32BitValues, shaderRegister, registerSpace); | ||
| 107 | } | ||
| 108 | |||
| 109 | inline void Init( | ||
| 110 | UINT num32BitValues, | ||
| 111 | UINT shaderRegister, | ||
| 112 | UINT registerSpace = 0) noexcept | ||
| 113 | { | ||
| 114 | Init(*this, num32BitValues, shaderRegister, registerSpace); | ||
| 115 | } | ||
| 116 | |||
| 117 | static inline void Init( | ||
| 118 | _Out_ D3D12_ROOT_CONSTANTS &rootConstants, | ||
| 119 | UINT num32BitValues, | ||
| 120 | UINT shaderRegister, | ||
| 121 | UINT registerSpace = 0) noexcept | ||
| 122 | { | ||
| 123 | rootConstants.Num32BitValues = num32BitValues; | ||
| 124 | rootConstants.ShaderRegister = shaderRegister; | ||
| 125 | rootConstants.RegisterSpace = registerSpace; | ||
| 126 | } | ||
| 127 | }; | ||
| 128 | |||
| 129 | //------------------------------------------------------------------------------------------------ | ||
| 130 | struct CD3DX12_ROOT_DESCRIPTOR : public D3D12_ROOT_DESCRIPTOR | ||
| 131 | { | ||
| 132 | CD3DX12_ROOT_DESCRIPTOR() = default; | ||
| 133 | explicit CD3DX12_ROOT_DESCRIPTOR(const D3D12_ROOT_DESCRIPTOR &o) noexcept : | ||
| 134 | D3D12_ROOT_DESCRIPTOR(o) | ||
| 135 | {} | ||
| 136 | CD3DX12_ROOT_DESCRIPTOR( | ||
| 137 | UINT shaderRegister, | ||
| 138 | UINT registerSpace = 0) noexcept | ||
| 139 | { | ||
| 140 | Init(shaderRegister, registerSpace); | ||
| 141 | } | ||
| 142 | |||
| 143 | inline void Init( | ||
| 144 | UINT shaderRegister, | ||
| 145 | UINT registerSpace = 0) noexcept | ||
| 146 | { | ||
| 147 | Init(*this, shaderRegister, registerSpace); | ||
| 148 | } | ||
| 149 | |||
| 150 | static inline void Init(_Out_ D3D12_ROOT_DESCRIPTOR &table, UINT shaderRegister, UINT registerSpace = 0) noexcept | ||
| 151 | { | ||
| 152 | table.ShaderRegister = shaderRegister; | ||
| 153 | table.RegisterSpace = registerSpace; | ||
| 154 | } | ||
| 155 | }; | ||
| 156 | |||
| 157 | //------------------------------------------------------------------------------------------------ | ||
| 158 | struct CD3DX12_ROOT_PARAMETER : public D3D12_ROOT_PARAMETER | ||
| 159 | { | ||
| 160 | CD3DX12_ROOT_PARAMETER() = default; | ||
| 161 | explicit CD3DX12_ROOT_PARAMETER(const D3D12_ROOT_PARAMETER &o) noexcept : | ||
| 162 | D3D12_ROOT_PARAMETER(o) | ||
| 163 | {} | ||
| 164 | |||
| 165 | static inline void InitAsDescriptorTable( | ||
| 166 | _Out_ D3D12_ROOT_PARAMETER &rootParam, | ||
| 167 | UINT numDescriptorRanges, | ||
| 168 | _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, | ||
| 169 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 170 | { | ||
| 171 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; | ||
| 172 | rootParam.ShaderVisibility = visibility; | ||
| 173 | CD3DX12_ROOT_DESCRIPTOR_TABLE::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); | ||
| 174 | } | ||
| 175 | |||
| 176 | static inline void InitAsConstants( | ||
| 177 | _Out_ D3D12_ROOT_PARAMETER &rootParam, | ||
| 178 | UINT num32BitValues, | ||
| 179 | UINT shaderRegister, | ||
| 180 | UINT registerSpace = 0, | ||
| 181 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 182 | { | ||
| 183 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; | ||
| 184 | rootParam.ShaderVisibility = visibility; | ||
| 185 | CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); | ||
| 186 | } | ||
| 187 | |||
| 188 | static inline void InitAsConstantBufferView( | ||
| 189 | _Out_ D3D12_ROOT_PARAMETER &rootParam, | ||
| 190 | UINT shaderRegister, | ||
| 191 | UINT registerSpace = 0, | ||
| 192 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 193 | { | ||
| 194 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; | ||
| 195 | rootParam.ShaderVisibility = visibility; | ||
| 196 | CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); | ||
| 197 | } | ||
| 198 | |||
| 199 | static inline void InitAsShaderResourceView( | ||
| 200 | _Out_ D3D12_ROOT_PARAMETER &rootParam, | ||
| 201 | UINT shaderRegister, | ||
| 202 | UINT registerSpace = 0, | ||
| 203 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 204 | { | ||
| 205 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; | ||
| 206 | rootParam.ShaderVisibility = visibility; | ||
| 207 | CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); | ||
| 208 | } | ||
| 209 | |||
| 210 | static inline void InitAsUnorderedAccessView( | ||
| 211 | _Out_ D3D12_ROOT_PARAMETER &rootParam, | ||
| 212 | UINT shaderRegister, | ||
| 213 | UINT registerSpace = 0, | ||
| 214 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 215 | { | ||
| 216 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; | ||
| 217 | rootParam.ShaderVisibility = visibility; | ||
| 218 | CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); | ||
| 219 | } | ||
| 220 | |||
| 221 | inline void InitAsDescriptorTable( | ||
| 222 | UINT numDescriptorRanges, | ||
| 223 | _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, | ||
| 224 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 225 | { | ||
| 226 | InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); | ||
| 227 | } | ||
| 228 | |||
| 229 | inline void InitAsConstants( | ||
| 230 | UINT num32BitValues, | ||
| 231 | UINT shaderRegister, | ||
| 232 | UINT registerSpace = 0, | ||
| 233 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 234 | { | ||
| 235 | InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); | ||
| 236 | } | ||
| 237 | |||
| 238 | inline void InitAsConstantBufferView( | ||
| 239 | UINT shaderRegister, | ||
| 240 | UINT registerSpace = 0, | ||
| 241 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 242 | { | ||
| 243 | InitAsConstantBufferView(*this, shaderRegister, registerSpace, visibility); | ||
| 244 | } | ||
| 245 | |||
| 246 | inline void InitAsShaderResourceView( | ||
| 247 | UINT shaderRegister, | ||
| 248 | UINT registerSpace = 0, | ||
| 249 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 250 | { | ||
| 251 | InitAsShaderResourceView(*this, shaderRegister, registerSpace, visibility); | ||
| 252 | } | ||
| 253 | |||
| 254 | inline void InitAsUnorderedAccessView( | ||
| 255 | UINT shaderRegister, | ||
| 256 | UINT registerSpace = 0, | ||
| 257 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 258 | { | ||
| 259 | InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, visibility); | ||
| 260 | } | ||
| 261 | }; | ||
| 262 | |||
| 263 | //------------------------------------------------------------------------------------------------ | ||
| 264 | struct CD3DX12_STATIC_SAMPLER_DESC : public D3D12_STATIC_SAMPLER_DESC | ||
| 265 | { | ||
| 266 | CD3DX12_STATIC_SAMPLER_DESC() = default; | ||
| 267 | explicit CD3DX12_STATIC_SAMPLER_DESC(const D3D12_STATIC_SAMPLER_DESC &o) noexcept : | ||
| 268 | D3D12_STATIC_SAMPLER_DESC(o) | ||
| 269 | {} | ||
| 270 | CD3DX12_STATIC_SAMPLER_DESC( | ||
| 271 | UINT shaderRegister, | ||
| 272 | D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, | ||
| 273 | D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 274 | D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 275 | D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 276 | FLOAT mipLODBias = 0, | ||
| 277 | UINT maxAnisotropy = 16, | ||
| 278 | D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, | ||
| 279 | D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, | ||
| 280 | FLOAT minLOD = 0.f, | ||
| 281 | FLOAT maxLOD = D3D12_FLOAT32_MAX, | ||
| 282 | D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, | ||
| 283 | UINT registerSpace = 0) noexcept | ||
| 284 | { | ||
| 285 | Init( | ||
| 286 | shaderRegister, | ||
| 287 | filter, | ||
| 288 | addressU, | ||
| 289 | addressV, | ||
| 290 | addressW, | ||
| 291 | mipLODBias, | ||
| 292 | maxAnisotropy, | ||
| 293 | comparisonFunc, | ||
| 294 | borderColor, | ||
| 295 | minLOD, | ||
| 296 | maxLOD, | ||
| 297 | shaderVisibility, | ||
| 298 | registerSpace); | ||
| 299 | } | ||
| 300 | |||
| 301 | static inline void Init( | ||
| 302 | _Out_ D3D12_STATIC_SAMPLER_DESC &samplerDesc, | ||
| 303 | UINT shaderRegister, | ||
| 304 | D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, | ||
| 305 | D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 306 | D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 307 | D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 308 | FLOAT mipLODBias = 0, | ||
| 309 | UINT maxAnisotropy = 16, | ||
| 310 | D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, | ||
| 311 | D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, | ||
| 312 | FLOAT minLOD = 0.f, | ||
| 313 | FLOAT maxLOD = D3D12_FLOAT32_MAX, | ||
| 314 | D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, | ||
| 315 | UINT registerSpace = 0) noexcept | ||
| 316 | { | ||
| 317 | samplerDesc.ShaderRegister = shaderRegister; | ||
| 318 | samplerDesc.Filter = filter; | ||
| 319 | samplerDesc.AddressU = addressU; | ||
| 320 | samplerDesc.AddressV = addressV; | ||
| 321 | samplerDesc.AddressW = addressW; | ||
| 322 | samplerDesc.MipLODBias = mipLODBias; | ||
| 323 | samplerDesc.MaxAnisotropy = maxAnisotropy; | ||
| 324 | samplerDesc.ComparisonFunc = comparisonFunc; | ||
| 325 | samplerDesc.BorderColor = borderColor; | ||
| 326 | samplerDesc.MinLOD = minLOD; | ||
| 327 | samplerDesc.MaxLOD = maxLOD; | ||
| 328 | samplerDesc.ShaderVisibility = shaderVisibility; | ||
| 329 | samplerDesc.RegisterSpace = registerSpace; | ||
| 330 | } | ||
| 331 | inline void Init( | ||
| 332 | UINT shaderRegister, | ||
| 333 | D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, | ||
| 334 | D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 335 | D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 336 | D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 337 | FLOAT mipLODBias = 0, | ||
| 338 | UINT maxAnisotropy = 16, | ||
| 339 | D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, | ||
| 340 | D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, | ||
| 341 | FLOAT minLOD = 0.f, | ||
| 342 | FLOAT maxLOD = D3D12_FLOAT32_MAX, | ||
| 343 | D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, | ||
| 344 | UINT registerSpace = 0) noexcept | ||
| 345 | { | ||
| 346 | Init( | ||
| 347 | *this, | ||
| 348 | shaderRegister, | ||
| 349 | filter, | ||
| 350 | addressU, | ||
| 351 | addressV, | ||
| 352 | addressW, | ||
| 353 | mipLODBias, | ||
| 354 | maxAnisotropy, | ||
| 355 | comparisonFunc, | ||
| 356 | borderColor, | ||
| 357 | minLOD, | ||
| 358 | maxLOD, | ||
| 359 | shaderVisibility, | ||
| 360 | registerSpace); | ||
| 361 | } | ||
| 362 | }; | ||
| 363 | |||
| 364 | //------------------------------------------------------------------------------------------------ | ||
| 365 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 366 | struct CD3DX12_STATIC_SAMPLER_DESC1 : public D3D12_STATIC_SAMPLER_DESC1 | ||
| 367 | { | ||
| 368 | CD3DX12_STATIC_SAMPLER_DESC1() = default; | ||
| 369 | explicit CD3DX12_STATIC_SAMPLER_DESC1(const D3D12_STATIC_SAMPLER_DESC &o) noexcept | ||
| 370 | { | ||
| 371 | memcpy(this, &o, sizeof(D3D12_STATIC_SAMPLER_DESC)); | ||
| 372 | Flags = D3D12_SAMPLER_FLAGS::D3D12_SAMPLER_FLAG_NONE; | ||
| 373 | } | ||
| 374 | explicit CD3DX12_STATIC_SAMPLER_DESC1(const D3D12_STATIC_SAMPLER_DESC1 & o) noexcept : | ||
| 375 | D3D12_STATIC_SAMPLER_DESC1(o) | ||
| 376 | {} | ||
| 377 | CD3DX12_STATIC_SAMPLER_DESC1( | ||
| 378 | UINT shaderRegister, | ||
| 379 | D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, | ||
| 380 | D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 381 | D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 382 | D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 383 | FLOAT mipLODBias = 0, | ||
| 384 | UINT maxAnisotropy = 16, | ||
| 385 | D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, | ||
| 386 | D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, | ||
| 387 | FLOAT minLOD = 0.f, | ||
| 388 | FLOAT maxLOD = D3D12_FLOAT32_MAX, | ||
| 389 | D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, | ||
| 390 | UINT registerSpace = 0, | ||
| 391 | D3D12_SAMPLER_FLAGS flags = D3D12_SAMPLER_FLAGS::D3D12_SAMPLER_FLAG_NONE) noexcept | ||
| 392 | { | ||
| 393 | Init( | ||
| 394 | shaderRegister, | ||
| 395 | filter, | ||
| 396 | addressU, | ||
| 397 | addressV, | ||
| 398 | addressW, | ||
| 399 | mipLODBias, | ||
| 400 | maxAnisotropy, | ||
| 401 | comparisonFunc, | ||
| 402 | borderColor, | ||
| 403 | minLOD, | ||
| 404 | maxLOD, | ||
| 405 | shaderVisibility, | ||
| 406 | registerSpace, | ||
| 407 | flags); | ||
| 408 | } | ||
| 409 | |||
| 410 | static inline void Init( | ||
| 411 | _Out_ D3D12_STATIC_SAMPLER_DESC1 &samplerDesc, | ||
| 412 | UINT shaderRegister, | ||
| 413 | D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, | ||
| 414 | D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 415 | D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 416 | D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 417 | FLOAT mipLODBias = 0, | ||
| 418 | UINT maxAnisotropy = 16, | ||
| 419 | D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, | ||
| 420 | D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, | ||
| 421 | FLOAT minLOD = 0.f, | ||
| 422 | FLOAT maxLOD = D3D12_FLOAT32_MAX, | ||
| 423 | D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, | ||
| 424 | UINT registerSpace = 0, | ||
| 425 | D3D12_SAMPLER_FLAGS flags = D3D12_SAMPLER_FLAGS::D3D12_SAMPLER_FLAG_NONE) noexcept | ||
| 426 | { | ||
| 427 | samplerDesc.ShaderRegister = shaderRegister; | ||
| 428 | samplerDesc.Filter = filter; | ||
| 429 | samplerDesc.AddressU = addressU; | ||
| 430 | samplerDesc.AddressV = addressV; | ||
| 431 | samplerDesc.AddressW = addressW; | ||
| 432 | samplerDesc.MipLODBias = mipLODBias; | ||
| 433 | samplerDesc.MaxAnisotropy = maxAnisotropy; | ||
| 434 | samplerDesc.ComparisonFunc = comparisonFunc; | ||
| 435 | samplerDesc.BorderColor = borderColor; | ||
| 436 | samplerDesc.MinLOD = minLOD; | ||
| 437 | samplerDesc.MaxLOD = maxLOD; | ||
| 438 | samplerDesc.ShaderVisibility = shaderVisibility; | ||
| 439 | samplerDesc.RegisterSpace = registerSpace; | ||
| 440 | samplerDesc.Flags = flags; | ||
| 441 | } | ||
| 442 | inline void Init( | ||
| 443 | UINT shaderRegister, | ||
| 444 | D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, | ||
| 445 | D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 446 | D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 447 | D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, | ||
| 448 | FLOAT mipLODBias = 0, | ||
| 449 | UINT maxAnisotropy = 16, | ||
| 450 | D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, | ||
| 451 | D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, | ||
| 452 | FLOAT minLOD = 0.f, | ||
| 453 | FLOAT maxLOD = D3D12_FLOAT32_MAX, | ||
| 454 | D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, | ||
| 455 | UINT registerSpace = 0, | ||
| 456 | D3D12_SAMPLER_FLAGS flags = D3D12_SAMPLER_FLAGS::D3D12_SAMPLER_FLAG_NONE) noexcept | ||
| 457 | { | ||
| 458 | Init( | ||
| 459 | *this, | ||
| 460 | shaderRegister, | ||
| 461 | filter, | ||
| 462 | addressU, | ||
| 463 | addressV, | ||
| 464 | addressW, | ||
| 465 | mipLODBias, | ||
| 466 | maxAnisotropy, | ||
| 467 | comparisonFunc, | ||
| 468 | borderColor, | ||
| 469 | minLOD, | ||
| 470 | maxLOD, | ||
| 471 | shaderVisibility, | ||
| 472 | registerSpace, | ||
| 473 | flags); | ||
| 474 | } | ||
| 475 | }; | ||
| 476 | #endif // D3D12_SDK_VERSION >= 609 | ||
| 477 | |||
| 478 | //------------------------------------------------------------------------------------------------ | ||
| 479 | struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC | ||
| 480 | { | ||
| 481 | CD3DX12_ROOT_SIGNATURE_DESC() = default; | ||
| 482 | explicit CD3DX12_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept : | ||
| 483 | D3D12_ROOT_SIGNATURE_DESC(o) | ||
| 484 | {} | ||
| 485 | CD3DX12_ROOT_SIGNATURE_DESC( | ||
| 486 | UINT numParameters, | ||
| 487 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, | ||
| 488 | UINT numStaticSamplers = 0, | ||
| 489 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 490 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 491 | { | ||
| 492 | Init(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); | ||
| 493 | } | ||
| 494 | CD3DX12_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept | ||
| 495 | { | ||
| 496 | Init(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); | ||
| 497 | } | ||
| 498 | |||
| 499 | inline void Init( | ||
| 500 | UINT numParameters, | ||
| 501 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, | ||
| 502 | UINT numStaticSamplers = 0, | ||
| 503 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 504 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 505 | { | ||
| 506 | Init(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); | ||
| 507 | } | ||
| 508 | |||
| 509 | static inline void Init( | ||
| 510 | _Out_ D3D12_ROOT_SIGNATURE_DESC &desc, | ||
| 511 | UINT numParameters, | ||
| 512 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, | ||
| 513 | UINT numStaticSamplers = 0, | ||
| 514 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 515 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 516 | { | ||
| 517 | desc.NumParameters = numParameters; | ||
| 518 | desc.pParameters = _pParameters; | ||
| 519 | desc.NumStaticSamplers = numStaticSamplers; | ||
| 520 | desc.pStaticSamplers = _pStaticSamplers; | ||
| 521 | desc.Flags = flags; | ||
| 522 | } | ||
| 523 | }; | ||
| 524 | |||
| 525 | //------------------------------------------------------------------------------------------------ | ||
| 526 | struct CD3DX12_DESCRIPTOR_RANGE1 : public D3D12_DESCRIPTOR_RANGE1 | ||
| 527 | { | ||
| 528 | CD3DX12_DESCRIPTOR_RANGE1() = default; | ||
| 529 | explicit CD3DX12_DESCRIPTOR_RANGE1(const D3D12_DESCRIPTOR_RANGE1 &o) noexcept : | ||
| 530 | D3D12_DESCRIPTOR_RANGE1(o) | ||
| 531 | {} | ||
| 532 | CD3DX12_DESCRIPTOR_RANGE1( | ||
| 533 | D3D12_DESCRIPTOR_RANGE_TYPE rangeType, | ||
| 534 | UINT numDescriptors, | ||
| 535 | UINT baseShaderRegister, | ||
| 536 | UINT registerSpace = 0, | ||
| 537 | D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, | ||
| 538 | UINT offsetInDescriptorsFromTableStart = | ||
| 539 | D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept | ||
| 540 | { | ||
| 541 | Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); | ||
| 542 | } | ||
| 543 | |||
| 544 | inline void Init( | ||
| 545 | D3D12_DESCRIPTOR_RANGE_TYPE rangeType, | ||
| 546 | UINT numDescriptors, | ||
| 547 | UINT baseShaderRegister, | ||
| 548 | UINT registerSpace = 0, | ||
| 549 | D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, | ||
| 550 | UINT offsetInDescriptorsFromTableStart = | ||
| 551 | D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept | ||
| 552 | { | ||
| 553 | Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); | ||
| 554 | } | ||
| 555 | |||
| 556 | static inline void Init( | ||
| 557 | _Out_ D3D12_DESCRIPTOR_RANGE1 &range, | ||
| 558 | D3D12_DESCRIPTOR_RANGE_TYPE rangeType, | ||
| 559 | UINT numDescriptors, | ||
| 560 | UINT baseShaderRegister, | ||
| 561 | UINT registerSpace = 0, | ||
| 562 | D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, | ||
| 563 | UINT offsetInDescriptorsFromTableStart = | ||
| 564 | D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept | ||
| 565 | { | ||
| 566 | range.RangeType = rangeType; | ||
| 567 | range.NumDescriptors = numDescriptors; | ||
| 568 | range.BaseShaderRegister = baseShaderRegister; | ||
| 569 | range.RegisterSpace = registerSpace; | ||
| 570 | range.Flags = flags; | ||
| 571 | range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; | ||
| 572 | } | ||
| 573 | }; | ||
| 574 | |||
| 575 | //------------------------------------------------------------------------------------------------ | ||
| 576 | struct CD3DX12_ROOT_DESCRIPTOR_TABLE1 : public D3D12_ROOT_DESCRIPTOR_TABLE1 | ||
| 577 | { | ||
| 578 | CD3DX12_ROOT_DESCRIPTOR_TABLE1() = default; | ||
| 579 | explicit CD3DX12_ROOT_DESCRIPTOR_TABLE1(const D3D12_ROOT_DESCRIPTOR_TABLE1 &o) noexcept : | ||
| 580 | D3D12_ROOT_DESCRIPTOR_TABLE1(o) | ||
| 581 | {} | ||
| 582 | CD3DX12_ROOT_DESCRIPTOR_TABLE1( | ||
| 583 | UINT numDescriptorRanges, | ||
| 584 | _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept | ||
| 585 | { | ||
| 586 | Init(numDescriptorRanges, _pDescriptorRanges); | ||
| 587 | } | ||
| 588 | |||
| 589 | inline void Init( | ||
| 590 | UINT numDescriptorRanges, | ||
| 591 | _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept | ||
| 592 | { | ||
| 593 | Init(*this, numDescriptorRanges, _pDescriptorRanges); | ||
| 594 | } | ||
| 595 | |||
| 596 | static inline void Init( | ||
| 597 | _Out_ D3D12_ROOT_DESCRIPTOR_TABLE1 &rootDescriptorTable, | ||
| 598 | UINT numDescriptorRanges, | ||
| 599 | _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept | ||
| 600 | { | ||
| 601 | rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; | ||
| 602 | rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; | ||
| 603 | } | ||
| 604 | }; | ||
| 605 | |||
| 606 | //------------------------------------------------------------------------------------------------ | ||
| 607 | struct CD3DX12_ROOT_DESCRIPTOR1 : public D3D12_ROOT_DESCRIPTOR1 | ||
| 608 | { | ||
| 609 | CD3DX12_ROOT_DESCRIPTOR1() = default; | ||
| 610 | explicit CD3DX12_ROOT_DESCRIPTOR1(const D3D12_ROOT_DESCRIPTOR1 &o) noexcept : | ||
| 611 | D3D12_ROOT_DESCRIPTOR1(o) | ||
| 612 | {} | ||
| 613 | CD3DX12_ROOT_DESCRIPTOR1( | ||
| 614 | UINT shaderRegister, | ||
| 615 | UINT registerSpace = 0, | ||
| 616 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept | ||
| 617 | { | ||
| 618 | Init(shaderRegister, registerSpace, flags); | ||
| 619 | } | ||
| 620 | |||
| 621 | inline void Init( | ||
| 622 | UINT shaderRegister, | ||
| 623 | UINT registerSpace = 0, | ||
| 624 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept | ||
| 625 | { | ||
| 626 | Init(*this, shaderRegister, registerSpace, flags); | ||
| 627 | } | ||
| 628 | |||
| 629 | static inline void Init( | ||
| 630 | _Out_ D3D12_ROOT_DESCRIPTOR1 &table, | ||
| 631 | UINT shaderRegister, | ||
| 632 | UINT registerSpace = 0, | ||
| 633 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept | ||
| 634 | { | ||
| 635 | table.ShaderRegister = shaderRegister; | ||
| 636 | table.RegisterSpace = registerSpace; | ||
| 637 | table.Flags = flags; | ||
| 638 | } | ||
| 639 | }; | ||
| 640 | |||
| 641 | //------------------------------------------------------------------------------------------------ | ||
| 642 | struct CD3DX12_ROOT_PARAMETER1 : public D3D12_ROOT_PARAMETER1 | ||
| 643 | { | ||
| 644 | CD3DX12_ROOT_PARAMETER1() = default; | ||
| 645 | explicit CD3DX12_ROOT_PARAMETER1(const D3D12_ROOT_PARAMETER1 &o) noexcept : | ||
| 646 | D3D12_ROOT_PARAMETER1(o) | ||
| 647 | {} | ||
| 648 | |||
| 649 | static inline void InitAsDescriptorTable( | ||
| 650 | _Out_ D3D12_ROOT_PARAMETER1 &rootParam, | ||
| 651 | UINT numDescriptorRanges, | ||
| 652 | _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, | ||
| 653 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 654 | { | ||
| 655 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; | ||
| 656 | rootParam.ShaderVisibility = visibility; | ||
| 657 | CD3DX12_ROOT_DESCRIPTOR_TABLE1::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); | ||
| 658 | } | ||
| 659 | |||
| 660 | static inline void InitAsConstants( | ||
| 661 | _Out_ D3D12_ROOT_PARAMETER1 &rootParam, | ||
| 662 | UINT num32BitValues, | ||
| 663 | UINT shaderRegister, | ||
| 664 | UINT registerSpace = 0, | ||
| 665 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 666 | { | ||
| 667 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; | ||
| 668 | rootParam.ShaderVisibility = visibility; | ||
| 669 | CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); | ||
| 670 | } | ||
| 671 | |||
| 672 | static inline void InitAsConstantBufferView( | ||
| 673 | _Out_ D3D12_ROOT_PARAMETER1 &rootParam, | ||
| 674 | UINT shaderRegister, | ||
| 675 | UINT registerSpace = 0, | ||
| 676 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, | ||
| 677 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 678 | { | ||
| 679 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; | ||
| 680 | rootParam.ShaderVisibility = visibility; | ||
| 681 | CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); | ||
| 682 | } | ||
| 683 | |||
| 684 | static inline void InitAsShaderResourceView( | ||
| 685 | _Out_ D3D12_ROOT_PARAMETER1 &rootParam, | ||
| 686 | UINT shaderRegister, | ||
| 687 | UINT registerSpace = 0, | ||
| 688 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, | ||
| 689 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 690 | { | ||
| 691 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; | ||
| 692 | rootParam.ShaderVisibility = visibility; | ||
| 693 | CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); | ||
| 694 | } | ||
| 695 | |||
| 696 | static inline void InitAsUnorderedAccessView( | ||
| 697 | _Out_ D3D12_ROOT_PARAMETER1 &rootParam, | ||
| 698 | UINT shaderRegister, | ||
| 699 | UINT registerSpace = 0, | ||
| 700 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, | ||
| 701 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 702 | { | ||
| 703 | rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; | ||
| 704 | rootParam.ShaderVisibility = visibility; | ||
| 705 | CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); | ||
| 706 | } | ||
| 707 | |||
| 708 | inline void InitAsDescriptorTable( | ||
| 709 | UINT numDescriptorRanges, | ||
| 710 | _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, | ||
| 711 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 712 | { | ||
| 713 | InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); | ||
| 714 | } | ||
| 715 | |||
| 716 | inline void InitAsConstants( | ||
| 717 | UINT num32BitValues, | ||
| 718 | UINT shaderRegister, | ||
| 719 | UINT registerSpace = 0, | ||
| 720 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 721 | { | ||
| 722 | InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); | ||
| 723 | } | ||
| 724 | |||
| 725 | inline void InitAsConstantBufferView( | ||
| 726 | UINT shaderRegister, | ||
| 727 | UINT registerSpace = 0, | ||
| 728 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, | ||
| 729 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 730 | { | ||
| 731 | InitAsConstantBufferView(*this, shaderRegister, registerSpace, flags, visibility); | ||
| 732 | } | ||
| 733 | |||
| 734 | inline void InitAsShaderResourceView( | ||
| 735 | UINT shaderRegister, | ||
| 736 | UINT registerSpace = 0, | ||
| 737 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, | ||
| 738 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 739 | { | ||
| 740 | InitAsShaderResourceView(*this, shaderRegister, registerSpace, flags, visibility); | ||
| 741 | } | ||
| 742 | |||
| 743 | inline void InitAsUnorderedAccessView( | ||
| 744 | UINT shaderRegister, | ||
| 745 | UINT registerSpace = 0, | ||
| 746 | D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, | ||
| 747 | D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept | ||
| 748 | { | ||
| 749 | InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, flags, visibility); | ||
| 750 | } | ||
| 751 | }; | ||
| 752 | |||
| 753 | //------------------------------------------------------------------------------------------------ | ||
| 754 | struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNATURE_DESC | ||
| 755 | { | ||
| 756 | CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC() = default; | ||
| 757 | explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC &o) noexcept : | ||
| 758 | D3D12_VERSIONED_ROOT_SIGNATURE_DESC(o) | ||
| 759 | {} | ||
| 760 | explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept | ||
| 761 | { | ||
| 762 | Version = D3D_ROOT_SIGNATURE_VERSION_1_0; | ||
| 763 | Desc_1_0 = o; | ||
| 764 | } | ||
| 765 | explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC1 &o) noexcept | ||
| 766 | { | ||
| 767 | Version = D3D_ROOT_SIGNATURE_VERSION_1_1; | ||
| 768 | Desc_1_1 = o; | ||
| 769 | } | ||
| 770 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 771 | explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC2& o) noexcept | ||
| 772 | { | ||
| 773 | Version = D3D_ROOT_SIGNATURE_VERSION_1_2; | ||
| 774 | Desc_1_2 = o; | ||
| 775 | } | ||
| 776 | #endif | ||
| 777 | CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( | ||
| 778 | UINT numParameters, | ||
| 779 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, | ||
| 780 | UINT numStaticSamplers = 0, | ||
| 781 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 782 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 783 | { | ||
| 784 | Init_1_0(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); | ||
| 785 | } | ||
| 786 | CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( | ||
| 787 | UINT numParameters, | ||
| 788 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, | ||
| 789 | UINT numStaticSamplers = 0, | ||
| 790 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 791 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 792 | { | ||
| 793 | Init_1_1(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); | ||
| 794 | } | ||
| 795 | CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept | ||
| 796 | { | ||
| 797 | Init_1_1(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); | ||
| 798 | } | ||
| 799 | |||
| 800 | inline void Init_1_0( | ||
| 801 | UINT numParameters, | ||
| 802 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, | ||
| 803 | UINT numStaticSamplers = 0, | ||
| 804 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 805 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 806 | { | ||
| 807 | Init_1_0(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); | ||
| 808 | } | ||
| 809 | |||
| 810 | static inline void Init_1_0( | ||
| 811 | _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, | ||
| 812 | UINT numParameters, | ||
| 813 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, | ||
| 814 | UINT numStaticSamplers = 0, | ||
| 815 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 816 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 817 | { | ||
| 818 | desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0; | ||
| 819 | desc.Desc_1_0.NumParameters = numParameters; | ||
| 820 | desc.Desc_1_0.pParameters = _pParameters; | ||
| 821 | desc.Desc_1_0.NumStaticSamplers = numStaticSamplers; | ||
| 822 | desc.Desc_1_0.pStaticSamplers = _pStaticSamplers; | ||
| 823 | desc.Desc_1_0.Flags = flags; | ||
| 824 | } | ||
| 825 | |||
| 826 | inline void Init_1_1( | ||
| 827 | UINT numParameters, | ||
| 828 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, | ||
| 829 | UINT numStaticSamplers = 0, | ||
| 830 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 831 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 832 | { | ||
| 833 | Init_1_1(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); | ||
| 834 | } | ||
| 835 | |||
| 836 | static inline void Init_1_1( | ||
| 837 | _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, | ||
| 838 | UINT numParameters, | ||
| 839 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, | ||
| 840 | UINT numStaticSamplers = 0, | ||
| 841 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, | ||
| 842 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 843 | { | ||
| 844 | desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_1; | ||
| 845 | desc.Desc_1_1.NumParameters = numParameters; | ||
| 846 | desc.Desc_1_1.pParameters = _pParameters; | ||
| 847 | desc.Desc_1_1.NumStaticSamplers = numStaticSamplers; | ||
| 848 | desc.Desc_1_1.pStaticSamplers = _pStaticSamplers; | ||
| 849 | desc.Desc_1_1.Flags = flags; | ||
| 850 | } | ||
| 851 | |||
| 852 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 853 | static inline void Init_1_2( | ||
| 854 | _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC& desc, | ||
| 855 | UINT numParameters, | ||
| 856 | _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, | ||
| 857 | UINT numStaticSamplers = 0, | ||
| 858 | _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC1* _pStaticSamplers = nullptr, | ||
| 859 | D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept | ||
| 860 | { | ||
| 861 | desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_2; | ||
| 862 | desc.Desc_1_2.NumParameters = numParameters; | ||
| 863 | desc.Desc_1_2.pParameters = _pParameters; | ||
| 864 | desc.Desc_1_2.NumStaticSamplers = numStaticSamplers; | ||
| 865 | desc.Desc_1_2.pStaticSamplers = _pStaticSamplers; | ||
| 866 | desc.Desc_1_2.Flags = flags; | ||
| 867 | } | ||
| 868 | #endif | ||
| 869 | }; | ||
| 870 | |||
| 871 | //------------------------------------------------------------------------------------------------ | ||
| 872 | struct CD3DX12_CPU_DESCRIPTOR_HANDLE : public D3D12_CPU_DESCRIPTOR_HANDLE | ||
| 873 | { | ||
| 874 | CD3DX12_CPU_DESCRIPTOR_HANDLE() = default; | ||
| 875 | explicit CD3DX12_CPU_DESCRIPTOR_HANDLE(const D3D12_CPU_DESCRIPTOR_HANDLE &o) noexcept : | ||
| 876 | D3D12_CPU_DESCRIPTOR_HANDLE(o) | ||
| 877 | {} | ||
| 878 | CD3DX12_CPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } | ||
| 879 | CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept | ||
| 880 | { | ||
| 881 | InitOffsetted(other, offsetScaledByIncrementSize); | ||
| 882 | } | ||
| 883 | CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 884 | { | ||
| 885 | InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); | ||
| 886 | } | ||
| 887 | CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 888 | { | ||
| 889 | ptr = SIZE_T(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); | ||
| 890 | return *this; | ||
| 891 | } | ||
| 892 | CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept | ||
| 893 | { | ||
| 894 | ptr = SIZE_T(INT64(ptr) + INT64(offsetScaledByIncrementSize)); | ||
| 895 | return *this; | ||
| 896 | } | ||
| 897 | bool operator==(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept | ||
| 898 | { | ||
| 899 | return (ptr == other.ptr); | ||
| 900 | } | ||
| 901 | bool operator!=(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept | ||
| 902 | { | ||
| 903 | return (ptr != other.ptr); | ||
| 904 | } | ||
| 905 | CD3DX12_CPU_DESCRIPTOR_HANDLE &operator=(const D3D12_CPU_DESCRIPTOR_HANDLE &other) noexcept | ||
| 906 | { | ||
| 907 | ptr = other.ptr; | ||
| 908 | return *this; | ||
| 909 | } | ||
| 910 | |||
| 911 | inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept | ||
| 912 | { | ||
| 913 | InitOffsetted(*this, base, offsetScaledByIncrementSize); | ||
| 914 | } | ||
| 915 | |||
| 916 | inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 917 | { | ||
| 918 | InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); | ||
| 919 | } | ||
| 920 | |||
| 921 | static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept | ||
| 922 | { | ||
| 923 | handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); | ||
| 924 | } | ||
| 925 | |||
| 926 | static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 927 | { | ||
| 928 | handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); | ||
| 929 | } | ||
| 930 | }; | ||
| 931 | |||
| 932 | //------------------------------------------------------------------------------------------------ | ||
| 933 | struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE | ||
| 934 | { | ||
| 935 | CD3DX12_GPU_DESCRIPTOR_HANDLE() = default; | ||
| 936 | explicit CD3DX12_GPU_DESCRIPTOR_HANDLE(const D3D12_GPU_DESCRIPTOR_HANDLE &o) noexcept : | ||
| 937 | D3D12_GPU_DESCRIPTOR_HANDLE(o) | ||
| 938 | {} | ||
| 939 | CD3DX12_GPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } | ||
| 940 | CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept | ||
| 941 | { | ||
| 942 | InitOffsetted(other, offsetScaledByIncrementSize); | ||
| 943 | } | ||
| 944 | CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 945 | { | ||
| 946 | InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); | ||
| 947 | } | ||
| 948 | CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 949 | { | ||
| 950 | ptr = UINT64(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); | ||
| 951 | return *this; | ||
| 952 | } | ||
| 953 | CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept | ||
| 954 | { | ||
| 955 | ptr = UINT64(INT64(ptr) + INT64(offsetScaledByIncrementSize)); | ||
| 956 | return *this; | ||
| 957 | } | ||
| 958 | inline bool operator==(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept | ||
| 959 | { | ||
| 960 | return (ptr == other.ptr); | ||
| 961 | } | ||
| 962 | inline bool operator!=(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept | ||
| 963 | { | ||
| 964 | return (ptr != other.ptr); | ||
| 965 | } | ||
| 966 | CD3DX12_GPU_DESCRIPTOR_HANDLE &operator=(const D3D12_GPU_DESCRIPTOR_HANDLE &other) noexcept | ||
| 967 | { | ||
| 968 | ptr = other.ptr; | ||
| 969 | return *this; | ||
| 970 | } | ||
| 971 | |||
| 972 | inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept | ||
| 973 | { | ||
| 974 | InitOffsetted(*this, base, offsetScaledByIncrementSize); | ||
| 975 | } | ||
| 976 | |||
| 977 | inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 978 | { | ||
| 979 | InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); | ||
| 980 | } | ||
| 981 | |||
| 982 | static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept | ||
| 983 | { | ||
| 984 | handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); | ||
| 985 | } | ||
| 986 | |||
| 987 | static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept | ||
| 988 | { | ||
| 989 | handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); | ||
| 990 | } | ||
| 991 | }; | ||
| 992 | |||
| 993 | //------------------------------------------------------------------------------------------------ | ||
| 994 | // D3D12 exports a new method for serializing root signatures in the Windows 10 Anniversary Update. | ||
| 995 | // To help enable root signature 1.1 features when they are available and not require maintaining | ||
| 996 | // two code paths for building root signatures, this helper method reconstructs a 1.0 signature when | ||
| 997 | // 1.1 is not supported. | ||
| 998 | #ifdef __clang__ | ||
| 999 | #pragma clang diagnostic push | ||
| 1000 | #pragma clang diagnostic ignored "-Wcovered-switch-default" | ||
| 1001 | #endif | ||
| 1002 | |||
| 1003 | inline HRESULT D3DX12SerializeVersionedRootSignature( | ||
| 1004 | _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* pRootSignatureDesc, | ||
| 1005 | D3D_ROOT_SIGNATURE_VERSION MaxVersion, | ||
| 1006 | _Outptr_ ID3DBlob** ppBlob, | ||
| 1007 | _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob) noexcept | ||
| 1008 | { | ||
| 1009 | if (ppErrorBlob != nullptr) | ||
| 1010 | { | ||
| 1011 | *ppErrorBlob = nullptr; | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | switch (MaxVersion) | ||
| 1015 | { | ||
| 1016 | case D3D_ROOT_SIGNATURE_VERSION_1_0: | ||
| 1017 | switch (pRootSignatureDesc->Version) | ||
| 1018 | { | ||
| 1019 | case D3D_ROOT_SIGNATURE_VERSION_1_0: | ||
| 1020 | return D3D12SerializeRootSignature(&pRootSignatureDesc->Desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); | ||
| 1021 | |||
| 1022 | case D3D_ROOT_SIGNATURE_VERSION_1_1: | ||
| 1023 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 1024 | case D3D_ROOT_SIGNATURE_VERSION_1_2: | ||
| 1025 | #endif | ||
| 1026 | { | ||
| 1027 | HRESULT hr = S_OK; | ||
| 1028 | const D3D12_ROOT_SIGNATURE_DESC1& desc_1_1 = pRootSignatureDesc->Desc_1_1; | ||
| 1029 | |||
| 1030 | const SIZE_T ParametersSize = sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters; | ||
| 1031 | void* pParameters = (ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : nullptr; | ||
| 1032 | if (ParametersSize > 0 && pParameters == nullptr) | ||
| 1033 | { | ||
| 1034 | hr = E_OUTOFMEMORY; | ||
| 1035 | } | ||
| 1036 | auto pParameters_1_0 = static_cast<D3D12_ROOT_PARAMETER*>(pParameters); | ||
| 1037 | |||
| 1038 | if (SUCCEEDED(hr)) | ||
| 1039 | { | ||
| 1040 | for (UINT n = 0; n < desc_1_1.NumParameters; n++) | ||
| 1041 | { | ||
| 1042 | __analysis_assume(ParametersSize == sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters); | ||
| 1043 | pParameters_1_0[n].ParameterType = desc_1_1.pParameters[n].ParameterType; | ||
| 1044 | pParameters_1_0[n].ShaderVisibility = desc_1_1.pParameters[n].ShaderVisibility; | ||
| 1045 | |||
| 1046 | switch (desc_1_1.pParameters[n].ParameterType) | ||
| 1047 | { | ||
| 1048 | case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: | ||
| 1049 | pParameters_1_0[n].Constants.Num32BitValues = desc_1_1.pParameters[n].Constants.Num32BitValues; | ||
| 1050 | pParameters_1_0[n].Constants.RegisterSpace = desc_1_1.pParameters[n].Constants.RegisterSpace; | ||
| 1051 | pParameters_1_0[n].Constants.ShaderRegister = desc_1_1.pParameters[n].Constants.ShaderRegister; | ||
| 1052 | break; | ||
| 1053 | |||
| 1054 | case D3D12_ROOT_PARAMETER_TYPE_CBV: | ||
| 1055 | case D3D12_ROOT_PARAMETER_TYPE_SRV: | ||
| 1056 | case D3D12_ROOT_PARAMETER_TYPE_UAV: | ||
| 1057 | pParameters_1_0[n].Descriptor.RegisterSpace = desc_1_1.pParameters[n].Descriptor.RegisterSpace; | ||
| 1058 | pParameters_1_0[n].Descriptor.ShaderRegister = desc_1_1.pParameters[n].Descriptor.ShaderRegister; | ||
| 1059 | break; | ||
| 1060 | |||
| 1061 | case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: | ||
| 1062 | { | ||
| 1063 | const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable; | ||
| 1064 | |||
| 1065 | const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges; | ||
| 1066 | void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : nullptr; | ||
| 1067 | if (DescriptorRangesSize > 0 && pDescriptorRanges == nullptr) | ||
| 1068 | { | ||
| 1069 | hr = E_OUTOFMEMORY; | ||
| 1070 | } | ||
| 1071 | auto pDescriptorRanges_1_0 = static_cast<D3D12_DESCRIPTOR_RANGE*>(pDescriptorRanges); | ||
| 1072 | |||
| 1073 | if (SUCCEEDED(hr)) | ||
| 1074 | { | ||
| 1075 | for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++) | ||
| 1076 | { | ||
| 1077 | __analysis_assume(DescriptorRangesSize == sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges); | ||
| 1078 | pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister; | ||
| 1079 | pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors; | ||
| 1080 | pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart; | ||
| 1081 | pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType; | ||
| 1082 | pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace; | ||
| 1083 | } | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable; | ||
| 1087 | table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges; | ||
| 1088 | table_1_0.pDescriptorRanges = pDescriptorRanges_1_0; | ||
| 1089 | } | ||
| 1090 | break; | ||
| 1091 | |||
| 1092 | default: | ||
| 1093 | break; | ||
| 1094 | } | ||
| 1095 | } | ||
| 1096 | } | ||
| 1097 | |||
| 1098 | D3D12_STATIC_SAMPLER_DESC* pStaticSamplers = nullptr; | ||
| 1099 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 1100 | if (desc_1_1.NumStaticSamplers > 0 && pRootSignatureDesc->Version == D3D_ROOT_SIGNATURE_VERSION_1_2) | ||
| 1101 | { | ||
| 1102 | const SIZE_T SamplersSize = sizeof(D3D12_STATIC_SAMPLER_DESC) * desc_1_1.NumStaticSamplers; | ||
| 1103 | pStaticSamplers = static_cast<D3D12_STATIC_SAMPLER_DESC*>(HeapAlloc(GetProcessHeap(), 0, SamplersSize)); | ||
| 1104 | |||
| 1105 | if (pStaticSamplers == nullptr) | ||
| 1106 | { | ||
| 1107 | hr = E_OUTOFMEMORY; | ||
| 1108 | } | ||
| 1109 | else | ||
| 1110 | { | ||
| 1111 | const D3D12_ROOT_SIGNATURE_DESC2& desc_1_2 = pRootSignatureDesc->Desc_1_2; | ||
| 1112 | for (UINT n = 0; n < desc_1_1.NumStaticSamplers; ++n) | ||
| 1113 | { | ||
| 1114 | if ((desc_1_2.pStaticSamplers[n].Flags & ~D3D12_SAMPLER_FLAG_UINT_BORDER_COLOR) != 0) | ||
| 1115 | { | ||
| 1116 | hr = E_INVALIDARG; | ||
| 1117 | break; | ||
| 1118 | } | ||
| 1119 | memcpy(pStaticSamplers + n, desc_1_2.pStaticSamplers + n, sizeof(D3D12_STATIC_SAMPLER_DESC)); | ||
| 1120 | } | ||
| 1121 | } | ||
| 1122 | } | ||
| 1123 | #endif | ||
| 1124 | |||
| 1125 | if (SUCCEEDED(hr)) | ||
| 1126 | { | ||
| 1127 | const CD3DX12_ROOT_SIGNATURE_DESC desc_1_0(desc_1_1.NumParameters, pParameters_1_0, desc_1_1.NumStaticSamplers, pStaticSamplers == nullptr ? desc_1_1.pStaticSamplers : pStaticSamplers, desc_1_1.Flags); | ||
| 1128 | hr = D3D12SerializeRootSignature(&desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | if (pParameters) | ||
| 1132 | { | ||
| 1133 | for (UINT n = 0; n < desc_1_1.NumParameters; n++) | ||
| 1134 | { | ||
| 1135 | if (desc_1_1.pParameters[n].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) | ||
| 1136 | { | ||
| 1137 | auto pDescriptorRanges_1_0 = pParameters_1_0[n].DescriptorTable.pDescriptorRanges; | ||
| 1138 | HeapFree(GetProcessHeap(), 0, reinterpret_cast<void*>(const_cast<D3D12_DESCRIPTOR_RANGE*>(pDescriptorRanges_1_0))); | ||
| 1139 | } | ||
| 1140 | } | ||
| 1141 | HeapFree(GetProcessHeap(), 0, pParameters); | ||
| 1142 | } | ||
| 1143 | |||
| 1144 | if (pStaticSamplers) | ||
| 1145 | { | ||
| 1146 | HeapFree(GetProcessHeap(), 0, pStaticSamplers); | ||
| 1147 | } | ||
| 1148 | |||
| 1149 | return hr; | ||
| 1150 | } | ||
| 1151 | |||
| 1152 | default: | ||
| 1153 | break; | ||
| 1154 | } | ||
| 1155 | break; | ||
| 1156 | |||
| 1157 | case D3D_ROOT_SIGNATURE_VERSION_1_1: | ||
| 1158 | switch (pRootSignatureDesc->Version) | ||
| 1159 | { | ||
| 1160 | case D3D_ROOT_SIGNATURE_VERSION_1_0: | ||
| 1161 | case D3D_ROOT_SIGNATURE_VERSION_1_1: | ||
| 1162 | return D3D12SerializeVersionedRootSignature(pRootSignatureDesc, ppBlob, ppErrorBlob); | ||
| 1163 | |||
| 1164 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 1165 | case D3D_ROOT_SIGNATURE_VERSION_1_2: | ||
| 1166 | { | ||
| 1167 | HRESULT hr = S_OK; | ||
| 1168 | const D3D12_ROOT_SIGNATURE_DESC1& desc_1_1 = pRootSignatureDesc->Desc_1_1; | ||
| 1169 | |||
| 1170 | D3D12_STATIC_SAMPLER_DESC* pStaticSamplers = nullptr; | ||
| 1171 | if (desc_1_1.NumStaticSamplers > 0) | ||
| 1172 | { | ||
| 1173 | const SIZE_T SamplersSize = sizeof(D3D12_STATIC_SAMPLER_DESC) * desc_1_1.NumStaticSamplers; | ||
| 1174 | pStaticSamplers = static_cast<D3D12_STATIC_SAMPLER_DESC*>(HeapAlloc(GetProcessHeap(), 0, SamplersSize)); | ||
| 1175 | |||
| 1176 | if (pStaticSamplers == nullptr) | ||
| 1177 | { | ||
| 1178 | hr = E_OUTOFMEMORY; | ||
| 1179 | } | ||
| 1180 | else | ||
| 1181 | { | ||
| 1182 | const D3D12_ROOT_SIGNATURE_DESC2& desc_1_2 = pRootSignatureDesc->Desc_1_2; | ||
| 1183 | for (UINT n = 0; n < desc_1_1.NumStaticSamplers; ++n) | ||
| 1184 | { | ||
| 1185 | if ((desc_1_2.pStaticSamplers[n].Flags & ~D3D12_SAMPLER_FLAG_UINT_BORDER_COLOR) != 0) | ||
| 1186 | { | ||
| 1187 | hr = E_INVALIDARG; | ||
| 1188 | break; | ||
| 1189 | } | ||
| 1190 | memcpy(pStaticSamplers + n, desc_1_2.pStaticSamplers + n, sizeof(D3D12_STATIC_SAMPLER_DESC)); | ||
| 1191 | } | ||
| 1192 | } | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | if (SUCCEEDED(hr)) | ||
| 1196 | { | ||
| 1197 | const CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC desc(desc_1_1.NumParameters, desc_1_1.pParameters, desc_1_1.NumStaticSamplers, pStaticSamplers == nullptr ? desc_1_1.pStaticSamplers : pStaticSamplers, desc_1_1.Flags); | ||
| 1198 | hr = D3D12SerializeVersionedRootSignature(&desc, ppBlob, ppErrorBlob); | ||
| 1199 | } | ||
| 1200 | |||
| 1201 | if (pStaticSamplers) | ||
| 1202 | { | ||
| 1203 | HeapFree(GetProcessHeap(), 0, pStaticSamplers); | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | return hr; | ||
| 1207 | } | ||
| 1208 | #endif | ||
| 1209 | |||
| 1210 | default: | ||
| 1211 | break; | ||
| 1212 | } | ||
| 1213 | break; | ||
| 1214 | |||
| 1215 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 1216 | case D3D_ROOT_SIGNATURE_VERSION_1_2: | ||
| 1217 | #endif | ||
| 1218 | default: | ||
| 1219 | return D3D12SerializeVersionedRootSignature(pRootSignatureDesc, ppBlob, ppErrorBlob); | ||
| 1220 | } | ||
| 1221 | |||
| 1222 | return E_INVALIDARG; | ||
| 1223 | } | ||
| 1224 | |||
| 1225 | #ifdef __clang__ | ||
| 1226 | #pragma clang diagnostic pop | ||
| 1227 | #endif | ||
