diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-02 16:39:36 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-02 16:39:36 -0800 |
| commit | 6c8ae19be66cee247980a48e736a4e05d14de179 (patch) | |
| tree | d860767907bf0cbe17ec66422e11bea700cf56d9 /contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12 | |
| parent | 8f594c8ebd11f0e5f8a0c6369c3fe7383d250cbe (diff) | |
Diffstat (limited to 'contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12')
11 files changed, 9835 insertions, 0 deletions
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12.h new file mode 100644 index 0000000..e8ec24e --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | //********************************************************* | ||
| 2 | // | ||
| 3 | // Copyright (c) Microsoft Corporation. | ||
| 4 | // Licensed under the MIT License (MIT). | ||
| 5 | // | ||
| 6 | //********************************************************* | ||
| 7 | |||
| 8 | #ifndef __D3DX12_H__ | ||
| 9 | #define __D3DX12_H__ | ||
| 10 | |||
| 11 | #include "d3d12.h" | ||
| 12 | |||
| 13 | #if defined( __cplusplus ) | ||
| 14 | |||
| 15 | #include "d3dx12_barriers.h" | ||
| 16 | #include "d3dx12_core.h" | ||
| 17 | #include "d3dx12_default.h" | ||
| 18 | #include "d3dx12_pipeline_state_stream.h" | ||
| 19 | #include "d3dx12_render_pass.h" | ||
| 20 | #include "d3dx12_resource_helpers.h" | ||
| 21 | #include "d3dx12_root_signature.h" | ||
| 22 | #include "d3dx12_property_format_table.h" | ||
| 23 | |||
| 24 | #ifndef D3DX12_NO_STATE_OBJECT_HELPERS | ||
| 25 | #include "d3dx12_state_object.h" | ||
| 26 | #endif // !D3DX12_NO_STATE_OBJECT_HELPERS | ||
| 27 | |||
| 28 | #ifndef D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS | ||
| 29 | #include "d3dx12_check_feature_support.h" | ||
| 30 | #endif // !D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS | ||
| 31 | |||
| 32 | #endif // defined( __cplusplus ) | ||
| 33 | |||
| 34 | #endif //__D3DX12_H__ | ||
| 35 | |||
| 36 | |||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_barriers.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_barriers.h new file mode 100644 index 0000000..1bd7a74 --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_barriers.h | |||
| @@ -0,0 +1,193 @@ | |||
| 1 | //********************************************************* | ||
| 2 | // | ||
| 3 | // Copyright (c) Microsoft Corporation. | ||
| 4 | // Licensed under the MIT License (MIT). | ||
| 5 | // | ||
| 6 | //********************************************************* | ||
| 7 | |||
| 8 | #ifndef __D3DX12_BARRIERS_H__ | ||
| 9 | #define __D3DX12_BARRIERS_H__ | ||
| 10 | |||
| 11 | #if defined( __cplusplus ) | ||
| 12 | |||
| 13 | #include "d3d12.h" | ||
| 14 | |||
| 15 | //------------------------------------------------------------------------------------------------ | ||
| 16 | struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER | ||
| 17 | { | ||
| 18 | CD3DX12_RESOURCE_BARRIER() = default; | ||
| 19 | explicit CD3DX12_RESOURCE_BARRIER(const D3D12_RESOURCE_BARRIER &o) noexcept : | ||
| 20 | D3D12_RESOURCE_BARRIER(o) | ||
| 21 | {} | ||
| 22 | static inline CD3DX12_RESOURCE_BARRIER Transition( | ||
| 23 | _In_ ID3D12Resource* pResource, | ||
| 24 | D3D12_RESOURCE_STATES stateBefore, | ||
| 25 | D3D12_RESOURCE_STATES stateAfter, | ||
| 26 | UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, | ||
| 27 | D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE) noexcept | ||
| 28 | { | ||
| 29 | CD3DX12_RESOURCE_BARRIER result = {}; | ||
| 30 | D3D12_RESOURCE_BARRIER &barrier = result; | ||
| 31 | result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; | ||
| 32 | result.Flags = flags; | ||
| 33 | barrier.Transition.pResource = pResource; | ||
| 34 | barrier.Transition.StateBefore = stateBefore; | ||
| 35 | barrier.Transition.StateAfter = stateAfter; | ||
| 36 | barrier.Transition.Subresource = subresource; | ||
| 37 | return result; | ||
| 38 | } | ||
| 39 | static inline CD3DX12_RESOURCE_BARRIER Aliasing( | ||
| 40 | _In_opt_ ID3D12Resource* pResourceBefore, | ||
| 41 | _In_opt_ ID3D12Resource* pResourceAfter) noexcept | ||
| 42 | { | ||
| 43 | CD3DX12_RESOURCE_BARRIER result = {}; | ||
| 44 | D3D12_RESOURCE_BARRIER &barrier = result; | ||
| 45 | result.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; | ||
| 46 | barrier.Aliasing.pResourceBefore = pResourceBefore; | ||
| 47 | barrier.Aliasing.pResourceAfter = pResourceAfter; | ||
| 48 | return result; | ||
| 49 | } | ||
| 50 | static inline CD3DX12_RESOURCE_BARRIER UAV( | ||
| 51 | _In_opt_ ID3D12Resource* pResource) noexcept | ||
| 52 | { | ||
| 53 | CD3DX12_RESOURCE_BARRIER result = {}; | ||
| 54 | D3D12_RESOURCE_BARRIER &barrier = result; | ||
| 55 | result.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; | ||
| 56 | barrier.UAV.pResource = pResource; | ||
| 57 | return result; | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | |||
| 61 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 62 | |||
| 63 | //================================================================================================ | ||
| 64 | // D3DX12 Enhanced Barrier Helpers | ||
| 65 | //================================================================================================ | ||
| 66 | |||
| 67 | class CD3DX12_BARRIER_SUBRESOURCE_RANGE : public D3D12_BARRIER_SUBRESOURCE_RANGE | ||
| 68 | { | ||
| 69 | public: | ||
| 70 | CD3DX12_BARRIER_SUBRESOURCE_RANGE() = default; | ||
| 71 | CD3DX12_BARRIER_SUBRESOURCE_RANGE(const D3D12_BARRIER_SUBRESOURCE_RANGE &o) noexcept : | ||
| 72 | D3D12_BARRIER_SUBRESOURCE_RANGE(o) | ||
| 73 | {} | ||
| 74 | explicit CD3DX12_BARRIER_SUBRESOURCE_RANGE(UINT Subresource) noexcept : | ||
| 75 | D3D12_BARRIER_SUBRESOURCE_RANGE{ Subresource, 0, 0, 0, 0, 0 } | ||
| 76 | {} | ||
| 77 | CD3DX12_BARRIER_SUBRESOURCE_RANGE( | ||
| 78 | UINT firstMipLevel, | ||
| 79 | UINT numMips, | ||
| 80 | UINT firstArraySlice, | ||
| 81 | UINT numArraySlices, | ||
| 82 | UINT firstPlane = 0, | ||
| 83 | UINT numPlanes = 1) noexcept : | ||
| 84 | D3D12_BARRIER_SUBRESOURCE_RANGE | ||
| 85 | { | ||
| 86 | firstMipLevel, | ||
| 87 | numMips, | ||
| 88 | firstArraySlice, | ||
| 89 | numArraySlices, | ||
| 90 | firstPlane, | ||
| 91 | numPlanes | ||
| 92 | } | ||
| 93 | {} | ||
| 94 | }; | ||
| 95 | |||
| 96 | class CD3DX12_GLOBAL_BARRIER : public D3D12_GLOBAL_BARRIER | ||
| 97 | { | ||
| 98 | public: | ||
| 99 | CD3DX12_GLOBAL_BARRIER() = default; | ||
| 100 | CD3DX12_GLOBAL_BARRIER(const D3D12_GLOBAL_BARRIER &o) noexcept : D3D12_GLOBAL_BARRIER(o){} | ||
| 101 | CD3DX12_GLOBAL_BARRIER( | ||
| 102 | D3D12_BARRIER_SYNC syncBefore, | ||
| 103 | D3D12_BARRIER_SYNC syncAfter, | ||
| 104 | D3D12_BARRIER_ACCESS accessBefore, | ||
| 105 | D3D12_BARRIER_ACCESS accessAfter) noexcept : D3D12_GLOBAL_BARRIER { | ||
| 106 | syncBefore, | ||
| 107 | syncAfter, | ||
| 108 | accessBefore, | ||
| 109 | accessAfter | ||
| 110 | } | ||
| 111 | {} | ||
| 112 | }; | ||
| 113 | |||
| 114 | class CD3DX12_BUFFER_BARRIER : public D3D12_BUFFER_BARRIER | ||
| 115 | { | ||
| 116 | public: | ||
| 117 | CD3DX12_BUFFER_BARRIER() = default; | ||
| 118 | CD3DX12_BUFFER_BARRIER(const D3D12_BUFFER_BARRIER &o) noexcept : D3D12_BUFFER_BARRIER(o){} | ||
| 119 | CD3DX12_BUFFER_BARRIER( | ||
| 120 | D3D12_BARRIER_SYNC syncBefore, | ||
| 121 | D3D12_BARRIER_SYNC syncAfter, | ||
| 122 | D3D12_BARRIER_ACCESS accessBefore, | ||
| 123 | D3D12_BARRIER_ACCESS accessAfter, | ||
| 124 | ID3D12Resource *pRes) noexcept : D3D12_BUFFER_BARRIER { | ||
| 125 | syncBefore, | ||
| 126 | syncAfter, | ||
| 127 | accessBefore, | ||
| 128 | accessAfter, | ||
| 129 | pRes, | ||
| 130 | 0, ULLONG_MAX | ||
| 131 | } | ||
| 132 | {} | ||
| 133 | }; | ||
| 134 | |||
| 135 | class CD3DX12_TEXTURE_BARRIER : public D3D12_TEXTURE_BARRIER | ||
| 136 | { | ||
| 137 | public: | ||
| 138 | CD3DX12_TEXTURE_BARRIER() = default; | ||
| 139 | CD3DX12_TEXTURE_BARRIER(const D3D12_TEXTURE_BARRIER &o) noexcept : D3D12_TEXTURE_BARRIER(o){} | ||
| 140 | CD3DX12_TEXTURE_BARRIER( | ||
| 141 | D3D12_BARRIER_SYNC syncBefore, | ||
| 142 | D3D12_BARRIER_SYNC syncAfter, | ||
| 143 | D3D12_BARRIER_ACCESS accessBefore, | ||
| 144 | D3D12_BARRIER_ACCESS accessAfter, | ||
| 145 | D3D12_BARRIER_LAYOUT layoutBefore, | ||
| 146 | D3D12_BARRIER_LAYOUT layoutAfter, | ||
| 147 | ID3D12Resource *pRes, | ||
| 148 | const D3D12_BARRIER_SUBRESOURCE_RANGE &subresources, | ||
| 149 | D3D12_TEXTURE_BARRIER_FLAGS flag = D3D12_TEXTURE_BARRIER_FLAG_NONE) noexcept : D3D12_TEXTURE_BARRIER { | ||
| 150 | syncBefore, | ||
| 151 | syncAfter, | ||
| 152 | accessBefore, | ||
| 153 | accessAfter, | ||
| 154 | layoutBefore, | ||
| 155 | layoutAfter, | ||
| 156 | pRes, | ||
| 157 | subresources, | ||
| 158 | flag | ||
| 159 | } | ||
| 160 | {} | ||
| 161 | }; | ||
| 162 | |||
| 163 | class CD3DX12_BARRIER_GROUP : public D3D12_BARRIER_GROUP | ||
| 164 | { | ||
| 165 | public: | ||
| 166 | CD3DX12_BARRIER_GROUP() = default; | ||
| 167 | CD3DX12_BARRIER_GROUP(const D3D12_BARRIER_GROUP &o) noexcept : D3D12_BARRIER_GROUP(o){} | ||
| 168 | CD3DX12_BARRIER_GROUP(UINT32 numBarriers, const D3D12_BUFFER_BARRIER *pBarriers) noexcept | ||
| 169 | { | ||
| 170 | Type = D3D12_BARRIER_TYPE_BUFFER; | ||
| 171 | NumBarriers = numBarriers; | ||
| 172 | pBufferBarriers = pBarriers; | ||
| 173 | } | ||
| 174 | CD3DX12_BARRIER_GROUP(UINT32 numBarriers, const D3D12_TEXTURE_BARRIER *pBarriers) noexcept | ||
| 175 | { | ||
| 176 | Type = D3D12_BARRIER_TYPE_TEXTURE; | ||
| 177 | NumBarriers = numBarriers; | ||
| 178 | pTextureBarriers = pBarriers; | ||
| 179 | } | ||
| 180 | CD3DX12_BARRIER_GROUP(UINT32 numBarriers, const D3D12_GLOBAL_BARRIER *pBarriers) noexcept | ||
| 181 | { | ||
| 182 | Type = D3D12_BARRIER_TYPE_GLOBAL; | ||
| 183 | NumBarriers = numBarriers; | ||
| 184 | pGlobalBarriers = pBarriers; | ||
| 185 | } | ||
| 186 | }; | ||
| 187 | #endif // D3D12_SDK_VERSION >= 608 | ||
| 188 | |||
| 189 | |||
| 190 | #endif // defined( __cplusplus ) | ||
| 191 | |||
| 192 | #endif // __D3DX12_BARRIERS_H__ | ||
| 193 | |||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_check_feature_support.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_check_feature_support.h new file mode 100644 index 0000000..725fb7f --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_check_feature_support.h | |||
| @@ -0,0 +1,1162 @@ | |||
| 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 | |||
| 16 | //================================================================================================ | ||
| 17 | // D3DX12 Check Feature Support | ||
| 18 | //================================================================================================ | ||
| 19 | |||
| 20 | #include <vector> | ||
| 21 | |||
| 22 | class CD3DX12FeatureSupport | ||
| 23 | { | ||
| 24 | public: // Function declaration | ||
| 25 | // Default constructor that creates an empty object | ||
| 26 | CD3DX12FeatureSupport() noexcept; | ||
| 27 | |||
| 28 | // Initialize data from the given device | ||
| 29 | HRESULT Init(ID3D12Device* pDevice); | ||
| 30 | |||
| 31 | // Retreives the status of the object. If an error occurred in the initialization process, the function returns the error code. | ||
| 32 | HRESULT GetStatus() const noexcept { return m_hStatus; } | ||
| 33 | |||
| 34 | // Getter functions for each feature class | ||
| 35 | // D3D12_OPTIONS | ||
| 36 | BOOL DoublePrecisionFloatShaderOps() const noexcept; | ||
| 37 | BOOL OutputMergerLogicOp() const noexcept; | ||
| 38 | D3D12_SHADER_MIN_PRECISION_SUPPORT MinPrecisionSupport() const noexcept; | ||
| 39 | D3D12_TILED_RESOURCES_TIER TiledResourcesTier() const noexcept; | ||
| 40 | D3D12_RESOURCE_BINDING_TIER ResourceBindingTier() const noexcept; | ||
| 41 | BOOL PSSpecifiedStencilRefSupported() const noexcept; | ||
| 42 | BOOL TypedUAVLoadAdditionalFormats() const noexcept; | ||
| 43 | BOOL ROVsSupported() const noexcept; | ||
| 44 | D3D12_CONSERVATIVE_RASTERIZATION_TIER ConservativeRasterizationTier() const noexcept; | ||
| 45 | BOOL StandardSwizzle64KBSupported() const noexcept; | ||
| 46 | BOOL CrossAdapterRowMajorTextureSupported() const noexcept; | ||
| 47 | BOOL VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation() const noexcept; | ||
| 48 | D3D12_RESOURCE_HEAP_TIER ResourceHeapTier() const noexcept; | ||
| 49 | D3D12_CROSS_NODE_SHARING_TIER CrossNodeSharingTier() const noexcept; | ||
| 50 | UINT MaxGPUVirtualAddressBitsPerResource() const noexcept; | ||
| 51 | |||
| 52 | // FEATURE_LEVELS | ||
| 53 | D3D_FEATURE_LEVEL MaxSupportedFeatureLevel() const noexcept; | ||
| 54 | |||
| 55 | // FORMAT_SUPPORT | ||
| 56 | HRESULT FormatSupport(DXGI_FORMAT Format, D3D12_FORMAT_SUPPORT1& Support1, D3D12_FORMAT_SUPPORT2& Support2) const; | ||
| 57 | |||
| 58 | // MUTLTISAMPLE_QUALITY_LEVELS | ||
| 59 | HRESULT MultisampleQualityLevels(DXGI_FORMAT Format, UINT SampleCount, D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags, UINT& NumQualityLevels) const; | ||
| 60 | |||
| 61 | // FORMAT_INFO | ||
| 62 | HRESULT FormatInfo(DXGI_FORMAT Format, UINT8& PlaneCount) const; | ||
| 63 | |||
| 64 | // GPU_VIRTUAL_ADDRESS_SUPPORT | ||
| 65 | UINT MaxGPUVirtualAddressBitsPerProcess() const noexcept; | ||
| 66 | |||
| 67 | // SHADER_MODEL | ||
| 68 | D3D_SHADER_MODEL HighestShaderModel() const noexcept; | ||
| 69 | |||
| 70 | // D3D12_OPTIONS1 | ||
| 71 | BOOL WaveOps() const noexcept; | ||
| 72 | UINT WaveLaneCountMin() const noexcept; | ||
| 73 | UINT WaveLaneCountMax() const noexcept; | ||
| 74 | UINT TotalLaneCount() const noexcept; | ||
| 75 | BOOL ExpandedComputeResourceStates() const noexcept; | ||
| 76 | BOOL Int64ShaderOps() const noexcept; | ||
| 77 | |||
| 78 | // PROTECTED_RESOURCE_SESSION_SUPPORT | ||
| 79 | D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS ProtectedResourceSessionSupport(UINT NodeIndex = 0) const; | ||
| 80 | |||
| 81 | // ROOT_SIGNATURE | ||
| 82 | D3D_ROOT_SIGNATURE_VERSION HighestRootSignatureVersion() const noexcept; | ||
| 83 | |||
| 84 | // ARCHITECTURE1 | ||
| 85 | BOOL TileBasedRenderer(UINT NodeIndex = 0) const; | ||
| 86 | BOOL UMA(UINT NodeIndex = 0) const; | ||
| 87 | BOOL CacheCoherentUMA(UINT NodeIndex = 0) const; | ||
| 88 | BOOL IsolatedMMU(UINT NodeIndex = 0) const; | ||
| 89 | |||
| 90 | // D3D12_OPTIONS2 | ||
| 91 | BOOL DepthBoundsTestSupported() const noexcept; | ||
| 92 | D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER ProgrammableSamplePositionsTier() const noexcept; | ||
| 93 | |||
| 94 | // SHADER_CACHE | ||
| 95 | D3D12_SHADER_CACHE_SUPPORT_FLAGS ShaderCacheSupportFlags() const noexcept; | ||
| 96 | |||
| 97 | // COMMAND_QUEUE_PRIORITY | ||
| 98 | BOOL CommandQueuePrioritySupported(D3D12_COMMAND_LIST_TYPE CommandListType, UINT Priority); | ||
| 99 | |||
| 100 | // D3D12_OPTIONS3 | ||
| 101 | BOOL CopyQueueTimestampQueriesSupported() const noexcept; | ||
| 102 | BOOL CastingFullyTypedFormatSupported() const noexcept; | ||
| 103 | D3D12_COMMAND_LIST_SUPPORT_FLAGS WriteBufferImmediateSupportFlags() const noexcept; | ||
| 104 | D3D12_VIEW_INSTANCING_TIER ViewInstancingTier() const noexcept; | ||
| 105 | BOOL BarycentricsSupported() const noexcept; | ||
| 106 | |||
| 107 | // EXISTING_HEAPS | ||
| 108 | BOOL ExistingHeapsSupported() const noexcept; | ||
| 109 | |||
| 110 | // D3D12_OPTIONS4 | ||
| 111 | BOOL MSAA64KBAlignedTextureSupported() const noexcept; | ||
| 112 | D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier() const noexcept; | ||
| 113 | BOOL Native16BitShaderOpsSupported() const noexcept; | ||
| 114 | |||
| 115 | // SERIALIZATION | ||
| 116 | D3D12_HEAP_SERIALIZATION_TIER HeapSerializationTier(UINT NodeIndex = 0) const; | ||
| 117 | |||
| 118 | // CROSS_NODE | ||
| 119 | // CrossNodeSharingTier handled in D3D12Options | ||
| 120 | BOOL CrossNodeAtomicShaderInstructions() const noexcept; | ||
| 121 | |||
| 122 | // D3D12_OPTIONS5 | ||
| 123 | BOOL SRVOnlyTiledResourceTier3() const noexcept; | ||
| 124 | D3D12_RENDER_PASS_TIER RenderPassesTier() const noexcept; | ||
| 125 | D3D12_RAYTRACING_TIER RaytracingTier() const noexcept; | ||
| 126 | |||
| 127 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 128 | // DISPLAYABLE | ||
| 129 | BOOL DisplayableTexture() const noexcept; | ||
| 130 | // SharedResourceCompatibilityTier handled in D3D12Options4 | ||
| 131 | #endif | ||
| 132 | |||
| 133 | // D3D12_OPTIONS6 | ||
| 134 | BOOL AdditionalShadingRatesSupported() const noexcept; | ||
| 135 | BOOL PerPrimitiveShadingRateSupportedWithViewportIndexing() const noexcept; | ||
| 136 | D3D12_VARIABLE_SHADING_RATE_TIER VariableShadingRateTier() const noexcept; | ||
| 137 | UINT ShadingRateImageTileSize() const noexcept; | ||
| 138 | BOOL BackgroundProcessingSupported() const noexcept; | ||
| 139 | |||
| 140 | // QUERY_META_COMMAND | ||
| 141 | HRESULT QueryMetaCommand(D3D12_FEATURE_DATA_QUERY_META_COMMAND& dQueryMetaCommand) const; | ||
| 142 | |||
| 143 | // D3D12_OPTIONS7 | ||
| 144 | D3D12_MESH_SHADER_TIER MeshShaderTier() const noexcept; | ||
| 145 | D3D12_SAMPLER_FEEDBACK_TIER SamplerFeedbackTier() const noexcept; | ||
| 146 | |||
| 147 | // PROTECTED_RESOURCE_SESSION_TYPE_COUNT | ||
| 148 | UINT ProtectedResourceSessionTypeCount(UINT NodeIndex = 0) const; | ||
| 149 | |||
| 150 | // PROTECTED_RESOURCE_SESSION_TYPES | ||
| 151 | std::vector<GUID> ProtectedResourceSessionTypes(UINT NodeIndex = 0) const; | ||
| 152 | |||
| 153 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3) | ||
| 154 | // D3D12_OPTIONS8 | ||
| 155 | BOOL UnalignedBlockTexturesSupported() const noexcept; | ||
| 156 | |||
| 157 | // D3D12_OPTIONS9 | ||
| 158 | BOOL MeshShaderPipelineStatsSupported() const noexcept; | ||
| 159 | BOOL MeshShaderSupportsFullRangeRenderTargetArrayIndex() const noexcept; | ||
| 160 | BOOL AtomicInt64OnTypedResourceSupported() const noexcept; | ||
| 161 | BOOL AtomicInt64OnGroupSharedSupported() const noexcept; | ||
| 162 | BOOL DerivativesInMeshAndAmplificationShadersSupported() const noexcept; | ||
| 163 | D3D12_WAVE_MMA_TIER WaveMMATier() const noexcept; | ||
| 164 | #endif | ||
| 165 | |||
| 166 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 167 | // D3D12_OPTIONS10 | ||
| 168 | BOOL VariableRateShadingSumCombinerSupported() const noexcept; | ||
| 169 | BOOL MeshShaderPerPrimitiveShadingRateSupported() const noexcept; | ||
| 170 | |||
| 171 | // D3D12_OPTIONS11 | ||
| 172 | BOOL AtomicInt64OnDescriptorHeapResourceSupported() const noexcept; | ||
| 173 | #endif | ||
| 174 | |||
| 175 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600) | ||
| 176 | // D3D12_OPTIONS12 | ||
| 177 | D3D12_TRI_STATE MSPrimitivesPipelineStatisticIncludesCulledPrimitives() const noexcept; | ||
| 178 | BOOL EnhancedBarriersSupported() const noexcept; | ||
| 179 | BOOL RelaxedFormatCastingSupported() const noexcept; | ||
| 180 | #endif | ||
| 181 | |||
| 182 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602) | ||
| 183 | // D3D12_OPTIONS13 | ||
| 184 | BOOL UnrestrictedBufferTextureCopyPitchSupported() const noexcept; | ||
| 185 | BOOL UnrestrictedVertexElementAlignmentSupported() const noexcept; | ||
| 186 | BOOL InvertedViewportHeightFlipsYSupported() const noexcept; | ||
| 187 | BOOL InvertedViewportDepthFlipsZSupported() const noexcept; | ||
| 188 | BOOL TextureCopyBetweenDimensionsSupported() const noexcept; | ||
| 189 | BOOL AlphaBlendFactorSupported() const noexcept; | ||
| 190 | #endif | ||
| 191 | |||
| 192 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 193 | // D3D12_OPTIONS14 | ||
| 194 | BOOL AdvancedTextureOpsSupported() const noexcept; | ||
| 195 | BOOL WriteableMSAATexturesSupported() const noexcept; | ||
| 196 | BOOL IndependentFrontAndBackStencilRefMaskSupported() const noexcept; | ||
| 197 | |||
| 198 | // D3D12_OPTIONS15 | ||
| 199 | BOOL TriangleFanSupported() const noexcept; | ||
| 200 | BOOL DynamicIndexBufferStripCutSupported() const noexcept; | ||
| 201 | #endif | ||
| 202 | |||
| 203 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 204 | // D3D12_OPTIONS16 | ||
| 205 | BOOL DynamicDepthBiasSupported() const noexcept; | ||
| 206 | #endif | ||
| 207 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 208 | BOOL GPUUploadHeapSupported() const noexcept; | ||
| 209 | |||
| 210 | // D3D12_OPTIONS17 | ||
| 211 | BOOL NonNormalizedCoordinateSamplersSupported() const noexcept; | ||
| 212 | BOOL ManualWriteTrackingResourceSupported() const noexcept; | ||
| 213 | |||
| 214 | // D3D12_OPTIONS18 | ||
| 215 | BOOL RenderPassesValid() const noexcept; | ||
| 216 | #endif | ||
| 217 | |||
| 218 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 219 | BOOL MismatchingOutputDimensionsSupported() const noexcept; | ||
| 220 | UINT SupportedSampleCountsWithNoOutputs() const noexcept; | ||
| 221 | BOOL PointSamplingAddressesNeverRoundUp() const noexcept; | ||
| 222 | BOOL RasterizerDesc2Supported() const noexcept; | ||
| 223 | BOOL NarrowQuadrilateralLinesSupported() const noexcept; | ||
| 224 | BOOL AnisoFilterWithPointMipSupported() const noexcept; | ||
| 225 | UINT MaxSamplerDescriptorHeapSize() const noexcept; | ||
| 226 | UINT MaxSamplerDescriptorHeapSizeWithStaticSamplers() const noexcept; | ||
| 227 | UINT MaxViewDescriptorHeapSize() const noexcept; | ||
| 228 | #endif | ||
| 229 | |||
| 230 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) | ||
| 231 | BOOL ComputeOnlyWriteWatchSupported() const noexcept; | ||
| 232 | #endif | ||
| 233 | |||
| 234 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 235 | D3D12_EXECUTE_INDIRECT_TIER ExecuteIndirectTier() const noexcept; | ||
| 236 | D3D12_WORK_GRAPHS_TIER WorkGraphsTier() const noexcept; | ||
| 237 | #endif | ||
| 238 | |||
| 239 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 617) | ||
| 240 | D3D12_TIGHT_ALIGNMENT_TIER TightAlignmentSupportTier() const noexcept; | ||
| 241 | #endif | ||
| 242 | |||
| 243 | private: // Private structs and helpers declaration | ||
| 244 | struct ProtectedResourceSessionTypesLocal : D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES | ||
| 245 | { | ||
| 246 | std::vector<GUID> TypeVec; | ||
| 247 | }; | ||
| 248 | |||
| 249 | // Helper function to decide the highest shader model supported by the system | ||
| 250 | // Stores the result in m_dShaderModel | ||
| 251 | // Must be updated whenever a new shader model is added to the d3d12.h header | ||
| 252 | HRESULT QueryHighestShaderModel(); | ||
| 253 | |||
| 254 | // Helper function to decide the highest root signature supported | ||
| 255 | // Must be updated whenever a new root signature version is added to the d3d12.h header | ||
| 256 | HRESULT QueryHighestRootSignatureVersion(); | ||
| 257 | |||
| 258 | // Helper funcion to decide the highest feature level | ||
| 259 | HRESULT QueryHighestFeatureLevel(); | ||
| 260 | |||
| 261 | // Helper function to initialize local protected resource session types structs | ||
| 262 | HRESULT QueryProtectedResourceSessionTypes(UINT NodeIndex, UINT Count); | ||
| 263 | |||
| 264 | private: // Member data | ||
| 265 | // Pointer to the underlying device | ||
| 266 | ID3D12Device* m_pDevice; | ||
| 267 | |||
| 268 | // Stores the error code from initialization | ||
| 269 | HRESULT m_hStatus; | ||
| 270 | |||
| 271 | // Feature support data structs | ||
| 272 | D3D12_FEATURE_DATA_D3D12_OPTIONS m_dOptions; | ||
| 273 | D3D_FEATURE_LEVEL m_eMaxFeatureLevel; | ||
| 274 | D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT m_dGPUVASupport; | ||
| 275 | D3D12_FEATURE_DATA_SHADER_MODEL m_dShaderModel; | ||
| 276 | D3D12_FEATURE_DATA_D3D12_OPTIONS1 m_dOptions1; | ||
| 277 | std::vector<D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_SUPPORT> m_dProtectedResourceSessionSupport; | ||
| 278 | D3D12_FEATURE_DATA_ROOT_SIGNATURE m_dRootSignature; | ||
| 279 | std::vector<D3D12_FEATURE_DATA_ARCHITECTURE1> m_dArchitecture1; | ||
| 280 | D3D12_FEATURE_DATA_D3D12_OPTIONS2 m_dOptions2; | ||
| 281 | D3D12_FEATURE_DATA_SHADER_CACHE m_dShaderCache; | ||
| 282 | D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY m_dCommandQueuePriority; | ||
| 283 | D3D12_FEATURE_DATA_D3D12_OPTIONS3 m_dOptions3; | ||
| 284 | D3D12_FEATURE_DATA_EXISTING_HEAPS m_dExistingHeaps; | ||
| 285 | D3D12_FEATURE_DATA_D3D12_OPTIONS4 m_dOptions4; | ||
| 286 | std::vector<D3D12_FEATURE_DATA_SERIALIZATION> m_dSerialization; // Cat2 NodeIndex | ||
| 287 | D3D12_FEATURE_DATA_CROSS_NODE m_dCrossNode; | ||
| 288 | D3D12_FEATURE_DATA_D3D12_OPTIONS5 m_dOptions5; | ||
| 289 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 290 | D3D12_FEATURE_DATA_DISPLAYABLE m_dDisplayable; | ||
| 291 | #endif | ||
| 292 | D3D12_FEATURE_DATA_D3D12_OPTIONS6 m_dOptions6; | ||
| 293 | D3D12_FEATURE_DATA_D3D12_OPTIONS7 m_dOptions7; | ||
| 294 | std::vector<D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPE_COUNT> m_dProtectedResourceSessionTypeCount; // Cat2 NodeIndex | ||
| 295 | std::vector<ProtectedResourceSessionTypesLocal> m_dProtectedResourceSessionTypes; // Cat3 | ||
| 296 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3) | ||
| 297 | D3D12_FEATURE_DATA_D3D12_OPTIONS8 m_dOptions8; | ||
| 298 | D3D12_FEATURE_DATA_D3D12_OPTIONS9 m_dOptions9; | ||
| 299 | #endif | ||
| 300 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 301 | D3D12_FEATURE_DATA_D3D12_OPTIONS10 m_dOptions10; | ||
| 302 | D3D12_FEATURE_DATA_D3D12_OPTIONS11 m_dOptions11; | ||
| 303 | #endif | ||
| 304 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600) | ||
| 305 | D3D12_FEATURE_DATA_D3D12_OPTIONS12 m_dOptions12; | ||
| 306 | #endif | ||
| 307 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602) | ||
| 308 | D3D12_FEATURE_DATA_D3D12_OPTIONS13 m_dOptions13; | ||
| 309 | #endif | ||
| 310 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 311 | D3D12_FEATURE_DATA_D3D12_OPTIONS14 m_dOptions14; | ||
| 312 | D3D12_FEATURE_DATA_D3D12_OPTIONS15 m_dOptions15; | ||
| 313 | #endif | ||
| 314 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 315 | D3D12_FEATURE_DATA_D3D12_OPTIONS16 m_dOptions16; | ||
| 316 | #endif | ||
| 317 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 318 | D3D12_FEATURE_DATA_D3D12_OPTIONS17 m_dOptions17; | ||
| 319 | #endif | ||
| 320 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 321 | D3D12_FEATURE_DATA_D3D12_OPTIONS18 m_dOptions18; | ||
| 322 | #endif | ||
| 323 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 324 | D3D12_FEATURE_DATA_D3D12_OPTIONS19 m_dOptions19; | ||
| 325 | #endif | ||
| 326 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) | ||
| 327 | D3D12_FEATURE_DATA_D3D12_OPTIONS20 m_dOptions20; | ||
| 328 | #endif | ||
| 329 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 330 | D3D12_FEATURE_DATA_D3D12_OPTIONS21 m_dOptions21; | ||
| 331 | #endif | ||
| 332 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 617) | ||
| 333 | D3D12_FEATURE_DATA_TIGHT_ALIGNMENT m_dTightAlignment; | ||
| 334 | #endif | ||
| 335 | }; | ||
| 336 | |||
| 337 | // Implementations for CD3DX12FeatureSupport functions | ||
| 338 | |||
| 339 | // Macro to set up a getter function for each entry in feature support data | ||
| 340 | // The getter function will have the same name as the feature option name | ||
| 341 | #define FEATURE_SUPPORT_GET(RETTYPE,FEATURE,OPTION) \ | ||
| 342 | inline RETTYPE CD3DX12FeatureSupport::OPTION() const noexcept \ | ||
| 343 | { \ | ||
| 344 | return FEATURE.OPTION; \ | ||
| 345 | } | ||
| 346 | |||
| 347 | // Macro to set up a getter function for each entry in feature support data | ||
| 348 | // Also specifies the name for the function which can be different from the feature name | ||
| 349 | #define FEATURE_SUPPORT_GET_NAME(RETTYPE,FEATURE,OPTION,NAME) \ | ||
| 350 | inline RETTYPE CD3DX12FeatureSupport::NAME() const noexcept \ | ||
| 351 | {\ | ||
| 352 | return FEATURE.OPTION; \ | ||
| 353 | } | ||
| 354 | |||
| 355 | // Macro to set up a getter function for feature data indexed by the graphics node ID | ||
| 356 | // The default parameter is 0, or the first availabe graphics device node | ||
| 357 | #define FEATURE_SUPPORT_GET_NODE_INDEXED(RETTYPE,FEATURE,OPTION) \ | ||
| 358 | inline RETTYPE CD3DX12FeatureSupport::OPTION(UINT NodeIndex) const \ | ||
| 359 | {\ | ||
| 360 | return FEATURE[NodeIndex].OPTION; \ | ||
| 361 | } | ||
| 362 | |||
| 363 | // Macro to set up a getter function for feature data indexed by NodeIndex | ||
| 364 | // Allows a custom name for the getter function | ||
| 365 | #define FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(RETTYPE,FEATURE,OPTION,NAME) \ | ||
| 366 | inline RETTYPE CD3DX12FeatureSupport::NAME(UINT NodeIndex) const \ | ||
| 367 | {\ | ||
| 368 | return FEATURE[NodeIndex].OPTION; \ | ||
| 369 | } | ||
| 370 | |||
| 371 | inline CD3DX12FeatureSupport::CD3DX12FeatureSupport() noexcept | ||
| 372 | : m_pDevice(nullptr) | ||
| 373 | , m_hStatus(E_INVALIDARG) | ||
| 374 | , m_dOptions{} | ||
| 375 | , m_eMaxFeatureLevel{} | ||
| 376 | , m_dGPUVASupport{} | ||
| 377 | , m_dShaderModel{} | ||
| 378 | , m_dOptions1{} | ||
| 379 | , m_dRootSignature{} | ||
| 380 | , m_dOptions2{} | ||
| 381 | , m_dShaderCache{} | ||
| 382 | , m_dCommandQueuePriority{} | ||
| 383 | , m_dOptions3{} | ||
| 384 | , m_dExistingHeaps{} | ||
| 385 | , m_dOptions4{} | ||
| 386 | , m_dCrossNode{} | ||
| 387 | , m_dOptions5{} | ||
| 388 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 389 | , m_dDisplayable{} | ||
| 390 | #endif | ||
| 391 | , m_dOptions6{} | ||
| 392 | , m_dOptions7{} | ||
| 393 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3) | ||
| 394 | , m_dOptions8{} | ||
| 395 | , m_dOptions9{} | ||
| 396 | #endif | ||
| 397 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 398 | , m_dOptions10{} | ||
| 399 | , m_dOptions11{} | ||
| 400 | #endif | ||
| 401 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600) | ||
| 402 | , m_dOptions12{} | ||
| 403 | #endif | ||
| 404 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602) | ||
| 405 | , m_dOptions13{} | ||
| 406 | #endif | ||
| 407 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 408 | , m_dOptions14{} | ||
| 409 | , m_dOptions15{} | ||
| 410 | #endif | ||
| 411 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 412 | , m_dOptions16{} | ||
| 413 | #endif | ||
| 414 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 415 | , m_dOptions17{} | ||
| 416 | #endif | ||
| 417 | #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 418 | , m_dOptions18{} | ||
| 419 | #endif | ||
| 420 | #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 421 | , m_dOptions19{} | ||
| 422 | #endif | ||
| 423 | #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) | ||
| 424 | , m_dOptions20{} | ||
| 425 | #endif | ||
| 426 | #if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 427 | , m_dOptions21{} | ||
| 428 | #endif | ||
| 429 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 617) | ||
| 430 | , m_dTightAlignment{} | ||
| 431 | #endif | ||
| 432 | {} | ||
| 433 | |||
| 434 | inline HRESULT CD3DX12FeatureSupport::Init(ID3D12Device* pDevice) | ||
| 435 | { | ||
| 436 | if (!pDevice) | ||
| 437 | { | ||
| 438 | m_hStatus = E_INVALIDARG; | ||
| 439 | return m_hStatus; | ||
| 440 | } | ||
| 441 | |||
| 442 | m_pDevice = pDevice; | ||
| 443 | |||
| 444 | // Initialize static feature support data structures | ||
| 445 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &m_dOptions, sizeof(m_dOptions)))) | ||
| 446 | { | ||
| 447 | m_dOptions = {}; | ||
| 448 | } | ||
| 449 | |||
| 450 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT, &m_dGPUVASupport, sizeof(m_dGPUVASupport)))) | ||
| 451 | { | ||
| 452 | m_dGPUVASupport = {}; | ||
| 453 | } | ||
| 454 | |||
| 455 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1, &m_dOptions1, sizeof(m_dOptions1)))) | ||
| 456 | { | ||
| 457 | m_dOptions1 = {}; | ||
| 458 | } | ||
| 459 | |||
| 460 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &m_dOptions2, sizeof(m_dOptions2)))) | ||
| 461 | { | ||
| 462 | m_dOptions2 = {}; | ||
| 463 | } | ||
| 464 | |||
| 465 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_CACHE, &m_dShaderCache, sizeof(m_dShaderCache)))) | ||
| 466 | { | ||
| 467 | m_dShaderCache = {}; | ||
| 468 | } | ||
| 469 | |||
| 470 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS3, &m_dOptions3, sizeof(m_dOptions3)))) | ||
| 471 | { | ||
| 472 | m_dOptions3 = {}; | ||
| 473 | } | ||
| 474 | |||
| 475 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_EXISTING_HEAPS, &m_dExistingHeaps, sizeof(m_dExistingHeaps)))) | ||
| 476 | { | ||
| 477 | m_dExistingHeaps = {}; | ||
| 478 | } | ||
| 479 | |||
| 480 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS4, &m_dOptions4, sizeof(m_dOptions4)))) | ||
| 481 | { | ||
| 482 | m_dOptions4 = {}; | ||
| 483 | } | ||
| 484 | |||
| 485 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_CROSS_NODE, &m_dCrossNode, sizeof(m_dCrossNode)))) | ||
| 486 | { | ||
| 487 | m_dCrossNode = {}; | ||
| 488 | } | ||
| 489 | |||
| 490 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &m_dOptions5, sizeof(m_dOptions5)))) | ||
| 491 | { | ||
| 492 | m_dOptions5 = {}; | ||
| 493 | } | ||
| 494 | |||
| 495 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 496 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_DISPLAYABLE, &m_dDisplayable, sizeof(m_dDisplayable)))) | ||
| 497 | { | ||
| 498 | m_dDisplayable = {}; | ||
| 499 | } | ||
| 500 | #endif | ||
| 501 | |||
| 502 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS6, &m_dOptions6, sizeof(m_dOptions6)))) | ||
| 503 | { | ||
| 504 | m_dOptions6 = {}; | ||
| 505 | } | ||
| 506 | |||
| 507 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &m_dOptions7, sizeof(m_dOptions7)))) | ||
| 508 | { | ||
| 509 | m_dOptions7 = {}; | ||
| 510 | } | ||
| 511 | |||
| 512 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3) | ||
| 513 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS8, &m_dOptions8, sizeof(m_dOptions8)))) | ||
| 514 | { | ||
| 515 | m_dOptions8 = {}; | ||
| 516 | } | ||
| 517 | |||
| 518 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS9, &m_dOptions9, sizeof(m_dOptions9)))) | ||
| 519 | { | ||
| 520 | m_dOptions9 = {}; | ||
| 521 | } | ||
| 522 | #endif | ||
| 523 | |||
| 524 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 525 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS10, &m_dOptions10, sizeof(m_dOptions10)))) | ||
| 526 | { | ||
| 527 | m_dOptions10 = {}; | ||
| 528 | } | ||
| 529 | |||
| 530 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS11, &m_dOptions11, sizeof(m_dOptions11)))) | ||
| 531 | { | ||
| 532 | m_dOptions11 = {}; | ||
| 533 | } | ||
| 534 | #endif | ||
| 535 | |||
| 536 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600) | ||
| 537 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &m_dOptions12, sizeof(m_dOptions12)))) | ||
| 538 | { | ||
| 539 | m_dOptions12 = {}; | ||
| 540 | m_dOptions12.MSPrimitivesPipelineStatisticIncludesCulledPrimitives = D3D12_TRI_STATE::D3D12_TRI_STATE_UNKNOWN; | ||
| 541 | } | ||
| 542 | #endif | ||
| 543 | |||
| 544 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602) | ||
| 545 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS13, &m_dOptions13, sizeof(m_dOptions13)))) | ||
| 546 | { | ||
| 547 | m_dOptions13 = {}; | ||
| 548 | } | ||
| 549 | #endif | ||
| 550 | |||
| 551 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 552 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS14, &m_dOptions14, sizeof(m_dOptions14)))) | ||
| 553 | { | ||
| 554 | m_dOptions14 = {}; | ||
| 555 | } | ||
| 556 | |||
| 557 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS15, &m_dOptions15, sizeof(m_dOptions15)))) | ||
| 558 | { | ||
| 559 | m_dOptions15 = {}; | ||
| 560 | } | ||
| 561 | #endif | ||
| 562 | |||
| 563 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 564 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS16, &m_dOptions16, sizeof(m_dOptions16)))) | ||
| 565 | { | ||
| 566 | m_dOptions16 = {}; | ||
| 567 | } | ||
| 568 | #endif | ||
| 569 | |||
| 570 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 571 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS17, &m_dOptions17, sizeof(m_dOptions17)))) | ||
| 572 | { | ||
| 573 | m_dOptions17 = {}; | ||
| 574 | } | ||
| 575 | |||
| 576 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS18, &m_dOptions18, sizeof(m_dOptions18)))) | ||
| 577 | { | ||
| 578 | m_dOptions18.RenderPassesValid = false; | ||
| 579 | } | ||
| 580 | #endif | ||
| 581 | |||
| 582 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 583 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, &m_dOptions19, sizeof(m_dOptions19)))) | ||
| 584 | { | ||
| 585 | m_dOptions19 = {}; | ||
| 586 | m_dOptions19.SupportedSampleCountsWithNoOutputs = 1; | ||
| 587 | m_dOptions19.MaxSamplerDescriptorHeapSize = D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE; | ||
| 588 | m_dOptions19.MaxSamplerDescriptorHeapSizeWithStaticSamplers = D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE; | ||
| 589 | m_dOptions19.MaxViewDescriptorHeapSize = D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1; | ||
| 590 | } | ||
| 591 | #endif | ||
| 592 | |||
| 593 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) | ||
| 594 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS20, &m_dOptions20, sizeof(m_dOptions20)))) | ||
| 595 | { | ||
| 596 | m_dOptions20 = {}; | ||
| 597 | } | ||
| 598 | #endif | ||
| 599 | |||
| 600 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 601 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS21, &m_dOptions21, sizeof(m_dOptions21)))) | ||
| 602 | { | ||
| 603 | m_dOptions21 = {}; | ||
| 604 | } | ||
| 605 | #endif | ||
| 606 | |||
| 607 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 617) | ||
| 608 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_TIGHT_ALIGNMENT, &m_dTightAlignment, sizeof(m_dTightAlignment)))) | ||
| 609 | { | ||
| 610 | m_dTightAlignment = {}; | ||
| 611 | } | ||
| 612 | #endif | ||
| 613 | |||
| 614 | // Initialize per-node feature support data structures | ||
| 615 | const UINT uNodeCount = m_pDevice->GetNodeCount(); | ||
| 616 | m_dProtectedResourceSessionSupport.resize(uNodeCount); | ||
| 617 | m_dArchitecture1.resize(uNodeCount); | ||
| 618 | m_dSerialization.resize(uNodeCount); | ||
| 619 | m_dProtectedResourceSessionTypeCount.resize(uNodeCount); | ||
| 620 | m_dProtectedResourceSessionTypes.resize(uNodeCount); | ||
| 621 | for (UINT NodeIndex = 0; NodeIndex < uNodeCount; NodeIndex++) | ||
| 622 | { | ||
| 623 | m_dProtectedResourceSessionSupport[NodeIndex].NodeIndex = NodeIndex; | ||
| 624 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_SUPPORT, &m_dProtectedResourceSessionSupport[NodeIndex], sizeof(m_dProtectedResourceSessionSupport[NodeIndex])))) | ||
| 625 | { | ||
| 626 | m_dProtectedResourceSessionSupport[NodeIndex].Support = D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG_NONE; | ||
| 627 | } | ||
| 628 | |||
| 629 | m_dArchitecture1[NodeIndex].NodeIndex = NodeIndex; | ||
| 630 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1, &m_dArchitecture1[NodeIndex], sizeof(m_dArchitecture1[NodeIndex])))) | ||
| 631 | { | ||
| 632 | D3D12_FEATURE_DATA_ARCHITECTURE dArchLocal = {}; | ||
| 633 | dArchLocal.NodeIndex = NodeIndex; | ||
| 634 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &dArchLocal, sizeof(dArchLocal)))) | ||
| 635 | { | ||
| 636 | dArchLocal.TileBasedRenderer = false; | ||
| 637 | dArchLocal.UMA = false; | ||
| 638 | dArchLocal.CacheCoherentUMA = false; | ||
| 639 | } | ||
| 640 | |||
| 641 | m_dArchitecture1[NodeIndex].TileBasedRenderer = dArchLocal.TileBasedRenderer; | ||
| 642 | m_dArchitecture1[NodeIndex].UMA = dArchLocal.UMA; | ||
| 643 | m_dArchitecture1[NodeIndex].CacheCoherentUMA = dArchLocal.CacheCoherentUMA; | ||
| 644 | m_dArchitecture1[NodeIndex].IsolatedMMU = false; | ||
| 645 | } | ||
| 646 | |||
| 647 | m_dSerialization[NodeIndex].NodeIndex = NodeIndex; | ||
| 648 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SERIALIZATION, &m_dSerialization[NodeIndex], sizeof(m_dSerialization[NodeIndex])))) | ||
| 649 | { | ||
| 650 | m_dSerialization[NodeIndex].HeapSerializationTier = D3D12_HEAP_SERIALIZATION_TIER_0; | ||
| 651 | } | ||
| 652 | |||
| 653 | m_dProtectedResourceSessionTypeCount[NodeIndex].NodeIndex = NodeIndex; | ||
| 654 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPE_COUNT, &m_dProtectedResourceSessionTypeCount[NodeIndex], sizeof(m_dProtectedResourceSessionTypeCount[NodeIndex])))) | ||
| 655 | { | ||
| 656 | m_dProtectedResourceSessionTypeCount[NodeIndex].Count = 0; | ||
| 657 | } | ||
| 658 | |||
| 659 | // Special procedure to initialize local protected resource session types structs | ||
| 660 | // Must wait until session type count initialized | ||
| 661 | QueryProtectedResourceSessionTypes(NodeIndex, m_dProtectedResourceSessionTypeCount[NodeIndex].Count); | ||
| 662 | } | ||
| 663 | |||
| 664 | // Initialize features that requires highest version check | ||
| 665 | if (FAILED(m_hStatus = QueryHighestShaderModel())) | ||
| 666 | { | ||
| 667 | return m_hStatus; | ||
| 668 | } | ||
| 669 | |||
| 670 | if (FAILED(m_hStatus = QueryHighestRootSignatureVersion())) | ||
| 671 | { | ||
| 672 | return m_hStatus; | ||
| 673 | } | ||
| 674 | |||
| 675 | // Initialize Feature Levels data | ||
| 676 | if (FAILED(m_hStatus = QueryHighestFeatureLevel())) | ||
| 677 | { | ||
| 678 | return m_hStatus; | ||
| 679 | } | ||
| 680 | |||
| 681 | return m_hStatus; | ||
| 682 | } | ||
| 683 | |||
| 684 | // 0: D3D12_OPTIONS | ||
| 685 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, DoublePrecisionFloatShaderOps); | ||
| 686 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, OutputMergerLogicOp); | ||
| 687 | FEATURE_SUPPORT_GET(D3D12_SHADER_MIN_PRECISION_SUPPORT, m_dOptions, MinPrecisionSupport); | ||
| 688 | FEATURE_SUPPORT_GET(D3D12_TILED_RESOURCES_TIER, m_dOptions, TiledResourcesTier); | ||
| 689 | FEATURE_SUPPORT_GET(D3D12_RESOURCE_BINDING_TIER, m_dOptions, ResourceBindingTier); | ||
| 690 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, PSSpecifiedStencilRefSupported); | ||
| 691 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, TypedUAVLoadAdditionalFormats); | ||
| 692 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, ROVsSupported); | ||
| 693 | FEATURE_SUPPORT_GET(D3D12_CONSERVATIVE_RASTERIZATION_TIER, m_dOptions, ConservativeRasterizationTier); | ||
| 694 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, StandardSwizzle64KBSupported); | ||
| 695 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, CrossAdapterRowMajorTextureSupported); | ||
| 696 | FEATURE_SUPPORT_GET(BOOL, m_dOptions, VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation); | ||
| 697 | FEATURE_SUPPORT_GET(D3D12_RESOURCE_HEAP_TIER, m_dOptions, ResourceHeapTier); | ||
| 698 | |||
| 699 | // Special procedure for handling caps that is also part of other features | ||
| 700 | inline D3D12_CROSS_NODE_SHARING_TIER CD3DX12FeatureSupport::CrossNodeSharingTier() const noexcept | ||
| 701 | { | ||
| 702 | if (m_dCrossNode.SharingTier > D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED) | ||
| 703 | { | ||
| 704 | return m_dCrossNode.SharingTier; | ||
| 705 | } | ||
| 706 | else | ||
| 707 | { | ||
| 708 | return m_dOptions.CrossNodeSharingTier; | ||
| 709 | } | ||
| 710 | } | ||
| 711 | |||
| 712 | inline UINT CD3DX12FeatureSupport::MaxGPUVirtualAddressBitsPerResource() const noexcept | ||
| 713 | { | ||
| 714 | if (m_dOptions.MaxGPUVirtualAddressBitsPerResource > 0) | ||
| 715 | { | ||
| 716 | return m_dOptions.MaxGPUVirtualAddressBitsPerResource; | ||
| 717 | } | ||
| 718 | else | ||
| 719 | { | ||
| 720 | return m_dGPUVASupport.MaxGPUVirtualAddressBitsPerResource; | ||
| 721 | } | ||
| 722 | } | ||
| 723 | |||
| 724 | // 1: Architecture | ||
| 725 | // Combined with Architecture1 | ||
| 726 | |||
| 727 | // 2: Feature Levels | ||
| 728 | // Simply returns the highest supported feature level | ||
| 729 | inline D3D_FEATURE_LEVEL CD3DX12FeatureSupport::MaxSupportedFeatureLevel() const noexcept | ||
| 730 | { | ||
| 731 | return m_eMaxFeatureLevel; | ||
| 732 | } | ||
| 733 | |||
| 734 | // 3: Feature Format Support | ||
| 735 | inline HRESULT CD3DX12FeatureSupport::FormatSupport(DXGI_FORMAT Format, D3D12_FORMAT_SUPPORT1& Support1, D3D12_FORMAT_SUPPORT2& Support2) const | ||
| 736 | { | ||
| 737 | D3D12_FEATURE_DATA_FORMAT_SUPPORT dFormatSupport; | ||
| 738 | dFormatSupport.Format = Format; | ||
| 739 | |||
| 740 | // It is possible that the function call returns an error | ||
| 741 | HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &dFormatSupport, sizeof(D3D12_FEATURE_DATA_FORMAT_SUPPORT)); | ||
| 742 | |||
| 743 | Support1 = dFormatSupport.Support1; | ||
| 744 | Support2 = dFormatSupport.Support2; // Two outputs. Probably better just to take in the struct as an argument? | ||
| 745 | |||
| 746 | return result; | ||
| 747 | } | ||
| 748 | |||
| 749 | // 4: Multisample Quality Levels | ||
| 750 | inline HRESULT CD3DX12FeatureSupport::MultisampleQualityLevels(DXGI_FORMAT Format, UINT SampleCount, D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags, UINT& NumQualityLevels) const | ||
| 751 | { | ||
| 752 | D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS dMultisampleQualityLevels; | ||
| 753 | dMultisampleQualityLevels.Format = Format; | ||
| 754 | dMultisampleQualityLevels.SampleCount = SampleCount; | ||
| 755 | dMultisampleQualityLevels.Flags = Flags; | ||
| 756 | |||
| 757 | HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &dMultisampleQualityLevels, sizeof(D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS)); | ||
| 758 | |||
| 759 | if (SUCCEEDED(result)) | ||
| 760 | { | ||
| 761 | NumQualityLevels = dMultisampleQualityLevels.NumQualityLevels; | ||
| 762 | } | ||
| 763 | else | ||
| 764 | { | ||
| 765 | NumQualityLevels = 0; | ||
| 766 | } | ||
| 767 | |||
| 768 | return result; | ||
| 769 | } | ||
| 770 | |||
| 771 | // 5: Format Info | ||
| 772 | inline HRESULT CD3DX12FeatureSupport::FormatInfo(DXGI_FORMAT Format, UINT8& PlaneCount) const | ||
| 773 | { | ||
| 774 | D3D12_FEATURE_DATA_FORMAT_INFO dFormatInfo; | ||
| 775 | dFormatInfo.Format = Format; | ||
| 776 | |||
| 777 | HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &dFormatInfo, sizeof(D3D12_FEATURE_DATA_FORMAT_INFO)); | ||
| 778 | if (FAILED(result)) | ||
| 779 | { | ||
| 780 | PlaneCount = 0; | ||
| 781 | } | ||
| 782 | else | ||
| 783 | { | ||
| 784 | PlaneCount = dFormatInfo.PlaneCount; | ||
| 785 | } | ||
| 786 | return result; | ||
| 787 | } | ||
| 788 | |||
| 789 | // 6: GPU Virtual Address Support | ||
| 790 | // MaxGPUVirtualAddressBitsPerResource handled in D3D12Options | ||
| 791 | FEATURE_SUPPORT_GET(UINT, m_dGPUVASupport, MaxGPUVirtualAddressBitsPerProcess); | ||
| 792 | |||
| 793 | // 7: Shader Model | ||
| 794 | inline D3D_SHADER_MODEL CD3DX12FeatureSupport::HighestShaderModel() const noexcept | ||
| 795 | { | ||
| 796 | return m_dShaderModel.HighestShaderModel; | ||
| 797 | } | ||
| 798 | |||
| 799 | // 8: D3D12 Options1 | ||
| 800 | FEATURE_SUPPORT_GET(BOOL, m_dOptions1, WaveOps); | ||
| 801 | FEATURE_SUPPORT_GET(UINT, m_dOptions1, WaveLaneCountMin); | ||
| 802 | FEATURE_SUPPORT_GET(UINT, m_dOptions1, WaveLaneCountMax); | ||
| 803 | FEATURE_SUPPORT_GET(UINT, m_dOptions1, TotalLaneCount); | ||
| 804 | FEATURE_SUPPORT_GET(BOOL, m_dOptions1, ExpandedComputeResourceStates); | ||
| 805 | FEATURE_SUPPORT_GET(BOOL, m_dOptions1, Int64ShaderOps); | ||
| 806 | |||
| 807 | // 10: Protected Resource Session Support | ||
| 808 | inline D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS CD3DX12FeatureSupport::ProtectedResourceSessionSupport(UINT NodeIndex) const | ||
| 809 | { | ||
| 810 | return m_dProtectedResourceSessionSupport[NodeIndex].Support; | ||
| 811 | } | ||
| 812 | |||
| 813 | // 12: Root Signature | ||
| 814 | inline D3D_ROOT_SIGNATURE_VERSION CD3DX12FeatureSupport::HighestRootSignatureVersion() const noexcept | ||
| 815 | { | ||
| 816 | return m_dRootSignature.HighestVersion; | ||
| 817 | } | ||
| 818 | |||
| 819 | // 16: Architecture1 | ||
| 820 | // Same data fields can be queried from m_dArchitecture | ||
| 821 | FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, TileBasedRenderer); | ||
| 822 | FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, UMA); | ||
| 823 | FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, CacheCoherentUMA); | ||
| 824 | FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, IsolatedMMU); | ||
| 825 | |||
| 826 | // 18: D3D12 Options2 | ||
| 827 | FEATURE_SUPPORT_GET(BOOL, m_dOptions2, DepthBoundsTestSupported); | ||
| 828 | FEATURE_SUPPORT_GET(D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER, m_dOptions2, ProgrammableSamplePositionsTier); | ||
| 829 | |||
| 830 | // 19: Shader Cache | ||
| 831 | FEATURE_SUPPORT_GET_NAME(D3D12_SHADER_CACHE_SUPPORT_FLAGS, m_dShaderCache, SupportFlags, ShaderCacheSupportFlags); | ||
| 832 | |||
| 833 | // 20: Command Queue Priority | ||
| 834 | inline BOOL CD3DX12FeatureSupport::CommandQueuePrioritySupported(D3D12_COMMAND_LIST_TYPE CommandListType, UINT Priority) | ||
| 835 | { | ||
| 836 | m_dCommandQueuePriority.CommandListType = CommandListType; | ||
| 837 | m_dCommandQueuePriority.Priority = Priority; | ||
| 838 | |||
| 839 | if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_COMMAND_QUEUE_PRIORITY, &m_dCommandQueuePriority, sizeof(D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY)))) | ||
| 840 | { | ||
| 841 | return false; | ||
| 842 | } | ||
| 843 | |||
| 844 | return m_dCommandQueuePriority.PriorityForTypeIsSupported; | ||
| 845 | } | ||
| 846 | |||
| 847 | // 21: D3D12 Options3 | ||
| 848 | FEATURE_SUPPORT_GET(BOOL, m_dOptions3, CopyQueueTimestampQueriesSupported); | ||
| 849 | FEATURE_SUPPORT_GET(BOOL, m_dOptions3, CastingFullyTypedFormatSupported); | ||
| 850 | FEATURE_SUPPORT_GET(D3D12_COMMAND_LIST_SUPPORT_FLAGS, m_dOptions3, WriteBufferImmediateSupportFlags); | ||
| 851 | FEATURE_SUPPORT_GET(D3D12_VIEW_INSTANCING_TIER, m_dOptions3, ViewInstancingTier); | ||
| 852 | FEATURE_SUPPORT_GET(BOOL, m_dOptions3, BarycentricsSupported); | ||
| 853 | |||
| 854 | // 22: Existing Heaps | ||
| 855 | FEATURE_SUPPORT_GET_NAME(BOOL, m_dExistingHeaps, Supported, ExistingHeapsSupported); | ||
| 856 | |||
| 857 | // 23: D3D12 Options4 | ||
| 858 | FEATURE_SUPPORT_GET(BOOL, m_dOptions4, MSAA64KBAlignedTextureSupported); | ||
| 859 | FEATURE_SUPPORT_GET(D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER, m_dOptions4, SharedResourceCompatibilityTier); | ||
| 860 | FEATURE_SUPPORT_GET(BOOL, m_dOptions4, Native16BitShaderOpsSupported); | ||
| 861 | |||
| 862 | // 24: Serialization | ||
| 863 | FEATURE_SUPPORT_GET_NODE_INDEXED(D3D12_HEAP_SERIALIZATION_TIER, m_dSerialization, HeapSerializationTier); | ||
| 864 | |||
| 865 | // 25: Cross Node | ||
| 866 | // CrossNodeSharingTier handled in D3D12Options | ||
| 867 | FEATURE_SUPPORT_GET_NAME(BOOL, m_dCrossNode, AtomicShaderInstructions, CrossNodeAtomicShaderInstructions); | ||
| 868 | |||
| 869 | // 27: D3D12 Options5 | ||
| 870 | FEATURE_SUPPORT_GET(BOOL, m_dOptions5, SRVOnlyTiledResourceTier3); | ||
| 871 | FEATURE_SUPPORT_GET(D3D12_RENDER_PASS_TIER, m_dOptions5, RenderPassesTier); | ||
| 872 | FEATURE_SUPPORT_GET(D3D12_RAYTRACING_TIER, m_dOptions5, RaytracingTier); | ||
| 873 | |||
| 874 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 875 | // 28: Displayable | ||
| 876 | FEATURE_SUPPORT_GET(BOOL, m_dDisplayable, DisplayableTexture); | ||
| 877 | // SharedResourceCompatibilityTier handled in D3D12Options4 | ||
| 878 | #endif | ||
| 879 | |||
| 880 | // 30: D3D12 Options6 | ||
| 881 | FEATURE_SUPPORT_GET(BOOL, m_dOptions6, AdditionalShadingRatesSupported); | ||
| 882 | FEATURE_SUPPORT_GET(BOOL, m_dOptions6, PerPrimitiveShadingRateSupportedWithViewportIndexing); | ||
| 883 | FEATURE_SUPPORT_GET(D3D12_VARIABLE_SHADING_RATE_TIER, m_dOptions6, VariableShadingRateTier); | ||
| 884 | FEATURE_SUPPORT_GET(UINT, m_dOptions6, ShadingRateImageTileSize); | ||
| 885 | FEATURE_SUPPORT_GET(BOOL, m_dOptions6, BackgroundProcessingSupported); | ||
| 886 | |||
| 887 | // 31: Query Meta Command | ||
| 888 | // Keep the original call routine | ||
| 889 | inline HRESULT CD3DX12FeatureSupport::QueryMetaCommand(D3D12_FEATURE_DATA_QUERY_META_COMMAND& dQueryMetaCommand) const | ||
| 890 | { | ||
| 891 | return m_pDevice->CheckFeatureSupport(D3D12_FEATURE_QUERY_META_COMMAND, &dQueryMetaCommand, sizeof(D3D12_FEATURE_DATA_QUERY_META_COMMAND)); | ||
| 892 | } | ||
| 893 | |||
| 894 | // 32: D3D12 Options7 | ||
| 895 | FEATURE_SUPPORT_GET(D3D12_MESH_SHADER_TIER, m_dOptions7, MeshShaderTier); | ||
| 896 | FEATURE_SUPPORT_GET(D3D12_SAMPLER_FEEDBACK_TIER, m_dOptions7, SamplerFeedbackTier); | ||
| 897 | |||
| 898 | // 33: Protected Resource Session Type Count | ||
| 899 | FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(UINT, m_dProtectedResourceSessionTypeCount, Count, ProtectedResourceSessionTypeCount); | ||
| 900 | |||
| 901 | // 34: Protected Resource Session Types | ||
| 902 | FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(std::vector<GUID>, m_dProtectedResourceSessionTypes, TypeVec, ProtectedResourceSessionTypes); | ||
| 903 | |||
| 904 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3) | ||
| 905 | // 36: Options8 | ||
| 906 | FEATURE_SUPPORT_GET(BOOL, m_dOptions8, UnalignedBlockTexturesSupported); | ||
| 907 | |||
| 908 | // 37: Options9 | ||
| 909 | FEATURE_SUPPORT_GET(BOOL, m_dOptions9, MeshShaderPipelineStatsSupported); | ||
| 910 | FEATURE_SUPPORT_GET(BOOL, m_dOptions9, MeshShaderSupportsFullRangeRenderTargetArrayIndex); | ||
| 911 | FEATURE_SUPPORT_GET(BOOL, m_dOptions9, AtomicInt64OnTypedResourceSupported); | ||
| 912 | FEATURE_SUPPORT_GET(BOOL, m_dOptions9, AtomicInt64OnGroupSharedSupported); | ||
| 913 | FEATURE_SUPPORT_GET(BOOL, m_dOptions9, DerivativesInMeshAndAmplificationShadersSupported); | ||
| 914 | FEATURE_SUPPORT_GET(D3D12_WAVE_MMA_TIER, m_dOptions9, WaveMMATier); | ||
| 915 | #endif | ||
| 916 | |||
| 917 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4) | ||
| 918 | // 39: Options10 | ||
| 919 | FEATURE_SUPPORT_GET(BOOL, m_dOptions10, VariableRateShadingSumCombinerSupported); | ||
| 920 | FEATURE_SUPPORT_GET(BOOL, m_dOptions10, MeshShaderPerPrimitiveShadingRateSupported); | ||
| 921 | |||
| 922 | // 40: Options11 | ||
| 923 | FEATURE_SUPPORT_GET(BOOL, m_dOptions11, AtomicInt64OnDescriptorHeapResourceSupported); | ||
| 924 | #endif | ||
| 925 | |||
| 926 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600) | ||
| 927 | // 41: Options12 | ||
| 928 | FEATURE_SUPPORT_GET(D3D12_TRI_STATE, m_dOptions12, MSPrimitivesPipelineStatisticIncludesCulledPrimitives); | ||
| 929 | FEATURE_SUPPORT_GET(BOOL, m_dOptions12, EnhancedBarriersSupported); | ||
| 930 | FEATURE_SUPPORT_GET(BOOL, m_dOptions12, RelaxedFormatCastingSupported); | ||
| 931 | #endif | ||
| 932 | |||
| 933 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602) | ||
| 934 | // 42: Options13 | ||
| 935 | FEATURE_SUPPORT_GET(BOOL, m_dOptions13, UnrestrictedBufferTextureCopyPitchSupported); | ||
| 936 | FEATURE_SUPPORT_GET(BOOL, m_dOptions13, UnrestrictedVertexElementAlignmentSupported); | ||
| 937 | FEATURE_SUPPORT_GET(BOOL, m_dOptions13, InvertedViewportHeightFlipsYSupported); | ||
| 938 | FEATURE_SUPPORT_GET(BOOL, m_dOptions13, InvertedViewportDepthFlipsZSupported); | ||
| 939 | FEATURE_SUPPORT_GET(BOOL, m_dOptions13, TextureCopyBetweenDimensionsSupported); | ||
| 940 | FEATURE_SUPPORT_GET(BOOL, m_dOptions13, AlphaBlendFactorSupported); | ||
| 941 | #endif | ||
| 942 | |||
| 943 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 944 | // 43: Options14 | ||
| 945 | FEATURE_SUPPORT_GET(BOOL, m_dOptions14, AdvancedTextureOpsSupported); | ||
| 946 | FEATURE_SUPPORT_GET(BOOL, m_dOptions14, WriteableMSAATexturesSupported); | ||
| 947 | FEATURE_SUPPORT_GET(BOOL, m_dOptions14, IndependentFrontAndBackStencilRefMaskSupported); | ||
| 948 | |||
| 949 | // 44: Options15 | ||
| 950 | FEATURE_SUPPORT_GET(BOOL, m_dOptions15, TriangleFanSupported); | ||
| 951 | FEATURE_SUPPORT_GET(BOOL, m_dOptions15, DynamicIndexBufferStripCutSupported); | ||
| 952 | #endif | ||
| 953 | |||
| 954 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 955 | // 45: Options16 | ||
| 956 | FEATURE_SUPPORT_GET(BOOL, m_dOptions16, DynamicDepthBiasSupported); | ||
| 957 | #endif | ||
| 958 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 959 | FEATURE_SUPPORT_GET(BOOL, m_dOptions16, GPUUploadHeapSupported); | ||
| 960 | |||
| 961 | // 46: Options17 | ||
| 962 | FEATURE_SUPPORT_GET(BOOL, m_dOptions17, NonNormalizedCoordinateSamplersSupported); | ||
| 963 | FEATURE_SUPPORT_GET(BOOL, m_dOptions17, ManualWriteTrackingResourceSupported); | ||
| 964 | |||
| 965 | // 47: Option18 | ||
| 966 | FEATURE_SUPPORT_GET(BOOL, m_dOptions18, RenderPassesValid); | ||
| 967 | #endif | ||
| 968 | |||
| 969 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 970 | FEATURE_SUPPORT_GET(BOOL, m_dOptions19, MismatchingOutputDimensionsSupported); | ||
| 971 | FEATURE_SUPPORT_GET(UINT, m_dOptions19, SupportedSampleCountsWithNoOutputs); | ||
| 972 | FEATURE_SUPPORT_GET(BOOL, m_dOptions19, PointSamplingAddressesNeverRoundUp); | ||
| 973 | FEATURE_SUPPORT_GET(BOOL, m_dOptions19, RasterizerDesc2Supported); | ||
| 974 | FEATURE_SUPPORT_GET(BOOL, m_dOptions19, NarrowQuadrilateralLinesSupported); | ||
| 975 | FEATURE_SUPPORT_GET(BOOL, m_dOptions19, AnisoFilterWithPointMipSupported); | ||
| 976 | FEATURE_SUPPORT_GET(UINT, m_dOptions19, MaxSamplerDescriptorHeapSize); | ||
| 977 | FEATURE_SUPPORT_GET(UINT, m_dOptions19, MaxSamplerDescriptorHeapSizeWithStaticSamplers); | ||
| 978 | FEATURE_SUPPORT_GET(UINT, m_dOptions19, MaxViewDescriptorHeapSize); | ||
| 979 | #endif | ||
| 980 | |||
| 981 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) | ||
| 982 | // 49: Options20 | ||
| 983 | FEATURE_SUPPORT_GET(BOOL, m_dOptions20, ComputeOnlyWriteWatchSupported); | ||
| 984 | #endif | ||
| 985 | |||
| 986 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 987 | // 50: Options21 | ||
| 988 | FEATURE_SUPPORT_GET(D3D12_EXECUTE_INDIRECT_TIER, m_dOptions21, ExecuteIndirectTier); | ||
| 989 | FEATURE_SUPPORT_GET(D3D12_WORK_GRAPHS_TIER, m_dOptions21, WorkGraphsTier); | ||
| 990 | #endif | ||
| 991 | |||
| 992 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 617) | ||
| 993 | // 51: TightAlignment | ||
| 994 | FEATURE_SUPPORT_GET_NAME(D3D12_TIGHT_ALIGNMENT_TIER, m_dTightAlignment, SupportTier, TightAlignmentSupportTier); | ||
| 995 | #endif | ||
| 996 | |||
| 997 | // Helper function to decide the highest shader model supported by the system | ||
| 998 | // Stores the result in m_dShaderModel | ||
| 999 | // Must be updated whenever a new shader model is added to the d3d12.h header | ||
| 1000 | inline HRESULT CD3DX12FeatureSupport::QueryHighestShaderModel() | ||
| 1001 | { | ||
| 1002 | // Check support in descending order | ||
| 1003 | HRESULT result; | ||
| 1004 | |||
| 1005 | const D3D_SHADER_MODEL allModelVersions[] = | ||
| 1006 | { | ||
| 1007 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 1008 | D3D_SHADER_MODEL_6_9, | ||
| 1009 | #endif | ||
| 1010 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 1011 | D3D_SHADER_MODEL_6_8, | ||
| 1012 | #endif | ||
| 1013 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3) | ||
| 1014 | D3D_SHADER_MODEL_6_7, | ||
| 1015 | #endif | ||
| 1016 | D3D_SHADER_MODEL_6_6, | ||
| 1017 | D3D_SHADER_MODEL_6_5, | ||
| 1018 | D3D_SHADER_MODEL_6_4, | ||
| 1019 | D3D_SHADER_MODEL_6_3, | ||
| 1020 | D3D_SHADER_MODEL_6_2, | ||
| 1021 | D3D_SHADER_MODEL_6_1, | ||
| 1022 | D3D_SHADER_MODEL_6_0, | ||
| 1023 | D3D_SHADER_MODEL_5_1 | ||
| 1024 | }; | ||
| 1025 | constexpr size_t numModelVersions = sizeof(allModelVersions) / sizeof(D3D_SHADER_MODEL); | ||
| 1026 | |||
| 1027 | for (size_t i = 0; i < numModelVersions; i++) | ||
| 1028 | { | ||
| 1029 | m_dShaderModel.HighestShaderModel = allModelVersions[i]; | ||
| 1030 | result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &m_dShaderModel, sizeof(D3D12_FEATURE_DATA_SHADER_MODEL)); | ||
| 1031 | if (result != E_INVALIDARG) | ||
| 1032 | { | ||
| 1033 | // Indicates that the version is recognizable by the runtime and stored in the struct | ||
| 1034 | // Also terminate on unexpected error code | ||
| 1035 | if (FAILED(result)) | ||
| 1036 | { | ||
| 1037 | m_dShaderModel.HighestShaderModel = static_cast<D3D_SHADER_MODEL>(0); | ||
| 1038 | } | ||
| 1039 | return result; | ||
| 1040 | } | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | // Shader model may not be supported. Continue the rest initializations | ||
| 1044 | m_dShaderModel.HighestShaderModel = static_cast<D3D_SHADER_MODEL>(0); | ||
| 1045 | return S_OK; | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | // Helper function to decide the highest root signature supported | ||
| 1049 | // Must be updated whenever a new root signature version is added to the d3d12.h header | ||
| 1050 | inline HRESULT CD3DX12FeatureSupport::QueryHighestRootSignatureVersion() | ||
| 1051 | { | ||
| 1052 | HRESULT result; | ||
| 1053 | |||
| 1054 | const D3D_ROOT_SIGNATURE_VERSION allRootSignatureVersions[] = | ||
| 1055 | { | ||
| 1056 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 1057 | D3D_ROOT_SIGNATURE_VERSION_1_2, | ||
| 1058 | #endif | ||
| 1059 | D3D_ROOT_SIGNATURE_VERSION_1_1, | ||
| 1060 | D3D_ROOT_SIGNATURE_VERSION_1_0, | ||
| 1061 | D3D_ROOT_SIGNATURE_VERSION_1, | ||
| 1062 | }; | ||
| 1063 | constexpr size_t numRootSignatureVersions = sizeof(allRootSignatureVersions) / sizeof(D3D_ROOT_SIGNATURE_VERSION); | ||
| 1064 | |||
| 1065 | for (size_t i = 0; i < numRootSignatureVersions; i++) | ||
| 1066 | { | ||
| 1067 | m_dRootSignature.HighestVersion = allRootSignatureVersions[i]; | ||
| 1068 | result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &m_dRootSignature, sizeof(D3D12_FEATURE_DATA_ROOT_SIGNATURE)); | ||
| 1069 | if (result != E_INVALIDARG) | ||
| 1070 | { | ||
| 1071 | if (FAILED(result)) | ||
| 1072 | { | ||
| 1073 | m_dRootSignature.HighestVersion = static_cast<D3D_ROOT_SIGNATURE_VERSION>(0); | ||
| 1074 | } | ||
| 1075 | // If succeeded, the highest version is already written into the member struct | ||
| 1076 | return result; | ||
| 1077 | } | ||
| 1078 | } | ||
| 1079 | |||
| 1080 | // No version left. Set to invalid value and continue. | ||
| 1081 | m_dRootSignature.HighestVersion = static_cast<D3D_ROOT_SIGNATURE_VERSION>(0); | ||
| 1082 | return S_OK; | ||
| 1083 | } | ||
| 1084 | |||
| 1085 | // Helper funcion to decide the highest feature level | ||
| 1086 | inline HRESULT CD3DX12FeatureSupport::QueryHighestFeatureLevel() | ||
| 1087 | { | ||
| 1088 | HRESULT result; | ||
| 1089 | |||
| 1090 | // Check against a list of all feature levels present in d3dcommon.h | ||
| 1091 | // Needs to be updated for future feature levels | ||
| 1092 | const D3D_FEATURE_LEVEL allLevels[] = | ||
| 1093 | { | ||
| 1094 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3) | ||
| 1095 | D3D_FEATURE_LEVEL_12_2, | ||
| 1096 | #endif | ||
| 1097 | D3D_FEATURE_LEVEL_12_1, | ||
| 1098 | D3D_FEATURE_LEVEL_12_0, | ||
| 1099 | D3D_FEATURE_LEVEL_11_1, | ||
| 1100 | D3D_FEATURE_LEVEL_11_0, | ||
| 1101 | D3D_FEATURE_LEVEL_10_1, | ||
| 1102 | D3D_FEATURE_LEVEL_10_0, | ||
| 1103 | D3D_FEATURE_LEVEL_9_3, | ||
| 1104 | D3D_FEATURE_LEVEL_9_2, | ||
| 1105 | D3D_FEATURE_LEVEL_9_1, | ||
| 1106 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 5) | ||
| 1107 | D3D_FEATURE_LEVEL_1_0_CORE, | ||
| 1108 | #endif | ||
| 1109 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611) | ||
| 1110 | D3D_FEATURE_LEVEL_1_0_GENERIC | ||
| 1111 | #endif | ||
| 1112 | }; | ||
| 1113 | |||
| 1114 | D3D12_FEATURE_DATA_FEATURE_LEVELS dFeatureLevel; | ||
| 1115 | dFeatureLevel.NumFeatureLevels = static_cast<UINT>(sizeof(allLevels) / sizeof(D3D_FEATURE_LEVEL)); | ||
| 1116 | dFeatureLevel.pFeatureLevelsRequested = allLevels; | ||
| 1117 | |||
| 1118 | result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &dFeatureLevel, sizeof(D3D12_FEATURE_DATA_FEATURE_LEVELS)); | ||
| 1119 | if (SUCCEEDED(result)) | ||
| 1120 | { | ||
| 1121 | m_eMaxFeatureLevel = dFeatureLevel.MaxSupportedFeatureLevel; | ||
| 1122 | } | ||
| 1123 | else | ||
| 1124 | { | ||
| 1125 | m_eMaxFeatureLevel = static_cast<D3D_FEATURE_LEVEL>(0); | ||
| 1126 | |||
| 1127 | if (result == DXGI_ERROR_UNSUPPORTED) | ||
| 1128 | { | ||
| 1129 | // Indicates that none supported. Continue initialization | ||
| 1130 | result = S_OK; | ||
| 1131 | } | ||
| 1132 | } | ||
| 1133 | return result; | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | // Helper function to initialize local protected resource session types structs | ||
| 1137 | inline HRESULT CD3DX12FeatureSupport::QueryProtectedResourceSessionTypes(UINT NodeIndex, UINT Count) | ||
| 1138 | { | ||
| 1139 | auto& CurrentPRSTypes = m_dProtectedResourceSessionTypes[NodeIndex]; | ||
| 1140 | CurrentPRSTypes.NodeIndex = NodeIndex; | ||
| 1141 | CurrentPRSTypes.Count = Count; | ||
| 1142 | CurrentPRSTypes.TypeVec.resize(CurrentPRSTypes.Count); | ||
| 1143 | CurrentPRSTypes.pTypes = CurrentPRSTypes.TypeVec.data(); | ||
| 1144 | |||
| 1145 | HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPES, &m_dProtectedResourceSessionTypes[NodeIndex], sizeof(D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES)); | ||
| 1146 | if (FAILED(result)) | ||
| 1147 | { | ||
| 1148 | // Resize TypeVec to empty | ||
| 1149 | CurrentPRSTypes.TypeVec.clear(); | ||
| 1150 | } | ||
| 1151 | |||
| 1152 | return result; | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | #undef FEATURE_SUPPORT_GET | ||
| 1156 | #undef FEATURE_SUPPORT_GET_NAME | ||
| 1157 | #undef FEATURE_SUPPORT_GET_NODE_INDEXED | ||
| 1158 | #undef FEATURE_SUPPORT_GET_NODE_INDEXED_NAME | ||
| 1159 | |||
| 1160 | // end CD3DX12FeatureSupport | ||
| 1161 | |||
| 1162 | |||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_core.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_core.h new file mode 100644 index 0000000..092a039 --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_core.h | |||
| @@ -0,0 +1,2072 @@ | |||
| 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 <string.h> | ||
| 15 | #include "d3d12.h" | ||
| 16 | #include "d3dx12_default.h" | ||
| 17 | |||
| 18 | //------------------------------------------------------------------------------------------------ | ||
| 19 | #ifndef D3DX12_ASSERT | ||
| 20 | #ifdef assert | ||
| 21 | #define D3DX12_ASSERT(x) assert(x) | ||
| 22 | #else | ||
| 23 | #define D3DX12_ASSERT(x) | ||
| 24 | #endif | ||
| 25 | #endif | ||
| 26 | |||
| 27 | //------------------------------------------------------------------------------------------------ | ||
| 28 | template <typename t_CommandListType> | ||
| 29 | inline ID3D12CommandList * const * CommandListCast(t_CommandListType * const * pp) noexcept | ||
| 30 | { | ||
| 31 | // This cast is useful for passing strongly typed command list pointers into | ||
| 32 | // ExecuteCommandLists. | ||
| 33 | // This cast is valid as long as the const-ness is respected. D3D12 APIs do | ||
| 34 | // respect the const-ness of their arguments. | ||
| 35 | return reinterpret_cast<ID3D12CommandList * const *>(pp); | ||
| 36 | } | ||
| 37 | |||
| 38 | #ifdef D3DX12_USE_ARRAY_COM_PTR | ||
| 39 | #include <vector> | ||
| 40 | //------------------------------------------------------------------------------------------------ | ||
| 41 | // CArrayComPtr - Useful RAII container of raw IUnknown pointers. | ||
| 42 | template<typename _T> | ||
| 43 | class CArrayComPtr | ||
| 44 | { | ||
| 45 | std::vector<_T *> m_array; | ||
| 46 | |||
| 47 | public: | ||
| 48 | class CProxyPtr | ||
| 49 | { | ||
| 50 | _T *&pObj; | ||
| 51 | |||
| 52 | CProxyPtr(_T *&obj) : | ||
| 53 | pObj(obj) {} | ||
| 54 | |||
| 55 | public: | ||
| 56 | operator _T*() { return pObj; } | ||
| 57 | _T **operator&() { return &pObj; } | ||
| 58 | CProxyPtr &operator=(_T*&obj) | ||
| 59 | { | ||
| 60 | if(pObj) | ||
| 61 | pObj->Release(); | ||
| 62 | |||
| 63 | pObj = obj; | ||
| 64 | |||
| 65 | if(pObj) | ||
| 66 | pObj->AddRef(); | ||
| 67 | } | ||
| 68 | |||
| 69 | friend class CArrayComPtr<_T>; | ||
| 70 | }; | ||
| 71 | |||
| 72 | public: | ||
| 73 | CArrayComPtr() = default; | ||
| 74 | |||
| 75 | CArrayComPtr(size_t size) : | ||
| 76 | m_array(size) { | ||
| 77 | } | ||
| 78 | |||
| 79 | CArrayComPtr(const CArrayComPtr &o) | ||
| 80 | { | ||
| 81 | m_array = o.m_array; | ||
| 82 | for (size_t i = 0; i < m_array.size(); ++i) | ||
| 83 | { | ||
| 84 | m_array[i]->AddRef(); | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | CArrayComPtr(CArrayComPtr &&o) = default; | ||
| 89 | |||
| 90 | ~CArrayComPtr() | ||
| 91 | { | ||
| 92 | for (auto ptr : m_array) | ||
| 93 | { | ||
| 94 | if (ptr) | ||
| 95 | { | ||
| 96 | ptr->Release(); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | _T *const *Get() { return m_array.data(); } | ||
| 102 | |||
| 103 | void Assign(size_t index, _T *ptr) | ||
| 104 | { | ||
| 105 | if (index >= m_array.size()) | ||
| 106 | { | ||
| 107 | Resize(index + 1); | ||
| 108 | } | ||
| 109 | |||
| 110 | // Release the old pointer if it exists | ||
| 111 | if (m_array[index]) | ||
| 112 | { | ||
| 113 | m_array[index]->Release(); | ||
| 114 | } | ||
| 115 | |||
| 116 | // Assign the new pointer and AddRef it if not null | ||
| 117 | m_array[index] = ptr; | ||
| 118 | if (ptr) | ||
| 119 | { | ||
| 120 | ptr->AddRef(); | ||
| 121 | } | ||
| 122 | } | ||
| 123 | |||
| 124 | void Resize(size_t size) | ||
| 125 | { | ||
| 126 | // If shrinking, release any pointers that will be discarded | ||
| 127 | if (size < m_array.size()) | ||
| 128 | { | ||
| 129 | for (size_t i = size; i < m_array.size(); ++i) | ||
| 130 | { | ||
| 131 | if (m_array[i]) | ||
| 132 | { | ||
| 133 | m_array[i]->Release(); | ||
| 134 | } | ||
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 138 | // Resize the vector, initializing new elements to nullptr | ||
| 139 | m_array.resize(size, nullptr); | ||
| 140 | } | ||
| 141 | |||
| 142 | void PushBack(_T *ptr) | ||
| 143 | { | ||
| 144 | // AddRef if not null | ||
| 145 | if (ptr) | ||
| 146 | { | ||
| 147 | ptr->AddRef(); | ||
| 148 | } | ||
| 149 | m_array.push_back(ptr); | ||
| 150 | } | ||
| 151 | |||
| 152 | CProxyPtr operator[](size_t index) | ||
| 153 | { | ||
| 154 | return CProxyPtr(m_array[index]); | ||
| 155 | } | ||
| 156 | }; | ||
| 157 | #endif | ||
| 158 | //------------------------------------------------------------------------------------------------ | ||
| 159 | inline bool operator==( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept | ||
| 160 | { | ||
| 161 | return l.TopLeftX == r.TopLeftX && l.TopLeftY == r.TopLeftY && l.Width == r.Width && | ||
| 162 | l.Height == r.Height && l.MinDepth == r.MinDepth && l.MaxDepth == r.MaxDepth; | ||
| 163 | } | ||
| 164 | |||
| 165 | //------------------------------------------------------------------------------------------------ | ||
| 166 | inline bool operator!=( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept | ||
| 167 | { return !( l == r ); } | ||
| 168 | |||
| 169 | //------------------------------------------------------------------------------------------------ | ||
| 170 | struct CD3DX12_RECT : public D3D12_RECT | ||
| 171 | { | ||
| 172 | CD3DX12_RECT() = default; | ||
| 173 | explicit CD3DX12_RECT( const D3D12_RECT& o ) noexcept : | ||
| 174 | D3D12_RECT( o ) | ||
| 175 | {} | ||
| 176 | explicit CD3DX12_RECT( | ||
| 177 | LONG Left, | ||
| 178 | LONG Top, | ||
| 179 | LONG Right, | ||
| 180 | LONG Bottom ) noexcept | ||
| 181 | { | ||
| 182 | left = Left; | ||
| 183 | top = Top; | ||
| 184 | right = Right; | ||
| 185 | bottom = Bottom; | ||
| 186 | } | ||
| 187 | }; | ||
| 188 | |||
| 189 | //------------------------------------------------------------------------------------------------ | ||
| 190 | struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT | ||
| 191 | { | ||
| 192 | CD3DX12_VIEWPORT() = default; | ||
| 193 | explicit CD3DX12_VIEWPORT( const D3D12_VIEWPORT& o ) noexcept : | ||
| 194 | D3D12_VIEWPORT( o ) | ||
| 195 | {} | ||
| 196 | explicit CD3DX12_VIEWPORT( | ||
| 197 | FLOAT topLeftX, | ||
| 198 | FLOAT topLeftY, | ||
| 199 | FLOAT width, | ||
| 200 | FLOAT height, | ||
| 201 | FLOAT minDepth = D3D12_MIN_DEPTH, | ||
| 202 | FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept | ||
| 203 | { | ||
| 204 | TopLeftX = topLeftX; | ||
| 205 | TopLeftY = topLeftY; | ||
| 206 | Width = width; | ||
| 207 | Height = height; | ||
| 208 | MinDepth = minDepth; | ||
| 209 | MaxDepth = maxDepth; | ||
| 210 | } | ||
| 211 | explicit CD3DX12_VIEWPORT( | ||
| 212 | _In_ ID3D12Resource* pResource, | ||
| 213 | UINT mipSlice = 0, | ||
| 214 | FLOAT topLeftX = 0.0f, | ||
| 215 | FLOAT topLeftY = 0.0f, | ||
| 216 | FLOAT minDepth = D3D12_MIN_DEPTH, | ||
| 217 | FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept | ||
| 218 | { | ||
| 219 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 220 | const auto Desc = pResource->GetDesc(); | ||
| 221 | #else | ||
| 222 | D3D12_RESOURCE_DESC tmpDesc; | ||
| 223 | const auto& Desc = *pResource->GetDesc(&tmpDesc); | ||
| 224 | #endif | ||
| 225 | const UINT64 SubresourceWidth = Desc.Width >> mipSlice; | ||
| 226 | const UINT64 SubresourceHeight = Desc.Height >> mipSlice; | ||
| 227 | switch (Desc.Dimension) | ||
| 228 | { | ||
| 229 | case D3D12_RESOURCE_DIMENSION_BUFFER: | ||
| 230 | TopLeftX = topLeftX; | ||
| 231 | TopLeftY = 0.0f; | ||
| 232 | Width = float(Desc.Width) - topLeftX; | ||
| 233 | Height = 1.0f; | ||
| 234 | break; | ||
| 235 | case D3D12_RESOURCE_DIMENSION_TEXTURE1D: | ||
| 236 | TopLeftX = topLeftX; | ||
| 237 | TopLeftY = 0.0f; | ||
| 238 | Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; | ||
| 239 | Height = 1.0f; | ||
| 240 | break; | ||
| 241 | case D3D12_RESOURCE_DIMENSION_TEXTURE2D: | ||
| 242 | case D3D12_RESOURCE_DIMENSION_TEXTURE3D: | ||
| 243 | TopLeftX = topLeftX; | ||
| 244 | TopLeftY = topLeftY; | ||
| 245 | Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; | ||
| 246 | Height = (SubresourceHeight ? float(SubresourceHeight) : 1.0f) - topLeftY; | ||
| 247 | break; | ||
| 248 | default: break; | ||
| 249 | } | ||
| 250 | |||
| 251 | MinDepth = minDepth; | ||
| 252 | MaxDepth = maxDepth; | ||
| 253 | } | ||
| 254 | }; | ||
| 255 | |||
| 256 | //------------------------------------------------------------------------------------------------ | ||
| 257 | struct CD3DX12_BOX : public D3D12_BOX | ||
| 258 | { | ||
| 259 | CD3DX12_BOX() = default; | ||
| 260 | explicit CD3DX12_BOX( const D3D12_BOX& o ) noexcept : | ||
| 261 | D3D12_BOX( o ) | ||
| 262 | {} | ||
| 263 | explicit CD3DX12_BOX( | ||
| 264 | LONG Left, | ||
| 265 | LONG Right ) noexcept | ||
| 266 | { | ||
| 267 | left = static_cast<UINT>(Left); | ||
| 268 | top = 0; | ||
| 269 | front = 0; | ||
| 270 | right = static_cast<UINT>(Right); | ||
| 271 | bottom = 1; | ||
| 272 | back = 1; | ||
| 273 | } | ||
| 274 | explicit CD3DX12_BOX( | ||
| 275 | LONG Left, | ||
| 276 | LONG Top, | ||
| 277 | LONG Right, | ||
| 278 | LONG Bottom ) noexcept | ||
| 279 | { | ||
| 280 | left = static_cast<UINT>(Left); | ||
| 281 | top = static_cast<UINT>(Top); | ||
| 282 | front = 0; | ||
| 283 | right = static_cast<UINT>(Right); | ||
| 284 | bottom = static_cast<UINT>(Bottom); | ||
| 285 | back = 1; | ||
| 286 | } | ||
| 287 | explicit CD3DX12_BOX( | ||
| 288 | LONG Left, | ||
| 289 | LONG Top, | ||
| 290 | LONG Front, | ||
| 291 | LONG Right, | ||
| 292 | LONG Bottom, | ||
| 293 | LONG Back ) noexcept | ||
| 294 | { | ||
| 295 | left = static_cast<UINT>(Left); | ||
| 296 | top = static_cast<UINT>(Top); | ||
| 297 | front = static_cast<UINT>(Front); | ||
| 298 | right = static_cast<UINT>(Right); | ||
| 299 | bottom = static_cast<UINT>(Bottom); | ||
| 300 | back = static_cast<UINT>(Back); | ||
| 301 | } | ||
| 302 | }; | ||
| 303 | inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept | ||
| 304 | { | ||
| 305 | return l.left == r.left && l.top == r.top && l.front == r.front && | ||
| 306 | l.right == r.right && l.bottom == r.bottom && l.back == r.back; | ||
| 307 | } | ||
| 308 | inline bool operator!=( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept | ||
| 309 | { return !( l == r ); } | ||
| 310 | |||
| 311 | //------------------------------------------------------------------------------------------------ | ||
| 312 | struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC | ||
| 313 | { | ||
| 314 | CD3DX12_DEPTH_STENCIL_DESC() = default; | ||
| 315 | explicit CD3DX12_DEPTH_STENCIL_DESC( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept : | ||
| 316 | D3D12_DEPTH_STENCIL_DESC( o ) | ||
| 317 | {} | ||
| 318 | explicit CD3DX12_DEPTH_STENCIL_DESC( CD3DX12_DEFAULT ) noexcept | ||
| 319 | { | ||
| 320 | DepthEnable = TRUE; | ||
| 321 | DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; | ||
| 322 | DepthFunc = D3D12_COMPARISON_FUNC_LESS; | ||
| 323 | StencilEnable = FALSE; | ||
| 324 | StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; | ||
| 325 | StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; | ||
| 326 | const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = | ||
| 327 | { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; | ||
| 328 | FrontFace = defaultStencilOp; | ||
| 329 | BackFace = defaultStencilOp; | ||
| 330 | } | ||
| 331 | explicit CD3DX12_DEPTH_STENCIL_DESC( | ||
| 332 | BOOL depthEnable, | ||
| 333 | D3D12_DEPTH_WRITE_MASK depthWriteMask, | ||
| 334 | D3D12_COMPARISON_FUNC depthFunc, | ||
| 335 | BOOL stencilEnable, | ||
| 336 | UINT8 stencilReadMask, | ||
| 337 | UINT8 stencilWriteMask, | ||
| 338 | D3D12_STENCIL_OP frontStencilFailOp, | ||
| 339 | D3D12_STENCIL_OP frontStencilDepthFailOp, | ||
| 340 | D3D12_STENCIL_OP frontStencilPassOp, | ||
| 341 | D3D12_COMPARISON_FUNC frontStencilFunc, | ||
| 342 | D3D12_STENCIL_OP backStencilFailOp, | ||
| 343 | D3D12_STENCIL_OP backStencilDepthFailOp, | ||
| 344 | D3D12_STENCIL_OP backStencilPassOp, | ||
| 345 | D3D12_COMPARISON_FUNC backStencilFunc ) noexcept | ||
| 346 | { | ||
| 347 | DepthEnable = depthEnable; | ||
| 348 | DepthWriteMask = depthWriteMask; | ||
| 349 | DepthFunc = depthFunc; | ||
| 350 | StencilEnable = stencilEnable; | ||
| 351 | StencilReadMask = stencilReadMask; | ||
| 352 | StencilWriteMask = stencilWriteMask; | ||
| 353 | FrontFace.StencilFailOp = frontStencilFailOp; | ||
| 354 | FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; | ||
| 355 | FrontFace.StencilPassOp = frontStencilPassOp; | ||
| 356 | FrontFace.StencilFunc = frontStencilFunc; | ||
| 357 | BackFace.StencilFailOp = backStencilFailOp; | ||
| 358 | BackFace.StencilDepthFailOp = backStencilDepthFailOp; | ||
| 359 | BackFace.StencilPassOp = backStencilPassOp; | ||
| 360 | BackFace.StencilFunc = backStencilFunc; | ||
| 361 | } | ||
| 362 | }; | ||
| 363 | |||
| 364 | //------------------------------------------------------------------------------------------------ | ||
| 365 | struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1 | ||
| 366 | { | ||
| 367 | CD3DX12_DEPTH_STENCIL_DESC1() = default; | ||
| 368 | explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC1& o ) noexcept : | ||
| 369 | D3D12_DEPTH_STENCIL_DESC1( o ) | ||
| 370 | {} | ||
| 371 | explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept | ||
| 372 | { | ||
| 373 | DepthEnable = o.DepthEnable; | ||
| 374 | DepthWriteMask = o.DepthWriteMask; | ||
| 375 | DepthFunc = o.DepthFunc; | ||
| 376 | StencilEnable = o.StencilEnable; | ||
| 377 | StencilReadMask = o.StencilReadMask; | ||
| 378 | StencilWriteMask = o.StencilWriteMask; | ||
| 379 | FrontFace.StencilFailOp = o.FrontFace.StencilFailOp; | ||
| 380 | FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp; | ||
| 381 | FrontFace.StencilPassOp = o.FrontFace.StencilPassOp; | ||
| 382 | FrontFace.StencilFunc = o.FrontFace.StencilFunc; | ||
| 383 | BackFace.StencilFailOp = o.BackFace.StencilFailOp; | ||
| 384 | BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp; | ||
| 385 | BackFace.StencilPassOp = o.BackFace.StencilPassOp; | ||
| 386 | BackFace.StencilFunc = o.BackFace.StencilFunc; | ||
| 387 | DepthBoundsTestEnable = FALSE; | ||
| 388 | } | ||
| 389 | explicit CD3DX12_DEPTH_STENCIL_DESC1( CD3DX12_DEFAULT ) noexcept | ||
| 390 | { | ||
| 391 | DepthEnable = TRUE; | ||
| 392 | DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; | ||
| 393 | DepthFunc = D3D12_COMPARISON_FUNC_LESS; | ||
| 394 | StencilEnable = FALSE; | ||
| 395 | StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; | ||
| 396 | StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; | ||
| 397 | const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = | ||
| 398 | { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; | ||
| 399 | FrontFace = defaultStencilOp; | ||
| 400 | BackFace = defaultStencilOp; | ||
| 401 | DepthBoundsTestEnable = FALSE; | ||
| 402 | } | ||
| 403 | explicit CD3DX12_DEPTH_STENCIL_DESC1( | ||
| 404 | BOOL depthEnable, | ||
| 405 | D3D12_DEPTH_WRITE_MASK depthWriteMask, | ||
| 406 | D3D12_COMPARISON_FUNC depthFunc, | ||
| 407 | BOOL stencilEnable, | ||
| 408 | UINT8 stencilReadMask, | ||
| 409 | UINT8 stencilWriteMask, | ||
| 410 | D3D12_STENCIL_OP frontStencilFailOp, | ||
| 411 | D3D12_STENCIL_OP frontStencilDepthFailOp, | ||
| 412 | D3D12_STENCIL_OP frontStencilPassOp, | ||
| 413 | D3D12_COMPARISON_FUNC frontStencilFunc, | ||
| 414 | D3D12_STENCIL_OP backStencilFailOp, | ||
| 415 | D3D12_STENCIL_OP backStencilDepthFailOp, | ||
| 416 | D3D12_STENCIL_OP backStencilPassOp, | ||
| 417 | D3D12_COMPARISON_FUNC backStencilFunc, | ||
| 418 | BOOL depthBoundsTestEnable ) noexcept | ||
| 419 | { | ||
| 420 | DepthEnable = depthEnable; | ||
| 421 | DepthWriteMask = depthWriteMask; | ||
| 422 | DepthFunc = depthFunc; | ||
| 423 | StencilEnable = stencilEnable; | ||
| 424 | StencilReadMask = stencilReadMask; | ||
| 425 | StencilWriteMask = stencilWriteMask; | ||
| 426 | FrontFace.StencilFailOp = frontStencilFailOp; | ||
| 427 | FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; | ||
| 428 | FrontFace.StencilPassOp = frontStencilPassOp; | ||
| 429 | FrontFace.StencilFunc = frontStencilFunc; | ||
| 430 | BackFace.StencilFailOp = backStencilFailOp; | ||
| 431 | BackFace.StencilDepthFailOp = backStencilDepthFailOp; | ||
| 432 | BackFace.StencilPassOp = backStencilPassOp; | ||
| 433 | BackFace.StencilFunc = backStencilFunc; | ||
| 434 | DepthBoundsTestEnable = depthBoundsTestEnable; | ||
| 435 | } | ||
| 436 | operator D3D12_DEPTH_STENCIL_DESC() const noexcept | ||
| 437 | { | ||
| 438 | D3D12_DEPTH_STENCIL_DESC D; | ||
| 439 | D.DepthEnable = DepthEnable; | ||
| 440 | D.DepthWriteMask = DepthWriteMask; | ||
| 441 | D.DepthFunc = DepthFunc; | ||
| 442 | D.StencilEnable = StencilEnable; | ||
| 443 | D.StencilReadMask = StencilReadMask; | ||
| 444 | D.StencilWriteMask = StencilWriteMask; | ||
| 445 | D.FrontFace.StencilFailOp = FrontFace.StencilFailOp; | ||
| 446 | D.FrontFace.StencilDepthFailOp = FrontFace.StencilDepthFailOp; | ||
| 447 | D.FrontFace.StencilPassOp = FrontFace.StencilPassOp; | ||
| 448 | D.FrontFace.StencilFunc = FrontFace.StencilFunc; | ||
| 449 | D.BackFace.StencilFailOp = BackFace.StencilFailOp; | ||
| 450 | D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp; | ||
| 451 | D.BackFace.StencilPassOp = BackFace.StencilPassOp; | ||
| 452 | D.BackFace.StencilFunc = BackFace.StencilFunc; | ||
| 453 | return D; | ||
| 454 | } | ||
| 455 | }; | ||
| 456 | |||
| 457 | //------------------------------------------------------------------------------------------------ | ||
| 458 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 459 | struct CD3DX12_DEPTH_STENCIL_DESC2 : public D3D12_DEPTH_STENCIL_DESC2 | ||
| 460 | { | ||
| 461 | CD3DX12_DEPTH_STENCIL_DESC2() = default; | ||
| 462 | explicit CD3DX12_DEPTH_STENCIL_DESC2( const D3D12_DEPTH_STENCIL_DESC2& o ) noexcept : | ||
| 463 | D3D12_DEPTH_STENCIL_DESC2( o ) | ||
| 464 | {} | ||
| 465 | explicit CD3DX12_DEPTH_STENCIL_DESC2( const D3D12_DEPTH_STENCIL_DESC1& o ) noexcept | ||
| 466 | { | ||
| 467 | DepthEnable = o.DepthEnable; | ||
| 468 | DepthWriteMask = o.DepthWriteMask; | ||
| 469 | DepthFunc = o.DepthFunc; | ||
| 470 | StencilEnable = o.StencilEnable; | ||
| 471 | FrontFace.StencilFailOp = o.FrontFace.StencilFailOp; | ||
| 472 | FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp; | ||
| 473 | FrontFace.StencilPassOp = o.FrontFace.StencilPassOp; | ||
| 474 | FrontFace.StencilFunc = o.FrontFace.StencilFunc; | ||
| 475 | FrontFace.StencilReadMask = o.StencilReadMask; | ||
| 476 | FrontFace.StencilWriteMask = o.StencilWriteMask; | ||
| 477 | |||
| 478 | BackFace.StencilFailOp = o.BackFace.StencilFailOp; | ||
| 479 | BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp; | ||
| 480 | BackFace.StencilPassOp = o.BackFace.StencilPassOp; | ||
| 481 | BackFace.StencilFunc = o.BackFace.StencilFunc; | ||
| 482 | BackFace.StencilReadMask = o.StencilReadMask; | ||
| 483 | BackFace.StencilWriteMask = o.StencilWriteMask; | ||
| 484 | DepthBoundsTestEnable = o.DepthBoundsTestEnable; | ||
| 485 | } | ||
| 486 | explicit CD3DX12_DEPTH_STENCIL_DESC2( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept | ||
| 487 | { | ||
| 488 | DepthEnable = o.DepthEnable; | ||
| 489 | DepthWriteMask = o.DepthWriteMask; | ||
| 490 | DepthFunc = o.DepthFunc; | ||
| 491 | StencilEnable = o.StencilEnable; | ||
| 492 | |||
| 493 | FrontFace.StencilFailOp = o.FrontFace.StencilFailOp; | ||
| 494 | FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp; | ||
| 495 | FrontFace.StencilPassOp = o.FrontFace.StencilPassOp; | ||
| 496 | FrontFace.StencilFunc = o.FrontFace.StencilFunc; | ||
| 497 | FrontFace.StencilReadMask = o.StencilReadMask; | ||
| 498 | FrontFace.StencilWriteMask = o.StencilWriteMask; | ||
| 499 | |||
| 500 | BackFace.StencilFailOp = o.BackFace.StencilFailOp; | ||
| 501 | BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp; | ||
| 502 | BackFace.StencilPassOp = o.BackFace.StencilPassOp; | ||
| 503 | BackFace.StencilFunc = o.BackFace.StencilFunc; | ||
| 504 | BackFace.StencilReadMask = o.StencilReadMask; | ||
| 505 | BackFace.StencilWriteMask = o.StencilWriteMask; | ||
| 506 | |||
| 507 | DepthBoundsTestEnable = FALSE; | ||
| 508 | } | ||
| 509 | explicit CD3DX12_DEPTH_STENCIL_DESC2( CD3DX12_DEFAULT ) noexcept | ||
| 510 | { | ||
| 511 | DepthEnable = TRUE; | ||
| 512 | DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; | ||
| 513 | DepthFunc = D3D12_COMPARISON_FUNC_LESS; | ||
| 514 | StencilEnable = FALSE; | ||
| 515 | const D3D12_DEPTH_STENCILOP_DESC1 defaultStencilOp = | ||
| 516 | { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS, D3D12_DEFAULT_STENCIL_READ_MASK, D3D12_DEFAULT_STENCIL_WRITE_MASK }; | ||
| 517 | FrontFace = defaultStencilOp; | ||
| 518 | BackFace = defaultStencilOp; | ||
| 519 | DepthBoundsTestEnable = FALSE; | ||
| 520 | } | ||
| 521 | explicit CD3DX12_DEPTH_STENCIL_DESC2( | ||
| 522 | BOOL depthEnable, | ||
| 523 | D3D12_DEPTH_WRITE_MASK depthWriteMask, | ||
| 524 | D3D12_COMPARISON_FUNC depthFunc, | ||
| 525 | BOOL stencilEnable, | ||
| 526 | D3D12_STENCIL_OP frontStencilFailOp, | ||
| 527 | D3D12_STENCIL_OP frontStencilDepthFailOp, | ||
| 528 | D3D12_STENCIL_OP frontStencilPassOp, | ||
| 529 | D3D12_COMPARISON_FUNC frontStencilFunc, | ||
| 530 | UINT8 frontStencilReadMask, | ||
| 531 | UINT8 frontStencilWriteMask, | ||
| 532 | D3D12_STENCIL_OP backStencilFailOp, | ||
| 533 | D3D12_STENCIL_OP backStencilDepthFailOp, | ||
| 534 | D3D12_STENCIL_OP backStencilPassOp, | ||
| 535 | D3D12_COMPARISON_FUNC backStencilFunc, | ||
| 536 | UINT8 backStencilReadMask, | ||
| 537 | UINT8 backStencilWriteMask, | ||
| 538 | BOOL depthBoundsTestEnable ) noexcept | ||
| 539 | { | ||
| 540 | DepthEnable = depthEnable; | ||
| 541 | DepthWriteMask = depthWriteMask; | ||
| 542 | DepthFunc = depthFunc; | ||
| 543 | StencilEnable = stencilEnable; | ||
| 544 | |||
| 545 | FrontFace.StencilFailOp = frontStencilFailOp; | ||
| 546 | FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; | ||
| 547 | FrontFace.StencilPassOp = frontStencilPassOp; | ||
| 548 | FrontFace.StencilFunc = frontStencilFunc; | ||
| 549 | FrontFace.StencilReadMask = frontStencilReadMask; | ||
| 550 | FrontFace.StencilWriteMask = frontStencilWriteMask; | ||
| 551 | |||
| 552 | BackFace.StencilFailOp = backStencilFailOp; | ||
| 553 | BackFace.StencilDepthFailOp = backStencilDepthFailOp; | ||
| 554 | BackFace.StencilPassOp = backStencilPassOp; | ||
| 555 | BackFace.StencilFunc = backStencilFunc; | ||
| 556 | BackFace.StencilReadMask = backStencilReadMask; | ||
| 557 | BackFace.StencilWriteMask = backStencilWriteMask; | ||
| 558 | |||
| 559 | DepthBoundsTestEnable = depthBoundsTestEnable; | ||
| 560 | } | ||
| 561 | |||
| 562 | operator D3D12_DEPTH_STENCIL_DESC() const noexcept | ||
| 563 | { | ||
| 564 | D3D12_DEPTH_STENCIL_DESC D; | ||
| 565 | D.DepthEnable = DepthEnable; | ||
| 566 | D.DepthWriteMask = DepthWriteMask; | ||
| 567 | D.DepthFunc = DepthFunc; | ||
| 568 | D.StencilEnable = StencilEnable; | ||
| 569 | D.StencilReadMask = FrontFace.StencilReadMask; | ||
| 570 | D.StencilWriteMask = FrontFace.StencilWriteMask; | ||
| 571 | D.FrontFace.StencilFailOp = FrontFace.StencilFailOp; | ||
| 572 | D.FrontFace.StencilDepthFailOp = FrontFace.StencilDepthFailOp; | ||
| 573 | D.FrontFace.StencilPassOp = FrontFace.StencilPassOp; | ||
| 574 | D.FrontFace.StencilFunc = FrontFace.StencilFunc; | ||
| 575 | D.BackFace.StencilFailOp = BackFace.StencilFailOp; | ||
| 576 | D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp; | ||
| 577 | D.BackFace.StencilPassOp = BackFace.StencilPassOp; | ||
| 578 | D.BackFace.StencilFunc = BackFace.StencilFunc; | ||
| 579 | return D; | ||
| 580 | } | ||
| 581 | }; | ||
| 582 | #endif // D3D12_SDK_VERSION >= 606 | ||
| 583 | |||
| 584 | //------------------------------------------------------------------------------------------------ | ||
| 585 | struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC | ||
| 586 | { | ||
| 587 | CD3DX12_BLEND_DESC() = default; | ||
| 588 | explicit CD3DX12_BLEND_DESC( const D3D12_BLEND_DESC& o ) noexcept : | ||
| 589 | D3D12_BLEND_DESC( o ) | ||
| 590 | {} | ||
| 591 | explicit CD3DX12_BLEND_DESC( CD3DX12_DEFAULT ) noexcept | ||
| 592 | { | ||
| 593 | AlphaToCoverageEnable = FALSE; | ||
| 594 | IndependentBlendEnable = FALSE; | ||
| 595 | const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = | ||
| 596 | { | ||
| 597 | FALSE,FALSE, | ||
| 598 | D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, | ||
| 599 | D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, | ||
| 600 | D3D12_LOGIC_OP_NOOP, | ||
| 601 | D3D12_COLOR_WRITE_ENABLE_ALL, | ||
| 602 | }; | ||
| 603 | for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) | ||
| 604 | RenderTarget[ i ] = defaultRenderTargetBlendDesc; | ||
| 605 | } | ||
| 606 | }; | ||
| 607 | |||
| 608 | //------------------------------------------------------------------------------------------------ | ||
| 609 | struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC | ||
| 610 | { | ||
| 611 | CD3DX12_RASTERIZER_DESC() = default; | ||
| 612 | explicit CD3DX12_RASTERIZER_DESC( const D3D12_RASTERIZER_DESC& o ) noexcept : | ||
| 613 | D3D12_RASTERIZER_DESC( o ) | ||
| 614 | {} | ||
| 615 | explicit CD3DX12_RASTERIZER_DESC( CD3DX12_DEFAULT ) noexcept | ||
| 616 | { | ||
| 617 | FillMode = D3D12_FILL_MODE_SOLID; | ||
| 618 | CullMode = D3D12_CULL_MODE_BACK; | ||
| 619 | FrontCounterClockwise = FALSE; | ||
| 620 | DepthBias = D3D12_DEFAULT_DEPTH_BIAS; | ||
| 621 | DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; | ||
| 622 | SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; | ||
| 623 | DepthClipEnable = TRUE; | ||
| 624 | MultisampleEnable = FALSE; | ||
| 625 | AntialiasedLineEnable = FALSE; | ||
| 626 | ForcedSampleCount = 0; | ||
| 627 | ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; | ||
| 628 | } | ||
| 629 | explicit CD3DX12_RASTERIZER_DESC( | ||
| 630 | D3D12_FILL_MODE fillMode, | ||
| 631 | D3D12_CULL_MODE cullMode, | ||
| 632 | BOOL frontCounterClockwise, | ||
| 633 | INT depthBias, | ||
| 634 | FLOAT depthBiasClamp, | ||
| 635 | FLOAT slopeScaledDepthBias, | ||
| 636 | BOOL depthClipEnable, | ||
| 637 | BOOL multisampleEnable, | ||
| 638 | BOOL antialiasedLineEnable, | ||
| 639 | UINT forcedSampleCount, | ||
| 640 | D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) noexcept | ||
| 641 | { | ||
| 642 | FillMode = fillMode; | ||
| 643 | CullMode = cullMode; | ||
| 644 | FrontCounterClockwise = frontCounterClockwise; | ||
| 645 | DepthBias = depthBias; | ||
| 646 | DepthBiasClamp = depthBiasClamp; | ||
| 647 | SlopeScaledDepthBias = slopeScaledDepthBias; | ||
| 648 | DepthClipEnable = depthClipEnable; | ||
| 649 | MultisampleEnable = multisampleEnable; | ||
| 650 | AntialiasedLineEnable = antialiasedLineEnable; | ||
| 651 | ForcedSampleCount = forcedSampleCount; | ||
| 652 | ConservativeRaster = conservativeRaster; | ||
| 653 | } | ||
| 654 | }; | ||
| 655 | |||
| 656 | |||
| 657 | //------------------------------------------------------------------------------------------------ | ||
| 658 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 659 | struct CD3DX12_RASTERIZER_DESC1 : public D3D12_RASTERIZER_DESC1 | ||
| 660 | { | ||
| 661 | CD3DX12_RASTERIZER_DESC1() = default; | ||
| 662 | explicit CD3DX12_RASTERIZER_DESC1(const D3D12_RASTERIZER_DESC1& o) noexcept : | ||
| 663 | D3D12_RASTERIZER_DESC1(o) | ||
| 664 | |||
| 665 | { | ||
| 666 | } | ||
| 667 | explicit CD3DX12_RASTERIZER_DESC1(const D3D12_RASTERIZER_DESC& o) noexcept | ||
| 668 | { | ||
| 669 | FillMode = o.FillMode; | ||
| 670 | CullMode = o.CullMode; | ||
| 671 | FrontCounterClockwise = o.FrontCounterClockwise; | ||
| 672 | DepthBias = static_cast<FLOAT>(o.DepthBias); | ||
| 673 | DepthBiasClamp = o.DepthBiasClamp; | ||
| 674 | SlopeScaledDepthBias = o.SlopeScaledDepthBias; | ||
| 675 | DepthClipEnable = o.DepthClipEnable; | ||
| 676 | MultisampleEnable = o.MultisampleEnable; | ||
| 677 | AntialiasedLineEnable = o.AntialiasedLineEnable; | ||
| 678 | ForcedSampleCount = o.ForcedSampleCount; | ||
| 679 | ConservativeRaster = o.ConservativeRaster; | ||
| 680 | } | ||
| 681 | explicit CD3DX12_RASTERIZER_DESC1(CD3DX12_DEFAULT) noexcept | ||
| 682 | { | ||
| 683 | FillMode = D3D12_FILL_MODE_SOLID; | ||
| 684 | CullMode = D3D12_CULL_MODE_BACK; | ||
| 685 | FrontCounterClockwise = FALSE; | ||
| 686 | DepthBias = D3D12_DEFAULT_DEPTH_BIAS; | ||
| 687 | DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; | ||
| 688 | SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; | ||
| 689 | DepthClipEnable = TRUE; | ||
| 690 | MultisampleEnable = FALSE; | ||
| 691 | AntialiasedLineEnable = FALSE; | ||
| 692 | ForcedSampleCount = 0; | ||
| 693 | ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; | ||
| 694 | } | ||
| 695 | explicit CD3DX12_RASTERIZER_DESC1( | ||
| 696 | D3D12_FILL_MODE fillMode, | ||
| 697 | D3D12_CULL_MODE cullMode, | ||
| 698 | BOOL frontCounterClockwise, | ||
| 699 | FLOAT depthBias, | ||
| 700 | FLOAT depthBiasClamp, | ||
| 701 | FLOAT slopeScaledDepthBias, | ||
| 702 | BOOL depthClipEnable, | ||
| 703 | BOOL multisampleEnable, | ||
| 704 | BOOL antialiasedLineEnable, | ||
| 705 | UINT forcedSampleCount, | ||
| 706 | D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) noexcept | ||
| 707 | { | ||
| 708 | FillMode = fillMode; | ||
| 709 | CullMode = cullMode; | ||
| 710 | FrontCounterClockwise = frontCounterClockwise; | ||
| 711 | DepthBias = depthBias; | ||
| 712 | DepthBiasClamp = depthBiasClamp; | ||
| 713 | SlopeScaledDepthBias = slopeScaledDepthBias; | ||
| 714 | DepthClipEnable = depthClipEnable; | ||
| 715 | MultisampleEnable = multisampleEnable; | ||
| 716 | AntialiasedLineEnable = antialiasedLineEnable; | ||
| 717 | ForcedSampleCount = forcedSampleCount; | ||
| 718 | ConservativeRaster = conservativeRaster; | ||
| 719 | } | ||
| 720 | |||
| 721 | |||
| 722 | operator D3D12_RASTERIZER_DESC() const noexcept | ||
| 723 | { | ||
| 724 | D3D12_RASTERIZER_DESC o; | ||
| 725 | |||
| 726 | o.FillMode = FillMode; | ||
| 727 | o.CullMode = CullMode; | ||
| 728 | o.FrontCounterClockwise = FrontCounterClockwise; | ||
| 729 | o.DepthBias = static_cast<INT>(DepthBias); | ||
| 730 | o.DepthBiasClamp = DepthBiasClamp; | ||
| 731 | o.SlopeScaledDepthBias = SlopeScaledDepthBias; | ||
| 732 | o.DepthClipEnable = DepthClipEnable; | ||
| 733 | o.MultisampleEnable = MultisampleEnable; | ||
| 734 | o.AntialiasedLineEnable = AntialiasedLineEnable; | ||
| 735 | o.ForcedSampleCount = ForcedSampleCount; | ||
| 736 | o.ConservativeRaster = ConservativeRaster; | ||
| 737 | |||
| 738 | return o; | ||
| 739 | } | ||
| 740 | }; | ||
| 741 | #endif // D3D12_SDK_VERSION >= 608 | ||
| 742 | |||
| 743 | //------------------------------------------------------------------------------------------------ | ||
| 744 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 745 | struct CD3DX12_RASTERIZER_DESC2 : public D3D12_RASTERIZER_DESC2 | ||
| 746 | { | ||
| 747 | CD3DX12_RASTERIZER_DESC2() = default; | ||
| 748 | explicit CD3DX12_RASTERIZER_DESC2(const D3D12_RASTERIZER_DESC2& o) noexcept : | ||
| 749 | D3D12_RASTERIZER_DESC2(o) | ||
| 750 | |||
| 751 | { | ||
| 752 | } | ||
| 753 | explicit CD3DX12_RASTERIZER_DESC2(const D3D12_RASTERIZER_DESC1& o) noexcept | ||
| 754 | { | ||
| 755 | FillMode = o.FillMode; | ||
| 756 | CullMode = o.CullMode; | ||
| 757 | FrontCounterClockwise = o.FrontCounterClockwise; | ||
| 758 | DepthBias = o.DepthBias; | ||
| 759 | DepthBiasClamp = o.DepthBiasClamp; | ||
| 760 | SlopeScaledDepthBias = o.SlopeScaledDepthBias; | ||
| 761 | DepthClipEnable = o.DepthClipEnable; | ||
| 762 | LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_ALIASED; | ||
| 763 | if (o.MultisampleEnable) | ||
| 764 | { | ||
| 765 | LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_QUADRILATERAL_WIDE; | ||
| 766 | } | ||
| 767 | else if (o.AntialiasedLineEnable) | ||
| 768 | { | ||
| 769 | LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_ALPHA_ANTIALIASED; | ||
| 770 | } | ||
| 771 | ForcedSampleCount = o.ForcedSampleCount; | ||
| 772 | ConservativeRaster = o.ConservativeRaster; | ||
| 773 | } | ||
| 774 | explicit CD3DX12_RASTERIZER_DESC2(const D3D12_RASTERIZER_DESC& o) noexcept | ||
| 775 | : CD3DX12_RASTERIZER_DESC2(CD3DX12_RASTERIZER_DESC1(o)) | ||
| 776 | { | ||
| 777 | } | ||
| 778 | explicit CD3DX12_RASTERIZER_DESC2(CD3DX12_DEFAULT) noexcept | ||
| 779 | { | ||
| 780 | FillMode = D3D12_FILL_MODE_SOLID; | ||
| 781 | CullMode = D3D12_CULL_MODE_BACK; | ||
| 782 | FrontCounterClockwise = FALSE; | ||
| 783 | DepthBias = D3D12_DEFAULT_DEPTH_BIAS; | ||
| 784 | DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; | ||
| 785 | SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; | ||
| 786 | DepthClipEnable = TRUE; | ||
| 787 | LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_ALIASED; | ||
| 788 | ForcedSampleCount = 0; | ||
| 789 | ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; | ||
| 790 | } | ||
| 791 | explicit CD3DX12_RASTERIZER_DESC2( | ||
| 792 | D3D12_FILL_MODE fillMode, | ||
| 793 | D3D12_CULL_MODE cullMode, | ||
| 794 | BOOL frontCounterClockwise, | ||
| 795 | FLOAT depthBias, | ||
| 796 | FLOAT depthBiasClamp, | ||
| 797 | FLOAT slopeScaledDepthBias, | ||
| 798 | BOOL depthClipEnable, | ||
| 799 | D3D12_LINE_RASTERIZATION_MODE lineRasterizationMode, | ||
| 800 | UINT forcedSampleCount, | ||
| 801 | D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) noexcept | ||
| 802 | { | ||
| 803 | FillMode = fillMode; | ||
| 804 | CullMode = cullMode; | ||
| 805 | FrontCounterClockwise = frontCounterClockwise; | ||
| 806 | DepthBias = depthBias; | ||
| 807 | DepthBiasClamp = depthBiasClamp; | ||
| 808 | SlopeScaledDepthBias = slopeScaledDepthBias; | ||
| 809 | DepthClipEnable = depthClipEnable; | ||
| 810 | LineRasterizationMode = lineRasterizationMode; | ||
| 811 | ForcedSampleCount = forcedSampleCount; | ||
| 812 | ConservativeRaster = conservativeRaster; | ||
| 813 | } | ||
| 814 | |||
| 815 | |||
| 816 | operator D3D12_RASTERIZER_DESC1() const noexcept | ||
| 817 | { | ||
| 818 | D3D12_RASTERIZER_DESC1 o; | ||
| 819 | |||
| 820 | o.FillMode = FillMode; | ||
| 821 | o.CullMode = CullMode; | ||
| 822 | o.FrontCounterClockwise = FrontCounterClockwise; | ||
| 823 | o.DepthBias = DepthBias; | ||
| 824 | o.DepthBiasClamp = DepthBiasClamp; | ||
| 825 | o.SlopeScaledDepthBias = SlopeScaledDepthBias; | ||
| 826 | o.DepthClipEnable = DepthClipEnable; | ||
| 827 | o.MultisampleEnable = FALSE; | ||
| 828 | o.AntialiasedLineEnable = FALSE; | ||
| 829 | if (LineRasterizationMode == D3D12_LINE_RASTERIZATION_MODE_ALPHA_ANTIALIASED) | ||
| 830 | { | ||
| 831 | o.AntialiasedLineEnable = TRUE; | ||
| 832 | } | ||
| 833 | else if (LineRasterizationMode != D3D12_LINE_RASTERIZATION_MODE_ALIASED) | ||
| 834 | { | ||
| 835 | o.MultisampleEnable = TRUE; | ||
| 836 | } | ||
| 837 | o.ForcedSampleCount = ForcedSampleCount; | ||
| 838 | o.ConservativeRaster = ConservativeRaster; | ||
| 839 | |||
| 840 | return o; | ||
| 841 | } | ||
| 842 | operator D3D12_RASTERIZER_DESC() const noexcept | ||
| 843 | { | ||
| 844 | return static_cast<D3D12_RASTERIZER_DESC>(CD3DX12_RASTERIZER_DESC1(static_cast<D3D12_RASTERIZER_DESC1>(*this))); | ||
| 845 | } | ||
| 846 | }; | ||
| 847 | #endif // D3D12_SDK_VERSION >= 610 | ||
| 848 | |||
| 849 | //------------------------------------------------------------------------------------------------ | ||
| 850 | struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO | ||
| 851 | { | ||
| 852 | CD3DX12_RESOURCE_ALLOCATION_INFO() = default; | ||
| 853 | explicit CD3DX12_RESOURCE_ALLOCATION_INFO( const D3D12_RESOURCE_ALLOCATION_INFO& o ) noexcept : | ||
| 854 | D3D12_RESOURCE_ALLOCATION_INFO( o ) | ||
| 855 | {} | ||
| 856 | CD3DX12_RESOURCE_ALLOCATION_INFO( | ||
| 857 | UINT64 size, | ||
| 858 | UINT64 alignment ) noexcept | ||
| 859 | { | ||
| 860 | SizeInBytes = size; | ||
| 861 | Alignment = alignment; | ||
| 862 | } | ||
| 863 | }; | ||
| 864 | |||
| 865 | //------------------------------------------------------------------------------------------------ | ||
| 866 | struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES | ||
| 867 | { | ||
| 868 | CD3DX12_HEAP_PROPERTIES() = default; | ||
| 869 | explicit CD3DX12_HEAP_PROPERTIES(const D3D12_HEAP_PROPERTIES &o) noexcept : | ||
| 870 | D3D12_HEAP_PROPERTIES(o) | ||
| 871 | {} | ||
| 872 | CD3DX12_HEAP_PROPERTIES( | ||
| 873 | D3D12_CPU_PAGE_PROPERTY cpuPageProperty, | ||
| 874 | D3D12_MEMORY_POOL memoryPoolPreference, | ||
| 875 | UINT creationNodeMask = 1, | ||
| 876 | UINT nodeMask = 1 ) noexcept | ||
| 877 | { | ||
| 878 | Type = D3D12_HEAP_TYPE_CUSTOM; | ||
| 879 | CPUPageProperty = cpuPageProperty; | ||
| 880 | MemoryPoolPreference = memoryPoolPreference; | ||
| 881 | CreationNodeMask = creationNodeMask; | ||
| 882 | VisibleNodeMask = nodeMask; | ||
| 883 | } | ||
| 884 | explicit CD3DX12_HEAP_PROPERTIES( | ||
| 885 | D3D12_HEAP_TYPE type, | ||
| 886 | UINT creationNodeMask = 1, | ||
| 887 | UINT nodeMask = 1 ) noexcept | ||
| 888 | { | ||
| 889 | Type = type; | ||
| 890 | CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; | ||
| 891 | MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; | ||
| 892 | CreationNodeMask = creationNodeMask; | ||
| 893 | VisibleNodeMask = nodeMask; | ||
| 894 | } | ||
| 895 | bool IsCPUAccessible() const noexcept | ||
| 896 | { | ||
| 897 | return Type == D3D12_HEAP_TYPE_UPLOAD || Type == D3D12_HEAP_TYPE_READBACK | ||
| 898 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 899 | || Type == D3D12_HEAP_TYPE_GPU_UPLOAD | ||
| 900 | #endif | ||
| 901 | || (Type == D3D12_HEAP_TYPE_CUSTOM && | ||
| 902 | (CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE || CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_BACK)); | ||
| 903 | } | ||
| 904 | }; | ||
| 905 | inline bool operator==( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept | ||
| 906 | { | ||
| 907 | return l.Type == r.Type && l.CPUPageProperty == r.CPUPageProperty && | ||
| 908 | l.MemoryPoolPreference == r.MemoryPoolPreference && | ||
| 909 | l.CreationNodeMask == r.CreationNodeMask && | ||
| 910 | l.VisibleNodeMask == r.VisibleNodeMask; | ||
| 911 | } | ||
| 912 | inline bool operator!=( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept | ||
| 913 | { return !( l == r ); } | ||
| 914 | |||
| 915 | //------------------------------------------------------------------------------------------------ | ||
| 916 | struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC | ||
| 917 | { | ||
| 918 | CD3DX12_HEAP_DESC() = default; | ||
| 919 | explicit CD3DX12_HEAP_DESC(const D3D12_HEAP_DESC &o) noexcept : | ||
| 920 | D3D12_HEAP_DESC(o) | ||
| 921 | {} | ||
| 922 | CD3DX12_HEAP_DESC( | ||
| 923 | UINT64 size, | ||
| 924 | D3D12_HEAP_PROPERTIES properties, | ||
| 925 | UINT64 alignment = 0, | ||
| 926 | D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept | ||
| 927 | { | ||
| 928 | SizeInBytes = size; | ||
| 929 | Properties = properties; | ||
| 930 | Alignment = alignment; | ||
| 931 | Flags = flags; | ||
| 932 | } | ||
| 933 | CD3DX12_HEAP_DESC( | ||
| 934 | UINT64 size, | ||
| 935 | D3D12_HEAP_TYPE type, | ||
| 936 | UINT64 alignment = 0, | ||
| 937 | D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept | ||
| 938 | { | ||
| 939 | SizeInBytes = size; | ||
| 940 | Properties = CD3DX12_HEAP_PROPERTIES( type ); | ||
| 941 | Alignment = alignment; | ||
| 942 | Flags = flags; | ||
| 943 | } | ||
| 944 | CD3DX12_HEAP_DESC( | ||
| 945 | UINT64 size, | ||
| 946 | D3D12_CPU_PAGE_PROPERTY cpuPageProperty, | ||
| 947 | D3D12_MEMORY_POOL memoryPoolPreference, | ||
| 948 | UINT64 alignment = 0, | ||
| 949 | D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept | ||
| 950 | { | ||
| 951 | SizeInBytes = size; | ||
| 952 | Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); | ||
| 953 | Alignment = alignment; | ||
| 954 | Flags = flags; | ||
| 955 | } | ||
| 956 | CD3DX12_HEAP_DESC( | ||
| 957 | const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, | ||
| 958 | D3D12_HEAP_PROPERTIES properties, | ||
| 959 | D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept | ||
| 960 | { | ||
| 961 | SizeInBytes = resAllocInfo.SizeInBytes; | ||
| 962 | Properties = properties; | ||
| 963 | Alignment = resAllocInfo.Alignment; | ||
| 964 | Flags = flags; | ||
| 965 | } | ||
| 966 | CD3DX12_HEAP_DESC( | ||
| 967 | const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, | ||
| 968 | D3D12_HEAP_TYPE type, | ||
| 969 | D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept | ||
| 970 | { | ||
| 971 | SizeInBytes = resAllocInfo.SizeInBytes; | ||
| 972 | Properties = CD3DX12_HEAP_PROPERTIES( type ); | ||
| 973 | Alignment = resAllocInfo.Alignment; | ||
| 974 | Flags = flags; | ||
| 975 | } | ||
| 976 | CD3DX12_HEAP_DESC( | ||
| 977 | const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, | ||
| 978 | D3D12_CPU_PAGE_PROPERTY cpuPageProperty, | ||
| 979 | D3D12_MEMORY_POOL memoryPoolPreference, | ||
| 980 | D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept | ||
| 981 | { | ||
| 982 | SizeInBytes = resAllocInfo.SizeInBytes; | ||
| 983 | Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); | ||
| 984 | Alignment = resAllocInfo.Alignment; | ||
| 985 | Flags = flags; | ||
| 986 | } | ||
| 987 | bool IsCPUAccessible() const noexcept | ||
| 988 | { return static_cast< const CD3DX12_HEAP_PROPERTIES* >( &Properties )->IsCPUAccessible(); } | ||
| 989 | }; | ||
| 990 | inline bool operator==( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept | ||
| 991 | { | ||
| 992 | return l.SizeInBytes == r.SizeInBytes && | ||
| 993 | l.Properties == r.Properties && | ||
| 994 | l.Alignment == r.Alignment && | ||
| 995 | l.Flags == r.Flags; | ||
| 996 | } | ||
| 997 | inline bool operator!=( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept | ||
| 998 | { return !( l == r ); } | ||
| 999 | |||
| 1000 | //------------------------------------------------------------------------------------------------ | ||
| 1001 | struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE | ||
| 1002 | { | ||
| 1003 | CD3DX12_CLEAR_VALUE() = default; | ||
| 1004 | explicit CD3DX12_CLEAR_VALUE(const D3D12_CLEAR_VALUE &o) noexcept : | ||
| 1005 | D3D12_CLEAR_VALUE(o) | ||
| 1006 | {} | ||
| 1007 | CD3DX12_CLEAR_VALUE( | ||
| 1008 | DXGI_FORMAT format, | ||
| 1009 | const FLOAT color[4] ) noexcept | ||
| 1010 | { | ||
| 1011 | Format = format; | ||
| 1012 | memcpy( Color, color, sizeof( Color ) ); | ||
| 1013 | } | ||
| 1014 | CD3DX12_CLEAR_VALUE( | ||
| 1015 | DXGI_FORMAT format, | ||
| 1016 | FLOAT depth, | ||
| 1017 | UINT8 stencil ) noexcept | ||
| 1018 | { | ||
| 1019 | Format = format; | ||
| 1020 | memset( &Color, 0, sizeof( Color ) ); | ||
| 1021 | /* Use memcpy to preserve NAN values */ | ||
| 1022 | memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) ); | ||
| 1023 | DepthStencil.Stencil = stencil; | ||
| 1024 | } | ||
| 1025 | }; | ||
| 1026 | |||
| 1027 | //------------------------------------------------------------------------------------------------ | ||
| 1028 | inline bool operator==( const D3D12_CLEAR_VALUE &a, const D3D12_CLEAR_VALUE &b) noexcept | ||
| 1029 | { | ||
| 1030 | if (a.Format != b.Format) return false; | ||
| 1031 | if (a.Format == DXGI_FORMAT_D24_UNORM_S8_UINT | ||
| 1032 | || a.Format == DXGI_FORMAT_D16_UNORM | ||
| 1033 | || a.Format == DXGI_FORMAT_D32_FLOAT | ||
| 1034 | || a.Format == DXGI_FORMAT_D32_FLOAT_S8X24_UINT) | ||
| 1035 | { | ||
| 1036 | return (a.DepthStencil.Depth == b.DepthStencil.Depth) && | ||
| 1037 | (a.DepthStencil.Stencil == b.DepthStencil.Stencil); | ||
| 1038 | } else { | ||
| 1039 | return (a.Color[0] == b.Color[0]) && | ||
| 1040 | (a.Color[1] == b.Color[1]) && | ||
| 1041 | (a.Color[2] == b.Color[2]) && | ||
| 1042 | (a.Color[3] == b.Color[3]); | ||
| 1043 | } | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | //------------------------------------------------------------------------------------------------ | ||
| 1047 | struct CD3DX12_RANGE : public D3D12_RANGE | ||
| 1048 | { | ||
| 1049 | CD3DX12_RANGE() = default; | ||
| 1050 | explicit CD3DX12_RANGE(const D3D12_RANGE &o) noexcept : | ||
| 1051 | D3D12_RANGE(o) | ||
| 1052 | {} | ||
| 1053 | CD3DX12_RANGE( | ||
| 1054 | SIZE_T begin, | ||
| 1055 | SIZE_T end ) noexcept | ||
| 1056 | { | ||
| 1057 | Begin = begin; | ||
| 1058 | End = end; | ||
| 1059 | } | ||
| 1060 | }; | ||
| 1061 | |||
| 1062 | //------------------------------------------------------------------------------------------------ | ||
| 1063 | struct CD3DX12_RANGE_UINT64 : public D3D12_RANGE_UINT64 | ||
| 1064 | { | ||
| 1065 | CD3DX12_RANGE_UINT64() = default; | ||
| 1066 | explicit CD3DX12_RANGE_UINT64(const D3D12_RANGE_UINT64 &o) noexcept : | ||
| 1067 | D3D12_RANGE_UINT64(o) | ||
| 1068 | {} | ||
| 1069 | CD3DX12_RANGE_UINT64( | ||
| 1070 | UINT64 begin, | ||
| 1071 | UINT64 end ) noexcept | ||
| 1072 | { | ||
| 1073 | Begin = begin; | ||
| 1074 | End = end; | ||
| 1075 | } | ||
| 1076 | }; | ||
| 1077 | |||
| 1078 | //------------------------------------------------------------------------------------------------ | ||
| 1079 | struct CD3DX12_SUBRESOURCE_RANGE_UINT64 : public D3D12_SUBRESOURCE_RANGE_UINT64 | ||
| 1080 | { | ||
| 1081 | CD3DX12_SUBRESOURCE_RANGE_UINT64() = default; | ||
| 1082 | explicit CD3DX12_SUBRESOURCE_RANGE_UINT64(const D3D12_SUBRESOURCE_RANGE_UINT64 &o) noexcept : | ||
| 1083 | D3D12_SUBRESOURCE_RANGE_UINT64(o) | ||
| 1084 | {} | ||
| 1085 | CD3DX12_SUBRESOURCE_RANGE_UINT64( | ||
| 1086 | UINT subresource, | ||
| 1087 | const D3D12_RANGE_UINT64& range ) noexcept | ||
| 1088 | { | ||
| 1089 | Subresource = subresource; | ||
| 1090 | Range = range; | ||
| 1091 | } | ||
| 1092 | CD3DX12_SUBRESOURCE_RANGE_UINT64( | ||
| 1093 | UINT subresource, | ||
| 1094 | UINT64 begin, | ||
| 1095 | UINT64 end ) noexcept | ||
| 1096 | { | ||
| 1097 | Subresource = subresource; | ||
| 1098 | Range.Begin = begin; | ||
| 1099 | Range.End = end; | ||
| 1100 | } | ||
| 1101 | }; | ||
| 1102 | |||
| 1103 | //------------------------------------------------------------------------------------------------ | ||
| 1104 | struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE | ||
| 1105 | { | ||
| 1106 | CD3DX12_SHADER_BYTECODE() = default; | ||
| 1107 | explicit CD3DX12_SHADER_BYTECODE(const D3D12_SHADER_BYTECODE &o) noexcept : | ||
| 1108 | D3D12_SHADER_BYTECODE(o) | ||
| 1109 | {} | ||
| 1110 | CD3DX12_SHADER_BYTECODE( | ||
| 1111 | _In_ ID3DBlob* pShaderBlob ) noexcept | ||
| 1112 | { | ||
| 1113 | pShaderBytecode = pShaderBlob->GetBufferPointer(); | ||
| 1114 | BytecodeLength = pShaderBlob->GetBufferSize(); | ||
| 1115 | } | ||
| 1116 | CD3DX12_SHADER_BYTECODE( | ||
| 1117 | const void* _pShaderBytecode, | ||
| 1118 | SIZE_T bytecodeLength ) noexcept | ||
| 1119 | { | ||
| 1120 | pShaderBytecode = _pShaderBytecode; | ||
| 1121 | BytecodeLength = bytecodeLength; | ||
| 1122 | } | ||
| 1123 | }; | ||
| 1124 | |||
| 1125 | //------------------------------------------------------------------------------------------------ | ||
| 1126 | struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINATE | ||
| 1127 | { | ||
| 1128 | CD3DX12_TILED_RESOURCE_COORDINATE() = default; | ||
| 1129 | explicit CD3DX12_TILED_RESOURCE_COORDINATE(const D3D12_TILED_RESOURCE_COORDINATE &o) noexcept : | ||
| 1130 | D3D12_TILED_RESOURCE_COORDINATE(o) | ||
| 1131 | {} | ||
| 1132 | CD3DX12_TILED_RESOURCE_COORDINATE( | ||
| 1133 | UINT x, | ||
| 1134 | UINT y, | ||
| 1135 | UINT z, | ||
| 1136 | UINT subresource ) noexcept | ||
| 1137 | { | ||
| 1138 | X = x; | ||
| 1139 | Y = y; | ||
| 1140 | Z = z; | ||
| 1141 | Subresource = subresource; | ||
| 1142 | } | ||
| 1143 | }; | ||
| 1144 | |||
| 1145 | //------------------------------------------------------------------------------------------------ | ||
| 1146 | struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE | ||
| 1147 | { | ||
| 1148 | CD3DX12_TILE_REGION_SIZE() = default; | ||
| 1149 | explicit CD3DX12_TILE_REGION_SIZE(const D3D12_TILE_REGION_SIZE &o) noexcept : | ||
| 1150 | D3D12_TILE_REGION_SIZE(o) | ||
| 1151 | {} | ||
| 1152 | CD3DX12_TILE_REGION_SIZE( | ||
| 1153 | UINT numTiles, | ||
| 1154 | BOOL useBox, | ||
| 1155 | UINT width, | ||
| 1156 | UINT16 height, | ||
| 1157 | UINT16 depth ) noexcept | ||
| 1158 | { | ||
| 1159 | NumTiles = numTiles; | ||
| 1160 | UseBox = useBox; | ||
| 1161 | Width = width; | ||
| 1162 | Height = height; | ||
| 1163 | Depth = depth; | ||
| 1164 | } | ||
| 1165 | }; | ||
| 1166 | |||
| 1167 | //------------------------------------------------------------------------------------------------ | ||
| 1168 | struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING | ||
| 1169 | { | ||
| 1170 | CD3DX12_SUBRESOURCE_TILING() = default; | ||
| 1171 | explicit CD3DX12_SUBRESOURCE_TILING(const D3D12_SUBRESOURCE_TILING &o) noexcept : | ||
| 1172 | D3D12_SUBRESOURCE_TILING(o) | ||
| 1173 | {} | ||
| 1174 | CD3DX12_SUBRESOURCE_TILING( | ||
| 1175 | UINT widthInTiles, | ||
| 1176 | UINT16 heightInTiles, | ||
| 1177 | UINT16 depthInTiles, | ||
| 1178 | UINT startTileIndexInOverallResource ) noexcept | ||
| 1179 | { | ||
| 1180 | WidthInTiles = widthInTiles; | ||
| 1181 | HeightInTiles = heightInTiles; | ||
| 1182 | DepthInTiles = depthInTiles; | ||
| 1183 | StartTileIndexInOverallResource = startTileIndexInOverallResource; | ||
| 1184 | } | ||
| 1185 | }; | ||
| 1186 | |||
| 1187 | //------------------------------------------------------------------------------------------------ | ||
| 1188 | struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE | ||
| 1189 | { | ||
| 1190 | CD3DX12_TILE_SHAPE() = default; | ||
| 1191 | explicit CD3DX12_TILE_SHAPE(const D3D12_TILE_SHAPE &o) noexcept : | ||
| 1192 | D3D12_TILE_SHAPE(o) | ||
| 1193 | {} | ||
| 1194 | CD3DX12_TILE_SHAPE( | ||
| 1195 | UINT widthInTexels, | ||
| 1196 | UINT heightInTexels, | ||
| 1197 | UINT depthInTexels ) noexcept | ||
| 1198 | { | ||
| 1199 | WidthInTexels = widthInTexels; | ||
| 1200 | HeightInTexels = heightInTexels; | ||
| 1201 | DepthInTexels = depthInTexels; | ||
| 1202 | } | ||
| 1203 | }; | ||
| 1204 | |||
| 1205 | //------------------------------------------------------------------------------------------------ | ||
| 1206 | struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO | ||
| 1207 | { | ||
| 1208 | CD3DX12_PACKED_MIP_INFO() = default; | ||
| 1209 | explicit CD3DX12_PACKED_MIP_INFO(const D3D12_PACKED_MIP_INFO &o) noexcept : | ||
| 1210 | D3D12_PACKED_MIP_INFO(o) | ||
| 1211 | {} | ||
| 1212 | CD3DX12_PACKED_MIP_INFO( | ||
| 1213 | UINT8 numStandardMips, | ||
| 1214 | UINT8 numPackedMips, | ||
| 1215 | UINT numTilesForPackedMips, | ||
| 1216 | UINT startTileIndexInOverallResource ) noexcept | ||
| 1217 | { | ||
| 1218 | NumStandardMips = numStandardMips; | ||
| 1219 | NumPackedMips = numPackedMips; | ||
| 1220 | NumTilesForPackedMips = numTilesForPackedMips; | ||
| 1221 | StartTileIndexInOverallResource = startTileIndexInOverallResource; | ||
| 1222 | } | ||
| 1223 | }; | ||
| 1224 | |||
| 1225 | //------------------------------------------------------------------------------------------------ | ||
| 1226 | struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT | ||
| 1227 | { | ||
| 1228 | CD3DX12_SUBRESOURCE_FOOTPRINT() = default; | ||
| 1229 | explicit CD3DX12_SUBRESOURCE_FOOTPRINT(const D3D12_SUBRESOURCE_FOOTPRINT &o) noexcept : | ||
| 1230 | D3D12_SUBRESOURCE_FOOTPRINT(o) | ||
| 1231 | {} | ||
| 1232 | CD3DX12_SUBRESOURCE_FOOTPRINT( | ||
| 1233 | DXGI_FORMAT format, | ||
| 1234 | UINT width, | ||
| 1235 | UINT height, | ||
| 1236 | UINT depth, | ||
| 1237 | UINT rowPitch ) noexcept | ||
| 1238 | { | ||
| 1239 | Format = format; | ||
| 1240 | Width = width; | ||
| 1241 | Height = height; | ||
| 1242 | Depth = depth; | ||
| 1243 | RowPitch = rowPitch; | ||
| 1244 | } | ||
| 1245 | explicit CD3DX12_SUBRESOURCE_FOOTPRINT( | ||
| 1246 | const D3D12_RESOURCE_DESC& resDesc, | ||
| 1247 | UINT rowPitch ) noexcept | ||
| 1248 | { | ||
| 1249 | Format = resDesc.Format; | ||
| 1250 | Width = UINT( resDesc.Width ); | ||
| 1251 | Height = resDesc.Height; | ||
| 1252 | Depth = (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc.DepthOrArraySize : 1u); | ||
| 1253 | RowPitch = rowPitch; | ||
| 1254 | } | ||
| 1255 | }; | ||
| 1256 | |||
| 1257 | //------------------------------------------------------------------------------------------------ | ||
| 1258 | struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION | ||
| 1259 | { | ||
| 1260 | CD3DX12_TEXTURE_COPY_LOCATION() = default; | ||
| 1261 | explicit CD3DX12_TEXTURE_COPY_LOCATION(const D3D12_TEXTURE_COPY_LOCATION &o) noexcept : | ||
| 1262 | D3D12_TEXTURE_COPY_LOCATION(o) | ||
| 1263 | {} | ||
| 1264 | CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes) noexcept | ||
| 1265 | { | ||
| 1266 | pResource = pRes; | ||
| 1267 | Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; | ||
| 1268 | PlacedFootprint = {}; | ||
| 1269 | } | ||
| 1270 | CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint) noexcept | ||
| 1271 | { | ||
| 1272 | pResource = pRes; | ||
| 1273 | Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; | ||
| 1274 | PlacedFootprint = Footprint; | ||
| 1275 | } | ||
| 1276 | CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, UINT Sub) noexcept | ||
| 1277 | { | ||
| 1278 | pResource = pRes; | ||
| 1279 | Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; | ||
| 1280 | PlacedFootprint = {}; | ||
| 1281 | SubresourceIndex = Sub; | ||
| 1282 | } | ||
| 1283 | }; | ||
| 1284 | |||
| 1285 | //------------------------------------------------------------------------------------------------ | ||
| 1286 | constexpr UINT D3D12CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT PlaneSlice, UINT MipLevels, UINT ArraySize ) noexcept | ||
| 1287 | { | ||
| 1288 | return MipSlice + ArraySlice * MipLevels + PlaneSlice * MipLevels * ArraySize; | ||
| 1289 | } | ||
| 1290 | |||
| 1291 | //------------------------------------------------------------------------------------------------ | ||
| 1292 | inline UINT8 D3D12GetFormatPlaneCount( | ||
| 1293 | _In_ ID3D12Device* pDevice, | ||
| 1294 | DXGI_FORMAT Format | ||
| 1295 | ) noexcept | ||
| 1296 | { | ||
| 1297 | D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = { Format, 0 }; | ||
| 1298 | if (FAILED(pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &formatInfo, sizeof(formatInfo)))) | ||
| 1299 | { | ||
| 1300 | return 0; | ||
| 1301 | } | ||
| 1302 | return formatInfo.PlaneCount; | ||
| 1303 | } | ||
| 1304 | |||
| 1305 | //------------------------------------------------------------------------------------------------ | ||
| 1306 | struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC | ||
| 1307 | { | ||
| 1308 | CD3DX12_RESOURCE_DESC() = default; | ||
| 1309 | explicit CD3DX12_RESOURCE_DESC( const D3D12_RESOURCE_DESC& o ) noexcept : | ||
| 1310 | D3D12_RESOURCE_DESC( o ) | ||
| 1311 | {} | ||
| 1312 | CD3DX12_RESOURCE_DESC( | ||
| 1313 | D3D12_RESOURCE_DIMENSION dimension, | ||
| 1314 | UINT64 alignment, | ||
| 1315 | UINT64 width, | ||
| 1316 | UINT height, | ||
| 1317 | UINT16 depthOrArraySize, | ||
| 1318 | UINT16 mipLevels, | ||
| 1319 | DXGI_FORMAT format, | ||
| 1320 | UINT sampleCount, | ||
| 1321 | UINT sampleQuality, | ||
| 1322 | D3D12_TEXTURE_LAYOUT layout, | ||
| 1323 | D3D12_RESOURCE_FLAGS flags ) noexcept | ||
| 1324 | { | ||
| 1325 | Dimension = dimension; | ||
| 1326 | Alignment = alignment; | ||
| 1327 | Width = width; | ||
| 1328 | Height = height; | ||
| 1329 | DepthOrArraySize = depthOrArraySize; | ||
| 1330 | MipLevels = mipLevels; | ||
| 1331 | Format = format; | ||
| 1332 | SampleDesc.Count = sampleCount; | ||
| 1333 | SampleDesc.Quality = sampleQuality; | ||
| 1334 | Layout = layout; | ||
| 1335 | Flags = flags; | ||
| 1336 | } | ||
| 1337 | static inline CD3DX12_RESOURCE_DESC Buffer( | ||
| 1338 | const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, | ||
| 1339 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept | ||
| 1340 | { | ||
| 1341 | return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, | ||
| 1342 | 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); | ||
| 1343 | } | ||
| 1344 | static inline CD3DX12_RESOURCE_DESC Buffer( | ||
| 1345 | UINT64 width, | ||
| 1346 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1347 | UINT64 alignment = 0 ) noexcept | ||
| 1348 | { | ||
| 1349 | return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, | ||
| 1350 | DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); | ||
| 1351 | } | ||
| 1352 | static inline CD3DX12_RESOURCE_DESC Tex1D( | ||
| 1353 | DXGI_FORMAT format, | ||
| 1354 | UINT64 width, | ||
| 1355 | UINT16 arraySize = 1, | ||
| 1356 | UINT16 mipLevels = 0, | ||
| 1357 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1358 | D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, | ||
| 1359 | UINT64 alignment = 0 ) noexcept | ||
| 1360 | { | ||
| 1361 | return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, | ||
| 1362 | mipLevels, format, 1, 0, layout, flags ); | ||
| 1363 | } | ||
| 1364 | static inline CD3DX12_RESOURCE_DESC Tex2D( | ||
| 1365 | DXGI_FORMAT format, | ||
| 1366 | UINT64 width, | ||
| 1367 | UINT height, | ||
| 1368 | UINT16 arraySize = 1, | ||
| 1369 | UINT16 mipLevels = 0, | ||
| 1370 | UINT sampleCount = 1, | ||
| 1371 | UINT sampleQuality = 0, | ||
| 1372 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1373 | D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, | ||
| 1374 | UINT64 alignment = 0 ) noexcept | ||
| 1375 | { | ||
| 1376 | return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, | ||
| 1377 | mipLevels, format, sampleCount, sampleQuality, layout, flags ); | ||
| 1378 | } | ||
| 1379 | static inline CD3DX12_RESOURCE_DESC Tex3D( | ||
| 1380 | DXGI_FORMAT format, | ||
| 1381 | UINT64 width, | ||
| 1382 | UINT height, | ||
| 1383 | UINT16 depth, | ||
| 1384 | UINT16 mipLevels = 0, | ||
| 1385 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1386 | D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, | ||
| 1387 | UINT64 alignment = 0 ) noexcept | ||
| 1388 | { | ||
| 1389 | return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, | ||
| 1390 | mipLevels, format, 1, 0, layout, flags ); | ||
| 1391 | } | ||
| 1392 | inline UINT16 Depth() const noexcept | ||
| 1393 | { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } | ||
| 1394 | inline UINT16 ArraySize() const noexcept | ||
| 1395 | { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } | ||
| 1396 | inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept | ||
| 1397 | { return D3D12GetFormatPlaneCount(pDevice, Format); } | ||
| 1398 | inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept | ||
| 1399 | { return static_cast<UINT>(MipLevels) * ArraySize() * PlaneCount(pDevice); } | ||
| 1400 | inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept | ||
| 1401 | { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } | ||
| 1402 | }; | ||
| 1403 | inline bool operator==( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept | ||
| 1404 | { | ||
| 1405 | return l.Dimension == r.Dimension && | ||
| 1406 | l.Alignment == r.Alignment && | ||
| 1407 | l.Width == r.Width && | ||
| 1408 | l.Height == r.Height && | ||
| 1409 | l.DepthOrArraySize == r.DepthOrArraySize && | ||
| 1410 | l.MipLevels == r.MipLevels && | ||
| 1411 | l.Format == r.Format && | ||
| 1412 | l.SampleDesc.Count == r.SampleDesc.Count && | ||
| 1413 | l.SampleDesc.Quality == r.SampleDesc.Quality && | ||
| 1414 | l.Layout == r.Layout && | ||
| 1415 | l.Flags == r.Flags; | ||
| 1416 | } | ||
| 1417 | inline bool operator!=( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept | ||
| 1418 | { return !( l == r ); } | ||
| 1419 | |||
| 1420 | //------------------------------------------------------------------------------------------------ | ||
| 1421 | struct CD3DX12_RESOURCE_DESC1 : public D3D12_RESOURCE_DESC1 | ||
| 1422 | { | ||
| 1423 | CD3DX12_RESOURCE_DESC1() = default; | ||
| 1424 | explicit CD3DX12_RESOURCE_DESC1( const D3D12_RESOURCE_DESC1& o ) noexcept : | ||
| 1425 | D3D12_RESOURCE_DESC1( o ) | ||
| 1426 | {} | ||
| 1427 | explicit CD3DX12_RESOURCE_DESC1( const D3D12_RESOURCE_DESC& o ) noexcept | ||
| 1428 | { | ||
| 1429 | Dimension = o.Dimension; | ||
| 1430 | Alignment = o.Alignment; | ||
| 1431 | Width = o.Width; | ||
| 1432 | Height = o.Height; | ||
| 1433 | DepthOrArraySize = o.DepthOrArraySize; | ||
| 1434 | MipLevels = o.MipLevels; | ||
| 1435 | Format = o.Format; | ||
| 1436 | SampleDesc = o.SampleDesc; | ||
| 1437 | Layout = o.Layout; | ||
| 1438 | Flags = o.Flags; | ||
| 1439 | SamplerFeedbackMipRegion = {}; | ||
| 1440 | } | ||
| 1441 | CD3DX12_RESOURCE_DESC1( | ||
| 1442 | D3D12_RESOURCE_DIMENSION dimension, | ||
| 1443 | UINT64 alignment, | ||
| 1444 | UINT64 width, | ||
| 1445 | UINT height, | ||
| 1446 | UINT16 depthOrArraySize, | ||
| 1447 | UINT16 mipLevels, | ||
| 1448 | DXGI_FORMAT format, | ||
| 1449 | UINT sampleCount, | ||
| 1450 | UINT sampleQuality, | ||
| 1451 | D3D12_TEXTURE_LAYOUT layout, | ||
| 1452 | D3D12_RESOURCE_FLAGS flags, | ||
| 1453 | UINT samplerFeedbackMipRegionWidth = 0, | ||
| 1454 | UINT samplerFeedbackMipRegionHeight = 0, | ||
| 1455 | UINT samplerFeedbackMipRegionDepth = 0) noexcept | ||
| 1456 | { | ||
| 1457 | Dimension = dimension; | ||
| 1458 | Alignment = alignment; | ||
| 1459 | Width = width; | ||
| 1460 | Height = height; | ||
| 1461 | DepthOrArraySize = depthOrArraySize; | ||
| 1462 | MipLevels = mipLevels; | ||
| 1463 | Format = format; | ||
| 1464 | SampleDesc.Count = sampleCount; | ||
| 1465 | SampleDesc.Quality = sampleQuality; | ||
| 1466 | Layout = layout; | ||
| 1467 | Flags = flags; | ||
| 1468 | SamplerFeedbackMipRegion.Width = samplerFeedbackMipRegionWidth; | ||
| 1469 | SamplerFeedbackMipRegion.Height = samplerFeedbackMipRegionHeight; | ||
| 1470 | SamplerFeedbackMipRegion.Depth = samplerFeedbackMipRegionDepth; | ||
| 1471 | } | ||
| 1472 | |||
| 1473 | static inline CD3DX12_RESOURCE_DESC1 Buffer( | ||
| 1474 | const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, | ||
| 1475 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept | ||
| 1476 | { | ||
| 1477 | return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, | ||
| 1478 | 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); | ||
| 1479 | } | ||
| 1480 | static inline CD3DX12_RESOURCE_DESC1 Buffer( | ||
| 1481 | UINT64 width, | ||
| 1482 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1483 | UINT64 alignment = 0 ) noexcept | ||
| 1484 | { | ||
| 1485 | return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, | ||
| 1486 | DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); | ||
| 1487 | } | ||
| 1488 | static inline CD3DX12_RESOURCE_DESC1 Tex1D( | ||
| 1489 | DXGI_FORMAT format, | ||
| 1490 | UINT64 width, | ||
| 1491 | UINT16 arraySize = 1, | ||
| 1492 | UINT16 mipLevels = 0, | ||
| 1493 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1494 | D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, | ||
| 1495 | UINT64 alignment = 0 ) noexcept | ||
| 1496 | { | ||
| 1497 | return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, | ||
| 1498 | mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); | ||
| 1499 | } | ||
| 1500 | static inline CD3DX12_RESOURCE_DESC1 Tex2D( | ||
| 1501 | DXGI_FORMAT format, | ||
| 1502 | UINT64 width, | ||
| 1503 | UINT height, | ||
| 1504 | UINT16 arraySize = 1, | ||
| 1505 | UINT16 mipLevels = 0, | ||
| 1506 | UINT sampleCount = 1, | ||
| 1507 | UINT sampleQuality = 0, | ||
| 1508 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1509 | D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, | ||
| 1510 | UINT64 alignment = 0, | ||
| 1511 | UINT samplerFeedbackMipRegionWidth = 0, | ||
| 1512 | UINT samplerFeedbackMipRegionHeight = 0, | ||
| 1513 | UINT samplerFeedbackMipRegionDepth = 0) noexcept | ||
| 1514 | { | ||
| 1515 | return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, | ||
| 1516 | mipLevels, format, sampleCount, sampleQuality, layout, flags, samplerFeedbackMipRegionWidth, | ||
| 1517 | samplerFeedbackMipRegionHeight, samplerFeedbackMipRegionDepth ); | ||
| 1518 | } | ||
| 1519 | static inline CD3DX12_RESOURCE_DESC1 Tex3D( | ||
| 1520 | DXGI_FORMAT format, | ||
| 1521 | UINT64 width, | ||
| 1522 | UINT height, | ||
| 1523 | UINT16 depth, | ||
| 1524 | UINT16 mipLevels = 0, | ||
| 1525 | D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, | ||
| 1526 | D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, | ||
| 1527 | UINT64 alignment = 0 ) noexcept | ||
| 1528 | { | ||
| 1529 | return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, | ||
| 1530 | mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); | ||
| 1531 | } | ||
| 1532 | inline UINT16 Depth() const noexcept | ||
| 1533 | { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } | ||
| 1534 | inline UINT16 ArraySize() const noexcept | ||
| 1535 | { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } | ||
| 1536 | inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept | ||
| 1537 | { return D3D12GetFormatPlaneCount(pDevice, Format); } | ||
| 1538 | inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept | ||
| 1539 | { return static_cast<UINT>(MipLevels) * ArraySize() * PlaneCount(pDevice); } | ||
| 1540 | inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept | ||
| 1541 | { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } | ||
| 1542 | }; | ||
| 1543 | inline bool operator==( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept | ||
| 1544 | { | ||
| 1545 | return l.Dimension == r.Dimension && | ||
| 1546 | l.Alignment == r.Alignment && | ||
| 1547 | l.Width == r.Width && | ||
| 1548 | l.Height == r.Height && | ||
| 1549 | l.DepthOrArraySize == r.DepthOrArraySize && | ||
| 1550 | l.MipLevels == r.MipLevels && | ||
| 1551 | l.Format == r.Format && | ||
| 1552 | l.SampleDesc.Count == r.SampleDesc.Count && | ||
| 1553 | l.SampleDesc.Quality == r.SampleDesc.Quality && | ||
| 1554 | l.Layout == r.Layout && | ||
| 1555 | l.Flags == r.Flags && | ||
| 1556 | l.SamplerFeedbackMipRegion.Width == r.SamplerFeedbackMipRegion.Width && | ||
| 1557 | l.SamplerFeedbackMipRegion.Height == r.SamplerFeedbackMipRegion.Height && | ||
| 1558 | l.SamplerFeedbackMipRegion.Depth == r.SamplerFeedbackMipRegion.Depth; | ||
| 1559 | } | ||
| 1560 | inline bool operator!=( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept | ||
| 1561 | { return !( l == r ); } | ||
| 1562 | |||
| 1563 | //------------------------------------------------------------------------------------------------ | ||
| 1564 | // Fills in the mipmap and alignment values of pDesc when either members are zero | ||
| 1565 | // Used to replace an implicit field to an explicit (0 mip map = max mip map level) | ||
| 1566 | // If expansion has occured, returns LclDesc, else returns the original pDesc | ||
| 1567 | inline const CD3DX12_RESOURCE_DESC1* D3DX12ConditionallyExpandAPIDesc( | ||
| 1568 | CD3DX12_RESOURCE_DESC1& LclDesc, | ||
| 1569 | const CD3DX12_RESOURCE_DESC1* pDesc, | ||
| 1570 | const bool tightAlignmentSupported = false, | ||
| 1571 | const bool alignAsCommitted = false) | ||
| 1572 | { | ||
| 1573 | // Expand mip levels: | ||
| 1574 | if (pDesc->MipLevels == 0 || pDesc->Alignment == 0) | ||
| 1575 | { | ||
| 1576 | LclDesc = *pDesc; | ||
| 1577 | if (pDesc->MipLevels == 0) | ||
| 1578 | { | ||
| 1579 | auto MaxMipLevels = [](UINT64 uiMaxDimension) -> UINT16 | ||
| 1580 | { | ||
| 1581 | UINT16 uiRet = 0; | ||
| 1582 | while (uiMaxDimension > 0) | ||
| 1583 | { | ||
| 1584 | uiRet++; | ||
| 1585 | uiMaxDimension >>= 1; | ||
| 1586 | } | ||
| 1587 | return uiRet; | ||
| 1588 | }; | ||
| 1589 | auto Max = [](UINT64 const& a, UINT64 const& b) | ||
| 1590 | { | ||
| 1591 | return (a < b) ? b : a; | ||
| 1592 | }; | ||
| 1593 | |||
| 1594 | LclDesc.MipLevels = MaxMipLevels( | ||
| 1595 | Max(LclDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? LclDesc.DepthOrArraySize : 1, | ||
| 1596 | Max(LclDesc.Width, LclDesc.Height))); | ||
| 1597 | } | ||
| 1598 | if (pDesc->Alignment == 0) | ||
| 1599 | { | ||
| 1600 | if (pDesc->Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE | ||
| 1601 | || pDesc->Layout == D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE | ||
| 1602 | ) | ||
| 1603 | { | ||
| 1604 | LclDesc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; | ||
| 1605 | } | ||
| 1606 | else if (!(tightAlignmentSupported && (pDesc->Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT)) | ||
| 1607 | || (pDesc->Flags & D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER)) | ||
| 1608 | { | ||
| 1609 | LclDesc.Alignment = | ||
| 1610 | (pDesc->SampleDesc.Count > 1 ? D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT); | ||
| 1611 | } | ||
| 1612 | else | ||
| 1613 | { | ||
| 1614 | // Tight alignment is supported and we aren't a cross adapter resource, now just need to set the alignment field to the minimum alignment for each type | ||
| 1615 | if(alignAsCommitted) | ||
| 1616 | LclDesc.Alignment = D3D12_TIGHT_ALIGNMENT_MIN_COMMITTED_RESOURCE_ALIGNMENT; | ||
| 1617 | else | ||
| 1618 | LclDesc.Alignment = D3D12_TIGHT_ALIGNMENT_MIN_PLACED_RESOURCE_ALIGNMENT; | ||
| 1619 | } | ||
| 1620 | } | ||
| 1621 | return &LclDesc; | ||
| 1622 | } | ||
| 1623 | else | ||
| 1624 | { | ||
| 1625 | return pDesc; | ||
| 1626 | } | ||
| 1627 | } | ||
| 1628 | |||
| 1629 | |||
| 1630 | //------------------------------------------------------------------------------------------------ | ||
| 1631 | struct CD3DX12_SHADER_RESOURCE_VIEW_DESC : public D3D12_SHADER_RESOURCE_VIEW_DESC | ||
| 1632 | { | ||
| 1633 | CD3DX12_SHADER_RESOURCE_VIEW_DESC() = default; | ||
| 1634 | explicit CD3DX12_SHADER_RESOURCE_VIEW_DESC( const D3D12_SHADER_RESOURCE_VIEW_DESC& o ) noexcept : | ||
| 1635 | D3D12_SHADER_RESOURCE_VIEW_DESC(o) | ||
| 1636 | {} | ||
| 1637 | |||
| 1638 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC StructuredBuffer( | ||
| 1639 | UINT NumElements, | ||
| 1640 | UINT StructureByteStride, | ||
| 1641 | UINT64 FirstElement = 0) noexcept | ||
| 1642 | { | ||
| 1643 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1644 | desc.Format = DXGI_FORMAT_UNKNOWN; | ||
| 1645 | desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; | ||
| 1646 | desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; | ||
| 1647 | desc.Buffer.FirstElement = FirstElement; | ||
| 1648 | desc.Buffer.NumElements = NumElements; | ||
| 1649 | desc.Buffer.StructureByteStride = StructureByteStride; | ||
| 1650 | desc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE; | ||
| 1651 | return desc; | ||
| 1652 | } | ||
| 1653 | |||
| 1654 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC RawBuffer( | ||
| 1655 | UINT NumElements, | ||
| 1656 | UINT64 FirstElement = 0) noexcept | ||
| 1657 | { | ||
| 1658 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1659 | desc.Format = DXGI_FORMAT_R32_UINT; | ||
| 1660 | desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; | ||
| 1661 | desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; | ||
| 1662 | desc.Buffer.FirstElement = FirstElement; | ||
| 1663 | desc.Buffer.NumElements = NumElements; | ||
| 1664 | desc.Buffer.StructureByteStride = 0; | ||
| 1665 | desc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; | ||
| 1666 | return desc; | ||
| 1667 | } | ||
| 1668 | |||
| 1669 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC TypedBuffer( | ||
| 1670 | DXGI_FORMAT Format, | ||
| 1671 | UINT NumElements, | ||
| 1672 | UINT64 FirstElement = 0, | ||
| 1673 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1674 | { | ||
| 1675 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1676 | desc.Format = Format; | ||
| 1677 | desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; | ||
| 1678 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1679 | desc.Buffer.FirstElement = FirstElement; | ||
| 1680 | desc.Buffer.NumElements = NumElements; | ||
| 1681 | desc.Buffer.StructureByteStride = 0; | ||
| 1682 | desc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE; | ||
| 1683 | return desc; | ||
| 1684 | } | ||
| 1685 | |||
| 1686 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC Tex1D( | ||
| 1687 | DXGI_FORMAT Format, | ||
| 1688 | UINT MipLevels = -1, | ||
| 1689 | UINT MostDetailedMip = 0, | ||
| 1690 | FLOAT ResourceMinLODClamp = 0.0f, | ||
| 1691 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1692 | { | ||
| 1693 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1694 | desc.Format = Format; | ||
| 1695 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D; | ||
| 1696 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1697 | desc.Texture1D.MostDetailedMip = MostDetailedMip; | ||
| 1698 | desc.Texture1D.MipLevels = MipLevels; | ||
| 1699 | desc.Texture1D.ResourceMinLODClamp = ResourceMinLODClamp; | ||
| 1700 | return desc; | ||
| 1701 | } | ||
| 1702 | |||
| 1703 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC Tex1DArray( | ||
| 1704 | DXGI_FORMAT Format, | ||
| 1705 | UINT ArraySize = -1, | ||
| 1706 | UINT MipLevels = -1, | ||
| 1707 | UINT FirstArraySlice = 0, | ||
| 1708 | UINT MostDetailedMip = 0, | ||
| 1709 | FLOAT ResourceMinLODClamp = 0.0f, | ||
| 1710 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1711 | { | ||
| 1712 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1713 | desc.Format = Format; | ||
| 1714 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY; | ||
| 1715 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1716 | desc.Texture1DArray.MostDetailedMip = MostDetailedMip; | ||
| 1717 | desc.Texture1DArray.MipLevels = MipLevels; | ||
| 1718 | desc.Texture1DArray.FirstArraySlice = FirstArraySlice; | ||
| 1719 | desc.Texture1DArray.ArraySize = ArraySize; | ||
| 1720 | desc.Texture1DArray.ResourceMinLODClamp = ResourceMinLODClamp; | ||
| 1721 | return desc; | ||
| 1722 | } | ||
| 1723 | |||
| 1724 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC Tex2D( | ||
| 1725 | DXGI_FORMAT Format, | ||
| 1726 | UINT MipLevels = -1, | ||
| 1727 | UINT MostDetailedMip = 0, | ||
| 1728 | UINT PlaneSlice = 0, | ||
| 1729 | FLOAT ResourceMinLODClamp = 0.0f, | ||
| 1730 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1731 | { | ||
| 1732 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1733 | desc.Format = Format; | ||
| 1734 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; | ||
| 1735 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1736 | desc.Texture2D.MostDetailedMip = MostDetailedMip; | ||
| 1737 | desc.Texture2D.MipLevels = MipLevels; | ||
| 1738 | desc.Texture2D.PlaneSlice = PlaneSlice; | ||
| 1739 | desc.Texture2D.ResourceMinLODClamp = ResourceMinLODClamp; | ||
| 1740 | return desc; | ||
| 1741 | } | ||
| 1742 | |||
| 1743 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC Tex2DArray( | ||
| 1744 | DXGI_FORMAT Format, | ||
| 1745 | UINT ArraySize = -1, | ||
| 1746 | UINT MipLevels = -1, | ||
| 1747 | UINT FirstArraySlice = 0, | ||
| 1748 | UINT MostDetailedMip = 0, | ||
| 1749 | UINT PlaneSlice = 0, | ||
| 1750 | FLOAT ResourceMinLODClamp = 0.0f, | ||
| 1751 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1752 | { | ||
| 1753 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1754 | desc.Format = Format; | ||
| 1755 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; | ||
| 1756 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1757 | desc.Texture2DArray.MostDetailedMip = MostDetailedMip; | ||
| 1758 | desc.Texture2DArray.MipLevels = MipLevels; | ||
| 1759 | desc.Texture2DArray.FirstArraySlice = FirstArraySlice; | ||
| 1760 | desc.Texture2DArray.ArraySize = ArraySize; | ||
| 1761 | desc.Texture2DArray.PlaneSlice = PlaneSlice; | ||
| 1762 | desc.Texture2DArray.ResourceMinLODClamp = ResourceMinLODClamp; | ||
| 1763 | return desc; | ||
| 1764 | } | ||
| 1765 | |||
| 1766 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC Tex2DMS( | ||
| 1767 | DXGI_FORMAT Format, | ||
| 1768 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1769 | { | ||
| 1770 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1771 | desc.Format = Format; | ||
| 1772 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; | ||
| 1773 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1774 | // desc.Texture2DMS.UnusedField_NothingToDefine = 0; | ||
| 1775 | return desc; | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC Tex2DMSArray( | ||
| 1779 | DXGI_FORMAT Format, | ||
| 1780 | UINT ArraySize, | ||
| 1781 | UINT FirstArraySlice = 0, | ||
| 1782 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1783 | { | ||
| 1784 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1785 | desc.Format = Format; | ||
| 1786 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY; | ||
| 1787 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1788 | desc.Texture2DMSArray.ArraySize = ArraySize; | ||
| 1789 | desc.Texture2DMSArray.FirstArraySlice = FirstArraySlice; | ||
| 1790 | return desc; | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC Tex3D( | ||
| 1794 | DXGI_FORMAT Format, | ||
| 1795 | UINT MipLevels = -1, | ||
| 1796 | UINT MostDetailedMip = 0, | ||
| 1797 | FLOAT ResourceMinLODClamp = 0.0f, | ||
| 1798 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1799 | { | ||
| 1800 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1801 | desc.Format = Format; | ||
| 1802 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; | ||
| 1803 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1804 | desc.Texture3D.MostDetailedMip = MostDetailedMip; | ||
| 1805 | desc.Texture3D.MipLevels = MipLevels; | ||
| 1806 | desc.Texture3D.ResourceMinLODClamp = ResourceMinLODClamp; | ||
| 1807 | return desc; | ||
| 1808 | } | ||
| 1809 | |||
| 1810 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC TexCube( | ||
| 1811 | DXGI_FORMAT Format, | ||
| 1812 | UINT MipLevels = -1, | ||
| 1813 | UINT MostDetailedMip = 0, | ||
| 1814 | FLOAT ResourceMinLODClamp = 0.0f, | ||
| 1815 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1816 | { | ||
| 1817 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1818 | desc.Format = Format; | ||
| 1819 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; | ||
| 1820 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1821 | desc.TextureCube.MostDetailedMip = MostDetailedMip; | ||
| 1822 | desc.TextureCube.MipLevels = MipLevels; | ||
| 1823 | desc.TextureCube.ResourceMinLODClamp = ResourceMinLODClamp; | ||
| 1824 | return desc; | ||
| 1825 | } | ||
| 1826 | |||
| 1827 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC TexCubeArray( | ||
| 1828 | DXGI_FORMAT Format, | ||
| 1829 | UINT NumCubes, | ||
| 1830 | UINT MipLevels = -1, | ||
| 1831 | UINT First2DArrayFace = 0, | ||
| 1832 | UINT MostDetailedMip = 0, | ||
| 1833 | FLOAT ResourceMinLODClamp = 0.0f, | ||
| 1834 | UINT Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING) noexcept | ||
| 1835 | { | ||
| 1836 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1837 | desc.Format = Format; | ||
| 1838 | desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; | ||
| 1839 | desc.Shader4ComponentMapping = Shader4ComponentMapping; | ||
| 1840 | desc.TextureCubeArray.NumCubes = NumCubes; | ||
| 1841 | desc.TextureCubeArray.MostDetailedMip = MostDetailedMip; | ||
| 1842 | desc.TextureCubeArray.MipLevels = MipLevels; | ||
| 1843 | desc.TextureCubeArray.First2DArrayFace = First2DArrayFace; | ||
| 1844 | desc.TextureCubeArray.ResourceMinLODClamp = ResourceMinLODClamp; | ||
| 1845 | return desc; | ||
| 1846 | } | ||
| 1847 | |||
| 1848 | static inline CD3DX12_SHADER_RESOURCE_VIEW_DESC RaytracingAccelStruct( | ||
| 1849 | D3D12_GPU_VIRTUAL_ADDRESS Location) noexcept | ||
| 1850 | { | ||
| 1851 | CD3DX12_SHADER_RESOURCE_VIEW_DESC desc; | ||
| 1852 | desc.Format = DXGI_FORMAT_UNKNOWN; | ||
| 1853 | desc.ViewDimension = D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE; | ||
| 1854 | desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; | ||
| 1855 | desc.RaytracingAccelerationStructure.Location = Location; | ||
| 1856 | return desc; | ||
| 1857 | } | ||
| 1858 | }; | ||
| 1859 | |||
| 1860 | //------------------------------------------------------------------------------------------------ | ||
| 1861 | struct CD3DX12_UNORDERED_ACCESS_VIEW_DESC : public D3D12_UNORDERED_ACCESS_VIEW_DESC | ||
| 1862 | { | ||
| 1863 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC() = default; | ||
| 1864 | explicit CD3DX12_UNORDERED_ACCESS_VIEW_DESC( const D3D12_UNORDERED_ACCESS_VIEW_DESC& o ) noexcept : | ||
| 1865 | D3D12_UNORDERED_ACCESS_VIEW_DESC(o) | ||
| 1866 | {} | ||
| 1867 | |||
| 1868 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC StructuredBuffer( | ||
| 1869 | UINT NumElements, | ||
| 1870 | UINT StructureByteStride, | ||
| 1871 | UINT64 FirstElement = 0, | ||
| 1872 | UINT64 CounterOffsetInBytes = 0) noexcept | ||
| 1873 | { | ||
| 1874 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1875 | desc.Format = DXGI_FORMAT_UNKNOWN; | ||
| 1876 | desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; | ||
| 1877 | desc.Buffer.FirstElement = FirstElement; | ||
| 1878 | desc.Buffer.NumElements = NumElements; | ||
| 1879 | desc.Buffer.StructureByteStride = StructureByteStride; | ||
| 1880 | desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; | ||
| 1881 | desc.Buffer.CounterOffsetInBytes = CounterOffsetInBytes; | ||
| 1882 | return desc; | ||
| 1883 | } | ||
| 1884 | |||
| 1885 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC RawBuffer( | ||
| 1886 | UINT NumElements, | ||
| 1887 | UINT64 FirstElement = 0, | ||
| 1888 | UINT64 CounterOffsetInBytes = 0) noexcept | ||
| 1889 | { | ||
| 1890 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1891 | desc.Format = DXGI_FORMAT_R32_UINT; | ||
| 1892 | desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; | ||
| 1893 | desc.Buffer.FirstElement = FirstElement; | ||
| 1894 | desc.Buffer.NumElements = NumElements; | ||
| 1895 | desc.Buffer.StructureByteStride = 0; | ||
| 1896 | desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW; | ||
| 1897 | desc.Buffer.CounterOffsetInBytes = CounterOffsetInBytes; | ||
| 1898 | return desc; | ||
| 1899 | } | ||
| 1900 | |||
| 1901 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC TypedBuffer( | ||
| 1902 | DXGI_FORMAT Format, | ||
| 1903 | UINT NumElements, | ||
| 1904 | UINT64 FirstElement = 0, | ||
| 1905 | UINT64 CounterOffsetInBytes = 0) noexcept | ||
| 1906 | { | ||
| 1907 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1908 | desc.Format = Format; | ||
| 1909 | desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; | ||
| 1910 | desc.Buffer.FirstElement = FirstElement; | ||
| 1911 | desc.Buffer.NumElements = NumElements; | ||
| 1912 | desc.Buffer.StructureByteStride = 0; | ||
| 1913 | desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; | ||
| 1914 | desc.Buffer.CounterOffsetInBytes = CounterOffsetInBytes; | ||
| 1915 | return desc; | ||
| 1916 | } | ||
| 1917 | |||
| 1918 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC Tex1D( | ||
| 1919 | DXGI_FORMAT Format, | ||
| 1920 | UINT MipSlice = 0) noexcept | ||
| 1921 | { | ||
| 1922 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1923 | desc.Format = Format; | ||
| 1924 | desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1D; | ||
| 1925 | desc.Texture1D.MipSlice = MipSlice; | ||
| 1926 | return desc; | ||
| 1927 | } | ||
| 1928 | |||
| 1929 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC Tex1DArray( | ||
| 1930 | DXGI_FORMAT Format, | ||
| 1931 | UINT ArraySize = -1, | ||
| 1932 | UINT FirstArraySlice = 0, | ||
| 1933 | UINT MipSlice = 0) noexcept | ||
| 1934 | { | ||
| 1935 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1936 | desc.Format = Format; | ||
| 1937 | desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1DARRAY; | ||
| 1938 | desc.Texture1DArray.MipSlice = MipSlice; | ||
| 1939 | desc.Texture1DArray.FirstArraySlice = FirstArraySlice; | ||
| 1940 | desc.Texture1DArray.ArraySize = ArraySize; | ||
| 1941 | return desc; | ||
| 1942 | } | ||
| 1943 | |||
| 1944 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC Tex2D( | ||
| 1945 | DXGI_FORMAT Format, | ||
| 1946 | UINT MipSlice = 0, | ||
| 1947 | UINT PlaneSlice = 0) noexcept | ||
| 1948 | { | ||
| 1949 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1950 | desc.Format = Format; | ||
| 1951 | desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; | ||
| 1952 | desc.Texture2D.MipSlice = MipSlice; | ||
| 1953 | desc.Texture2D.PlaneSlice = PlaneSlice; | ||
| 1954 | return desc; | ||
| 1955 | } | ||
| 1956 | |||
| 1957 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC Tex2DArray( | ||
| 1958 | DXGI_FORMAT Format, | ||
| 1959 | UINT ArraySize = -1, | ||
| 1960 | UINT FirstArraySlice = 0, | ||
| 1961 | UINT MipSlice = 0, | ||
| 1962 | UINT PlaneSlice = 0) noexcept | ||
| 1963 | { | ||
| 1964 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1965 | desc.Format = Format; | ||
| 1966 | desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; | ||
| 1967 | desc.Texture2DArray.MipSlice = MipSlice; | ||
| 1968 | desc.Texture2DArray.FirstArraySlice = FirstArraySlice; | ||
| 1969 | desc.Texture2DArray.ArraySize = ArraySize; | ||
| 1970 | desc.Texture2DArray.PlaneSlice = PlaneSlice; | ||
| 1971 | return desc; | ||
| 1972 | } | ||
| 1973 | |||
| 1974 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC Tex2DMS( | ||
| 1975 | DXGI_FORMAT Format) noexcept | ||
| 1976 | { | ||
| 1977 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1978 | desc.Format = Format; | ||
| 1979 | desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DMS; | ||
| 1980 | //desc.Texture2DMS.UnusedField_NothingToDefine = 0; | ||
| 1981 | return desc; | ||
| 1982 | } | ||
| 1983 | |||
| 1984 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC Tex2DMSArray( | ||
| 1985 | DXGI_FORMAT Format, | ||
| 1986 | UINT ArraySize = -1, | ||
| 1987 | UINT FirstArraySlice = 0) noexcept | ||
| 1988 | { | ||
| 1989 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 1990 | desc.Format = Format; | ||
| 1991 | desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DMSARRAY; | ||
| 1992 | desc.Texture2DMSArray.FirstArraySlice = FirstArraySlice; | ||
| 1993 | desc.Texture2DMSArray.ArraySize = ArraySize; | ||
| 1994 | return desc; | ||
| 1995 | } | ||
| 1996 | |||
| 1997 | static inline CD3DX12_UNORDERED_ACCESS_VIEW_DESC Tex3D( | ||
| 1998 | DXGI_FORMAT Format, | ||
| 1999 | UINT WSize = -1, | ||
| 2000 | UINT FirstWSlice = 0, | ||
| 2001 | UINT MipSlice = 0) noexcept | ||
| 2002 | { | ||
| 2003 | CD3DX12_UNORDERED_ACCESS_VIEW_DESC desc; | ||
| 2004 | desc.Format = Format; | ||
| 2005 | desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D; | ||
| 2006 | desc.Texture3D.MipSlice = MipSlice; | ||
| 2007 | desc.Texture3D.FirstWSlice = FirstWSlice; | ||
| 2008 | desc.Texture3D.WSize = WSize; | ||
| 2009 | return desc; | ||
| 2010 | } | ||
| 2011 | }; | ||
| 2012 | |||
| 2013 | //------------------------------------------------------------------------------------------------ | ||
| 2014 | struct CD3DX12_VIEW_INSTANCING_DESC : public D3D12_VIEW_INSTANCING_DESC | ||
| 2015 | { | ||
| 2016 | CD3DX12_VIEW_INSTANCING_DESC() = default; | ||
| 2017 | explicit CD3DX12_VIEW_INSTANCING_DESC( const D3D12_VIEW_INSTANCING_DESC& o ) noexcept : | ||
| 2018 | D3D12_VIEW_INSTANCING_DESC( o ) | ||
| 2019 | {} | ||
| 2020 | explicit CD3DX12_VIEW_INSTANCING_DESC( CD3DX12_DEFAULT ) noexcept | ||
| 2021 | { | ||
| 2022 | ViewInstanceCount = 0; | ||
| 2023 | pViewInstanceLocations = nullptr; | ||
| 2024 | Flags = D3D12_VIEW_INSTANCING_FLAG_NONE; | ||
| 2025 | } | ||
| 2026 | explicit CD3DX12_VIEW_INSTANCING_DESC( | ||
| 2027 | UINT InViewInstanceCount, | ||
| 2028 | const D3D12_VIEW_INSTANCE_LOCATION* InViewInstanceLocations, | ||
| 2029 | D3D12_VIEW_INSTANCING_FLAGS InFlags) noexcept | ||
| 2030 | { | ||
| 2031 | ViewInstanceCount = InViewInstanceCount; | ||
| 2032 | pViewInstanceLocations = InViewInstanceLocations; | ||
| 2033 | Flags = InFlags; | ||
| 2034 | } | ||
| 2035 | }; | ||
| 2036 | |||
| 2037 | //------------------------------------------------------------------------------------------------ | ||
| 2038 | struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY | ||
| 2039 | { | ||
| 2040 | CD3DX12_RT_FORMAT_ARRAY() = default; | ||
| 2041 | explicit CD3DX12_RT_FORMAT_ARRAY(const D3D12_RT_FORMAT_ARRAY& o) noexcept | ||
| 2042 | : D3D12_RT_FORMAT_ARRAY(o) | ||
| 2043 | {} | ||
| 2044 | explicit CD3DX12_RT_FORMAT_ARRAY(_In_reads_(NumFormats) const DXGI_FORMAT* pFormats, UINT NumFormats) noexcept | ||
| 2045 | { | ||
| 2046 | NumRenderTargets = NumFormats; | ||
| 2047 | memcpy(RTFormats, pFormats, sizeof(RTFormats)); | ||
| 2048 | // assumes ARRAY_SIZE(pFormats) == ARRAY_SIZE(RTFormats) | ||
| 2049 | } | ||
| 2050 | }; | ||
| 2051 | |||
| 2052 | //------------------------------------------------------------------------------------------------ | ||
| 2053 | struct CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC : public D3D12_SERIALIZED_ROOT_SIGNATURE_DESC | ||
| 2054 | { | ||
| 2055 | CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC() = default; | ||
| 2056 | explicit CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC(const D3D12_SERIALIZED_ROOT_SIGNATURE_DESC& o) noexcept : | ||
| 2057 | D3D12_SERIALIZED_ROOT_SIGNATURE_DESC(o) | ||
| 2058 | { | ||
| 2059 | } | ||
| 2060 | explicit CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC( CD3DX12_DEFAULT ) noexcept | ||
| 2061 | { | ||
| 2062 | pSerializedBlob = nullptr; | ||
| 2063 | SerializedBlobSizeInBytes = 0; | ||
| 2064 | } | ||
| 2065 | explicit CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC( const void* pData, SIZE_T size) noexcept | ||
| 2066 | { | ||
| 2067 | pSerializedBlob = pData; | ||
| 2068 | SerializedBlobSizeInBytes = size; | ||
| 2069 | } | ||
| 2070 | }; | ||
| 2071 | |||
| 2072 | |||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_default.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_default.h new file mode 100644 index 0000000..2b74d70 --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_default.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | //********************************************************* | ||
| 2 | // | ||
| 3 | // Copyright (c) Microsoft Corporation. | ||
| 4 | // Licensed under the MIT License (MIT). | ||
| 5 | // | ||
| 6 | //********************************************************* | ||
| 7 | |||
| 8 | #pragma once | ||
| 9 | |||
| 10 | struct CD3DX12_DEFAULT {}; | ||
| 11 | extern const DECLSPEC_SELECTANY CD3DX12_DEFAULT D3D12_DEFAULT; | ||
| 12 | |||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_pipeline_state_stream.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_pipeline_state_stream.h new file mode 100644 index 0000000..456583b --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_pipeline_state_stream.h | |||
| @@ -0,0 +1,1718 @@ | |||
| 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 "d3dx12_default.h" | ||
| 15 | #include "d3d12.h" | ||
| 16 | #include "d3dx12_core.h" | ||
| 17 | |||
| 18 | //------------------------------------------------------------------------------------------------ | ||
| 19 | // Pipeline State Stream Helpers | ||
| 20 | //------------------------------------------------------------------------------------------------ | ||
| 21 | |||
| 22 | //------------------------------------------------------------------------------------------------ | ||
| 23 | // Stream Subobjects, i.e. elements of a stream | ||
| 24 | |||
| 25 | struct DefaultSampleMask { operator UINT() noexcept { return UINT_MAX; } }; | ||
| 26 | struct DefaultSampleDesc { operator DXGI_SAMPLE_DESC() noexcept { return DXGI_SAMPLE_DESC{1, 0}; } }; | ||
| 27 | |||
| 28 | #ifdef _MSC_VER | ||
| 29 | #pragma warning(push) | ||
| 30 | #pragma warning(disable : 4324) | ||
| 31 | #endif | ||
| 32 | template <typename InnerStructType, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type, typename DefaultArg = InnerStructType> | ||
| 33 | class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT | ||
| 34 | { | ||
| 35 | private: | ||
| 36 | D3D12_PIPELINE_STATE_SUBOBJECT_TYPE pssType; | ||
| 37 | InnerStructType pssInner; | ||
| 38 | public: | ||
| 39 | CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() noexcept : pssType(Type), pssInner(DefaultArg()) {} | ||
| 40 | CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) noexcept : pssType(Type), pssInner(i) {} | ||
| 41 | CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) noexcept { pssType = Type; pssInner = i; return *this; } | ||
| 42 | operator InnerStructType const&() const noexcept { return pssInner; } | ||
| 43 | operator InnerStructType&() noexcept { return pssInner; } | ||
| 44 | InnerStructType* operator&() noexcept { return &pssInner; } | ||
| 45 | InnerStructType const* operator&() const noexcept { return &pssInner; } | ||
| 46 | }; | ||
| 47 | #ifdef _MSC_VER | ||
| 48 | #pragma warning(pop) | ||
| 49 | #endif | ||
| 50 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS; | ||
| 51 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK; | ||
| 52 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE; | ||
| 53 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INPUT_LAYOUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT> CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT; | ||
| 54 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE> CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE; | ||
| 55 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PRIMITIVE_TOPOLOGY_TYPE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY> CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY; | ||
| 56 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS> CD3DX12_PIPELINE_STATE_STREAM_VS; | ||
| 57 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS> CD3DX12_PIPELINE_STATE_STREAM_GS; | ||
| 58 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_STREAM_OUTPUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT> CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT; | ||
| 59 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS> CD3DX12_PIPELINE_STATE_STREAM_HS; | ||
| 60 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS> CD3DX12_PIPELINE_STATE_STREAM_DS; | ||
| 61 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> CD3DX12_PIPELINE_STATE_STREAM_PS; | ||
| 62 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS> CD3DX12_PIPELINE_STATE_STREAM_AS; | ||
| 63 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS> CD3DX12_PIPELINE_STATE_STREAM_MS; | ||
| 64 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS> CD3DX12_PIPELINE_STATE_STREAM_CS; | ||
| 65 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC; | ||
| 66 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL; | ||
| 67 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC1, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1; | ||
| 68 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 69 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC2, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2; | ||
| 70 | #endif | ||
| 71 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT; | ||
| 72 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER; | ||
| 73 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 74 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC1, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER1, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER1; | ||
| 75 | #endif | ||
| 76 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 77 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC2, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER2, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER2; | ||
| 78 | #endif | ||
| 79 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS; | ||
| 80 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC, DefaultSampleDesc> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC; | ||
| 81 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK, DefaultSampleMask> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK; | ||
| 82 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO; | ||
| 83 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_VIEW_INSTANCING_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING; | ||
| 84 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 85 | typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SERIALIZED_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_SERIALIZED_ROOT_SIGNATURE; | ||
| 86 | #endif | ||
| 87 | |||
| 88 | //------------------------------------------------------------------------------------------------ | ||
| 89 | // Stream Parser Helpers | ||
| 90 | |||
| 91 | struct ID3DX12PipelineParserCallbacks | ||
| 92 | { | ||
| 93 | // Subobject Callbacks | ||
| 94 | virtual void FlagsCb(D3D12_PIPELINE_STATE_FLAGS) {} | ||
| 95 | virtual void NodeMaskCb(UINT) {} | ||
| 96 | virtual void RootSignatureCb(ID3D12RootSignature*) {} | ||
| 97 | virtual void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC&) {} | ||
| 98 | virtual void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE) {} | ||
| 99 | virtual void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE) {} | ||
| 100 | virtual void VSCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 101 | virtual void GSCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 102 | virtual void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC&) {} | ||
| 103 | virtual void HSCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 104 | virtual void DSCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 105 | virtual void PSCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 106 | virtual void CSCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 107 | virtual void ASCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 108 | virtual void MSCb(const D3D12_SHADER_BYTECODE&) {} | ||
| 109 | virtual void BlendStateCb(const D3D12_BLEND_DESC&) {} | ||
| 110 | virtual void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC&) {} | ||
| 111 | virtual void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1&) {} | ||
| 112 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 113 | virtual void DepthStencilState2Cb(const D3D12_DEPTH_STENCIL_DESC2&) {} | ||
| 114 | #endif | ||
| 115 | virtual void DSVFormatCb(DXGI_FORMAT) {} | ||
| 116 | virtual void RasterizerStateCb(const D3D12_RASTERIZER_DESC&) {} | ||
| 117 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 118 | virtual void RasterizerState1Cb(const D3D12_RASTERIZER_DESC1&) {} | ||
| 119 | #endif | ||
| 120 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 121 | virtual void RasterizerState2Cb(const D3D12_RASTERIZER_DESC2&) {} | ||
| 122 | #endif | ||
| 123 | virtual void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY&) {} | ||
| 124 | virtual void SampleDescCb(const DXGI_SAMPLE_DESC&) {} | ||
| 125 | virtual void SampleMaskCb(UINT) {} | ||
| 126 | virtual void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC&) {} | ||
| 127 | virtual void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE&) {} | ||
| 128 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 129 | virtual void SerializedRootSignatureCb(const D3D12_SERIALIZED_ROOT_SIGNATURE_DESC&) {} | ||
| 130 | #endif | ||
| 131 | |||
| 132 | // Error Callbacks | ||
| 133 | virtual void ErrorBadInputParameter(UINT /*ParameterIndex*/) {} | ||
| 134 | virtual void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE /*DuplicateType*/) {} | ||
| 135 | virtual void ErrorUnknownSubobject(UINT /*UnknownTypeValue*/) {} | ||
| 136 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613) | ||
| 137 | virtual void FinalizeCb() {} | ||
| 138 | #endif | ||
| 139 | |||
| 140 | virtual ~ID3DX12PipelineParserCallbacks() = default; | ||
| 141 | }; | ||
| 142 | |||
| 143 | struct D3DX12_MESH_SHADER_PIPELINE_STATE_DESC | ||
| 144 | { | ||
| 145 | ID3D12RootSignature* pRootSignature; | ||
| 146 | D3D12_SHADER_BYTECODE AS; | ||
| 147 | D3D12_SHADER_BYTECODE MS; | ||
| 148 | D3D12_SHADER_BYTECODE PS; | ||
| 149 | D3D12_BLEND_DESC BlendState; | ||
| 150 | UINT SampleMask; | ||
| 151 | D3D12_RASTERIZER_DESC RasterizerState; | ||
| 152 | D3D12_DEPTH_STENCIL_DESC DepthStencilState; | ||
| 153 | D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType; | ||
| 154 | UINT NumRenderTargets; | ||
| 155 | DXGI_FORMAT RTVFormats[ D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ]; | ||
| 156 | DXGI_FORMAT DSVFormat; | ||
| 157 | DXGI_SAMPLE_DESC SampleDesc; | ||
| 158 | UINT NodeMask; | ||
| 159 | D3D12_CACHED_PIPELINE_STATE CachedPSO; | ||
| 160 | D3D12_PIPELINE_STATE_FLAGS Flags; | ||
| 161 | }; | ||
| 162 | |||
| 163 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 164 | struct CD3DX12_PIPELINE_STATE_STREAM6 | ||
| 165 | { | ||
| 166 | CD3DX12_PIPELINE_STATE_STREAM6() = default; | ||
| 167 | // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC | ||
| 168 | CD3DX12_PIPELINE_STATE_STREAM6(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 169 | : Flags(Desc.Flags) | ||
| 170 | , NodeMask(Desc.NodeMask) | ||
| 171 | , pRootSignature(Desc.pRootSignature) | ||
| 172 | , InputLayout(Desc.InputLayout) | ||
| 173 | , IBStripCutValue(Desc.IBStripCutValue) | ||
| 174 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 175 | , VS(Desc.VS) | ||
| 176 | , GS(Desc.GS) | ||
| 177 | , StreamOutput(Desc.StreamOutput) | ||
| 178 | , HS(Desc.HS) | ||
| 179 | , DS(Desc.DS) | ||
| 180 | , PS(Desc.PS) | ||
| 181 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 182 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 183 | , DSVFormat(Desc.DSVFormat) | ||
| 184 | , RasterizerState(CD3DX12_RASTERIZER_DESC2(Desc.RasterizerState)) | ||
| 185 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 186 | , SampleDesc(Desc.SampleDesc) | ||
| 187 | , SampleMask(Desc.SampleMask) | ||
| 188 | , CachedPSO(Desc.CachedPSO) | ||
| 189 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 190 | , SerializedRootSignature(CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT())) | ||
| 191 | { | ||
| 192 | } | ||
| 193 | CD3DX12_PIPELINE_STATE_STREAM6(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 194 | : Flags(Desc.Flags) | ||
| 195 | , NodeMask(Desc.NodeMask) | ||
| 196 | , pRootSignature(Desc.pRootSignature) | ||
| 197 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 198 | , PS(Desc.PS) | ||
| 199 | , AS(Desc.AS) | ||
| 200 | , MS(Desc.MS) | ||
| 201 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 202 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 203 | , DSVFormat(Desc.DSVFormat) | ||
| 204 | , RasterizerState(CD3DX12_RASTERIZER_DESC2(Desc.RasterizerState)) | ||
| 205 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 206 | , SampleDesc(Desc.SampleDesc) | ||
| 207 | , SampleMask(Desc.SampleMask) | ||
| 208 | , CachedPSO(Desc.CachedPSO) | ||
| 209 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 210 | , SerializedRootSignature(CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT())) | ||
| 211 | { | ||
| 212 | } | ||
| 213 | CD3DX12_PIPELINE_STATE_STREAM6(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 214 | : Flags(Desc.Flags) | ||
| 215 | , NodeMask(Desc.NodeMask) | ||
| 216 | , pRootSignature(Desc.pRootSignature) | ||
| 217 | , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) | ||
| 218 | , CachedPSO(Desc.CachedPSO) | ||
| 219 | , SerializedRootSignature(CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT())) | ||
| 220 | { | ||
| 221 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(DepthStencilState).DepthEnable = false; | ||
| 222 | } | ||
| 223 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 224 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 225 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 226 | CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; | ||
| 227 | CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; | ||
| 228 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 229 | CD3DX12_PIPELINE_STATE_STREAM_VS VS; | ||
| 230 | CD3DX12_PIPELINE_STATE_STREAM_GS GS; | ||
| 231 | CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; | ||
| 232 | CD3DX12_PIPELINE_STATE_STREAM_HS HS; | ||
| 233 | CD3DX12_PIPELINE_STATE_STREAM_DS DS; | ||
| 234 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 235 | CD3DX12_PIPELINE_STATE_STREAM_AS AS; | ||
| 236 | CD3DX12_PIPELINE_STATE_STREAM_MS MS; | ||
| 237 | CD3DX12_PIPELINE_STATE_STREAM_CS CS; | ||
| 238 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 239 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 DepthStencilState; | ||
| 240 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 241 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER2 RasterizerState; | ||
| 242 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 243 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 244 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 245 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 246 | CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; | ||
| 247 | CD3DX12_PIPELINE_STATE_STREAM_SERIALIZED_ROOT_SIGNATURE SerializedRootSignature; | ||
| 248 | |||
| 249 | D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept | ||
| 250 | { | ||
| 251 | D3D12_GRAPHICS_PIPELINE_STATE_DESC D; | ||
| 252 | D.Flags = this->Flags; | ||
| 253 | D.NodeMask = this->NodeMask; | ||
| 254 | D.pRootSignature = this->pRootSignature; | ||
| 255 | D.InputLayout = this->InputLayout; | ||
| 256 | D.IBStripCutValue = this->IBStripCutValue; | ||
| 257 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 258 | D.VS = this->VS; | ||
| 259 | D.GS = this->GS; | ||
| 260 | D.StreamOutput = this->StreamOutput; | ||
| 261 | D.HS = this->HS; | ||
| 262 | D.DS = this->DS; | ||
| 263 | D.PS = this->PS; | ||
| 264 | D.BlendState = this->BlendState; | ||
| 265 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(D3D12_DEPTH_STENCIL_DESC2(this->DepthStencilState)); | ||
| 266 | D.DSVFormat = this->DSVFormat; | ||
| 267 | D.RasterizerState = CD3DX12_RASTERIZER_DESC2(D3D12_RASTERIZER_DESC2(this->RasterizerState)); | ||
| 268 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 269 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 270 | D.SampleDesc = this->SampleDesc; | ||
| 271 | D.SampleMask = this->SampleMask; | ||
| 272 | D.CachedPSO = this->CachedPSO; | ||
| 273 | return D; | ||
| 274 | } | ||
| 275 | D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept | ||
| 276 | { | ||
| 277 | D3D12_COMPUTE_PIPELINE_STATE_DESC D; | ||
| 278 | D.Flags = this->Flags; | ||
| 279 | D.NodeMask = this->NodeMask; | ||
| 280 | D.pRootSignature = this->pRootSignature; | ||
| 281 | D.CS = this->CS; | ||
| 282 | D.CachedPSO = this->CachedPSO; | ||
| 283 | return D; | ||
| 284 | } | ||
| 285 | }; | ||
| 286 | #endif | ||
| 287 | |||
| 288 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 289 | // Use CD3DX12_PIPELINE_STATE_STREAM5 for D3D12_RASTERIZER_DESC2 when CheckFeatureSupport returns true for Options19::RasterizerDesc2Supported is true | ||
| 290 | // Use CD3DX12_PIPELINE_STATE_STREAM4 for D3D12_RASTERIZER_DESC1 when CheckFeatureSupport returns true for Options16::DynamicDepthBiasSupported is true | ||
| 291 | // Use CD3DX12_PIPELINE_STATE_STREAM3 for D3D12_DEPTH_STENCIL_DESC2 when CheckFeatureSupport returns true for Options14::IndependentFrontAndBackStencilSupported is true | ||
| 292 | // Use CD3DX12_PIPELINE_STATE_STREAM2 for OS Build 19041+ (where there is a new mesh shader pipeline). | ||
| 293 | // Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject). | ||
| 294 | // Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. | ||
| 295 | struct CD3DX12_PIPELINE_STATE_STREAM5 | ||
| 296 | { | ||
| 297 | CD3DX12_PIPELINE_STATE_STREAM5() = default; | ||
| 298 | // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC | ||
| 299 | CD3DX12_PIPELINE_STATE_STREAM5(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 300 | : Flags(Desc.Flags) | ||
| 301 | , NodeMask(Desc.NodeMask) | ||
| 302 | , pRootSignature(Desc.pRootSignature) | ||
| 303 | , InputLayout(Desc.InputLayout) | ||
| 304 | , IBStripCutValue(Desc.IBStripCutValue) | ||
| 305 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 306 | , VS(Desc.VS) | ||
| 307 | , GS(Desc.GS) | ||
| 308 | , StreamOutput(Desc.StreamOutput) | ||
| 309 | , HS(Desc.HS) | ||
| 310 | , DS(Desc.DS) | ||
| 311 | , PS(Desc.PS) | ||
| 312 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 313 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 314 | , DSVFormat(Desc.DSVFormat) | ||
| 315 | , RasterizerState(CD3DX12_RASTERIZER_DESC2(Desc.RasterizerState)) | ||
| 316 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 317 | , SampleDesc(Desc.SampleDesc) | ||
| 318 | , SampleMask(Desc.SampleMask) | ||
| 319 | , CachedPSO(Desc.CachedPSO) | ||
| 320 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 321 | {} | ||
| 322 | CD3DX12_PIPELINE_STATE_STREAM5(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 323 | : Flags(Desc.Flags) | ||
| 324 | , NodeMask(Desc.NodeMask) | ||
| 325 | , pRootSignature(Desc.pRootSignature) | ||
| 326 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 327 | , PS(Desc.PS) | ||
| 328 | , AS(Desc.AS) | ||
| 329 | , MS(Desc.MS) | ||
| 330 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 331 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 332 | , DSVFormat(Desc.DSVFormat) | ||
| 333 | , RasterizerState(CD3DX12_RASTERIZER_DESC2(Desc.RasterizerState)) | ||
| 334 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 335 | , SampleDesc(Desc.SampleDesc) | ||
| 336 | , SampleMask(Desc.SampleMask) | ||
| 337 | , CachedPSO(Desc.CachedPSO) | ||
| 338 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 339 | {} | ||
| 340 | CD3DX12_PIPELINE_STATE_STREAM5(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 341 | : Flags(Desc.Flags) | ||
| 342 | , NodeMask(Desc.NodeMask) | ||
| 343 | , pRootSignature(Desc.pRootSignature) | ||
| 344 | , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) | ||
| 345 | , CachedPSO(Desc.CachedPSO) | ||
| 346 | { | ||
| 347 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(DepthStencilState).DepthEnable = false; | ||
| 348 | } | ||
| 349 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 350 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 351 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 352 | CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; | ||
| 353 | CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; | ||
| 354 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 355 | CD3DX12_PIPELINE_STATE_STREAM_VS VS; | ||
| 356 | CD3DX12_PIPELINE_STATE_STREAM_GS GS; | ||
| 357 | CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; | ||
| 358 | CD3DX12_PIPELINE_STATE_STREAM_HS HS; | ||
| 359 | CD3DX12_PIPELINE_STATE_STREAM_DS DS; | ||
| 360 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 361 | CD3DX12_PIPELINE_STATE_STREAM_AS AS; | ||
| 362 | CD3DX12_PIPELINE_STATE_STREAM_MS MS; | ||
| 363 | CD3DX12_PIPELINE_STATE_STREAM_CS CS; | ||
| 364 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 365 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 DepthStencilState; | ||
| 366 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 367 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER2 RasterizerState; | ||
| 368 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 369 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 370 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 371 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 372 | CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; | ||
| 373 | |||
| 374 | D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept | ||
| 375 | { | ||
| 376 | D3D12_GRAPHICS_PIPELINE_STATE_DESC D; | ||
| 377 | D.Flags = this->Flags; | ||
| 378 | D.NodeMask = this->NodeMask; | ||
| 379 | D.pRootSignature = this->pRootSignature; | ||
| 380 | D.InputLayout = this->InputLayout; | ||
| 381 | D.IBStripCutValue = this->IBStripCutValue; | ||
| 382 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 383 | D.VS = this->VS; | ||
| 384 | D.GS = this->GS; | ||
| 385 | D.StreamOutput = this->StreamOutput; | ||
| 386 | D.HS = this->HS; | ||
| 387 | D.DS = this->DS; | ||
| 388 | D.PS = this->PS; | ||
| 389 | D.BlendState = this->BlendState; | ||
| 390 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(D3D12_DEPTH_STENCIL_DESC2(this->DepthStencilState)); | ||
| 391 | D.DSVFormat = this->DSVFormat; | ||
| 392 | D.RasterizerState = CD3DX12_RASTERIZER_DESC2(D3D12_RASTERIZER_DESC2(this->RasterizerState)); | ||
| 393 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 394 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 395 | D.SampleDesc = this->SampleDesc; | ||
| 396 | D.SampleMask = this->SampleMask; | ||
| 397 | D.CachedPSO = this->CachedPSO; | ||
| 398 | return D; | ||
| 399 | } | ||
| 400 | D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept | ||
| 401 | { | ||
| 402 | D3D12_COMPUTE_PIPELINE_STATE_DESC D; | ||
| 403 | D.Flags = this->Flags; | ||
| 404 | D.NodeMask = this->NodeMask; | ||
| 405 | D.pRootSignature = this->pRootSignature; | ||
| 406 | D.CS = this->CS; | ||
| 407 | D.CachedPSO = this->CachedPSO; | ||
| 408 | return D; | ||
| 409 | } | ||
| 410 | }; | ||
| 411 | #endif // D3D12_SDK_VERSION >= 610 | ||
| 412 | |||
| 413 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 414 | // Use CD3DX12_PIPELINE_STATE_STREAM4 for D3D12_RASTERIZER_DESC1 when CheckFeatureSupport returns true for Options16::DynamicDepthBiasSupported is true | ||
| 415 | // Use CD3DX12_PIPELINE_STATE_STREAM3 for D3D12_DEPTH_STENCIL_DESC2 when CheckFeatureSupport returns true for Options14::IndependentFrontAndBackStencilSupported is true | ||
| 416 | // Use CD3DX12_PIPELINE_STATE_STREAM2 for OS Build 19041+ (where there is a new mesh shader pipeline). | ||
| 417 | // Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject). | ||
| 418 | // Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. | ||
| 419 | struct CD3DX12_PIPELINE_STATE_STREAM4 | ||
| 420 | { | ||
| 421 | CD3DX12_PIPELINE_STATE_STREAM4() = default; | ||
| 422 | // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC | ||
| 423 | CD3DX12_PIPELINE_STATE_STREAM4(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 424 | : Flags(Desc.Flags) | ||
| 425 | , NodeMask(Desc.NodeMask) | ||
| 426 | , pRootSignature(Desc.pRootSignature) | ||
| 427 | , InputLayout(Desc.InputLayout) | ||
| 428 | , IBStripCutValue(Desc.IBStripCutValue) | ||
| 429 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 430 | , VS(Desc.VS) | ||
| 431 | , GS(Desc.GS) | ||
| 432 | , StreamOutput(Desc.StreamOutput) | ||
| 433 | , HS(Desc.HS) | ||
| 434 | , DS(Desc.DS) | ||
| 435 | , PS(Desc.PS) | ||
| 436 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 437 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 438 | , DSVFormat(Desc.DSVFormat) | ||
| 439 | , RasterizerState(CD3DX12_RASTERIZER_DESC1(Desc.RasterizerState)) | ||
| 440 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 441 | , SampleDesc(Desc.SampleDesc) | ||
| 442 | , SampleMask(Desc.SampleMask) | ||
| 443 | , CachedPSO(Desc.CachedPSO) | ||
| 444 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 445 | {} | ||
| 446 | CD3DX12_PIPELINE_STATE_STREAM4(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 447 | : Flags(Desc.Flags) | ||
| 448 | , NodeMask(Desc.NodeMask) | ||
| 449 | , pRootSignature(Desc.pRootSignature) | ||
| 450 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 451 | , PS(Desc.PS) | ||
| 452 | , AS(Desc.AS) | ||
| 453 | , MS(Desc.MS) | ||
| 454 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 455 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 456 | , DSVFormat(Desc.DSVFormat) | ||
| 457 | , RasterizerState(CD3DX12_RASTERIZER_DESC1(Desc.RasterizerState)) | ||
| 458 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 459 | , SampleDesc(Desc.SampleDesc) | ||
| 460 | , SampleMask(Desc.SampleMask) | ||
| 461 | , CachedPSO(Desc.CachedPSO) | ||
| 462 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 463 | {} | ||
| 464 | CD3DX12_PIPELINE_STATE_STREAM4(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 465 | : Flags(Desc.Flags) | ||
| 466 | , NodeMask(Desc.NodeMask) | ||
| 467 | , pRootSignature(Desc.pRootSignature) | ||
| 468 | , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) | ||
| 469 | , CachedPSO(Desc.CachedPSO) | ||
| 470 | { | ||
| 471 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(DepthStencilState).DepthEnable = false; | ||
| 472 | } | ||
| 473 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 474 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 475 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 476 | CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; | ||
| 477 | CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; | ||
| 478 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 479 | CD3DX12_PIPELINE_STATE_STREAM_VS VS; | ||
| 480 | CD3DX12_PIPELINE_STATE_STREAM_GS GS; | ||
| 481 | CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; | ||
| 482 | CD3DX12_PIPELINE_STATE_STREAM_HS HS; | ||
| 483 | CD3DX12_PIPELINE_STATE_STREAM_DS DS; | ||
| 484 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 485 | CD3DX12_PIPELINE_STATE_STREAM_AS AS; | ||
| 486 | CD3DX12_PIPELINE_STATE_STREAM_MS MS; | ||
| 487 | CD3DX12_PIPELINE_STATE_STREAM_CS CS; | ||
| 488 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 489 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 DepthStencilState; | ||
| 490 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 491 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER1 RasterizerState; | ||
| 492 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 493 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 494 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 495 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 496 | CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; | ||
| 497 | |||
| 498 | D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept | ||
| 499 | { | ||
| 500 | D3D12_GRAPHICS_PIPELINE_STATE_DESC D; | ||
| 501 | D.Flags = this->Flags; | ||
| 502 | D.NodeMask = this->NodeMask; | ||
| 503 | D.pRootSignature = this->pRootSignature; | ||
| 504 | D.InputLayout = this->InputLayout; | ||
| 505 | D.IBStripCutValue = this->IBStripCutValue; | ||
| 506 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 507 | D.VS = this->VS; | ||
| 508 | D.GS = this->GS; | ||
| 509 | D.StreamOutput = this->StreamOutput; | ||
| 510 | D.HS = this->HS; | ||
| 511 | D.DS = this->DS; | ||
| 512 | D.PS = this->PS; | ||
| 513 | D.BlendState = this->BlendState; | ||
| 514 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(D3D12_DEPTH_STENCIL_DESC2(this->DepthStencilState)); | ||
| 515 | D.DSVFormat = this->DSVFormat; | ||
| 516 | D.RasterizerState = CD3DX12_RASTERIZER_DESC1(D3D12_RASTERIZER_DESC1(this->RasterizerState)); | ||
| 517 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 518 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 519 | D.SampleDesc = this->SampleDesc; | ||
| 520 | D.SampleMask = this->SampleMask; | ||
| 521 | D.CachedPSO = this->CachedPSO; | ||
| 522 | return D; | ||
| 523 | } | ||
| 524 | D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept | ||
| 525 | { | ||
| 526 | D3D12_COMPUTE_PIPELINE_STATE_DESC D; | ||
| 527 | D.Flags = this->Flags; | ||
| 528 | D.NodeMask = this->NodeMask; | ||
| 529 | D.pRootSignature = this->pRootSignature; | ||
| 530 | D.CS = this->CS; | ||
| 531 | D.CachedPSO = this->CachedPSO; | ||
| 532 | return D; | ||
| 533 | } | ||
| 534 | }; | ||
| 535 | #endif // D3D12_SDK_VERSION >= 608 | ||
| 536 | |||
| 537 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 538 | // Use CD3DX12_PIPELINE_STATE_STREAM3 for D3D12_DEPTH_STENCIL_DESC2 when CheckFeatureSupport returns true for Options14::IndependentFrontAndBackStencilSupported is true | ||
| 539 | // Use CD3DX12_PIPELINE_STATE_STREAM2 for OS Build 19041+ (where there is a new mesh shader pipeline). | ||
| 540 | // Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject). | ||
| 541 | // Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. | ||
| 542 | struct CD3DX12_PIPELINE_STATE_STREAM3 | ||
| 543 | { | ||
| 544 | CD3DX12_PIPELINE_STATE_STREAM3() = default; | ||
| 545 | // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC | ||
| 546 | CD3DX12_PIPELINE_STATE_STREAM3(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 547 | : Flags(Desc.Flags) | ||
| 548 | , NodeMask(Desc.NodeMask) | ||
| 549 | , pRootSignature(Desc.pRootSignature) | ||
| 550 | , InputLayout(Desc.InputLayout) | ||
| 551 | , IBStripCutValue(Desc.IBStripCutValue) | ||
| 552 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 553 | , VS(Desc.VS) | ||
| 554 | , GS(Desc.GS) | ||
| 555 | , StreamOutput(Desc.StreamOutput) | ||
| 556 | , HS(Desc.HS) | ||
| 557 | , DS(Desc.DS) | ||
| 558 | , PS(Desc.PS) | ||
| 559 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 560 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 561 | , DSVFormat(Desc.DSVFormat) | ||
| 562 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 563 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 564 | , SampleDesc(Desc.SampleDesc) | ||
| 565 | , SampleMask(Desc.SampleMask) | ||
| 566 | , CachedPSO(Desc.CachedPSO) | ||
| 567 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 568 | {} | ||
| 569 | CD3DX12_PIPELINE_STATE_STREAM3(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 570 | : Flags(Desc.Flags) | ||
| 571 | , NodeMask(Desc.NodeMask) | ||
| 572 | , pRootSignature(Desc.pRootSignature) | ||
| 573 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 574 | , PS(Desc.PS) | ||
| 575 | , AS(Desc.AS) | ||
| 576 | , MS(Desc.MS) | ||
| 577 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 578 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC2(Desc.DepthStencilState)) | ||
| 579 | , DSVFormat(Desc.DSVFormat) | ||
| 580 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 581 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 582 | , SampleDesc(Desc.SampleDesc) | ||
| 583 | , SampleMask(Desc.SampleMask) | ||
| 584 | , CachedPSO(Desc.CachedPSO) | ||
| 585 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 586 | {} | ||
| 587 | CD3DX12_PIPELINE_STATE_STREAM3(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 588 | : Flags(Desc.Flags) | ||
| 589 | , NodeMask(Desc.NodeMask) | ||
| 590 | , pRootSignature(Desc.pRootSignature) | ||
| 591 | , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) | ||
| 592 | , CachedPSO(Desc.CachedPSO) | ||
| 593 | { | ||
| 594 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(DepthStencilState).DepthEnable = false; | ||
| 595 | } | ||
| 596 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 597 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 598 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 599 | CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; | ||
| 600 | CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; | ||
| 601 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 602 | CD3DX12_PIPELINE_STATE_STREAM_VS VS; | ||
| 603 | CD3DX12_PIPELINE_STATE_STREAM_GS GS; | ||
| 604 | CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; | ||
| 605 | CD3DX12_PIPELINE_STATE_STREAM_HS HS; | ||
| 606 | CD3DX12_PIPELINE_STATE_STREAM_DS DS; | ||
| 607 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 608 | CD3DX12_PIPELINE_STATE_STREAM_AS AS; | ||
| 609 | CD3DX12_PIPELINE_STATE_STREAM_MS MS; | ||
| 610 | CD3DX12_PIPELINE_STATE_STREAM_CS CS; | ||
| 611 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 612 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 DepthStencilState; | ||
| 613 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 614 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; | ||
| 615 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 616 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 617 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 618 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 619 | CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; | ||
| 620 | |||
| 621 | D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept | ||
| 622 | { | ||
| 623 | D3D12_GRAPHICS_PIPELINE_STATE_DESC D; | ||
| 624 | D.Flags = this->Flags; | ||
| 625 | D.NodeMask = this->NodeMask; | ||
| 626 | D.pRootSignature = this->pRootSignature; | ||
| 627 | D.InputLayout = this->InputLayout; | ||
| 628 | D.IBStripCutValue = this->IBStripCutValue; | ||
| 629 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 630 | D.VS = this->VS; | ||
| 631 | D.GS = this->GS; | ||
| 632 | D.StreamOutput = this->StreamOutput; | ||
| 633 | D.HS = this->HS; | ||
| 634 | D.DS = this->DS; | ||
| 635 | D.PS = this->PS; | ||
| 636 | D.BlendState = this->BlendState; | ||
| 637 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(D3D12_DEPTH_STENCIL_DESC2(this->DepthStencilState)); | ||
| 638 | D.DSVFormat = this->DSVFormat; | ||
| 639 | D.RasterizerState = this->RasterizerState; | ||
| 640 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 641 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 642 | D.SampleDesc = this->SampleDesc; | ||
| 643 | D.SampleMask = this->SampleMask; | ||
| 644 | D.CachedPSO = this->CachedPSO; | ||
| 645 | return D; | ||
| 646 | } | ||
| 647 | D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept | ||
| 648 | { | ||
| 649 | D3D12_COMPUTE_PIPELINE_STATE_DESC D; | ||
| 650 | D.Flags = this->Flags; | ||
| 651 | D.NodeMask = this->NodeMask; | ||
| 652 | D.pRootSignature = this->pRootSignature; | ||
| 653 | D.CS = this->CS; | ||
| 654 | D.CachedPSO = this->CachedPSO; | ||
| 655 | return D; | ||
| 656 | } | ||
| 657 | }; | ||
| 658 | #endif // D3D12_SDK_VERSION >= 606 | ||
| 659 | |||
| 660 | // CD3DX12_PIPELINE_STATE_STREAM2 Works on OS Build 19041+ (where there is a new mesh shader pipeline). | ||
| 661 | // Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject). | ||
| 662 | // Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. | ||
| 663 | struct CD3DX12_PIPELINE_STATE_STREAM2 | ||
| 664 | { | ||
| 665 | CD3DX12_PIPELINE_STATE_STREAM2() = default; | ||
| 666 | // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC | ||
| 667 | CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 668 | : Flags(Desc.Flags) | ||
| 669 | , NodeMask(Desc.NodeMask) | ||
| 670 | , pRootSignature(Desc.pRootSignature) | ||
| 671 | , InputLayout(Desc.InputLayout) | ||
| 672 | , IBStripCutValue(Desc.IBStripCutValue) | ||
| 673 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 674 | , VS(Desc.VS) | ||
| 675 | , GS(Desc.GS) | ||
| 676 | , StreamOutput(Desc.StreamOutput) | ||
| 677 | , HS(Desc.HS) | ||
| 678 | , DS(Desc.DS) | ||
| 679 | , PS(Desc.PS) | ||
| 680 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 681 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) | ||
| 682 | , DSVFormat(Desc.DSVFormat) | ||
| 683 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 684 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 685 | , SampleDesc(Desc.SampleDesc) | ||
| 686 | , SampleMask(Desc.SampleMask) | ||
| 687 | , CachedPSO(Desc.CachedPSO) | ||
| 688 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 689 | {} | ||
| 690 | CD3DX12_PIPELINE_STATE_STREAM2(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 691 | : Flags(Desc.Flags) | ||
| 692 | , NodeMask(Desc.NodeMask) | ||
| 693 | , pRootSignature(Desc.pRootSignature) | ||
| 694 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 695 | , PS(Desc.PS) | ||
| 696 | , AS(Desc.AS) | ||
| 697 | , MS(Desc.MS) | ||
| 698 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 699 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) | ||
| 700 | , DSVFormat(Desc.DSVFormat) | ||
| 701 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 702 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 703 | , SampleDesc(Desc.SampleDesc) | ||
| 704 | , SampleMask(Desc.SampleMask) | ||
| 705 | , CachedPSO(Desc.CachedPSO) | ||
| 706 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 707 | {} | ||
| 708 | CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 709 | : Flags(Desc.Flags) | ||
| 710 | , NodeMask(Desc.NodeMask) | ||
| 711 | , pRootSignature(Desc.pRootSignature) | ||
| 712 | , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) | ||
| 713 | , CachedPSO(Desc.CachedPSO) | ||
| 714 | { | ||
| 715 | static_cast<D3D12_DEPTH_STENCIL_DESC1&>(DepthStencilState).DepthEnable = false; | ||
| 716 | } | ||
| 717 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 718 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 719 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 720 | CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; | ||
| 721 | CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; | ||
| 722 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 723 | CD3DX12_PIPELINE_STATE_STREAM_VS VS; | ||
| 724 | CD3DX12_PIPELINE_STATE_STREAM_GS GS; | ||
| 725 | CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; | ||
| 726 | CD3DX12_PIPELINE_STATE_STREAM_HS HS; | ||
| 727 | CD3DX12_PIPELINE_STATE_STREAM_DS DS; | ||
| 728 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 729 | CD3DX12_PIPELINE_STATE_STREAM_AS AS; | ||
| 730 | CD3DX12_PIPELINE_STATE_STREAM_MS MS; | ||
| 731 | CD3DX12_PIPELINE_STATE_STREAM_CS CS; | ||
| 732 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 733 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; | ||
| 734 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 735 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; | ||
| 736 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 737 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 738 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 739 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 740 | CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; | ||
| 741 | D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept | ||
| 742 | { | ||
| 743 | D3D12_GRAPHICS_PIPELINE_STATE_DESC D; | ||
| 744 | D.Flags = this->Flags; | ||
| 745 | D.NodeMask = this->NodeMask; | ||
| 746 | D.pRootSignature = this->pRootSignature; | ||
| 747 | D.InputLayout = this->InputLayout; | ||
| 748 | D.IBStripCutValue = this->IBStripCutValue; | ||
| 749 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 750 | D.VS = this->VS; | ||
| 751 | D.GS = this->GS; | ||
| 752 | D.StreamOutput = this->StreamOutput; | ||
| 753 | D.HS = this->HS; | ||
| 754 | D.DS = this->DS; | ||
| 755 | D.PS = this->PS; | ||
| 756 | D.BlendState = this->BlendState; | ||
| 757 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); | ||
| 758 | D.DSVFormat = this->DSVFormat; | ||
| 759 | D.RasterizerState = this->RasterizerState; | ||
| 760 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 761 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 762 | D.SampleDesc = this->SampleDesc; | ||
| 763 | D.SampleMask = this->SampleMask; | ||
| 764 | D.CachedPSO = this->CachedPSO; | ||
| 765 | return D; | ||
| 766 | } | ||
| 767 | D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept | ||
| 768 | { | ||
| 769 | D3D12_COMPUTE_PIPELINE_STATE_DESC D; | ||
| 770 | D.Flags = this->Flags; | ||
| 771 | D.NodeMask = this->NodeMask; | ||
| 772 | D.pRootSignature = this->pRootSignature; | ||
| 773 | D.CS = this->CS; | ||
| 774 | D.CachedPSO = this->CachedPSO; | ||
| 775 | return D; | ||
| 776 | } | ||
| 777 | }; | ||
| 778 | |||
| 779 | // CD3DX12_PIPELINE_STATE_STREAM1 Works on OS Build 16299+ (where there is a new view instancing subobject). | ||
| 780 | // Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. | ||
| 781 | struct CD3DX12_PIPELINE_STATE_STREAM1 | ||
| 782 | { | ||
| 783 | CD3DX12_PIPELINE_STATE_STREAM1() = default; | ||
| 784 | // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC | ||
| 785 | CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 786 | : Flags(Desc.Flags) | ||
| 787 | , NodeMask(Desc.NodeMask) | ||
| 788 | , pRootSignature(Desc.pRootSignature) | ||
| 789 | , InputLayout(Desc.InputLayout) | ||
| 790 | , IBStripCutValue(Desc.IBStripCutValue) | ||
| 791 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 792 | , VS(Desc.VS) | ||
| 793 | , GS(Desc.GS) | ||
| 794 | , StreamOutput(Desc.StreamOutput) | ||
| 795 | , HS(Desc.HS) | ||
| 796 | , DS(Desc.DS) | ||
| 797 | , PS(Desc.PS) | ||
| 798 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 799 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) | ||
| 800 | , DSVFormat(Desc.DSVFormat) | ||
| 801 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 802 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 803 | , SampleDesc(Desc.SampleDesc) | ||
| 804 | , SampleMask(Desc.SampleMask) | ||
| 805 | , CachedPSO(Desc.CachedPSO) | ||
| 806 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 807 | {} | ||
| 808 | CD3DX12_PIPELINE_STATE_STREAM1(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 809 | : Flags(Desc.Flags) | ||
| 810 | , NodeMask(Desc.NodeMask) | ||
| 811 | , pRootSignature(Desc.pRootSignature) | ||
| 812 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 813 | , PS(Desc.PS) | ||
| 814 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 815 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) | ||
| 816 | , DSVFormat(Desc.DSVFormat) | ||
| 817 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 818 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 819 | , SampleDesc(Desc.SampleDesc) | ||
| 820 | , SampleMask(Desc.SampleMask) | ||
| 821 | , CachedPSO(Desc.CachedPSO) | ||
| 822 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 823 | {} | ||
| 824 | CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 825 | : Flags(Desc.Flags) | ||
| 826 | , NodeMask(Desc.NodeMask) | ||
| 827 | , pRootSignature(Desc.pRootSignature) | ||
| 828 | , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) | ||
| 829 | , CachedPSO(Desc.CachedPSO) | ||
| 830 | { | ||
| 831 | static_cast<D3D12_DEPTH_STENCIL_DESC1&>(DepthStencilState).DepthEnable = false; | ||
| 832 | } | ||
| 833 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 834 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 835 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 836 | CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; | ||
| 837 | CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; | ||
| 838 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 839 | CD3DX12_PIPELINE_STATE_STREAM_VS VS; | ||
| 840 | CD3DX12_PIPELINE_STATE_STREAM_GS GS; | ||
| 841 | CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; | ||
| 842 | CD3DX12_PIPELINE_STATE_STREAM_HS HS; | ||
| 843 | CD3DX12_PIPELINE_STATE_STREAM_DS DS; | ||
| 844 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 845 | CD3DX12_PIPELINE_STATE_STREAM_CS CS; | ||
| 846 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 847 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; | ||
| 848 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 849 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; | ||
| 850 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 851 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 852 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 853 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 854 | CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; | ||
| 855 | D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept | ||
| 856 | { | ||
| 857 | D3D12_GRAPHICS_PIPELINE_STATE_DESC D; | ||
| 858 | D.Flags = this->Flags; | ||
| 859 | D.NodeMask = this->NodeMask; | ||
| 860 | D.pRootSignature = this->pRootSignature; | ||
| 861 | D.InputLayout = this->InputLayout; | ||
| 862 | D.IBStripCutValue = this->IBStripCutValue; | ||
| 863 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 864 | D.VS = this->VS; | ||
| 865 | D.GS = this->GS; | ||
| 866 | D.StreamOutput = this->StreamOutput; | ||
| 867 | D.HS = this->HS; | ||
| 868 | D.DS = this->DS; | ||
| 869 | D.PS = this->PS; | ||
| 870 | D.BlendState = this->BlendState; | ||
| 871 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); | ||
| 872 | D.DSVFormat = this->DSVFormat; | ||
| 873 | D.RasterizerState = this->RasterizerState; | ||
| 874 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 875 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 876 | D.SampleDesc = this->SampleDesc; | ||
| 877 | D.SampleMask = this->SampleMask; | ||
| 878 | D.CachedPSO = this->CachedPSO; | ||
| 879 | return D; | ||
| 880 | } | ||
| 881 | D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept | ||
| 882 | { | ||
| 883 | D3D12_COMPUTE_PIPELINE_STATE_DESC D; | ||
| 884 | D.Flags = this->Flags; | ||
| 885 | D.NodeMask = this->NodeMask; | ||
| 886 | D.pRootSignature = this->pRootSignature; | ||
| 887 | D.CS = this->CS; | ||
| 888 | D.CachedPSO = this->CachedPSO; | ||
| 889 | return D; | ||
| 890 | } | ||
| 891 | }; | ||
| 892 | |||
| 893 | |||
| 894 | struct CD3DX12_PIPELINE_MESH_STATE_STREAM | ||
| 895 | { | ||
| 896 | CD3DX12_PIPELINE_MESH_STATE_STREAM() = default; | ||
| 897 | CD3DX12_PIPELINE_MESH_STATE_STREAM(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 898 | : Flags(Desc.Flags) | ||
| 899 | , NodeMask(Desc.NodeMask) | ||
| 900 | , pRootSignature(Desc.pRootSignature) | ||
| 901 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 902 | , PS(Desc.PS) | ||
| 903 | , AS(Desc.AS) | ||
| 904 | , MS(Desc.MS) | ||
| 905 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 906 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) | ||
| 907 | , DSVFormat(Desc.DSVFormat) | ||
| 908 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 909 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 910 | , SampleDesc(Desc.SampleDesc) | ||
| 911 | , SampleMask(Desc.SampleMask) | ||
| 912 | , CachedPSO(Desc.CachedPSO) | ||
| 913 | , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) | ||
| 914 | {} | ||
| 915 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 916 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 917 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 918 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 919 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 920 | CD3DX12_PIPELINE_STATE_STREAM_AS AS; | ||
| 921 | CD3DX12_PIPELINE_STATE_STREAM_MS MS; | ||
| 922 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 923 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; | ||
| 924 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 925 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; | ||
| 926 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 927 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 928 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 929 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 930 | CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; | ||
| 931 | D3DX12_MESH_SHADER_PIPELINE_STATE_DESC MeshShaderDescV0() const noexcept | ||
| 932 | { | ||
| 933 | D3DX12_MESH_SHADER_PIPELINE_STATE_DESC D; | ||
| 934 | D.Flags = this->Flags; | ||
| 935 | D.NodeMask = this->NodeMask; | ||
| 936 | D.pRootSignature = this->pRootSignature; | ||
| 937 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 938 | D.PS = this->PS; | ||
| 939 | D.AS = this->AS; | ||
| 940 | D.MS = this->MS; | ||
| 941 | D.BlendState = this->BlendState; | ||
| 942 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); | ||
| 943 | D.DSVFormat = this->DSVFormat; | ||
| 944 | D.RasterizerState = this->RasterizerState; | ||
| 945 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 946 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 947 | D.SampleDesc = this->SampleDesc; | ||
| 948 | D.SampleMask = this->SampleMask; | ||
| 949 | D.CachedPSO = this->CachedPSO; | ||
| 950 | return D; | ||
| 951 | } | ||
| 952 | }; | ||
| 953 | |||
| 954 | // CD3DX12_PIPELINE_STATE_STREAM works on OS Build 15063+ but does not support new subobject(s) added in OS Build 16299+. | ||
| 955 | // See CD3DX12_PIPELINE_STATE_STREAM1 for instance. | ||
| 956 | struct CD3DX12_PIPELINE_STATE_STREAM | ||
| 957 | { | ||
| 958 | CD3DX12_PIPELINE_STATE_STREAM() = default; | ||
| 959 | CD3DX12_PIPELINE_STATE_STREAM(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 960 | : Flags(Desc.Flags) | ||
| 961 | , NodeMask(Desc.NodeMask) | ||
| 962 | , pRootSignature(Desc.pRootSignature) | ||
| 963 | , InputLayout(Desc.InputLayout) | ||
| 964 | , IBStripCutValue(Desc.IBStripCutValue) | ||
| 965 | , PrimitiveTopologyType(Desc.PrimitiveTopologyType) | ||
| 966 | , VS(Desc.VS) | ||
| 967 | , GS(Desc.GS) | ||
| 968 | , StreamOutput(Desc.StreamOutput) | ||
| 969 | , HS(Desc.HS) | ||
| 970 | , DS(Desc.DS) | ||
| 971 | , PS(Desc.PS) | ||
| 972 | , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) | ||
| 973 | , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) | ||
| 974 | , DSVFormat(Desc.DSVFormat) | ||
| 975 | , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) | ||
| 976 | , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) | ||
| 977 | , SampleDesc(Desc.SampleDesc) | ||
| 978 | , SampleMask(Desc.SampleMask) | ||
| 979 | , CachedPSO(Desc.CachedPSO) | ||
| 980 | {} | ||
| 981 | CD3DX12_PIPELINE_STATE_STREAM(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept | ||
| 982 | : Flags(Desc.Flags) | ||
| 983 | , NodeMask(Desc.NodeMask) | ||
| 984 | , pRootSignature(Desc.pRootSignature) | ||
| 985 | , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) | ||
| 986 | , CachedPSO(Desc.CachedPSO) | ||
| 987 | {} | ||
| 988 | CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; | ||
| 989 | CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; | ||
| 990 | CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; | ||
| 991 | CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; | ||
| 992 | CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; | ||
| 993 | CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; | ||
| 994 | CD3DX12_PIPELINE_STATE_STREAM_VS VS; | ||
| 995 | CD3DX12_PIPELINE_STATE_STREAM_GS GS; | ||
| 996 | CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; | ||
| 997 | CD3DX12_PIPELINE_STATE_STREAM_HS HS; | ||
| 998 | CD3DX12_PIPELINE_STATE_STREAM_DS DS; | ||
| 999 | CD3DX12_PIPELINE_STATE_STREAM_PS PS; | ||
| 1000 | CD3DX12_PIPELINE_STATE_STREAM_CS CS; | ||
| 1001 | CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; | ||
| 1002 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; | ||
| 1003 | CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; | ||
| 1004 | CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; | ||
| 1005 | CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; | ||
| 1006 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; | ||
| 1007 | CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; | ||
| 1008 | CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; | ||
| 1009 | D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept | ||
| 1010 | { | ||
| 1011 | D3D12_GRAPHICS_PIPELINE_STATE_DESC D; | ||
| 1012 | D.Flags = this->Flags; | ||
| 1013 | D.NodeMask = this->NodeMask; | ||
| 1014 | D.pRootSignature = this->pRootSignature; | ||
| 1015 | D.InputLayout = this->InputLayout; | ||
| 1016 | D.IBStripCutValue = this->IBStripCutValue; | ||
| 1017 | D.PrimitiveTopologyType = this->PrimitiveTopologyType; | ||
| 1018 | D.VS = this->VS; | ||
| 1019 | D.GS = this->GS; | ||
| 1020 | D.StreamOutput = this->StreamOutput; | ||
| 1021 | D.HS = this->HS; | ||
| 1022 | D.DS = this->DS; | ||
| 1023 | D.PS = this->PS; | ||
| 1024 | D.BlendState = this->BlendState; | ||
| 1025 | D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); | ||
| 1026 | D.DSVFormat = this->DSVFormat; | ||
| 1027 | D.RasterizerState = this->RasterizerState; | ||
| 1028 | D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; | ||
| 1029 | memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); | ||
| 1030 | D.SampleDesc = this->SampleDesc; | ||
| 1031 | D.SampleMask = this->SampleMask; | ||
| 1032 | D.CachedPSO = this->CachedPSO; | ||
| 1033 | return D; | ||
| 1034 | } | ||
| 1035 | D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept | ||
| 1036 | { | ||
| 1037 | D3D12_COMPUTE_PIPELINE_STATE_DESC D; | ||
| 1038 | D.Flags = this->Flags; | ||
| 1039 | D.NodeMask = this->NodeMask; | ||
| 1040 | D.pRootSignature = this->pRootSignature; | ||
| 1041 | D.CS = this->CS; | ||
| 1042 | D.CachedPSO = this->CachedPSO; | ||
| 1043 | return D; | ||
| 1044 | } | ||
| 1045 | }; | ||
| 1046 | |||
| 1047 | |||
| 1048 | struct CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER : public ID3DX12PipelineParserCallbacks | ||
| 1049 | { | ||
| 1050 | CD3DX12_PIPELINE_STATE_STREAM2 PipelineStream; | ||
| 1051 | CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER() noexcept | ||
| 1052 | : SeenDSS(false) | ||
| 1053 | { | ||
| 1054 | // Adjust defaults to account for absent members. | ||
| 1055 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; | ||
| 1056 | |||
| 1057 | // Depth disabled if no DSV format specified. | ||
| 1058 | static_cast<D3D12_DEPTH_STENCIL_DESC1&>(PipelineStream.DepthStencilState).DepthEnable = false; | ||
| 1059 | } | ||
| 1060 | |||
| 1061 | // ID3DX12PipelineParserCallbacks | ||
| 1062 | void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} | ||
| 1063 | void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} | ||
| 1064 | void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} | ||
| 1065 | void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} | ||
| 1066 | void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} | ||
| 1067 | void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} | ||
| 1068 | void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} | ||
| 1069 | void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} | ||
| 1070 | void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} | ||
| 1071 | void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} | ||
| 1072 | void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} | ||
| 1073 | void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} | ||
| 1074 | void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} | ||
| 1075 | void ASCb(const D3D12_SHADER_BYTECODE& AS) override {PipelineStream.AS = AS;} | ||
| 1076 | void MSCb(const D3D12_SHADER_BYTECODE& MS) override {PipelineStream.MS = MS;} | ||
| 1077 | void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} | ||
| 1078 | void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override | ||
| 1079 | { | ||
| 1080 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); | ||
| 1081 | SeenDSS = true; | ||
| 1082 | } | ||
| 1083 | void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override | ||
| 1084 | { | ||
| 1085 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); | ||
| 1086 | SeenDSS = true; | ||
| 1087 | } | ||
| 1088 | void DSVFormatCb(DXGI_FORMAT DSVFormat) override | ||
| 1089 | { | ||
| 1090 | PipelineStream.DSVFormat = DSVFormat; | ||
| 1091 | if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) | ||
| 1092 | { | ||
| 1093 | // Re-enable depth for the default state. | ||
| 1094 | static_cast<D3D12_DEPTH_STENCIL_DESC1&>(PipelineStream.DepthStencilState).DepthEnable = true; | ||
| 1095 | } | ||
| 1096 | } | ||
| 1097 | void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} | ||
| 1098 | void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} | ||
| 1099 | void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} | ||
| 1100 | void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} | ||
| 1101 | void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} | ||
| 1102 | void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} | ||
| 1103 | |||
| 1104 | private: | ||
| 1105 | bool SeenDSS; | ||
| 1106 | }; | ||
| 1107 | |||
| 1108 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 1109 | struct CD3DX12_PIPELINE_STATE_STREAM3_PARSE_HELPER : public ID3DX12PipelineParserCallbacks | ||
| 1110 | { | ||
| 1111 | CD3DX12_PIPELINE_STATE_STREAM3 PipelineStream; | ||
| 1112 | CD3DX12_PIPELINE_STATE_STREAM3_PARSE_HELPER() noexcept | ||
| 1113 | : SeenDSS(false) | ||
| 1114 | { | ||
| 1115 | // Adjust defaults to account for absent members. | ||
| 1116 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; | ||
| 1117 | |||
| 1118 | // Depth disabled if no DSV format specified. | ||
| 1119 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = false; | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | // ID3DX12PipelineParserCallbacks | ||
| 1123 | void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override { PipelineStream.Flags = Flags; } | ||
| 1124 | void NodeMaskCb(UINT NodeMask) override { PipelineStream.NodeMask = NodeMask; } | ||
| 1125 | void RootSignatureCb(ID3D12RootSignature* pRootSignature) override { PipelineStream.pRootSignature = pRootSignature; } | ||
| 1126 | void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override { PipelineStream.InputLayout = InputLayout; } | ||
| 1127 | void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override { PipelineStream.IBStripCutValue = IBStripCutValue; } | ||
| 1128 | void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override { PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType; } | ||
| 1129 | void VSCb(const D3D12_SHADER_BYTECODE& VS) override { PipelineStream.VS = VS; } | ||
| 1130 | void GSCb(const D3D12_SHADER_BYTECODE& GS) override { PipelineStream.GS = GS; } | ||
| 1131 | void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override { PipelineStream.StreamOutput = StreamOutput; } | ||
| 1132 | void HSCb(const D3D12_SHADER_BYTECODE& HS) override { PipelineStream.HS = HS; } | ||
| 1133 | void DSCb(const D3D12_SHADER_BYTECODE& DS) override { PipelineStream.DS = DS; } | ||
| 1134 | void PSCb(const D3D12_SHADER_BYTECODE& PS) override { PipelineStream.PS = PS; } | ||
| 1135 | void CSCb(const D3D12_SHADER_BYTECODE& CS) override { PipelineStream.CS = CS; } | ||
| 1136 | void ASCb(const D3D12_SHADER_BYTECODE& AS) override { PipelineStream.AS = AS; } | ||
| 1137 | void MSCb(const D3D12_SHADER_BYTECODE& MS) override { PipelineStream.MS = MS; } | ||
| 1138 | void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override { PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState); } | ||
| 1139 | void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override | ||
| 1140 | { | ||
| 1141 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1142 | SeenDSS = true; | ||
| 1143 | } | ||
| 1144 | void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override | ||
| 1145 | { | ||
| 1146 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1147 | SeenDSS = true; | ||
| 1148 | } | ||
| 1149 | void DepthStencilState2Cb(const D3D12_DEPTH_STENCIL_DESC2& DepthStencilState) override | ||
| 1150 | { | ||
| 1151 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1152 | SeenDSS = true; | ||
| 1153 | } | ||
| 1154 | void DSVFormatCb(DXGI_FORMAT DSVFormat) override | ||
| 1155 | { | ||
| 1156 | PipelineStream.DSVFormat = DSVFormat; | ||
| 1157 | if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) | ||
| 1158 | { | ||
| 1159 | // Re-enable depth for the default state. | ||
| 1160 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = true; | ||
| 1161 | } | ||
| 1162 | } | ||
| 1163 | void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState); } | ||
| 1164 | void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override { PipelineStream.RTVFormats = RTVFormats; } | ||
| 1165 | void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override { PipelineStream.SampleDesc = SampleDesc; } | ||
| 1166 | void SampleMaskCb(UINT SampleMask) override { PipelineStream.SampleMask = SampleMask; } | ||
| 1167 | void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override { PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc); } | ||
| 1168 | void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override { PipelineStream.CachedPSO = CachedPSO; } | ||
| 1169 | |||
| 1170 | private: | ||
| 1171 | bool SeenDSS; | ||
| 1172 | }; | ||
| 1173 | #endif // D3D12_SDK_VERSION >= 606 | ||
| 1174 | |||
| 1175 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 1176 | struct CD3DX12_PIPELINE_STATE_STREAM4_PARSE_HELPER : public ID3DX12PipelineParserCallbacks | ||
| 1177 | { | ||
| 1178 | CD3DX12_PIPELINE_STATE_STREAM4 PipelineStream; | ||
| 1179 | CD3DX12_PIPELINE_STATE_STREAM4_PARSE_HELPER() noexcept | ||
| 1180 | : SeenDSS(false) | ||
| 1181 | { | ||
| 1182 | // Adjust defaults to account for absent members. | ||
| 1183 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; | ||
| 1184 | |||
| 1185 | // Depth disabled if no DSV format specified. | ||
| 1186 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = false; | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | // ID3DX12PipelineParserCallbacks | ||
| 1190 | void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override { PipelineStream.Flags = Flags; } | ||
| 1191 | void NodeMaskCb(UINT NodeMask) override { PipelineStream.NodeMask = NodeMask; } | ||
| 1192 | void RootSignatureCb(ID3D12RootSignature* pRootSignature) override { PipelineStream.pRootSignature = pRootSignature; } | ||
| 1193 | void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override { PipelineStream.InputLayout = InputLayout; } | ||
| 1194 | void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override { PipelineStream.IBStripCutValue = IBStripCutValue; } | ||
| 1195 | void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override { PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType; } | ||
| 1196 | void VSCb(const D3D12_SHADER_BYTECODE& VS) override { PipelineStream.VS = VS; } | ||
| 1197 | void GSCb(const D3D12_SHADER_BYTECODE& GS) override { PipelineStream.GS = GS; } | ||
| 1198 | void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override { PipelineStream.StreamOutput = StreamOutput; } | ||
| 1199 | void HSCb(const D3D12_SHADER_BYTECODE& HS) override { PipelineStream.HS = HS; } | ||
| 1200 | void DSCb(const D3D12_SHADER_BYTECODE& DS) override { PipelineStream.DS = DS; } | ||
| 1201 | void PSCb(const D3D12_SHADER_BYTECODE& PS) override { PipelineStream.PS = PS; } | ||
| 1202 | void CSCb(const D3D12_SHADER_BYTECODE& CS) override { PipelineStream.CS = CS; } | ||
| 1203 | void ASCb(const D3D12_SHADER_BYTECODE& AS) override { PipelineStream.AS = AS; } | ||
| 1204 | void MSCb(const D3D12_SHADER_BYTECODE& MS) override { PipelineStream.MS = MS; } | ||
| 1205 | void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override { PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState); } | ||
| 1206 | void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override | ||
| 1207 | { | ||
| 1208 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1209 | SeenDSS = true; | ||
| 1210 | } | ||
| 1211 | void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override | ||
| 1212 | { | ||
| 1213 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1214 | SeenDSS = true; | ||
| 1215 | } | ||
| 1216 | void DepthStencilState2Cb(const D3D12_DEPTH_STENCIL_DESC2& DepthStencilState) override | ||
| 1217 | { | ||
| 1218 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1219 | SeenDSS = true; | ||
| 1220 | } | ||
| 1221 | void DSVFormatCb(DXGI_FORMAT DSVFormat) override | ||
| 1222 | { | ||
| 1223 | PipelineStream.DSVFormat = DSVFormat; | ||
| 1224 | if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) | ||
| 1225 | { | ||
| 1226 | // Re-enable depth for the default state. | ||
| 1227 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = true; | ||
| 1228 | } | ||
| 1229 | } | ||
| 1230 | void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC1(RasterizerState); } | ||
| 1231 | void RasterizerState1Cb(const D3D12_RASTERIZER_DESC1& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC1(RasterizerState); } | ||
| 1232 | void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override { PipelineStream.RTVFormats = RTVFormats; } | ||
| 1233 | void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override { PipelineStream.SampleDesc = SampleDesc; } | ||
| 1234 | void SampleMaskCb(UINT SampleMask) override { PipelineStream.SampleMask = SampleMask; } | ||
| 1235 | void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override { PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc); } | ||
| 1236 | void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override { PipelineStream.CachedPSO = CachedPSO; } | ||
| 1237 | |||
| 1238 | private: | ||
| 1239 | bool SeenDSS; | ||
| 1240 | }; | ||
| 1241 | #endif // D3D12_SDK_VERSION >= 608 | ||
| 1242 | |||
| 1243 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613) | ||
| 1244 | // This SDK 613 version has better primitive topology default handling than the v610 equivalent below. | ||
| 1245 | struct CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER : public ID3DX12PipelineParserCallbacks | ||
| 1246 | { | ||
| 1247 | CD3DX12_PIPELINE_STATE_STREAM5 PipelineStream; | ||
| 1248 | CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER() noexcept | ||
| 1249 | : SeenDSS(false), | ||
| 1250 | SeenMS(false), | ||
| 1251 | SeenTopology(false) | ||
| 1252 | { | ||
| 1253 | // Adjust defaults to account for absent members. | ||
| 1254 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; | ||
| 1255 | |||
| 1256 | // Depth disabled if no DSV format specified. | ||
| 1257 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = false; | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | // ID3DX12PipelineParserCallbacks | ||
| 1261 | void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override { PipelineStream.Flags = Flags; } | ||
| 1262 | void NodeMaskCb(UINT NodeMask) override { PipelineStream.NodeMask = NodeMask; } | ||
| 1263 | void RootSignatureCb(ID3D12RootSignature* pRootSignature) override { PipelineStream.pRootSignature = pRootSignature; } | ||
| 1264 | void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override { PipelineStream.InputLayout = InputLayout; } | ||
| 1265 | void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override { PipelineStream.IBStripCutValue = IBStripCutValue; } | ||
| 1266 | void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override | ||
| 1267 | { | ||
| 1268 | PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType; | ||
| 1269 | SeenTopology = true; | ||
| 1270 | } | ||
| 1271 | void VSCb(const D3D12_SHADER_BYTECODE& VS) override { PipelineStream.VS = VS; } | ||
| 1272 | void GSCb(const D3D12_SHADER_BYTECODE& GS) override { PipelineStream.GS = GS; } | ||
| 1273 | void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override { PipelineStream.StreamOutput = StreamOutput; } | ||
| 1274 | void HSCb(const D3D12_SHADER_BYTECODE& HS) override { PipelineStream.HS = HS; } | ||
| 1275 | void DSCb(const D3D12_SHADER_BYTECODE& DS) override { PipelineStream.DS = DS; } | ||
| 1276 | void PSCb(const D3D12_SHADER_BYTECODE& PS) override { PipelineStream.PS = PS; } | ||
| 1277 | void CSCb(const D3D12_SHADER_BYTECODE& CS) override { PipelineStream.CS = CS; } | ||
| 1278 | void ASCb(const D3D12_SHADER_BYTECODE& AS) override { PipelineStream.AS = AS; } | ||
| 1279 | void MSCb(const D3D12_SHADER_BYTECODE& MS) override { PipelineStream.MS = MS; SeenMS = true; } | ||
| 1280 | void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override { PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState); } | ||
| 1281 | void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override | ||
| 1282 | { | ||
| 1283 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1284 | SeenDSS = true; | ||
| 1285 | } | ||
| 1286 | void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override | ||
| 1287 | { | ||
| 1288 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1289 | SeenDSS = true; | ||
| 1290 | } | ||
| 1291 | void DepthStencilState2Cb(const D3D12_DEPTH_STENCIL_DESC2& DepthStencilState) override | ||
| 1292 | { | ||
| 1293 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1294 | SeenDSS = true; | ||
| 1295 | } | ||
| 1296 | void DSVFormatCb(DXGI_FORMAT DSVFormat) override {PipelineStream.DSVFormat = DSVFormat;} | ||
| 1297 | void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1298 | void RasterizerState1Cb(const D3D12_RASTERIZER_DESC1& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1299 | void RasterizerState2Cb(const D3D12_RASTERIZER_DESC2& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1300 | void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override { PipelineStream.RTVFormats = RTVFormats; } | ||
| 1301 | void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override { PipelineStream.SampleDesc = SampleDesc; } | ||
| 1302 | void SampleMaskCb(UINT SampleMask) override { PipelineStream.SampleMask = SampleMask; } | ||
| 1303 | void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override { PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc); } | ||
| 1304 | void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override { PipelineStream.CachedPSO = CachedPSO; } | ||
| 1305 | void FinalizeCb() override | ||
| 1306 | { | ||
| 1307 | if (!SeenDSS && PipelineStream.DSVFormat != DXGI_FORMAT_UNKNOWN) | ||
| 1308 | { | ||
| 1309 | // Re-enable depth for the default state. | ||
| 1310 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = true; | ||
| 1311 | } | ||
| 1312 | if (!SeenTopology && SeenMS) | ||
| 1313 | { | ||
| 1314 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED; | ||
| 1315 | } | ||
| 1316 | } | ||
| 1317 | |||
| 1318 | private: | ||
| 1319 | bool SeenDSS; | ||
| 1320 | bool SeenMS; | ||
| 1321 | bool SeenTopology; | ||
| 1322 | }; | ||
| 1323 | #elif defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 1324 | struct CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER : public ID3DX12PipelineParserCallbacks | ||
| 1325 | { | ||
| 1326 | CD3DX12_PIPELINE_STATE_STREAM5 PipelineStream; | ||
| 1327 | CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER() noexcept | ||
| 1328 | : SeenDSS(false) | ||
| 1329 | { | ||
| 1330 | // Adjust defaults to account for absent members. | ||
| 1331 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; | ||
| 1332 | |||
| 1333 | // Depth disabled if no DSV format specified. | ||
| 1334 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = false; | ||
| 1335 | } | ||
| 1336 | |||
| 1337 | // ID3DX12PipelineParserCallbacks | ||
| 1338 | void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override { PipelineStream.Flags = Flags; } | ||
| 1339 | void NodeMaskCb(UINT NodeMask) override { PipelineStream.NodeMask = NodeMask; } | ||
| 1340 | void RootSignatureCb(ID3D12RootSignature* pRootSignature) override { PipelineStream.pRootSignature = pRootSignature; } | ||
| 1341 | void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override { PipelineStream.InputLayout = InputLayout; } | ||
| 1342 | void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override { PipelineStream.IBStripCutValue = IBStripCutValue; } | ||
| 1343 | void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override { PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType; } | ||
| 1344 | void VSCb(const D3D12_SHADER_BYTECODE& VS) override { PipelineStream.VS = VS; } | ||
| 1345 | void GSCb(const D3D12_SHADER_BYTECODE& GS) override { PipelineStream.GS = GS; } | ||
| 1346 | void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override { PipelineStream.StreamOutput = StreamOutput; } | ||
| 1347 | void HSCb(const D3D12_SHADER_BYTECODE& HS) override { PipelineStream.HS = HS; } | ||
| 1348 | void DSCb(const D3D12_SHADER_BYTECODE& DS) override { PipelineStream.DS = DS; } | ||
| 1349 | void PSCb(const D3D12_SHADER_BYTECODE& PS) override { PipelineStream.PS = PS; } | ||
| 1350 | void CSCb(const D3D12_SHADER_BYTECODE& CS) override { PipelineStream.CS = CS; } | ||
| 1351 | void ASCb(const D3D12_SHADER_BYTECODE& AS) override { PipelineStream.AS = AS; } | ||
| 1352 | void MSCb(const D3D12_SHADER_BYTECODE& MS) override { PipelineStream.MS = MS; } | ||
| 1353 | void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override { PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState); } | ||
| 1354 | void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override | ||
| 1355 | { | ||
| 1356 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1357 | SeenDSS = true; | ||
| 1358 | } | ||
| 1359 | void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override | ||
| 1360 | { | ||
| 1361 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1362 | SeenDSS = true; | ||
| 1363 | } | ||
| 1364 | void DepthStencilState2Cb(const D3D12_DEPTH_STENCIL_DESC2& DepthStencilState) override | ||
| 1365 | { | ||
| 1366 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1367 | SeenDSS = true; | ||
| 1368 | } | ||
| 1369 | void DSVFormatCb(DXGI_FORMAT DSVFormat) override | ||
| 1370 | { | ||
| 1371 | PipelineStream.DSVFormat = DSVFormat; | ||
| 1372 | if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) | ||
| 1373 | { | ||
| 1374 | // Re-enable depth for the default state. | ||
| 1375 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = true; | ||
| 1376 | } | ||
| 1377 | } | ||
| 1378 | void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1379 | void RasterizerState1Cb(const D3D12_RASTERIZER_DESC1& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1380 | void RasterizerState2Cb(const D3D12_RASTERIZER_DESC2& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1381 | void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override { PipelineStream.RTVFormats = RTVFormats; } | ||
| 1382 | void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override { PipelineStream.SampleDesc = SampleDesc; } | ||
| 1383 | void SampleMaskCb(UINT SampleMask) override { PipelineStream.SampleMask = SampleMask; } | ||
| 1384 | void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override { PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc); } | ||
| 1385 | void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override { PipelineStream.CachedPSO = CachedPSO; } | ||
| 1386 | |||
| 1387 | private: | ||
| 1388 | bool SeenDSS; | ||
| 1389 | }; | ||
| 1390 | #endif // D3D12_SDK_VERSION >= 610 | ||
| 1391 | |||
| 1392 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 1393 | struct CD3DX12_PIPELINE_STATE_STREAM6_PARSE_HELPER : public ID3DX12PipelineParserCallbacks | ||
| 1394 | { | ||
| 1395 | CD3DX12_PIPELINE_STATE_STREAM6 PipelineStream; | ||
| 1396 | CD3DX12_PIPELINE_STATE_STREAM6_PARSE_HELPER() noexcept | ||
| 1397 | : SeenDSS(false), | ||
| 1398 | SeenMS(false), | ||
| 1399 | SeenTopology(false) | ||
| 1400 | { | ||
| 1401 | // Adjust defaults to account for absent members. | ||
| 1402 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; | ||
| 1403 | |||
| 1404 | // Depth disabled if no DSV format specified. | ||
| 1405 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = false; | ||
| 1406 | } | ||
| 1407 | |||
| 1408 | // ID3DX12PipelineParserCallbacks | ||
| 1409 | void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override { PipelineStream.Flags = Flags; } | ||
| 1410 | void NodeMaskCb(UINT NodeMask) override { PipelineStream.NodeMask = NodeMask; } | ||
| 1411 | void RootSignatureCb(ID3D12RootSignature* pRootSignature) override { PipelineStream.pRootSignature = pRootSignature; } | ||
| 1412 | void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override { PipelineStream.InputLayout = InputLayout; } | ||
| 1413 | void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override { PipelineStream.IBStripCutValue = IBStripCutValue; } | ||
| 1414 | void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override | ||
| 1415 | { | ||
| 1416 | PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType; | ||
| 1417 | SeenTopology = true; | ||
| 1418 | } | ||
| 1419 | void VSCb(const D3D12_SHADER_BYTECODE& VS) override { PipelineStream.VS = VS; } | ||
| 1420 | void GSCb(const D3D12_SHADER_BYTECODE& GS) override { PipelineStream.GS = GS; } | ||
| 1421 | void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override { PipelineStream.StreamOutput = StreamOutput; } | ||
| 1422 | void HSCb(const D3D12_SHADER_BYTECODE& HS) override { PipelineStream.HS = HS; } | ||
| 1423 | void DSCb(const D3D12_SHADER_BYTECODE& DS) override { PipelineStream.DS = DS; } | ||
| 1424 | void PSCb(const D3D12_SHADER_BYTECODE& PS) override { PipelineStream.PS = PS; } | ||
| 1425 | void CSCb(const D3D12_SHADER_BYTECODE& CS) override { PipelineStream.CS = CS; } | ||
| 1426 | void ASCb(const D3D12_SHADER_BYTECODE& AS) override { PipelineStream.AS = AS; } | ||
| 1427 | void MSCb(const D3D12_SHADER_BYTECODE& MS) override { PipelineStream.MS = MS; SeenMS = true; } | ||
| 1428 | void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override { PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState); } | ||
| 1429 | void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override | ||
| 1430 | { | ||
| 1431 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1432 | SeenDSS = true; | ||
| 1433 | } | ||
| 1434 | void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override | ||
| 1435 | { | ||
| 1436 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1437 | SeenDSS = true; | ||
| 1438 | } | ||
| 1439 | void DepthStencilState2Cb(const D3D12_DEPTH_STENCIL_DESC2& DepthStencilState) override | ||
| 1440 | { | ||
| 1441 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2(DepthStencilState); | ||
| 1442 | SeenDSS = true; | ||
| 1443 | } | ||
| 1444 | void DSVFormatCb(DXGI_FORMAT DSVFormat) override { PipelineStream.DSVFormat = DSVFormat; } | ||
| 1445 | void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1446 | void RasterizerState1Cb(const D3D12_RASTERIZER_DESC1& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1447 | void RasterizerState2Cb(const D3D12_RASTERIZER_DESC2& RasterizerState) override { PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC2(RasterizerState); } | ||
| 1448 | void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override { PipelineStream.RTVFormats = RTVFormats; } | ||
| 1449 | void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override { PipelineStream.SampleDesc = SampleDesc; } | ||
| 1450 | void SampleMaskCb(UINT SampleMask) override { PipelineStream.SampleMask = SampleMask; } | ||
| 1451 | void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override { PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc); } | ||
| 1452 | void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override { PipelineStream.CachedPSO = CachedPSO; } | ||
| 1453 | void FinalizeCb() override | ||
| 1454 | { | ||
| 1455 | if (!SeenDSS && PipelineStream.DSVFormat != DXGI_FORMAT_UNKNOWN) | ||
| 1456 | { | ||
| 1457 | // Re-enable depth for the default state. | ||
| 1458 | static_cast<D3D12_DEPTH_STENCIL_DESC2&>(PipelineStream.DepthStencilState).DepthEnable = true; | ||
| 1459 | } | ||
| 1460 | if (!SeenTopology && SeenMS) | ||
| 1461 | { | ||
| 1462 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED; | ||
| 1463 | } | ||
| 1464 | } | ||
| 1465 | void SerializedRootSignatureCb(const D3D12_SERIALIZED_ROOT_SIGNATURE_DESC& SerializedRootSignature) override { PipelineStream.SerializedRootSignature = CD3DX12_SERIALIZED_ROOT_SIGNATURE_DESC(SerializedRootSignature); } | ||
| 1466 | |||
| 1467 | private: | ||
| 1468 | bool SeenDSS; | ||
| 1469 | bool SeenMS; | ||
| 1470 | bool SeenTopology; | ||
| 1471 | }; | ||
| 1472 | #endif // D3D12_SDK_VERSION >= 618 | ||
| 1473 | |||
| 1474 | struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParserCallbacks | ||
| 1475 | { | ||
| 1476 | CD3DX12_PIPELINE_STATE_STREAM1 PipelineStream; | ||
| 1477 | CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER() noexcept | ||
| 1478 | : SeenDSS(false) | ||
| 1479 | { | ||
| 1480 | // Adjust defaults to account for absent members. | ||
| 1481 | PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; | ||
| 1482 | |||
| 1483 | // Depth disabled if no DSV format specified. | ||
| 1484 | static_cast<D3D12_DEPTH_STENCIL_DESC1&>(PipelineStream.DepthStencilState).DepthEnable = false; | ||
| 1485 | } | ||
| 1486 | |||
| 1487 | // ID3DX12PipelineParserCallbacks | ||
| 1488 | void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} | ||
| 1489 | void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} | ||
| 1490 | void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} | ||
| 1491 | void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} | ||
| 1492 | void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} | ||
| 1493 | void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} | ||
| 1494 | void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} | ||
| 1495 | void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} | ||
| 1496 | void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} | ||
| 1497 | void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} | ||
| 1498 | void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} | ||
| 1499 | void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} | ||
| 1500 | void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} | ||
| 1501 | void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} | ||
| 1502 | void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override | ||
| 1503 | { | ||
| 1504 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); | ||
| 1505 | SeenDSS = true; | ||
| 1506 | } | ||
| 1507 | void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override | ||
| 1508 | { | ||
| 1509 | PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); | ||
| 1510 | SeenDSS = true; | ||
| 1511 | } | ||
| 1512 | void DSVFormatCb(DXGI_FORMAT DSVFormat) override | ||
| 1513 | { | ||
| 1514 | PipelineStream.DSVFormat = DSVFormat; | ||
| 1515 | if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) | ||
| 1516 | { | ||
| 1517 | // Re-enable depth for the default state. | ||
| 1518 | static_cast<D3D12_DEPTH_STENCIL_DESC1&>(PipelineStream.DepthStencilState).DepthEnable = true; | ||
| 1519 | } | ||
| 1520 | } | ||
| 1521 | void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} | ||
| 1522 | void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} | ||
| 1523 | void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} | ||
| 1524 | void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} | ||
| 1525 | void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} | ||
| 1526 | void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} | ||
| 1527 | |||
| 1528 | private: | ||
| 1529 | bool SeenDSS; | ||
| 1530 | }; | ||
| 1531 | |||
| 1532 | |||
| 1533 | inline D3D12_PIPELINE_STATE_SUBOBJECT_TYPE D3DX12GetBaseSubobjectType(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubobjectType) noexcept | ||
| 1534 | { | ||
| 1535 | switch (SubobjectType) | ||
| 1536 | { | ||
| 1537 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: | ||
| 1538 | return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL; | ||
| 1539 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 1540 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2: | ||
| 1541 | return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL; | ||
| 1542 | #endif | ||
| 1543 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 1544 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER1: | ||
| 1545 | return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER; | ||
| 1546 | #endif | ||
| 1547 | default: | ||
| 1548 | return SubobjectType; | ||
| 1549 | } | ||
| 1550 | } | ||
| 1551 | |||
| 1552 | inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC& Desc, ID3DX12PipelineParserCallbacks* pCallbacks) | ||
| 1553 | { | ||
| 1554 | if (pCallbacks == nullptr) | ||
| 1555 | { | ||
| 1556 | return E_INVALIDARG; | ||
| 1557 | } | ||
| 1558 | |||
| 1559 | if (Desc.SizeInBytes == 0 || Desc.pPipelineStateSubobjectStream == nullptr) | ||
| 1560 | { | ||
| 1561 | pCallbacks->ErrorBadInputParameter(1); // first parameter issue | ||
| 1562 | return E_INVALIDARG; | ||
| 1563 | } | ||
| 1564 | |||
| 1565 | bool SubobjectSeen[D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID] = {}; | ||
| 1566 | for (SIZE_T CurOffset = 0, SizeOfSubobject = 0; CurOffset < Desc.SizeInBytes; CurOffset += SizeOfSubobject) | ||
| 1567 | { | ||
| 1568 | BYTE* pStream = static_cast<BYTE*>(Desc.pPipelineStateSubobjectStream)+CurOffset; | ||
| 1569 | auto SubobjectType = *reinterpret_cast<D3D12_PIPELINE_STATE_SUBOBJECT_TYPE*>(pStream); | ||
| 1570 | if (SubobjectType < 0 || SubobjectType >= D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID) | ||
| 1571 | { | ||
| 1572 | pCallbacks->ErrorUnknownSubobject(SubobjectType); | ||
| 1573 | return E_INVALIDARG; | ||
| 1574 | } | ||
| 1575 | if (SubobjectSeen[D3DX12GetBaseSubobjectType(SubobjectType)]) | ||
| 1576 | { | ||
| 1577 | pCallbacks->ErrorDuplicateSubobject(SubobjectType); | ||
| 1578 | return E_INVALIDARG; // disallow subobject duplicates in a stream | ||
| 1579 | } | ||
| 1580 | SubobjectSeen[SubobjectType] = true; | ||
| 1581 | switch (SubobjectType) | ||
| 1582 | { | ||
| 1583 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE: | ||
| 1584 | pCallbacks->RootSignatureCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::pRootSignature)*>(pStream)); | ||
| 1585 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::pRootSignature); | ||
| 1586 | break; | ||
| 1587 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS: | ||
| 1588 | pCallbacks->VSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::VS)*>(pStream)); | ||
| 1589 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::VS); | ||
| 1590 | break; | ||
| 1591 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS: | ||
| 1592 | pCallbacks->PSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::PS)*>(pStream)); | ||
| 1593 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PS); | ||
| 1594 | break; | ||
| 1595 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS: | ||
| 1596 | pCallbacks->DSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::DS)*>(pStream)); | ||
| 1597 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DS); | ||
| 1598 | break; | ||
| 1599 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS: | ||
| 1600 | pCallbacks->HSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::HS)*>(pStream)); | ||
| 1601 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::HS); | ||
| 1602 | break; | ||
| 1603 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS: | ||
| 1604 | pCallbacks->GSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::GS)*>(pStream)); | ||
| 1605 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::GS); | ||
| 1606 | break; | ||
| 1607 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS: | ||
| 1608 | pCallbacks->CSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::CS)*>(pStream)); | ||
| 1609 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CS); | ||
| 1610 | break; | ||
| 1611 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS: | ||
| 1612 | pCallbacks->ASCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM2::AS)*>(pStream)); | ||
| 1613 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::AS); | ||
| 1614 | break; | ||
| 1615 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS: | ||
| 1616 | pCallbacks->MSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM2::MS)*>(pStream)); | ||
| 1617 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::MS); | ||
| 1618 | break; | ||
| 1619 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT: | ||
| 1620 | pCallbacks->StreamOutputCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::StreamOutput)*>(pStream)); | ||
| 1621 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::StreamOutput); | ||
| 1622 | break; | ||
| 1623 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND: | ||
| 1624 | pCallbacks->BlendStateCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::BlendState)*>(pStream)); | ||
| 1625 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::BlendState); | ||
| 1626 | break; | ||
| 1627 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK: | ||
| 1628 | pCallbacks->SampleMaskCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::SampleMask)*>(pStream)); | ||
| 1629 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleMask); | ||
| 1630 | break; | ||
| 1631 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER: | ||
| 1632 | pCallbacks->RasterizerStateCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::RasterizerState)*>(pStream)); | ||
| 1633 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RasterizerState); | ||
| 1634 | break; | ||
| 1635 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608) | ||
| 1636 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER1: | ||
| 1637 | pCallbacks->RasterizerState1Cb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM4::RasterizerState)*>(pStream)); | ||
| 1638 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM4::RasterizerState); | ||
| 1639 | break; | ||
| 1640 | #endif | ||
| 1641 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610) | ||
| 1642 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER2: | ||
| 1643 | pCallbacks->RasterizerState2Cb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM5::RasterizerState)*>(pStream)); | ||
| 1644 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM5::RasterizerState); | ||
| 1645 | break; | ||
| 1646 | #endif | ||
| 1647 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL: | ||
| 1648 | pCallbacks->DepthStencilStateCb(*reinterpret_cast<CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL*>(pStream)); | ||
| 1649 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL); | ||
| 1650 | break; | ||
| 1651 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: | ||
| 1652 | pCallbacks->DepthStencilState1Cb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::DepthStencilState)*>(pStream)); | ||
| 1653 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DepthStencilState); | ||
| 1654 | break; | ||
| 1655 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 1656 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2: | ||
| 1657 | pCallbacks->DepthStencilState2Cb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM3::DepthStencilState)*>(pStream)); | ||
| 1658 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM3::DepthStencilState); | ||
| 1659 | break; | ||
| 1660 | #endif | ||
| 1661 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT: | ||
| 1662 | pCallbacks->InputLayoutCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::InputLayout)*>(pStream)); | ||
| 1663 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::InputLayout); | ||
| 1664 | break; | ||
| 1665 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE: | ||
| 1666 | pCallbacks->IBStripCutValueCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::IBStripCutValue)*>(pStream)); | ||
| 1667 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::IBStripCutValue); | ||
| 1668 | break; | ||
| 1669 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY: | ||
| 1670 | pCallbacks->PrimitiveTopologyTypeCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::PrimitiveTopologyType)*>(pStream)); | ||
| 1671 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PrimitiveTopologyType); | ||
| 1672 | break; | ||
| 1673 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS: | ||
| 1674 | pCallbacks->RTVFormatsCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::RTVFormats)*>(pStream)); | ||
| 1675 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RTVFormats); | ||
| 1676 | break; | ||
| 1677 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT: | ||
| 1678 | pCallbacks->DSVFormatCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::DSVFormat)*>(pStream)); | ||
| 1679 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DSVFormat); | ||
| 1680 | break; | ||
| 1681 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC: | ||
| 1682 | pCallbacks->SampleDescCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::SampleDesc)*>(pStream)); | ||
| 1683 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleDesc); | ||
| 1684 | break; | ||
| 1685 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK: | ||
| 1686 | pCallbacks->NodeMaskCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::NodeMask)*>(pStream)); | ||
| 1687 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::NodeMask); | ||
| 1688 | break; | ||
| 1689 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO: | ||
| 1690 | pCallbacks->CachedPSOCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::CachedPSO)*>(pStream)); | ||
| 1691 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CachedPSO); | ||
| 1692 | break; | ||
| 1693 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS: | ||
| 1694 | pCallbacks->FlagsCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::Flags)*>(pStream)); | ||
| 1695 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::Flags); | ||
| 1696 | break; | ||
| 1697 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING: | ||
| 1698 | pCallbacks->ViewInstancingCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM1::ViewInstancingDesc)*>(pStream)); | ||
| 1699 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM1::ViewInstancingDesc); | ||
| 1700 | break; | ||
| 1701 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 1702 | case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SERIALIZED_ROOT_SIGNATURE: | ||
| 1703 | pCallbacks->SerializedRootSignatureCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM6::SerializedRootSignature)*>(pStream)); | ||
| 1704 | SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM6::SerializedRootSignature); | ||
| 1705 | break; | ||
| 1706 | #endif | ||
| 1707 | default: | ||
| 1708 | pCallbacks->ErrorUnknownSubobject(SubobjectType); | ||
| 1709 | return E_INVALIDARG; | ||
| 1710 | } | ||
| 1711 | } | ||
| 1712 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613) | ||
| 1713 | pCallbacks->FinalizeCb(); | ||
| 1714 | #endif | ||
| 1715 | |||
| 1716 | return S_OK; | ||
| 1717 | } | ||
| 1718 | |||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_property_format_table.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_property_format_table.h new file mode 100644 index 0000000..66c7600 --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_property_format_table.h | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | //********************************************************* | ||
| 2 | // | ||
| 3 | // Copyright (c) Microsoft Corporation. | ||
| 4 | // Licensed under the MIT License (MIT). | ||
| 5 | // | ||
| 6 | //********************************************************* | ||
| 7 | #ifndef __D3D12_PROPERTY_LAYOUT_FORMAT_TABLE_H__ | ||
| 8 | #define __D3D12_PROPERTY_LAYOUT_FORMAT_TABLE_H__ | ||
| 9 | #include "d3d12.h" | ||
| 10 | #define MAP_ALIGN_REQUIREMENT 16 // Map is required to return 16-byte aligned addresses | ||
| 11 | |||
| 12 | struct D3D12_PROPERTY_LAYOUT_FORMAT_TABLE | ||
| 13 | { | ||
| 14 | public: | ||
| 15 | // ---------------------------------------------------------------------------- | ||
| 16 | // Information describing everything about a D3D Resource Format | ||
| 17 | // ---------------------------------------------------------------------------- | ||
| 18 | typedef struct FORMAT_DETAIL | ||
| 19 | { | ||
| 20 | DXGI_FORMAT DXGIFormat; | ||
| 21 | DXGI_FORMAT ParentFormat; | ||
| 22 | const DXGI_FORMAT* pDefaultFormatCastSet; // This is dependent on FL/driver version, but is here to save a lot of space | ||
| 23 | UINT8 BitsPerComponent[4]; // only used for D3DFTL_PARTIAL_TYPE or FULL_TYPE | ||
| 24 | UINT8 BitsPerUnit; | ||
| 25 | BYTE SRGBFormat : 1; | ||
| 26 | UINT WidthAlignment : 4; // number of texels to align to in a mip level. | ||
| 27 | UINT HeightAlignment : 4; // Top level dimensions must be a multiple of these | ||
| 28 | UINT DepthAlignment : 1; // values. | ||
| 29 | D3D_FORMAT_LAYOUT Layout : 1; | ||
| 30 | D3D_FORMAT_TYPE_LEVEL TypeLevel : 2; | ||
| 31 | D3D_FORMAT_COMPONENT_NAME ComponentName0 : 3; // RED ... only used for D3DFTL_PARTIAL_TYPE or FULL_TYPE | ||
| 32 | D3D_FORMAT_COMPONENT_NAME ComponentName1 : 3; // GREEN ... only used for D3DFTL_PARTIAL_TYPE or FULL_TYPE | ||
| 33 | D3D_FORMAT_COMPONENT_NAME ComponentName2 : 3; // BLUE ... only used for D3DFTL_PARTIAL_TYPE or FULL_TYPE | ||
| 34 | D3D_FORMAT_COMPONENT_NAME ComponentName3 : 3; // ALPHA ... only used for D3DFTL_PARTIAL_TYPE or FULL_TYPE | ||
| 35 | D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation0 : 3; // only used for D3DFTL_FULL_TYPE | ||
| 36 | D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation1 : 3; // only used for D3DFTL_FULL_TYPE | ||
| 37 | D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation2 : 3; // only used for D3DFTL_FULL_TYPE | ||
| 38 | D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation3 : 3; // only used for D3DFTL_FULL_TYPE | ||
| 39 | bool bDX9VertexOrIndexFormat : 1; | ||
| 40 | bool bDX9TextureFormat : 1; | ||
| 41 | bool bFloatNormFormat : 1; | ||
| 42 | bool bPlanar : 1; | ||
| 43 | bool bYUV : 1; | ||
| 44 | bool bDependantFormatCastSet : 1; // This indicates that the format cast set is dependent on FL/driver version | ||
| 45 | bool bInternal : 1; | ||
| 46 | } FORMAT_DETAIL; | ||
| 47 | |||
| 48 | private: | ||
| 49 | static const FORMAT_DETAIL s_FormatDetail[]; | ||
| 50 | static const UINT s_NumFormats; | ||
| 51 | static const LPCSTR s_FormatNames[]; // separate from above structure so it can be compiled out of runtime. | ||
| 52 | public: | ||
| 53 | static UINT GetNumFormats(); | ||
| 54 | static const FORMAT_DETAIL* GetFormatTable(); | ||
| 55 | static D3D_FEATURE_LEVEL GetHighestDefinedFeatureLevel(); | ||
| 56 | |||
| 57 | static DXGI_FORMAT GetFormat (SIZE_T Index); | ||
| 58 | static bool FormatExists (DXGI_FORMAT Format); | ||
| 59 | static bool FormatExistsInHeader (DXGI_FORMAT Format, bool bExternalHeader = true); | ||
| 60 | static UINT GetByteAlignment (DXGI_FORMAT Format); | ||
| 61 | static bool IsBlockCompressFormat (DXGI_FORMAT Format); | ||
| 62 | static LPCSTR GetName (DXGI_FORMAT Format, bool bHideInternalFormats = true); | ||
| 63 | static bool IsSRGBFormat (DXGI_FORMAT Format); | ||
| 64 | static UINT GetBitsPerStencil (DXGI_FORMAT Format); | ||
| 65 | static UINT GetBitsPerDepth (DXGI_FORMAT Format); | ||
| 66 | static void GetFormatReturnTypes (DXGI_FORMAT Format, D3D_FORMAT_COMPONENT_INTERPRETATION* pInterpretations); // return array of 4 components | ||
| 67 | static UINT GetNumComponentsInFormat(DXGI_FORMAT Format); | ||
| 68 | static UINT GetMinNumComponentsInFormats(DXGI_FORMAT FormatA, DXGI_FORMAT FormatB); | ||
| 69 | |||
| 70 | // Converts the sequential component index (range from 0 to GetNumComponentsInFormat()) to | ||
| 71 | // the absolute component index (range 0 to 3). | ||
| 72 | static UINT Sequential2AbsoluteComponentIndex (DXGI_FORMAT Format, UINT SequentialComponentIndex); | ||
| 73 | static bool CanBeCastEvenFullyTyped (DXGI_FORMAT Format, D3D_FEATURE_LEVEL fl); | ||
| 74 | static UINT8 GetAddressingBitsPerAlignedSize (DXGI_FORMAT Format); | ||
| 75 | static DXGI_FORMAT GetParentFormat (DXGI_FORMAT Format); | ||
| 76 | static const DXGI_FORMAT* GetFormatCastSet (DXGI_FORMAT Format); | ||
| 77 | static D3D_FORMAT_LAYOUT GetLayout (DXGI_FORMAT Format); | ||
| 78 | static D3D_FORMAT_TYPE_LEVEL GetTypeLevel (DXGI_FORMAT Format); | ||
| 79 | static UINT GetBitsPerUnit (DXGI_FORMAT Format); | ||
| 80 | static UINT GetBitsPerUnitThrow (DXGI_FORMAT Format); | ||
| 81 | static UINT GetBitsPerElement (DXGI_FORMAT Format); // Legacy function used to support D3D10on9 only. Do not use. | ||
| 82 | static UINT GetWidthAlignment (DXGI_FORMAT Format); | ||
| 83 | static UINT GetHeightAlignment (DXGI_FORMAT Format); | ||
| 84 | static UINT GetDepthAlignment (DXGI_FORMAT Format); | ||
| 85 | static BOOL Planar (DXGI_FORMAT Format); | ||
| 86 | static BOOL NonOpaquePlanar (DXGI_FORMAT Format); | ||
| 87 | static BOOL YUV (DXGI_FORMAT Format); | ||
| 88 | static BOOL Opaque (DXGI_FORMAT Format); | ||
| 89 | static bool FamilySupportsStencil (DXGI_FORMAT Format); | ||
| 90 | static UINT NonOpaquePlaneCount (DXGI_FORMAT Format); | ||
| 91 | static BOOL DX9VertexOrIndexFormat (DXGI_FORMAT Format); | ||
| 92 | static BOOL DX9TextureFormat (DXGI_FORMAT Format); | ||
| 93 | static BOOL FloatNormTextureFormat (DXGI_FORMAT Format); | ||
| 94 | static bool DepthOnlyFormat (DXGI_FORMAT format); | ||
| 95 | static UINT8 GetPlaneCount (DXGI_FORMAT Format); | ||
| 96 | static bool MotionEstimatorAllowedInputFormat (DXGI_FORMAT Format); | ||
| 97 | static bool SupportsSamplerFeedback (DXGI_FORMAT Format); | ||
| 98 | static bool DecodeHistogramAllowedForOutputFormatSupport(DXGI_FORMAT Format); | ||
| 99 | static UINT8 GetPlaneSliceFromViewFormat (DXGI_FORMAT ResourceFormat, DXGI_FORMAT ViewFormat); | ||
| 100 | static bool FloatAndNotFloatFormats (DXGI_FORMAT FormatA, DXGI_FORMAT FormatB); | ||
| 101 | static bool SNORMAndUNORMFormats (DXGI_FORMAT FormatA, DXGI_FORMAT FormatB); | ||
| 102 | static bool ValidCastToR32UAV (DXGI_FORMAT from, DXGI_FORMAT to); | ||
| 103 | static bool IsSupportedTextureDisplayableFormat (DXGI_FORMAT, bool bMediaFormatOnly); | ||
| 104 | static D3D_FORMAT_COMPONENT_INTERPRETATION GetFormatComponentInterpretation (DXGI_FORMAT Format, UINT AbsoluteComponentIndex); | ||
| 105 | static UINT GetBitsPerComponent (DXGI_FORMAT Format, UINT AbsoluteComponentIndex); | ||
| 106 | static D3D_FORMAT_COMPONENT_NAME GetComponentName (DXGI_FORMAT Format, UINT AbsoluteComponentIndex); | ||
| 107 | static HRESULT CalculateExtraPlanarRows (DXGI_FORMAT format, UINT plane0Height, _Out_ UINT& totalHeight); | ||
| 108 | static HRESULT CalculateMinimumRowMajorRowPitch (DXGI_FORMAT Format, UINT Width, _Out_ UINT& RowPitch); | ||
| 109 | static HRESULT CalculateMinimumRowMajorSlicePitch (DXGI_FORMAT Format, UINT ContextBasedRowPitch, UINT Height, _Out_ UINT& SlicePitch); | ||
| 110 | static void GetYCbCrChromaSubsampling (DXGI_FORMAT Format, _Out_ UINT& HorizontalSubsampling, _Out_ UINT& VerticalSubsampling); | ||
| 111 | |||
| 112 | static HRESULT CalculateResourceSize (UINT width, UINT height, UINT depth, DXGI_FORMAT format, UINT mipLevels, UINT subresources, _Out_ SIZE_T& totalByteSize, _Out_writes_opt_(subresources) D3D12_MEMCPY_DEST* pDst = nullptr); | ||
| 113 | static void GetTileShape (D3D12_TILE_SHAPE* pTileShape, DXGI_FORMAT Format, D3D12_RESOURCE_DIMENSION Dimension, UINT SampleCount); | ||
| 114 | static void Get4KTileShape (D3D12_TILE_SHAPE* pTileShape, DXGI_FORMAT Format, D3D12_RESOURCE_DIMENSION Dimension, UINT SampleCount); | ||
| 115 | static void GetMipDimensions (UINT8 mipSlice, _Inout_ UINT64* pWidth, _Inout_opt_ UINT64* pHeight = nullptr, _Inout_opt_ UINT64* pDepth = nullptr); | ||
| 116 | static void GetPlaneSubsampledSizeAndFormatForCopyableLayout(UINT PlaneSlice, DXGI_FORMAT Format, UINT Width, UINT Height, _Out_ DXGI_FORMAT& PlaneFormat, _Out_ UINT& MinPlanePitchWidth, _Out_ UINT& PlaneWidth, _Out_ UINT& PlaneHeight); | ||
| 117 | |||
| 118 | static UINT GetDetailTableIndex (DXGI_FORMAT Format); | ||
| 119 | static UINT GetDetailTableIndexNoThrow (DXGI_FORMAT Format); | ||
| 120 | static UINT GetDetailTableIndexThrow (DXGI_FORMAT Format); | ||
| 121 | static bool SupportsDepth (DXGI_FORMAT Format); | ||
| 122 | static bool SupportsStencil (DXGI_FORMAT Format); | ||
| 123 | private: | ||
| 124 | static const FORMAT_DETAIL* GetFormatDetail (DXGI_FORMAT Format); | ||
| 125 | |||
| 126 | }; | ||
| 127 | |||
| 128 | #endif \ No newline at end of file | ||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_render_pass.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_render_pass.h new file mode 100644 index 0000000..c88fbdf --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_render_pass.h | |||
| @@ -0,0 +1,105 @@ | |||
| 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 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 16 | inline bool operator==(const D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS& a, const D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS& b) noexcept | ||
| 17 | { | ||
| 18 | return ((a.AdditionalWidth == b.AdditionalWidth) && (a.AdditionalHeight == b.AdditionalHeight)); | ||
| 19 | } | ||
| 20 | |||
| 21 | inline bool operator==(const D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS& a, const D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS& b) noexcept | ||
| 22 | { | ||
| 23 | return ((a.AdditionalWidth == b.AdditionalWidth) && (a.AdditionalHeight == b.AdditionalHeight)); | ||
| 24 | } | ||
| 25 | |||
| 26 | inline bool operator==(const D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS& a, const D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS& b) noexcept | ||
| 27 | { | ||
| 28 | return ((a.AdditionalWidth == b.AdditionalWidth) && (a.AdditionalHeight == b.AdditionalHeight)); | ||
| 29 | } | ||
| 30 | #endif | ||
| 31 | |||
| 32 | inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &b) noexcept | ||
| 33 | { | ||
| 34 | return a.ClearValue == b.ClearValue; | ||
| 35 | } | ||
| 36 | |||
| 37 | inline bool operator==( const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &a, const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &b) noexcept | ||
| 38 | { | ||
| 39 | if (a.pSrcResource != b.pSrcResource) return false; | ||
| 40 | if (a.pDstResource != b.pDstResource) return false; | ||
| 41 | if (a.SubresourceCount != b.SubresourceCount) return false; | ||
| 42 | if (a.Format != b.Format) return false; | ||
| 43 | if (a.ResolveMode != b.ResolveMode) return false; | ||
| 44 | if (a.PreserveResolveSource != b.PreserveResolveSource) return false; | ||
| 45 | return true; | ||
| 46 | } | ||
| 47 | |||
| 48 | inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS &b) noexcept | ||
| 49 | { | ||
| 50 | if (a.Type != b.Type) return false; | ||
| 51 | switch (a.Type) | ||
| 52 | { | ||
| 53 | case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR: | ||
| 54 | if (!(a.Clear == b.Clear)) return false; | ||
| 55 | break; | ||
| 56 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 57 | case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER: | ||
| 58 | case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_SRV: | ||
| 59 | case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_UAV: | ||
| 60 | if (!(a.PreserveLocal == b.PreserveLocal)) return false; | ||
| 61 | break; | ||
| 62 | #endif | ||
| 63 | default: | ||
| 64 | break; | ||
| 65 | } | ||
| 66 | return true; | ||
| 67 | } | ||
| 68 | |||
| 69 | inline bool operator==(const D3D12_RENDER_PASS_ENDING_ACCESS& a, const D3D12_RENDER_PASS_ENDING_ACCESS& b) noexcept | ||
| 70 | { | ||
| 71 | if (a.Type != b.Type) return false; | ||
| 72 | switch (a.Type) | ||
| 73 | { | ||
| 74 | case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE: | ||
| 75 | if (!(a.Resolve == b.Resolve)) return false; | ||
| 76 | break; | ||
| 77 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609) | ||
| 78 | case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER: | ||
| 79 | case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_SRV: | ||
| 80 | case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_UAV: | ||
| 81 | if (!(a.PreserveLocal == b.PreserveLocal)) return false; | ||
| 82 | break; | ||
| 83 | #endif | ||
| 84 | default: | ||
| 85 | break; | ||
| 86 | } | ||
| 87 | return true; | ||
| 88 | } | ||
| 89 | |||
| 90 | inline bool operator==( const D3D12_RENDER_PASS_RENDER_TARGET_DESC &a, const D3D12_RENDER_PASS_RENDER_TARGET_DESC &b) noexcept | ||
| 91 | { | ||
| 92 | if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; | ||
| 93 | if (!(a.BeginningAccess == b.BeginningAccess)) return false; | ||
| 94 | if (!(a.EndingAccess == b.EndingAccess)) return false; | ||
| 95 | return true; | ||
| 96 | } | ||
| 97 | inline bool operator==( const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &a, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &b) noexcept | ||
| 98 | { | ||
| 99 | if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; | ||
| 100 | if (!(a.DepthBeginningAccess == b.DepthBeginningAccess)) return false; | ||
| 101 | if (!(a.StencilBeginningAccess == b.StencilBeginningAccess)) return false; | ||
| 102 | if (!(a.DepthEndingAccess == b.DepthEndingAccess)) return false; | ||
| 103 | if (!(a.StencilEndingAccess == b.StencilEndingAccess)) return false; | ||
| 104 | return true; | ||
| 105 | } | ||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_resource_helpers.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_resource_helpers.h new file mode 100644 index 0000000..5c1c980 --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_resource_helpers.h | |||
| @@ -0,0 +1,612 @@ | |||
| 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 "d3dx12_property_format_table.h" | ||
| 15 | #include "d3d12.h" | ||
| 16 | #include "d3dx12_core.h" | ||
| 17 | //------------------------------------------------------------------------------------------------ | ||
| 18 | template <typename T, typename U, typename V> | ||
| 19 | inline void D3D12DecomposeSubresource( UINT Subresource, UINT MipLevels, UINT ArraySize, _Out_ T& MipSlice, _Out_ U& ArraySlice, _Out_ V& PlaneSlice ) noexcept | ||
| 20 | { | ||
| 21 | MipSlice = static_cast<T>(Subresource % MipLevels); | ||
| 22 | ArraySlice = static_cast<U>((Subresource / MipLevels) % ArraySize); | ||
| 23 | PlaneSlice = static_cast<V>(Subresource / (MipLevels * ArraySize)); | ||
| 24 | } | ||
| 25 | |||
| 26 | //------------------------------------------------------------------------------------------------ | ||
| 27 | // Row-by-row memcpy | ||
| 28 | inline void MemcpySubresource( | ||
| 29 | _In_ const D3D12_MEMCPY_DEST* pDest, | ||
| 30 | _In_ const D3D12_SUBRESOURCE_DATA* pSrc, | ||
| 31 | SIZE_T RowSizeInBytes, | ||
| 32 | UINT NumRows, | ||
| 33 | UINT NumSlices) noexcept | ||
| 34 | { | ||
| 35 | for (UINT z = 0; z < NumSlices; ++z) | ||
| 36 | { | ||
| 37 | auto pDestSlice = static_cast<BYTE*>(pDest->pData) + pDest->SlicePitch * z; | ||
| 38 | auto pSrcSlice = static_cast<const BYTE*>(pSrc->pData) + pSrc->SlicePitch * LONG_PTR(z); | ||
| 39 | for (UINT y = 0; y < NumRows; ++y) | ||
| 40 | { | ||
| 41 | memcpy(pDestSlice + pDest->RowPitch * y, | ||
| 42 | pSrcSlice + pSrc->RowPitch * LONG_PTR(y), | ||
| 43 | RowSizeInBytes); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | //------------------------------------------------------------------------------------------------ | ||
| 49 | // Row-by-row memcpy | ||
| 50 | inline void MemcpySubresource( | ||
| 51 | _In_ const D3D12_MEMCPY_DEST* pDest, | ||
| 52 | _In_ const void* pResourceData, | ||
| 53 | _In_ const D3D12_SUBRESOURCE_INFO* pSrc, | ||
| 54 | SIZE_T RowSizeInBytes, | ||
| 55 | UINT NumRows, | ||
| 56 | UINT NumSlices) noexcept | ||
| 57 | { | ||
| 58 | for (UINT z = 0; z < NumSlices; ++z) | ||
| 59 | { | ||
| 60 | auto pDestSlice = static_cast<BYTE*>(pDest->pData) + pDest->SlicePitch * z; | ||
| 61 | auto pSrcSlice = (static_cast<const BYTE*>(pResourceData) + pSrc->Offset) + pSrc->DepthPitch * ULONG_PTR(z); | ||
| 62 | for (UINT y = 0; y < NumRows; ++y) | ||
| 63 | { | ||
| 64 | memcpy(pDestSlice + pDest->RowPitch * y, | ||
| 65 | pSrcSlice + pSrc->RowPitch * ULONG_PTR(y), | ||
| 66 | RowSizeInBytes); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | //------------------------------------------------------------------------------------------------ | ||
| 72 | // Returns required size of a buffer to be used for data upload | ||
| 73 | inline UINT64 GetRequiredIntermediateSize( | ||
| 74 | _In_ ID3D12Resource* pDestinationResource, | ||
| 75 | _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, | ||
| 76 | _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources) noexcept | ||
| 77 | { | ||
| 78 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 79 | const auto Desc = pDestinationResource->GetDesc(); | ||
| 80 | #else | ||
| 81 | D3D12_RESOURCE_DESC tmpDesc; | ||
| 82 | const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc); | ||
| 83 | #endif | ||
| 84 | UINT64 RequiredSize = 0; | ||
| 85 | |||
| 86 | ID3D12Device* pDevice = nullptr; | ||
| 87 | pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice)); | ||
| 88 | pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize); | ||
| 89 | pDevice->Release(); | ||
| 90 | |||
| 91 | return RequiredSize; | ||
| 92 | } | ||
| 93 | |||
| 94 | //------------------------------------------------------------------------------------------------ | ||
| 95 | // All arrays must be populated (e.g. by calling GetCopyableFootprints) | ||
| 96 | inline UINT64 UpdateSubresources( | ||
| 97 | _In_ ID3D12GraphicsCommandList* pCmdList, | ||
| 98 | _In_ ID3D12Resource* pDestinationResource, | ||
| 99 | _In_ ID3D12Resource* pIntermediate, | ||
| 100 | _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, | ||
| 101 | _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, | ||
| 102 | UINT64 RequiredSize, | ||
| 103 | _In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, | ||
| 104 | _In_reads_(NumSubresources) const UINT* pNumRows, | ||
| 105 | _In_reads_(NumSubresources) const UINT64* pRowSizesInBytes, | ||
| 106 | _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept | ||
| 107 | { | ||
| 108 | // Minor validation | ||
| 109 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 110 | const auto IntermediateDesc = pIntermediate->GetDesc(); | ||
| 111 | const auto DestinationDesc = pDestinationResource->GetDesc(); | ||
| 112 | #else | ||
| 113 | D3D12_RESOURCE_DESC tmpDesc1, tmpDesc2; | ||
| 114 | const auto& IntermediateDesc = *pIntermediate->GetDesc(&tmpDesc1); | ||
| 115 | const auto& DestinationDesc = *pDestinationResource->GetDesc(&tmpDesc2); | ||
| 116 | #endif | ||
| 117 | if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || | ||
| 118 | IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || | ||
| 119 | RequiredSize > SIZE_T(-1) || | ||
| 120 | (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && | ||
| 121 | (FirstSubresource != 0 || NumSubresources != 1))) | ||
| 122 | { | ||
| 123 | return 0; | ||
| 124 | } | ||
| 125 | |||
| 126 | BYTE* pData; | ||
| 127 | HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast<void**>(&pData)); | ||
| 128 | if (FAILED(hr)) | ||
| 129 | { | ||
| 130 | return 0; | ||
| 131 | } | ||
| 132 | |||
| 133 | for (UINT i = 0; i < NumSubresources; ++i) | ||
| 134 | { | ||
| 135 | if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0; | ||
| 136 | D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) }; | ||
| 137 | MemcpySubresource(&DestData, &pSrcData[i], static_cast<SIZE_T>(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth); | ||
| 138 | } | ||
| 139 | pIntermediate->Unmap(0, nullptr); | ||
| 140 | |||
| 141 | if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) | ||
| 142 | { | ||
| 143 | pCmdList->CopyBufferRegion( | ||
| 144 | pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width); | ||
| 145 | } | ||
| 146 | else | ||
| 147 | { | ||
| 148 | for (UINT i = 0; i < NumSubresources; ++i) | ||
| 149 | { | ||
| 150 | const CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource); | ||
| 151 | const CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]); | ||
| 152 | pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | return RequiredSize; | ||
| 156 | } | ||
| 157 | |||
| 158 | //------------------------------------------------------------------------------------------------ | ||
| 159 | // All arrays must be populated (e.g. by calling GetCopyableFootprints) | ||
| 160 | inline UINT64 UpdateSubresources( | ||
| 161 | _In_ ID3D12GraphicsCommandList* pCmdList, | ||
| 162 | _In_ ID3D12Resource* pDestinationResource, | ||
| 163 | _In_ ID3D12Resource* pIntermediate, | ||
| 164 | _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, | ||
| 165 | _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, | ||
| 166 | UINT64 RequiredSize, | ||
| 167 | _In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, | ||
| 168 | _In_reads_(NumSubresources) const UINT* pNumRows, | ||
| 169 | _In_reads_(NumSubresources) const UINT64* pRowSizesInBytes, | ||
| 170 | _In_ const void* pResourceData, | ||
| 171 | _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept | ||
| 172 | { | ||
| 173 | // Minor validation | ||
| 174 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 175 | const auto IntermediateDesc = pIntermediate->GetDesc(); | ||
| 176 | const auto DestinationDesc = pDestinationResource->GetDesc(); | ||
| 177 | #else | ||
| 178 | D3D12_RESOURCE_DESC tmpDesc1, tmpDesc2; | ||
| 179 | const auto& IntermediateDesc = *pIntermediate->GetDesc(&tmpDesc1); | ||
| 180 | const auto& DestinationDesc = *pDestinationResource->GetDesc(&tmpDesc2); | ||
| 181 | #endif | ||
| 182 | if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || | ||
| 183 | IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || | ||
| 184 | RequiredSize > SIZE_T(-1) || | ||
| 185 | (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && | ||
| 186 | (FirstSubresource != 0 || NumSubresources != 1))) | ||
| 187 | { | ||
| 188 | return 0; | ||
| 189 | } | ||
| 190 | |||
| 191 | BYTE* pData; | ||
| 192 | HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast<void**>(&pData)); | ||
| 193 | if (FAILED(hr)) | ||
| 194 | { | ||
| 195 | return 0; | ||
| 196 | } | ||
| 197 | |||
| 198 | for (UINT i = 0; i < NumSubresources; ++i) | ||
| 199 | { | ||
| 200 | if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0; | ||
| 201 | D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) }; | ||
| 202 | MemcpySubresource(&DestData, pResourceData, &pSrcData[i], static_cast<SIZE_T>(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth); | ||
| 203 | } | ||
| 204 | pIntermediate->Unmap(0, nullptr); | ||
| 205 | |||
| 206 | if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) | ||
| 207 | { | ||
| 208 | pCmdList->CopyBufferRegion( | ||
| 209 | pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width); | ||
| 210 | } | ||
| 211 | else | ||
| 212 | { | ||
| 213 | for (UINT i = 0; i < NumSubresources; ++i) | ||
| 214 | { | ||
| 215 | const CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource); | ||
| 216 | const CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]); | ||
| 217 | pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr); | ||
| 218 | } | ||
| 219 | } | ||
| 220 | return RequiredSize; | ||
| 221 | } | ||
| 222 | |||
| 223 | //------------------------------------------------------------------------------------------------ | ||
| 224 | // Heap-allocating UpdateSubresources implementation | ||
| 225 | inline UINT64 UpdateSubresources( | ||
| 226 | _In_ ID3D12GraphicsCommandList* pCmdList, | ||
| 227 | _In_ ID3D12Resource* pDestinationResource, | ||
| 228 | _In_ ID3D12Resource* pIntermediate, | ||
| 229 | UINT64 IntermediateOffset, | ||
| 230 | _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, | ||
| 231 | _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, | ||
| 232 | _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept | ||
| 233 | { | ||
| 234 | UINT64 RequiredSize = 0; | ||
| 235 | const auto MemToAlloc = static_cast<UINT64>(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources; | ||
| 236 | if (MemToAlloc > SIZE_MAX) | ||
| 237 | { | ||
| 238 | return 0; | ||
| 239 | } | ||
| 240 | void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast<SIZE_T>(MemToAlloc)); | ||
| 241 | if (pMem == nullptr) | ||
| 242 | { | ||
| 243 | return 0; | ||
| 244 | } | ||
| 245 | auto pLayouts = static_cast<D3D12_PLACED_SUBRESOURCE_FOOTPRINT*>(pMem); | ||
| 246 | auto pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources); | ||
| 247 | auto pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources); | ||
| 248 | |||
| 249 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 250 | const auto Desc = pDestinationResource->GetDesc(); | ||
| 251 | #else | ||
| 252 | D3D12_RESOURCE_DESC tmpDesc; | ||
| 253 | const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc); | ||
| 254 | #endif | ||
| 255 | ID3D12Device* pDevice = nullptr; | ||
| 256 | pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice)); | ||
| 257 | pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); | ||
| 258 | pDevice->Release(); | ||
| 259 | |||
| 260 | const UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pSrcData); | ||
| 261 | HeapFree(GetProcessHeap(), 0, pMem); | ||
| 262 | return Result; | ||
| 263 | } | ||
| 264 | |||
| 265 | //------------------------------------------------------------------------------------------------ | ||
| 266 | // Heap-allocating UpdateSubresources implementation | ||
| 267 | inline UINT64 UpdateSubresources( | ||
| 268 | _In_ ID3D12GraphicsCommandList* pCmdList, | ||
| 269 | _In_ ID3D12Resource* pDestinationResource, | ||
| 270 | _In_ ID3D12Resource* pIntermediate, | ||
| 271 | UINT64 IntermediateOffset, | ||
| 272 | _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, | ||
| 273 | _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, | ||
| 274 | _In_ const void* pResourceData, | ||
| 275 | _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept | ||
| 276 | { | ||
| 277 | UINT64 RequiredSize = 0; | ||
| 278 | const auto MemToAlloc = static_cast<UINT64>(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources; | ||
| 279 | if (MemToAlloc > SIZE_MAX) | ||
| 280 | { | ||
| 281 | return 0; | ||
| 282 | } | ||
| 283 | void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast<SIZE_T>(MemToAlloc)); | ||
| 284 | if (pMem == nullptr) | ||
| 285 | { | ||
| 286 | return 0; | ||
| 287 | } | ||
| 288 | auto pLayouts = static_cast<D3D12_PLACED_SUBRESOURCE_FOOTPRINT*>(pMem); | ||
| 289 | auto pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources); | ||
| 290 | auto pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources); | ||
| 291 | |||
| 292 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 293 | const auto Desc = pDestinationResource->GetDesc(); | ||
| 294 | #else | ||
| 295 | D3D12_RESOURCE_DESC tmpDesc; | ||
| 296 | const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc); | ||
| 297 | #endif | ||
| 298 | ID3D12Device* pDevice = nullptr; | ||
| 299 | pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice)); | ||
| 300 | pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); | ||
| 301 | pDevice->Release(); | ||
| 302 | |||
| 303 | const UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pResourceData, pSrcData); | ||
| 304 | HeapFree(GetProcessHeap(), 0, pMem); | ||
| 305 | return Result; | ||
| 306 | } | ||
| 307 | |||
| 308 | //------------------------------------------------------------------------------------------------ | ||
| 309 | // Stack-allocating UpdateSubresources implementation | ||
| 310 | template <UINT MaxSubresources> | ||
| 311 | inline UINT64 UpdateSubresources( | ||
| 312 | _In_ ID3D12GraphicsCommandList* pCmdList, | ||
| 313 | _In_ ID3D12Resource* pDestinationResource, | ||
| 314 | _In_ ID3D12Resource* pIntermediate, | ||
| 315 | UINT64 IntermediateOffset, | ||
| 316 | _In_range_(0,MaxSubresources) UINT FirstSubresource, | ||
| 317 | _In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources, | ||
| 318 | _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept | ||
| 319 | { | ||
| 320 | UINT64 RequiredSize = 0; | ||
| 321 | D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; | ||
| 322 | UINT NumRows[MaxSubresources]; | ||
| 323 | UINT64 RowSizesInBytes[MaxSubresources]; | ||
| 324 | |||
| 325 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 326 | const auto Desc = pDestinationResource->GetDesc(); | ||
| 327 | #else | ||
| 328 | D3D12_RESOURCE_DESC tmpDesc; | ||
| 329 | const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc); | ||
| 330 | #endif | ||
| 331 | ID3D12Device* pDevice = nullptr; | ||
| 332 | pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice)); | ||
| 333 | pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize); | ||
| 334 | pDevice->Release(); | ||
| 335 | |||
| 336 | return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData); | ||
| 337 | } | ||
| 338 | |||
| 339 | //------------------------------------------------------------------------------------------------ | ||
| 340 | // Stack-allocating UpdateSubresources implementation | ||
| 341 | template <UINT MaxSubresources> | ||
| 342 | inline UINT64 UpdateSubresources( | ||
| 343 | _In_ ID3D12GraphicsCommandList* pCmdList, | ||
| 344 | _In_ ID3D12Resource* pDestinationResource, | ||
| 345 | _In_ ID3D12Resource* pIntermediate, | ||
| 346 | UINT64 IntermediateOffset, | ||
| 347 | _In_range_(0,MaxSubresources) UINT FirstSubresource, | ||
| 348 | _In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources, | ||
| 349 | _In_ const void* pResourceData, | ||
| 350 | _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept | ||
| 351 | { | ||
| 352 | UINT64 RequiredSize = 0; | ||
| 353 | D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; | ||
| 354 | UINT NumRows[MaxSubresources]; | ||
| 355 | UINT64 RowSizesInBytes[MaxSubresources]; | ||
| 356 | |||
| 357 | #if defined(_MSC_VER) || !defined(_WIN32) | ||
| 358 | const auto Desc = pDestinationResource->GetDesc(); | ||
| 359 | #else | ||
| 360 | D3D12_RESOURCE_DESC tmpDesc; | ||
| 361 | const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc); | ||
| 362 | #endif | ||
| 363 | ID3D12Device* pDevice = nullptr; | ||
| 364 | pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice)); | ||
| 365 | pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize); | ||
| 366 | pDevice->Release(); | ||
| 367 | |||
| 368 | return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pResourceData, pSrcData); | ||
| 369 | } | ||
| 370 | |||
| 371 | //------------------------------------------------------------------------------------------------ | ||
| 372 | constexpr bool D3D12IsLayoutOpaque( D3D12_TEXTURE_LAYOUT Layout ) noexcept | ||
| 373 | { return Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN || Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; } | ||
| 374 | |||
| 375 | //------------------------------------------------------------------------------------------------ | ||
| 376 | template< typename T > | ||
| 377 | inline T D3DX12Align(T uValue, T uAlign) | ||
| 378 | { | ||
| 379 | // Assert power of 2 alignment | ||
| 380 | D3DX12_ASSERT(0 == (uAlign & (uAlign - 1))); | ||
| 381 | T uMask = uAlign - 1; | ||
| 382 | T uResult = (uValue + uMask) & ~uMask; | ||
| 383 | D3DX12_ASSERT(uResult >= uValue); | ||
| 384 | D3DX12_ASSERT(0 == (uResult % uAlign)); | ||
| 385 | return uResult; | ||
| 386 | } | ||
| 387 | |||
| 388 | //------------------------------------------------------------------------------------------------ | ||
| 389 | template< typename T > | ||
| 390 | inline T D3DX12AlignAtLeast(T uValue, T uAlign) | ||
| 391 | { | ||
| 392 | T aligned = D3DX12Align(uValue, uAlign); | ||
| 393 | return aligned > uAlign ? aligned : uAlign; | ||
| 394 | } | ||
| 395 | |||
| 396 | inline const CD3DX12_RESOURCE_DESC1* D3DX12ConditionallyExpandAPIDesc( | ||
| 397 | D3D12_RESOURCE_DESC1& LclDesc, | ||
| 398 | const D3D12_RESOURCE_DESC1* pDesc, | ||
| 399 | const bool tightAlignmentSupported = false, | ||
| 400 | const bool alignAsCommitted = false) | ||
| 401 | { | ||
| 402 | return D3DX12ConditionallyExpandAPIDesc(static_cast<CD3DX12_RESOURCE_DESC1&>(LclDesc), static_cast<const CD3DX12_RESOURCE_DESC1*>(pDesc), tightAlignmentSupported, alignAsCommitted); | ||
| 403 | } | ||
| 404 | |||
| 405 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) | ||
| 406 | //------------------------------------------------------------------------------------------------ | ||
| 407 | // The difference between D3DX12GetCopyableFootprints and ID3D12Device::GetCopyableFootprints | ||
| 408 | // is that this one loses a lot of error checking by assuming the arguments are correct | ||
| 409 | inline bool D3DX12GetCopyableFootprints( | ||
| 410 | _In_ const D3D12_RESOURCE_DESC1& ResourceDesc, | ||
| 411 | _In_range_(0, D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, | ||
| 412 | _In_range_(0, D3D12_REQ_SUBRESOURCES - FirstSubresource) UINT NumSubresources, | ||
| 413 | UINT64 BaseOffset, | ||
| 414 | _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, | ||
| 415 | _Out_writes_opt_(NumSubresources) UINT* pNumRows, | ||
| 416 | _Out_writes_opt_(NumSubresources) UINT64* pRowSizeInBytes, | ||
| 417 | _Out_opt_ UINT64* pTotalBytes) | ||
| 418 | { | ||
| 419 | constexpr UINT64 uint64_max = ~0ull; | ||
| 420 | UINT64 TotalBytes = uint64_max; | ||
| 421 | UINT uSubRes = 0; | ||
| 422 | |||
| 423 | bool bResourceOverflow = false; | ||
| 424 | TotalBytes = 0; | ||
| 425 | |||
| 426 | const DXGI_FORMAT Format = ResourceDesc.Format; | ||
| 427 | |||
| 428 | CD3DX12_RESOURCE_DESC1 LresourceDesc; | ||
| 429 | const CD3DX12_RESOURCE_DESC1& resourceDesc = *D3DX12ConditionallyExpandAPIDesc(LresourceDesc, &ResourceDesc); | ||
| 430 | |||
| 431 | // Check if its a valid format | ||
| 432 | D3DX12_ASSERT(D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::FormatExists(Format)); | ||
| 433 | |||
| 434 | // D3DX12GetCopyableFootprints does not support buffers with width larger than UINT_MAX. | ||
| 435 | if (ResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && ResourceDesc.Width >= UINT_MAX) | ||
| 436 | { | ||
| 437 | return false; | ||
| 438 | } | ||
| 439 | |||
| 440 | const UINT WidthAlignment = D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetWidthAlignment( Format ); | ||
| 441 | const UINT HeightAlignment = D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetHeightAlignment( Format ); | ||
| 442 | const UINT16 DepthAlignment = UINT16( D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetDepthAlignment( Format ) ); | ||
| 443 | |||
| 444 | for (; uSubRes < NumSubresources; ++uSubRes) | ||
| 445 | { | ||
| 446 | bool bOverflow = false; | ||
| 447 | UINT Subresource = FirstSubresource + uSubRes; | ||
| 448 | |||
| 449 | D3DX12_ASSERT(resourceDesc.MipLevels != 0); | ||
| 450 | UINT subresourceCount = resourceDesc.MipLevels * resourceDesc.ArraySize() * D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetPlaneCount(resourceDesc.Format); | ||
| 451 | |||
| 452 | if (Subresource > subresourceCount) | ||
| 453 | { | ||
| 454 | break; | ||
| 455 | } | ||
| 456 | |||
| 457 | TotalBytes = D3DX12Align< UINT64 >( TotalBytes, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT ); | ||
| 458 | |||
| 459 | UINT MipLevel, ArraySlice, PlaneSlice; | ||
| 460 | D3D12DecomposeSubresource(Subresource, resourceDesc.MipLevels, resourceDesc.ArraySize(), /*_Out_*/MipLevel, /*_Out_*/ArraySlice, /*_Out_*/PlaneSlice); | ||
| 461 | |||
| 462 | const UINT64 Width = D3DX12AlignAtLeast<UINT64>(resourceDesc.Width >> MipLevel, WidthAlignment); | ||
| 463 | const UINT Height = D3DX12AlignAtLeast(resourceDesc.Height >> MipLevel, HeightAlignment); | ||
| 464 | const UINT16 Depth = D3DX12AlignAtLeast<UINT16>(resourceDesc.Depth() >> MipLevel, DepthAlignment); | ||
| 465 | |||
| 466 | // Adjust for the current PlaneSlice. Most formats have only one plane. | ||
| 467 | DXGI_FORMAT PlaneFormat; | ||
| 468 | UINT32 MinPlanePitchWidth, PlaneWidth, PlaneHeight; | ||
| 469 | D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetPlaneSubsampledSizeAndFormatForCopyableLayout(PlaneSlice, Format, (UINT)Width, Height, /*_Out_*/ PlaneFormat, /*_Out_*/ MinPlanePitchWidth, /* _Out_ */ PlaneWidth, /*_Out_*/ PlaneHeight); | ||
| 470 | |||
| 471 | D3D12_SUBRESOURCE_FOOTPRINT LocalPlacement = {}; | ||
| 472 | auto& Placement = pLayouts ? pLayouts[uSubRes].Footprint : LocalPlacement; | ||
| 473 | Placement.Format = PlaneFormat; | ||
| 474 | Placement.Width = PlaneWidth; | ||
| 475 | Placement.Height = PlaneHeight; | ||
| 476 | Placement.Depth = Depth; | ||
| 477 | |||
| 478 | // Calculate row pitch | ||
| 479 | UINT MinPlaneRowPitch = 0; | ||
| 480 | D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::CalculateMinimumRowMajorRowPitch(PlaneFormat, MinPlanePitchWidth, MinPlaneRowPitch); | ||
| 481 | |||
| 482 | // Formats with more than one plane choose a larger pitch alignment to ensure that each plane begins on the row | ||
| 483 | // immediately following the previous plane while still adhering to subresource alignment restrictions. | ||
| 484 | static_assert( D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT >= D3D12_TEXTURE_DATA_PITCH_ALIGNMENT | ||
| 485 | && ((D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT % D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) == 0), | ||
| 486 | "D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT must be >= and evenly divisible by D3D12_TEXTURE_DATA_PITCH_ALIGNMENT." ); | ||
| 487 | |||
| 488 | Placement.RowPitch = D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::Planar(Format) | ||
| 489 | ? D3DX12Align< UINT >( MinPlaneRowPitch, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT ) | ||
| 490 | : D3DX12Align< UINT >( MinPlaneRowPitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT ); | ||
| 491 | |||
| 492 | if (pRowSizeInBytes) | ||
| 493 | { | ||
| 494 | UINT PlaneRowSize = 0; | ||
| 495 | D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::CalculateMinimumRowMajorRowPitch(PlaneFormat, PlaneWidth, PlaneRowSize); | ||
| 496 | |||
| 497 | pRowSizeInBytes[uSubRes] = PlaneRowSize; | ||
| 498 | } | ||
| 499 | |||
| 500 | // Number of rows (accounting for block compression and additional planes) | ||
| 501 | UINT NumRows = 0; | ||
| 502 | if (D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::Planar(Format)) | ||
| 503 | { | ||
| 504 | NumRows = PlaneHeight; | ||
| 505 | } | ||
| 506 | else | ||
| 507 | { | ||
| 508 | D3DX12_ASSERT(Height % HeightAlignment == 0); | ||
| 509 | NumRows = Height / HeightAlignment; | ||
| 510 | } | ||
| 511 | |||
| 512 | if (pNumRows) | ||
| 513 | { | ||
| 514 | pNumRows[uSubRes] = NumRows; | ||
| 515 | } | ||
| 516 | |||
| 517 | // Offsetting | ||
| 518 | if (pLayouts) | ||
| 519 | { | ||
| 520 | pLayouts[uSubRes].Offset = (bOverflow ? uint64_max : TotalBytes + BaseOffset); | ||
| 521 | } | ||
| 522 | |||
| 523 | const UINT16 NumSlices = Depth; | ||
| 524 | const UINT64 SubresourceSize = (NumRows * NumSlices - 1) * Placement.RowPitch + MinPlaneRowPitch; | ||
| 525 | |||
| 526 | // uint64 addition with overflow checking | ||
| 527 | TotalBytes = TotalBytes + SubresourceSize; | ||
| 528 | if(TotalBytes < SubresourceSize) | ||
| 529 | { | ||
| 530 | TotalBytes = uint64_max; | ||
| 531 | } | ||
| 532 | bResourceOverflow = bResourceOverflow || bOverflow; | ||
| 533 | } | ||
| 534 | |||
| 535 | // Overflow error | ||
| 536 | if (bResourceOverflow) | ||
| 537 | { | ||
| 538 | TotalBytes = uint64_max; | ||
| 539 | } | ||
| 540 | |||
| 541 | |||
| 542 | if (pLayouts) | ||
| 543 | { | ||
| 544 | memset( pLayouts + uSubRes, -1, sizeof( *pLayouts ) * (NumSubresources - uSubRes) ); | ||
| 545 | } | ||
| 546 | if (pNumRows) | ||
| 547 | { | ||
| 548 | memset(pNumRows + uSubRes, -1, sizeof(*pNumRows) * (NumSubresources - uSubRes)); | ||
| 549 | } | ||
| 550 | if (pRowSizeInBytes) | ||
| 551 | { | ||
| 552 | memset(pRowSizeInBytes + uSubRes, -1, sizeof(*pRowSizeInBytes) * (NumSubresources - uSubRes)); | ||
| 553 | } | ||
| 554 | if (pTotalBytes) | ||
| 555 | { | ||
| 556 | *pTotalBytes = TotalBytes; | ||
| 557 | } | ||
| 558 | if(TotalBytes == uint64_max) | ||
| 559 | { | ||
| 560 | return false; | ||
| 561 | } | ||
| 562 | return true; | ||
| 563 | } | ||
| 564 | |||
| 565 | //------------------------------------------------------------------------------------------------ | ||
| 566 | inline D3D12_RESOURCE_DESC1 D3DX12ResourceDesc0ToDesc1(D3D12_RESOURCE_DESC const& desc0) | ||
| 567 | { | ||
| 568 | D3D12_RESOURCE_DESC1 desc1; | ||
| 569 | desc1.Dimension = desc0.Dimension; | ||
| 570 | desc1.Alignment = desc0.Alignment; | ||
| 571 | desc1.Width = desc0.Width; | ||
| 572 | desc1.Height = desc0.Height; | ||
| 573 | desc1.DepthOrArraySize = desc0.DepthOrArraySize; | ||
| 574 | desc1.MipLevels = desc0.MipLevels; | ||
| 575 | desc1.Format = desc0.Format; | ||
| 576 | desc1.SampleDesc.Count = desc0.SampleDesc.Count; | ||
| 577 | desc1.SampleDesc.Quality = desc0.SampleDesc.Quality; | ||
| 578 | desc1.Layout = desc0.Layout; | ||
| 579 | desc1.Flags = desc0.Flags; | ||
| 580 | desc1.SamplerFeedbackMipRegion.Width = 0; | ||
| 581 | desc1.SamplerFeedbackMipRegion.Height = 0; | ||
| 582 | desc1.SamplerFeedbackMipRegion.Depth = 0; | ||
| 583 | return desc1; | ||
| 584 | } | ||
| 585 | |||
| 586 | //------------------------------------------------------------------------------------------------ | ||
| 587 | inline bool D3DX12GetCopyableFootprints( | ||
| 588 | _In_ const D3D12_RESOURCE_DESC& pResourceDesc, | ||
| 589 | _In_range_(0, D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, | ||
| 590 | _In_range_(0, D3D12_REQ_SUBRESOURCES - FirstSubresource) UINT NumSubresources, | ||
| 591 | UINT64 BaseOffset, | ||
| 592 | _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, | ||
| 593 | _Out_writes_opt_(NumSubresources) UINT* pNumRows, | ||
| 594 | _Out_writes_opt_(NumSubresources) UINT64* pRowSizeInBytes, | ||
| 595 | _Out_opt_ UINT64* pTotalBytes) | ||
| 596 | { | ||
| 597 | // From D3D12_RESOURCE_DESC to D3D12_RESOURCE_DESC1 | ||
| 598 | D3D12_RESOURCE_DESC1 desc = D3DX12ResourceDesc0ToDesc1(pResourceDesc); | ||
| 599 | return D3DX12GetCopyableFootprints( | ||
| 600 | *static_cast<CD3DX12_RESOURCE_DESC1*>(&desc),// From D3D12_RESOURCE_DESC1 to CD3DX12_RESOURCE_DESC1 | ||
| 601 | FirstSubresource, | ||
| 602 | NumSubresources, | ||
| 603 | BaseOffset, | ||
| 604 | pLayouts, | ||
| 605 | pNumRows, | ||
| 606 | pRowSizeInBytes, | ||
| 607 | pTotalBytes); | ||
| 608 | } | ||
| 609 | |||
| 610 | #endif // D3D12_SDK_VERSION >= 606 | ||
| 611 | |||
| 612 | |||
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 | ||
diff --git a/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_state_object.h b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_state_object.h new file mode 100644 index 0000000..579ecc8 --- /dev/null +++ b/contrib/microsoft.direct3d.d3d12.1.618.4/build/native/include/d3dx12/d3dx12_state_object.h | |||
| @@ -0,0 +1,2570 @@ | |||
| 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 "d3dx12_default.h" | ||
| 15 | #include "d3d12.h" | ||
| 16 | #include "d3dx12_core.h" | ||
| 17 | |||
| 18 | //================================================================================================ | ||
| 19 | // D3DX12 State Object Creation Helpers | ||
| 20 | // | ||
| 21 | // Helper classes for creating new style state objects out of an arbitrary set of subobjects. | ||
| 22 | // Uses STL | ||
| 23 | // | ||
| 24 | // Start by instantiating CD3DX12_STATE_OBJECT_DESC (see its public methods). | ||
| 25 | // One of its methods is CreateSubobject(), which has a comment showing a couple of options for | ||
| 26 | // defining subobjects using the helper classes for each subobject (CD3DX12_DXIL_LIBRARY_SUBOBJECT | ||
| 27 | // etc.). The subobject helpers each have methods specific to the subobject for configuring its | ||
| 28 | // contents. | ||
| 29 | // | ||
| 30 | //================================================================================================ | ||
| 31 | #include <list> | ||
| 32 | #include <forward_list> | ||
| 33 | #include <vector> | ||
| 34 | #include <memory> | ||
| 35 | #include <string> | ||
| 36 | #include <vector> | ||
| 37 | #ifndef D3DX12_USE_ATL | ||
| 38 | #include <wrl/client.h> | ||
| 39 | #define D3DX12_COM_PTR Microsoft::WRL::ComPtr | ||
| 40 | #define D3DX12_COM_PTR_GET(x) x.Get() | ||
| 41 | #define D3DX12_COM_PTR_ADDRESSOF(x) x.GetAddressOf() | ||
| 42 | #else | ||
| 43 | #include <atlbase.h> | ||
| 44 | #define D3DX12_COM_PTR ATL::CComPtr | ||
| 45 | #define D3DX12_COM_PTR_GET(x) x.p | ||
| 46 | #define D3DX12_COM_PTR_ADDRESSOF(x) &x.p | ||
| 47 | #endif | ||
| 48 | |||
| 49 | //------------------------------------------------------------------------------------------------ | ||
| 50 | class CD3DX12_STATE_OBJECT_DESC | ||
| 51 | { | ||
| 52 | public: | ||
| 53 | CD3DX12_STATE_OBJECT_DESC() noexcept | ||
| 54 | { | ||
| 55 | Init(D3D12_STATE_OBJECT_TYPE_COLLECTION); | ||
| 56 | } | ||
| 57 | CD3DX12_STATE_OBJECT_DESC(D3D12_STATE_OBJECT_TYPE Type) noexcept | ||
| 58 | { | ||
| 59 | Init(Type); | ||
| 60 | } | ||
| 61 | void SetStateObjectType(D3D12_STATE_OBJECT_TYPE Type) noexcept { m_Desc.Type = Type; } | ||
| 62 | CD3DX12_STATE_OBJECT_DESC(const CD3DX12_STATE_OBJECT_DESC& other) = delete; | ||
| 63 | CD3DX12_STATE_OBJECT_DESC& operator=(const CD3DX12_STATE_OBJECT_DESC& other) = delete; | ||
| 64 | CD3DX12_STATE_OBJECT_DESC(CD3DX12_STATE_OBJECT_DESC&& other) = default; | ||
| 65 | CD3DX12_STATE_OBJECT_DESC& operator=(CD3DX12_STATE_OBJECT_DESC&& other) = default; | ||
| 66 | operator const D3D12_STATE_OBJECT_DESC& () | ||
| 67 | { | ||
| 68 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 69 | m_RepointedSubobjectVectors.clear(); | ||
| 70 | m_RepointedPrograms.clear(); | ||
| 71 | #endif | ||
| 72 | m_RepointedAssociations.clear(); | ||
| 73 | m_SubobjectArray.clear(); | ||
| 74 | m_SubobjectArray.reserve(m_Desc.NumSubobjects); | ||
| 75 | // Flatten subobjects into an array (each flattened subobject still has a | ||
| 76 | // member that's a pointer to its desc that's not flattened) | ||
| 77 | for (auto Iter = m_SubobjectList.begin(); | ||
| 78 | Iter != m_SubobjectList.end(); Iter++) | ||
| 79 | { | ||
| 80 | m_SubobjectArray.push_back(*Iter); | ||
| 81 | // Store new location in array so we can redirect pointers contained in subobjects | ||
| 82 | Iter->pSubobjectArrayLocation = &m_SubobjectArray.back(); | ||
| 83 | } | ||
| 84 | // For subobjects with pointer fields, create a new copy of those subobject definitions | ||
| 85 | // with fixed pointers | ||
| 86 | for (UINT i = 0; i < m_Desc.NumSubobjects; i++) | ||
| 87 | { | ||
| 88 | if (m_SubobjectArray[i].Type == D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION) | ||
| 89 | { | ||
| 90 | auto pOriginalSubobjectAssociation = | ||
| 91 | static_cast<const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION*>(m_SubobjectArray[i].pDesc); | ||
| 92 | D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION Repointed = *pOriginalSubobjectAssociation; | ||
| 93 | auto pWrapper = | ||
| 94 | static_cast<const SUBOBJECT_WRAPPER*>(pOriginalSubobjectAssociation->pSubobjectToAssociate); | ||
| 95 | Repointed.pSubobjectToAssociate = pWrapper->pSubobjectArrayLocation; | ||
| 96 | m_RepointedAssociations.push_back(Repointed); | ||
| 97 | m_SubobjectArray[i].pDesc = &m_RepointedAssociations.back(); | ||
| 98 | } | ||
| 99 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 100 | else if (m_SubobjectArray[i].Type == D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM) | ||
| 101 | { | ||
| 102 | auto originalGenericProgramDesc = | ||
| 103 | static_cast<const D3D12_GENERIC_PROGRAM_DESC*>(m_SubobjectArray[i].pDesc); | ||
| 104 | D3D12_GENERIC_PROGRAM_DESC Repointed = *originalGenericProgramDesc; | ||
| 105 | if (originalGenericProgramDesc->NumSubobjects > 0) | ||
| 106 | { | ||
| 107 | m_RepointedSubobjectVectors.emplace_back(std::vector<const D3D12_STATE_SUBOBJECT*>()); | ||
| 108 | std::vector<D3D12_STATE_SUBOBJECT const*>& repointedGenericProgramSubobjects = m_RepointedSubobjectVectors.back(); | ||
| 109 | repointedGenericProgramSubobjects.resize(originalGenericProgramDesc->NumSubobjects); | ||
| 110 | for (UINT s = 0; s < originalGenericProgramDesc->NumSubobjects; s++) | ||
| 111 | { | ||
| 112 | auto pWrapper = | ||
| 113 | static_cast<const SUBOBJECT_WRAPPER*>(originalGenericProgramDesc->ppSubobjects[s]); | ||
| 114 | repointedGenericProgramSubobjects[s] = pWrapper->pSubobjectArrayLocation; | ||
| 115 | } | ||
| 116 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 117 | Repointed.ppSubobjects = &repointedGenericProgramSubobjects[0]; | ||
| 118 | } | ||
| 119 | m_RepointedPrograms.push_back(Repointed); | ||
| 120 | m_SubobjectArray[i].pDesc = &m_RepointedPrograms.back(); | ||
| 121 | } | ||
| 122 | #endif | ||
| 123 | } | ||
| 124 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 125 | m_Desc.pSubobjects = m_Desc.NumSubobjects ? &m_SubobjectArray[0] : nullptr; | ||
| 126 | return m_Desc; | ||
| 127 | } | ||
| 128 | operator const D3D12_STATE_OBJECT_DESC* () | ||
| 129 | { | ||
| 130 | // Cast calls the above final preparation work | ||
| 131 | return &static_cast<const D3D12_STATE_OBJECT_DESC&>(*this); | ||
| 132 | } | ||
| 133 | |||
| 134 | // CreateSubobject creates a sububject helper (e.g. CD3DX12_HIT_GROUP_SUBOBJECT) | ||
| 135 | // whose lifetime is owned by this class. | ||
| 136 | // e.g. | ||
| 137 | // | ||
| 138 | // CD3DX12_STATE_OBJECT_DESC Collection1(D3D12_STATE_OBJECT_TYPE_COLLECTION); | ||
| 139 | // auto Lib0 = Collection1.CreateSubobject<CD3DX12_DXIL_LIBRARY_SUBOBJECT>(); | ||
| 140 | // Lib0->SetDXILLibrary(&pMyAppDxilLibs[0]); | ||
| 141 | // Lib0->DefineExport(L"rayGenShader0"); // in practice these export listings might be | ||
| 142 | // // data/engine driven | ||
| 143 | // etc. | ||
| 144 | // | ||
| 145 | // Alternatively, users can instantiate sububject helpers explicitly, such as via local | ||
| 146 | // variables instead, passing the state object desc that should point to it into the helper | ||
| 147 | // constructor (or call mySubobjectHelper.AddToStateObject(Collection1)). | ||
| 148 | // In this alternative scenario, the user must keep the subobject alive as long as the state | ||
| 149 | // object it is associated with is alive, else its pointer references will be stale. | ||
| 150 | // e.g. | ||
| 151 | // | ||
| 152 | // CD3DX12_STATE_OBJECT_DESC RaytracingState2(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE); | ||
| 153 | // CD3DX12_DXIL_LIBRARY_SUBOBJECT LibA(RaytracingState2); | ||
| 154 | // LibA.SetDXILLibrary(&pMyAppDxilLibs[4]); // not manually specifying exports | ||
| 155 | // // - meaning all exports in the libraries | ||
| 156 | // // are exported | ||
| 157 | // etc. | ||
| 158 | |||
| 159 | template<typename T> | ||
| 160 | T* CreateSubobject() | ||
| 161 | { | ||
| 162 | T* pSubobject = new T(*this); | ||
| 163 | m_OwnedSubobjectHelpers.emplace_back(pSubobject); | ||
| 164 | return pSubobject; | ||
| 165 | } | ||
| 166 | |||
| 167 | template<typename T, typename U> | ||
| 168 | T* CreateSubobject(U&& arg) | ||
| 169 | { | ||
| 170 | T* pSubobject = new T(std::forward<U>(arg), *this); | ||
| 171 | m_OwnedSubobjectHelpers.emplace_back(pSubobject); | ||
| 172 | return pSubobject; | ||
| 173 | } | ||
| 174 | |||
| 175 | private: | ||
| 176 | D3D12_STATE_SUBOBJECT* TrackSubobject(D3D12_STATE_SUBOBJECT_TYPE Type, void* pDesc) | ||
| 177 | { | ||
| 178 | SUBOBJECT_WRAPPER Subobject; | ||
| 179 | Subobject.pSubobjectArrayLocation = nullptr; | ||
| 180 | Subobject.Type = Type; | ||
| 181 | Subobject.pDesc = pDesc; | ||
| 182 | m_SubobjectList.push_back(Subobject); | ||
| 183 | m_Desc.NumSubobjects++; | ||
| 184 | return &m_SubobjectList.back(); | ||
| 185 | } | ||
| 186 | void Init(D3D12_STATE_OBJECT_TYPE Type) noexcept | ||
| 187 | { | ||
| 188 | SetStateObjectType(Type); | ||
| 189 | m_Desc.pSubobjects = nullptr; | ||
| 190 | m_Desc.NumSubobjects = 0; | ||
| 191 | m_SubobjectList.clear(); | ||
| 192 | m_SubobjectArray.clear(); | ||
| 193 | m_RepointedAssociations.clear(); | ||
| 194 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 195 | m_RepointedSubobjectVectors.clear(); | ||
| 196 | m_RepointedPrograms.clear(); | ||
| 197 | #endif | ||
| 198 | } | ||
| 199 | typedef struct SUBOBJECT_WRAPPER : public D3D12_STATE_SUBOBJECT | ||
| 200 | { | ||
| 201 | D3D12_STATE_SUBOBJECT* pSubobjectArrayLocation; // new location when flattened into array | ||
| 202 | // for repointing pointers in subobjects | ||
| 203 | } SUBOBJECT_WRAPPER; | ||
| 204 | D3D12_STATE_OBJECT_DESC m_Desc; | ||
| 205 | std::list<SUBOBJECT_WRAPPER> m_SubobjectList; // Pointers to list nodes handed out so | ||
| 206 | // these can be edited live | ||
| 207 | std::vector<D3D12_STATE_SUBOBJECT> m_SubobjectArray; // Built at the end, copying list contents | ||
| 208 | |||
| 209 | std::list<D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION> | ||
| 210 | m_RepointedAssociations; // subobject type that contains pointers to other subobjects, | ||
| 211 | // repointed to flattened array | ||
| 212 | |||
| 213 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 214 | std::list<std::vector<D3D12_STATE_SUBOBJECT const*>> | ||
| 215 | m_RepointedSubobjectVectors; | ||
| 216 | std::list<D3D12_GENERIC_PROGRAM_DESC> | ||
| 217 | m_RepointedPrograms; | ||
| 218 | #endif | ||
| 219 | |||
| 220 | template<typename CStr, typename StdStr> | ||
| 221 | class StringContainer | ||
| 222 | { | ||
| 223 | public: | ||
| 224 | CStr LocalCopy(CStr string, bool bSingleString = false) | ||
| 225 | { | ||
| 226 | if (string) | ||
| 227 | { | ||
| 228 | if (bSingleString) | ||
| 229 | { | ||
| 230 | m_Strings.clear(); | ||
| 231 | m_Strings.push_back(string); | ||
| 232 | } | ||
| 233 | else | ||
| 234 | { | ||
| 235 | m_Strings.push_back(string); | ||
| 236 | } | ||
| 237 | return m_Strings.back().c_str(); | ||
| 238 | } | ||
| 239 | else | ||
| 240 | { | ||
| 241 | return nullptr; | ||
| 242 | } | ||
| 243 | } | ||
| 244 | void clear() noexcept { m_Strings.clear(); } | ||
| 245 | private: | ||
| 246 | std::list<StdStr> m_Strings; | ||
| 247 | }; | ||
| 248 | |||
| 249 | public: | ||
| 250 | class SUBOBJECT_HELPER_BASE | ||
| 251 | { | ||
| 252 | public: | ||
| 253 | SUBOBJECT_HELPER_BASE() noexcept { Init(); } | ||
| 254 | virtual ~SUBOBJECT_HELPER_BASE() = default; | ||
| 255 | virtual D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept = 0; | ||
| 256 | SUBOBJECT_HELPER_BASE(const SUBOBJECT_HELPER_BASE& other) = delete; | ||
| 257 | SUBOBJECT_HELPER_BASE& operator=(const SUBOBJECT_HELPER_BASE& other) = delete; | ||
| 258 | SUBOBJECT_HELPER_BASE(SUBOBJECT_HELPER_BASE&& other) = default; | ||
| 259 | SUBOBJECT_HELPER_BASE& operator=(SUBOBJECT_HELPER_BASE&& other) = default; | ||
| 260 | void AddToStateObject(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 261 | { | ||
| 262 | m_pSubobject = ContainingStateObject.TrackSubobject(Type(), Data()); | ||
| 263 | } | ||
| 264 | operator const D3D12_STATE_SUBOBJECT& () const noexcept { return *m_pSubobject; } | ||
| 265 | protected: | ||
| 266 | virtual void* Data() noexcept = 0; | ||
| 267 | void Init() noexcept { m_pSubobject = nullptr; } | ||
| 268 | D3D12_STATE_SUBOBJECT* m_pSubobject; | ||
| 269 | }; | ||
| 270 | |||
| 271 | private: | ||
| 272 | std::list<std::unique_ptr<SUBOBJECT_HELPER_BASE>> m_OwnedSubobjectHelpers; | ||
| 273 | |||
| 274 | friend class CD3DX12_DXIL_LIBRARY_SUBOBJECT; | ||
| 275 | friend class CD3DX12_EXISTING_COLLECTION_SUBOBJECT; | ||
| 276 | friend class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT; | ||
| 277 | friend class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; | ||
| 278 | friend class CD3DX12_HIT_GROUP_SUBOBJECT; | ||
| 279 | friend class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT; | ||
| 280 | friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT; | ||
| 281 | friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT; | ||
| 282 | friend class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT; | ||
| 283 | friend class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT; | ||
| 284 | friend class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT; | ||
| 285 | friend class CD3DX12_NODE_MASK_SUBOBJECT; | ||
| 286 | //TODO: SDK Version check should include all the newly added subobject type for the public release. | ||
| 287 | // The SDK version check will be changed based on when we release state objects. | ||
| 288 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 289 | friend class CD3DX12_GENERIC_PROGRAM_SUBOBJECT; | ||
| 290 | friend class CD3DX12_WORK_GRAPH_SUBOBJECT; | ||
| 291 | friend class CD3DX12_STREAM_OUTPUT_SUBOBJECT; | ||
| 292 | friend class CD3DX12_BLEND_SUBOBJECT; | ||
| 293 | friend class CD3DX12_RASTERIZER_SUBOBJECT; | ||
| 294 | friend class CD3DX12_DEPTH_STENCIL2_SUBOBJECT; | ||
| 295 | friend class CD3DX12_INPUT_LAYOUT_SUBOBJECT; | ||
| 296 | friend class CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT; | ||
| 297 | friend class CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT; | ||
| 298 | friend class CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT; | ||
| 299 | friend class CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT; | ||
| 300 | friend class CD3DX12_SAMPLE_DESC_SUBOBJECT; | ||
| 301 | friend class CD3DX12_FLAGS_SUBOBJECT; | ||
| 302 | friend class CD3DX12_VIEW_INSTANCING_SUBOBJECT; | ||
| 303 | friend class CD3DX12_DEPTH_STENCIL_SUBOBJECT; | ||
| 304 | friend class CD3DX12_DEPTH_STENCIL1_SUBOBJECT; | ||
| 305 | friend class CD3DX12_SAMPLE_MASK_SUBOBJECT; | ||
| 306 | friend class CD3DX12_NODE_OUTPUT_OVERRIDES; | ||
| 307 | friend class CD3DX12_NODE_HELPER_BASE; | ||
| 308 | friend class CD3DX12_SHADER_NODE; | ||
| 309 | friend class CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES; | ||
| 310 | friend class CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES; | ||
| 311 | friend class CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES; | ||
| 312 | friend class CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES; | ||
| 313 | #endif // D3D12_SDK_VERSION >= 612 | ||
| 314 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 315 | friend class CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT; | ||
| 316 | friend class CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT; | ||
| 317 | friend class CD3DX12_COMPILER_EXISTING_COLLECTION_SUBOBJECT; | ||
| 318 | friend class CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT; | ||
| 319 | #endif | ||
| 320 | }; | ||
| 321 | |||
| 322 | //------------------------------------------------------------------------------------------------ | ||
| 323 | class CD3DX12_DXIL_LIBRARY_SUBOBJECT | ||
| 324 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 325 | { | ||
| 326 | public: | ||
| 327 | CD3DX12_DXIL_LIBRARY_SUBOBJECT() noexcept | ||
| 328 | { | ||
| 329 | Init(); | ||
| 330 | } | ||
| 331 | CD3DX12_DXIL_LIBRARY_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 332 | { | ||
| 333 | Init(); | ||
| 334 | AddToStateObject(ContainingStateObject); | ||
| 335 | } | ||
| 336 | CD3DX12_DXIL_LIBRARY_SUBOBJECT(const CD3DX12_DXIL_LIBRARY_SUBOBJECT& other) = delete; | ||
| 337 | CD3DX12_DXIL_LIBRARY_SUBOBJECT& operator=(const CD3DX12_DXIL_LIBRARY_SUBOBJECT& other) = delete; | ||
| 338 | CD3DX12_DXIL_LIBRARY_SUBOBJECT(CD3DX12_DXIL_LIBRARY_SUBOBJECT&& other) = default; | ||
| 339 | CD3DX12_DXIL_LIBRARY_SUBOBJECT& operator=(CD3DX12_DXIL_LIBRARY_SUBOBJECT&& other) = default; | ||
| 340 | void SetDXILLibrary(const D3D12_SHADER_BYTECODE* pCode) noexcept | ||
| 341 | { | ||
| 342 | static const D3D12_SHADER_BYTECODE Default = {}; | ||
| 343 | m_Desc.DXILLibrary = pCode ? *pCode : Default; | ||
| 344 | } | ||
| 345 | void DefineExport( | ||
| 346 | LPCWSTR Name, | ||
| 347 | LPCWSTR ExportToRename = nullptr, | ||
| 348 | D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) | ||
| 349 | { | ||
| 350 | D3D12_EXPORT_DESC Export; | ||
| 351 | Export.Name = m_Strings.LocalCopy(Name); | ||
| 352 | Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); | ||
| 353 | Export.Flags = Flags; | ||
| 354 | m_Exports.push_back(Export); | ||
| 355 | m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined | ||
| 356 | m_Desc.NumExports = static_cast<UINT>(m_Exports.size()); | ||
| 357 | } | ||
| 358 | template<size_t N> | ||
| 359 | void DefineExports(LPCWSTR(&Exports)[N]) | ||
| 360 | { | ||
| 361 | for (UINT i = 0; i < N; i++) | ||
| 362 | { | ||
| 363 | DefineExport(Exports[i]); | ||
| 364 | } | ||
| 365 | } | ||
| 366 | void DefineExports(const LPCWSTR* Exports, UINT N) | ||
| 367 | { | ||
| 368 | for (UINT i = 0; i < N; i++) | ||
| 369 | { | ||
| 370 | DefineExport(Exports[i]); | ||
| 371 | } | ||
| 372 | } | ||
| 373 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 374 | { | ||
| 375 | return D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; | ||
| 376 | } | ||
| 377 | operator const D3D12_DXIL_LIBRARY_DESC&() const noexcept { return m_Desc; } | ||
| 378 | private: | ||
| 379 | void Init() noexcept | ||
| 380 | { | ||
| 381 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 382 | m_Desc = {}; | ||
| 383 | m_Strings.clear(); | ||
| 384 | m_Exports.clear(); | ||
| 385 | } | ||
| 386 | void* Data() noexcept override { return &m_Desc; } | ||
| 387 | D3D12_DXIL_LIBRARY_DESC m_Desc; | ||
| 388 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 389 | std::vector<D3D12_EXPORT_DESC> m_Exports; | ||
| 390 | }; | ||
| 391 | |||
| 392 | //------------------------------------------------------------------------------------------------ | ||
| 393 | class CD3DX12_EXISTING_COLLECTION_SUBOBJECT | ||
| 394 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 395 | { | ||
| 396 | public: | ||
| 397 | CD3DX12_EXISTING_COLLECTION_SUBOBJECT() noexcept | ||
| 398 | { | ||
| 399 | Init(); | ||
| 400 | } | ||
| 401 | CD3DX12_EXISTING_COLLECTION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 402 | { | ||
| 403 | Init(); | ||
| 404 | AddToStateObject(ContainingStateObject); | ||
| 405 | } | ||
| 406 | CD3DX12_EXISTING_COLLECTION_SUBOBJECT(const CD3DX12_EXISTING_COLLECTION_SUBOBJECT& other) = delete; | ||
| 407 | CD3DX12_EXISTING_COLLECTION_SUBOBJECT& operator=(const CD3DX12_EXISTING_COLLECTION_SUBOBJECT& other) = delete; | ||
| 408 | CD3DX12_EXISTING_COLLECTION_SUBOBJECT(CD3DX12_EXISTING_COLLECTION_SUBOBJECT&& other) = default; | ||
| 409 | CD3DX12_EXISTING_COLLECTION_SUBOBJECT& operator=(CD3DX12_EXISTING_COLLECTION_SUBOBJECT&& other) = default; | ||
| 410 | void SetExistingCollection(ID3D12StateObject*pExistingCollection) noexcept | ||
| 411 | { | ||
| 412 | m_Desc.pExistingCollection = pExistingCollection; | ||
| 413 | m_CollectionRef = pExistingCollection; | ||
| 414 | } | ||
| 415 | void DefineExport( | ||
| 416 | LPCWSTR Name, | ||
| 417 | LPCWSTR ExportToRename = nullptr, | ||
| 418 | D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) | ||
| 419 | { | ||
| 420 | D3D12_EXPORT_DESC Export; | ||
| 421 | Export.Name = m_Strings.LocalCopy(Name); | ||
| 422 | Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); | ||
| 423 | Export.Flags = Flags; | ||
| 424 | m_Exports.push_back(Export); | ||
| 425 | m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined | ||
| 426 | m_Desc.NumExports = static_cast<UINT>(m_Exports.size()); | ||
| 427 | } | ||
| 428 | template<size_t N> | ||
| 429 | void DefineExports(LPCWSTR(&Exports)[N]) | ||
| 430 | { | ||
| 431 | for (UINT i = 0; i < N; i++) | ||
| 432 | { | ||
| 433 | DefineExport(Exports[i]); | ||
| 434 | } | ||
| 435 | } | ||
| 436 | void DefineExports(const LPCWSTR* Exports, UINT N) | ||
| 437 | { | ||
| 438 | for (UINT i = 0; i < N; i++) | ||
| 439 | { | ||
| 440 | DefineExport(Exports[i]); | ||
| 441 | } | ||
| 442 | } | ||
| 443 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 444 | { | ||
| 445 | return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION; | ||
| 446 | } | ||
| 447 | operator const D3D12_EXISTING_COLLECTION_DESC&() const noexcept { return m_Desc; } | ||
| 448 | private: | ||
| 449 | void Init() noexcept | ||
| 450 | { | ||
| 451 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 452 | m_Desc = {}; | ||
| 453 | m_CollectionRef = nullptr; | ||
| 454 | m_Strings.clear(); | ||
| 455 | m_Exports.clear(); | ||
| 456 | } | ||
| 457 | void* Data() noexcept override { return &m_Desc; } | ||
| 458 | D3D12_EXISTING_COLLECTION_DESC m_Desc; | ||
| 459 | D3DX12_COM_PTR<ID3D12StateObject> m_CollectionRef; | ||
| 460 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 461 | std::vector<D3D12_EXPORT_DESC> m_Exports; | ||
| 462 | }; | ||
| 463 | |||
| 464 | //------------------------------------------------------------------------------------------------ | ||
| 465 | class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT | ||
| 466 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 467 | { | ||
| 468 | public: | ||
| 469 | CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT() noexcept | ||
| 470 | { | ||
| 471 | Init(); | ||
| 472 | } | ||
| 473 | CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 474 | { | ||
| 475 | Init(); | ||
| 476 | AddToStateObject(ContainingStateObject); | ||
| 477 | } | ||
| 478 | CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT(const CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT& other) = delete; | ||
| 479 | CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT& operator=(const CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT& other) = delete; | ||
| 480 | CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT(CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT&& other) = default; | ||
| 481 | CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT& operator=(CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT&& other) = default; | ||
| 482 | void SetSubobjectToAssociate(const D3D12_STATE_SUBOBJECT& SubobjectToAssociate) noexcept | ||
| 483 | { | ||
| 484 | m_Desc.pSubobjectToAssociate = &SubobjectToAssociate; | ||
| 485 | } | ||
| 486 | void AddExport(LPCWSTR Export) | ||
| 487 | { | ||
| 488 | m_Desc.NumExports++; | ||
| 489 | m_Exports.push_back(m_Strings.LocalCopy(Export)); | ||
| 490 | m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined | ||
| 491 | } | ||
| 492 | template<size_t N> | ||
| 493 | void AddExports(LPCWSTR (&Exports)[N]) | ||
| 494 | { | ||
| 495 | for (UINT i = 0; i < N; i++) | ||
| 496 | { | ||
| 497 | AddExport(Exports[i]); | ||
| 498 | } | ||
| 499 | } | ||
| 500 | void AddExports(const LPCWSTR* Exports, UINT N) | ||
| 501 | { | ||
| 502 | for (UINT i = 0; i < N; i++) | ||
| 503 | { | ||
| 504 | AddExport(Exports[i]); | ||
| 505 | } | ||
| 506 | } | ||
| 507 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 508 | { | ||
| 509 | return D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; | ||
| 510 | } | ||
| 511 | operator const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } | ||
| 512 | private: | ||
| 513 | void Init() noexcept | ||
| 514 | { | ||
| 515 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 516 | m_Desc = {}; | ||
| 517 | m_Strings.clear(); | ||
| 518 | m_Exports.clear(); | ||
| 519 | } | ||
| 520 | void* Data() noexcept override { return &m_Desc; } | ||
| 521 | D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; | ||
| 522 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 523 | std::vector<LPCWSTR> m_Exports; | ||
| 524 | }; | ||
| 525 | |||
| 526 | //------------------------------------------------------------------------------------------------ | ||
| 527 | class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION | ||
| 528 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 529 | { | ||
| 530 | public: | ||
| 531 | CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION() noexcept | ||
| 532 | { | ||
| 533 | Init(); | ||
| 534 | } | ||
| 535 | CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 536 | { | ||
| 537 | Init(); | ||
| 538 | AddToStateObject(ContainingStateObject); | ||
| 539 | } | ||
| 540 | CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION(const CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION& other) = delete; | ||
| 541 | CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION& operator=(const CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION& other) = delete; | ||
| 542 | CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION(CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&& other) = default; | ||
| 543 | CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION& operator=(CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&& other) = default; | ||
| 544 | void SetSubobjectNameToAssociate(LPCWSTR SubobjectToAssociate) | ||
| 545 | { | ||
| 546 | m_Desc.SubobjectToAssociate = m_SubobjectName.LocalCopy(SubobjectToAssociate, true); | ||
| 547 | } | ||
| 548 | void AddExport(LPCWSTR Export) | ||
| 549 | { | ||
| 550 | m_Desc.NumExports++; | ||
| 551 | m_Exports.push_back(m_Strings.LocalCopy(Export)); | ||
| 552 | m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined | ||
| 553 | } | ||
| 554 | template<size_t N> | ||
| 555 | void AddExports(LPCWSTR (&Exports)[N]) | ||
| 556 | { | ||
| 557 | for (UINT i = 0; i < N; i++) | ||
| 558 | { | ||
| 559 | AddExport(Exports[i]); | ||
| 560 | } | ||
| 561 | } | ||
| 562 | void AddExports(const LPCWSTR* Exports, UINT N) | ||
| 563 | { | ||
| 564 | for (UINT i = 0; i < N; i++) | ||
| 565 | { | ||
| 566 | AddExport(Exports[i]); | ||
| 567 | } | ||
| 568 | } | ||
| 569 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 570 | { | ||
| 571 | return D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; | ||
| 572 | } | ||
| 573 | operator const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } | ||
| 574 | private: | ||
| 575 | void Init() noexcept | ||
| 576 | { | ||
| 577 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 578 | m_Desc = {}; | ||
| 579 | m_Strings.clear(); | ||
| 580 | m_SubobjectName.clear(); | ||
| 581 | m_Exports.clear(); | ||
| 582 | } | ||
| 583 | void* Data() noexcept override { return &m_Desc; } | ||
| 584 | D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; | ||
| 585 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 586 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_SubobjectName; | ||
| 587 | std::vector<LPCWSTR> m_Exports; | ||
| 588 | }; | ||
| 589 | |||
| 590 | //------------------------------------------------------------------------------------------------ | ||
| 591 | class CD3DX12_HIT_GROUP_SUBOBJECT | ||
| 592 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 593 | { | ||
| 594 | public: | ||
| 595 | CD3DX12_HIT_GROUP_SUBOBJECT() noexcept | ||
| 596 | { | ||
| 597 | Init(); | ||
| 598 | } | ||
| 599 | CD3DX12_HIT_GROUP_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 600 | { | ||
| 601 | Init(); | ||
| 602 | AddToStateObject(ContainingStateObject); | ||
| 603 | } | ||
| 604 | CD3DX12_HIT_GROUP_SUBOBJECT(const CD3DX12_HIT_GROUP_SUBOBJECT& other) = delete; | ||
| 605 | CD3DX12_HIT_GROUP_SUBOBJECT& operator=(const CD3DX12_HIT_GROUP_SUBOBJECT& other) = delete; | ||
| 606 | CD3DX12_HIT_GROUP_SUBOBJECT(CD3DX12_HIT_GROUP_SUBOBJECT&& other) = default; | ||
| 607 | CD3DX12_HIT_GROUP_SUBOBJECT& operator=(CD3DX12_HIT_GROUP_SUBOBJECT&& other) = default; | ||
| 608 | void SetHitGroupExport(LPCWSTR exportName) | ||
| 609 | { | ||
| 610 | m_Desc.HitGroupExport = m_Strings[0].LocalCopy(exportName, true); | ||
| 611 | } | ||
| 612 | void SetHitGroupType(D3D12_HIT_GROUP_TYPE Type) noexcept { m_Desc.Type = Type; } | ||
| 613 | void SetAnyHitShaderImport(LPCWSTR importName) | ||
| 614 | { | ||
| 615 | m_Desc.AnyHitShaderImport = m_Strings[1].LocalCopy(importName, true); | ||
| 616 | } | ||
| 617 | void SetClosestHitShaderImport(LPCWSTR importName) | ||
| 618 | { | ||
| 619 | m_Desc.ClosestHitShaderImport = m_Strings[2].LocalCopy(importName, true); | ||
| 620 | } | ||
| 621 | void SetIntersectionShaderImport(LPCWSTR importName) | ||
| 622 | { | ||
| 623 | m_Desc.IntersectionShaderImport = m_Strings[3].LocalCopy(importName, true); | ||
| 624 | } | ||
| 625 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 626 | { | ||
| 627 | return D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; | ||
| 628 | } | ||
| 629 | operator const D3D12_HIT_GROUP_DESC&() const noexcept { return m_Desc; } | ||
| 630 | private: | ||
| 631 | void Init() noexcept | ||
| 632 | { | ||
| 633 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 634 | m_Desc = {}; | ||
| 635 | for (UINT i = 0; i < m_NumStrings; i++) | ||
| 636 | { | ||
| 637 | m_Strings[i].clear(); | ||
| 638 | } | ||
| 639 | } | ||
| 640 | void* Data() noexcept override { return &m_Desc; } | ||
| 641 | D3D12_HIT_GROUP_DESC m_Desc; | ||
| 642 | static constexpr UINT m_NumStrings = 4; | ||
| 643 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> | ||
| 644 | m_Strings[m_NumStrings]; // one string for every entrypoint name | ||
| 645 | }; | ||
| 646 | |||
| 647 | //------------------------------------------------------------------------------------------------ | ||
| 648 | class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT | ||
| 649 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 650 | { | ||
| 651 | public: | ||
| 652 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT() noexcept | ||
| 653 | : m_Desc({}) | ||
| 654 | { | ||
| 655 | Init(); | ||
| 656 | } | ||
| 657 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 658 | : m_Desc({}) | ||
| 659 | { | ||
| 660 | Init(); | ||
| 661 | AddToStateObject(ContainingStateObject); | ||
| 662 | } | ||
| 663 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(const D3D12_RAYTRACING_SHADER_CONFIG &desc) | ||
| 664 | : m_Desc(desc) | ||
| 665 | { | ||
| 666 | Init(); | ||
| 667 | } | ||
| 668 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(const D3D12_RAYTRACING_SHADER_CONFIG &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 669 | : m_Desc(desc) | ||
| 670 | { | ||
| 671 | Init(); | ||
| 672 | AddToStateObject(ContainingStateObject); | ||
| 673 | } | ||
| 674 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(const CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT& other) = delete; | ||
| 675 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT& operator=(const CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT& other) = delete; | ||
| 676 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT&& other) = default; | ||
| 677 | CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT& operator=(CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT&& other) = default; | ||
| 678 | void Config(UINT MaxPayloadSizeInBytes, UINT MaxAttributeSizeInBytes) noexcept | ||
| 679 | { | ||
| 680 | m_Desc.MaxPayloadSizeInBytes = MaxPayloadSizeInBytes; | ||
| 681 | m_Desc.MaxAttributeSizeInBytes = MaxAttributeSizeInBytes; | ||
| 682 | } | ||
| 683 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 684 | { | ||
| 685 | return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; | ||
| 686 | } | ||
| 687 | operator const D3D12_RAYTRACING_SHADER_CONFIG&() const noexcept { return m_Desc; } | ||
| 688 | operator D3D12_RAYTRACING_SHADER_CONFIG&() noexcept { return m_Desc; } | ||
| 689 | private: | ||
| 690 | void Init() noexcept | ||
| 691 | { | ||
| 692 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 693 | } | ||
| 694 | void* Data() noexcept override { return &m_Desc; } | ||
| 695 | D3D12_RAYTRACING_SHADER_CONFIG m_Desc; | ||
| 696 | }; | ||
| 697 | |||
| 698 | //------------------------------------------------------------------------------------------------ | ||
| 699 | class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT | ||
| 700 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 701 | { | ||
| 702 | public: | ||
| 703 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT() noexcept | ||
| 704 | : m_Desc({}) | ||
| 705 | { | ||
| 706 | Init(); | ||
| 707 | } | ||
| 708 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 709 | : m_Desc({}) | ||
| 710 | { | ||
| 711 | Init(); | ||
| 712 | AddToStateObject(ContainingStateObject); | ||
| 713 | } | ||
| 714 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(const D3D12_RAYTRACING_PIPELINE_CONFIG &desc) | ||
| 715 | : m_Desc(desc) | ||
| 716 | { | ||
| 717 | Init(); | ||
| 718 | } | ||
| 719 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(const D3D12_RAYTRACING_PIPELINE_CONFIG &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 720 | : m_Desc(desc) | ||
| 721 | { | ||
| 722 | Init(); | ||
| 723 | AddToStateObject(ContainingStateObject); | ||
| 724 | } | ||
| 725 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(const CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT& other) = delete; | ||
| 726 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT& operator=(const CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT& other) = delete; | ||
| 727 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT&& other) = default; | ||
| 728 | CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT& operator=(CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT&& other) = default; | ||
| 729 | void Config(UINT MaxTraceRecursionDepth) noexcept | ||
| 730 | { | ||
| 731 | m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; | ||
| 732 | } | ||
| 733 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 734 | { | ||
| 735 | return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; | ||
| 736 | } | ||
| 737 | operator const D3D12_RAYTRACING_PIPELINE_CONFIG&() const noexcept { return m_Desc; } | ||
| 738 | operator D3D12_RAYTRACING_PIPELINE_CONFIG&() noexcept { return m_Desc; } | ||
| 739 | private: | ||
| 740 | void Init() noexcept | ||
| 741 | { | ||
| 742 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 743 | } | ||
| 744 | void* Data() noexcept override { return &m_Desc; } | ||
| 745 | D3D12_RAYTRACING_PIPELINE_CONFIG m_Desc; | ||
| 746 | }; | ||
| 747 | |||
| 748 | //------------------------------------------------------------------------------------------------ | ||
| 749 | class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT | ||
| 750 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 751 | { | ||
| 752 | public: | ||
| 753 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT() noexcept | ||
| 754 | : m_Desc({}) | ||
| 755 | { | ||
| 756 | Init(); | ||
| 757 | } | ||
| 758 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 759 | : m_Desc({}) | ||
| 760 | { | ||
| 761 | Init(); | ||
| 762 | AddToStateObject(ContainingStateObject); | ||
| 763 | } | ||
| 764 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(const D3D12_RAYTRACING_PIPELINE_CONFIG1 &desc) | ||
| 765 | : m_Desc(desc) | ||
| 766 | { | ||
| 767 | Init(); | ||
| 768 | } | ||
| 769 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(const D3D12_RAYTRACING_PIPELINE_CONFIG1 &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 770 | : m_Desc(desc) | ||
| 771 | { | ||
| 772 | Init(); | ||
| 773 | AddToStateObject(ContainingStateObject); | ||
| 774 | } | ||
| 775 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(const CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT& other) = delete; | ||
| 776 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT& operator=(const CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT& other) = delete; | ||
| 777 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT&& other) = default; | ||
| 778 | CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT& operator=(CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT&& other) = default; | ||
| 779 | void Config(UINT MaxTraceRecursionDepth, D3D12_RAYTRACING_PIPELINE_FLAGS Flags) noexcept | ||
| 780 | { | ||
| 781 | m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; | ||
| 782 | m_Desc.Flags = Flags; | ||
| 783 | } | ||
| 784 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 785 | { | ||
| 786 | return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1; | ||
| 787 | } | ||
| 788 | operator const D3D12_RAYTRACING_PIPELINE_CONFIG1&() const noexcept { return m_Desc; } | ||
| 789 | operator D3D12_RAYTRACING_PIPELINE_CONFIG1&() noexcept { return m_Desc; } | ||
| 790 | private: | ||
| 791 | void Init() noexcept | ||
| 792 | { | ||
| 793 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 794 | } | ||
| 795 | void* Data() noexcept override { return &m_Desc; } | ||
| 796 | D3D12_RAYTRACING_PIPELINE_CONFIG1 m_Desc; | ||
| 797 | }; | ||
| 798 | |||
| 799 | //------------------------------------------------------------------------------------------------ | ||
| 800 | class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT | ||
| 801 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 802 | { | ||
| 803 | public: | ||
| 804 | CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT() noexcept | ||
| 805 | { | ||
| 806 | Init(); | ||
| 807 | } | ||
| 808 | CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 809 | { | ||
| 810 | Init(); | ||
| 811 | AddToStateObject(ContainingStateObject); | ||
| 812 | } | ||
| 813 | CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT(const CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 814 | CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT& operator=(const CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 815 | CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 816 | CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT& operator=(CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 817 | void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept | ||
| 818 | { | ||
| 819 | m_pRootSig = pRootSig; | ||
| 820 | } | ||
| 821 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 822 | { | ||
| 823 | return D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE; | ||
| 824 | } | ||
| 825 | operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } | ||
| 826 | private: | ||
| 827 | void Init() noexcept | ||
| 828 | { | ||
| 829 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 830 | m_pRootSig = nullptr; | ||
| 831 | } | ||
| 832 | void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } | ||
| 833 | D3DX12_COM_PTR<ID3D12RootSignature> m_pRootSig; | ||
| 834 | }; | ||
| 835 | |||
| 836 | |||
| 837 | //------------------------------------------------------------------------------------------------ | ||
| 838 | class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT | ||
| 839 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 840 | { | ||
| 841 | public: | ||
| 842 | CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT() noexcept | ||
| 843 | { | ||
| 844 | Init(); | ||
| 845 | } | ||
| 846 | CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 847 | { | ||
| 848 | Init(); | ||
| 849 | AddToStateObject(ContainingStateObject); | ||
| 850 | } | ||
| 851 | CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT(const CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 852 | CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT& operator=(const CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 853 | CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 854 | CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT& operator=(CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 855 | void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept | ||
| 856 | { | ||
| 857 | m_pRootSig = pRootSig; | ||
| 858 | } | ||
| 859 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 860 | { | ||
| 861 | return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; | ||
| 862 | } | ||
| 863 | operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } | ||
| 864 | private: | ||
| 865 | void Init() noexcept | ||
| 866 | { | ||
| 867 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 868 | m_pRootSig = nullptr; | ||
| 869 | } | ||
| 870 | void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } | ||
| 871 | D3DX12_COM_PTR<ID3D12RootSignature> m_pRootSig; | ||
| 872 | }; | ||
| 873 | |||
| 874 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 875 | //------------------------------------------------------------------------------------------------ | ||
| 876 | class CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT | ||
| 877 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 878 | { | ||
| 879 | public: | ||
| 880 | CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT() noexcept | ||
| 881 | : m_Desc({}) | ||
| 882 | { | ||
| 883 | Init(); | ||
| 884 | } | ||
| 885 | CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 886 | : m_Desc({}) | ||
| 887 | { | ||
| 888 | Init(); | ||
| 889 | AddToStateObject(ContainingStateObject); | ||
| 890 | } | ||
| 891 | CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT(const CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 892 | CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& operator=(const CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 893 | CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 894 | CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& operator=(CD3DX12_GLOBAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 895 | void SetRootSignature(const D3D12_SERIALIZED_ROOT_SIGNATURE_DESC* pDesc) noexcept | ||
| 896 | { | ||
| 897 | if (pDesc) | ||
| 898 | { | ||
| 899 | m_Desc.Desc = {}; | ||
| 900 | m_Desc.Desc.pSerializedBlob = pDesc->pSerializedBlob; | ||
| 901 | m_Desc.Desc.SerializedBlobSizeInBytes = pDesc->SerializedBlobSizeInBytes; | ||
| 902 | } | ||
| 903 | } | ||
| 904 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 905 | { | ||
| 906 | return D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_SERIALIZED_ROOT_SIGNATURE; | ||
| 907 | } | ||
| 908 | operator const D3D12_GLOBAL_SERIALIZED_ROOT_SIGNATURE&() const noexcept { return m_Desc; } | ||
| 909 | operator D3D12_GLOBAL_SERIALIZED_ROOT_SIGNATURE&() noexcept { return m_Desc; } | ||
| 910 | private: | ||
| 911 | void Init() noexcept | ||
| 912 | { | ||
| 913 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 914 | m_Desc = {}; | ||
| 915 | } | ||
| 916 | void* Data() noexcept override { return &m_Desc; } | ||
| 917 | D3D12_GLOBAL_SERIALIZED_ROOT_SIGNATURE m_Desc; | ||
| 918 | }; | ||
| 919 | |||
| 920 | //------------------------------------------------------------------------------------------------ | ||
| 921 | class CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT | ||
| 922 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 923 | { | ||
| 924 | public: | ||
| 925 | CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT() noexcept | ||
| 926 | : m_Desc({}) | ||
| 927 | { | ||
| 928 | Init(); | ||
| 929 | } | ||
| 930 | CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 931 | : m_Desc({}) | ||
| 932 | { | ||
| 933 | Init(); | ||
| 934 | AddToStateObject(ContainingStateObject); | ||
| 935 | } | ||
| 936 | CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT(const CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 937 | CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& operator=(const CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& other) = delete; | ||
| 938 | CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 939 | CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT& operator=(CD3DX12_LOCAL_SERIALIZED_ROOT_SIGNATURE_SUBOBJECT&& other) = default; | ||
| 940 | void SetRootSignature(const D3D12_SERIALIZED_ROOT_SIGNATURE_DESC* pDesc) noexcept | ||
| 941 | { | ||
| 942 | if (pDesc) | ||
| 943 | { | ||
| 944 | m_Desc.Desc = {}; | ||
| 945 | m_Desc.Desc.pSerializedBlob = pDesc->pSerializedBlob; | ||
| 946 | m_Desc.Desc.SerializedBlobSizeInBytes = pDesc->SerializedBlobSizeInBytes; | ||
| 947 | } | ||
| 948 | } | ||
| 949 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 950 | { | ||
| 951 | return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_SERIALIZED_ROOT_SIGNATURE; | ||
| 952 | } | ||
| 953 | operator const D3D12_LOCAL_SERIALIZED_ROOT_SIGNATURE&() const noexcept { return m_Desc; } | ||
| 954 | operator D3D12_LOCAL_SERIALIZED_ROOT_SIGNATURE&() noexcept { return m_Desc; } | ||
| 955 | private: | ||
| 956 | void Init() noexcept | ||
| 957 | { | ||
| 958 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 959 | m_Desc = {}; | ||
| 960 | } | ||
| 961 | void* Data() noexcept override { return &m_Desc; } | ||
| 962 | D3D12_LOCAL_SERIALIZED_ROOT_SIGNATURE m_Desc; | ||
| 963 | }; | ||
| 964 | |||
| 965 | |||
| 966 | //------------------------------------------------------------------------------------------------ | ||
| 967 | class CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT | ||
| 968 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 969 | { | ||
| 970 | public: | ||
| 971 | CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT() noexcept | ||
| 972 | { | ||
| 973 | Init(); | ||
| 974 | } | ||
| 975 | CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 976 | { | ||
| 977 | Init(); | ||
| 978 | AddToStateObject(ContainingStateObject); | ||
| 979 | } | ||
| 980 | CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT(const CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT& other) = delete; | ||
| 981 | CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT& operator=(const CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT& other) = delete; | ||
| 982 | CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT(CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT&& other) = default; | ||
| 983 | CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT& operator=(CD3DX12_EXISTING_COLLECTION_BY_KEY_SUBOBJECT&& other) = default; | ||
| 984 | void SetExistingCollection(const void* pKey, UINT KeySize) noexcept | ||
| 985 | { | ||
| 986 | const unsigned char* pKeyBytes = static_cast<const unsigned char *>(pKey); | ||
| 987 | m_Key.clear(); | ||
| 988 | m_Key.insert(m_Key.begin(), pKeyBytes, pKeyBytes + KeySize); | ||
| 989 | m_Desc.pKey = m_Key.data(); | ||
| 990 | m_Desc.KeySize = KeySize; | ||
| 991 | } | ||
| 992 | void DefineExport( | ||
| 993 | LPCWSTR Name, | ||
| 994 | LPCWSTR ExportToRename = nullptr, | ||
| 995 | D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) | ||
| 996 | { | ||
| 997 | D3D12_EXPORT_DESC Export; | ||
| 998 | Export.Name = m_Strings.LocalCopy(Name); | ||
| 999 | Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); | ||
| 1000 | Export.Flags = Flags; | ||
| 1001 | m_Exports.push_back(Export); | ||
| 1002 | m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined | ||
| 1003 | m_Desc.NumExports = static_cast<UINT>(m_Exports.size()); | ||
| 1004 | } | ||
| 1005 | template<size_t N> | ||
| 1006 | void DefineExports(LPCWSTR(&Exports)[N]) | ||
| 1007 | { | ||
| 1008 | for (UINT i = 0; i < N; i++) | ||
| 1009 | { | ||
| 1010 | DefineExport(Exports[i]); | ||
| 1011 | } | ||
| 1012 | } | ||
| 1013 | void DefineExports(const LPCWSTR* Exports, UINT N) | ||
| 1014 | { | ||
| 1015 | for (UINT i = 0; i < N; i++) | ||
| 1016 | { | ||
| 1017 | DefineExport(Exports[i]); | ||
| 1018 | } | ||
| 1019 | } | ||
| 1020 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1021 | { | ||
| 1022 | return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION_BY_KEY; | ||
| 1023 | } | ||
| 1024 | operator const D3D12_EXISTING_COLLECTION_BY_KEY_DESC&() const noexcept { return m_Desc; } | ||
| 1025 | private: | ||
| 1026 | void Init() noexcept | ||
| 1027 | { | ||
| 1028 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1029 | m_Desc = {}; | ||
| 1030 | m_Strings.clear(); | ||
| 1031 | m_Exports.clear(); | ||
| 1032 | } | ||
| 1033 | void* Data() noexcept override { return &m_Desc; } | ||
| 1034 | D3D12_EXISTING_COLLECTION_BY_KEY_DESC m_Desc; | ||
| 1035 | std::vector<unsigned char> m_Key; | ||
| 1036 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 1037 | std::vector<D3D12_EXPORT_DESC> m_Exports; | ||
| 1038 | }; | ||
| 1039 | |||
| 1040 | #endif // defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 618) | ||
| 1041 | |||
| 1042 | //------------------------------------------------------------------------------------------------ | ||
| 1043 | class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT | ||
| 1044 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1045 | { | ||
| 1046 | public: | ||
| 1047 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT() noexcept | ||
| 1048 | : m_Desc({}) | ||
| 1049 | { | ||
| 1050 | Init(); | ||
| 1051 | } | ||
| 1052 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1053 | : m_Desc({}) | ||
| 1054 | { | ||
| 1055 | Init(); | ||
| 1056 | AddToStateObject(ContainingStateObject); | ||
| 1057 | } | ||
| 1058 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(const D3D12_STATE_OBJECT_CONFIG &desc) noexcept | ||
| 1059 | : m_Desc(desc) | ||
| 1060 | { | ||
| 1061 | Init(); | ||
| 1062 | } | ||
| 1063 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(const D3D12_STATE_OBJECT_CONFIG &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1064 | : m_Desc(desc) | ||
| 1065 | { | ||
| 1066 | Init(); | ||
| 1067 | AddToStateObject(ContainingStateObject); | ||
| 1068 | } | ||
| 1069 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(const CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT& other) = delete; | ||
| 1070 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT& operator=(const CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT& other) = delete; | ||
| 1071 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT&& other) = default; | ||
| 1072 | CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT& operator=(CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT&& other) = default; | ||
| 1073 | void SetFlags(D3D12_STATE_OBJECT_FLAGS Flags) noexcept | ||
| 1074 | { | ||
| 1075 | m_Desc.Flags = Flags; | ||
| 1076 | } | ||
| 1077 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1078 | { | ||
| 1079 | return D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG; | ||
| 1080 | } | ||
| 1081 | operator const D3D12_STATE_OBJECT_CONFIG&() const noexcept { return m_Desc; } | ||
| 1082 | operator D3D12_STATE_OBJECT_CONFIG&() noexcept { return m_Desc; } | ||
| 1083 | private: | ||
| 1084 | void Init() noexcept | ||
| 1085 | { | ||
| 1086 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1087 | } | ||
| 1088 | void* Data() noexcept override { return &m_Desc; } | ||
| 1089 | D3D12_STATE_OBJECT_CONFIG m_Desc; | ||
| 1090 | }; | ||
| 1091 | |||
| 1092 | //------------------------------------------------------------------------------------------------ | ||
| 1093 | class CD3DX12_NODE_MASK_SUBOBJECT | ||
| 1094 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1095 | { | ||
| 1096 | public: | ||
| 1097 | CD3DX12_NODE_MASK_SUBOBJECT() noexcept | ||
| 1098 | : m_Desc({}) | ||
| 1099 | { | ||
| 1100 | Init(); | ||
| 1101 | } | ||
| 1102 | CD3DX12_NODE_MASK_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1103 | : m_Desc({}) | ||
| 1104 | { | ||
| 1105 | Init(); | ||
| 1106 | AddToStateObject(ContainingStateObject); | ||
| 1107 | } | ||
| 1108 | CD3DX12_NODE_MASK_SUBOBJECT(const D3D12_NODE_MASK &desc) noexcept | ||
| 1109 | : m_Desc(desc) | ||
| 1110 | { | ||
| 1111 | Init(); | ||
| 1112 | } | ||
| 1113 | CD3DX12_NODE_MASK_SUBOBJECT(const D3D12_NODE_MASK &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1114 | : m_Desc(desc) | ||
| 1115 | { | ||
| 1116 | Init(); | ||
| 1117 | AddToStateObject(ContainingStateObject); | ||
| 1118 | } | ||
| 1119 | CD3DX12_NODE_MASK_SUBOBJECT(const CD3DX12_NODE_MASK_SUBOBJECT& other) = delete; | ||
| 1120 | CD3DX12_NODE_MASK_SUBOBJECT& operator=(const CD3DX12_NODE_MASK_SUBOBJECT& other) = delete; | ||
| 1121 | CD3DX12_NODE_MASK_SUBOBJECT(CD3DX12_NODE_MASK_SUBOBJECT&& other) = default; | ||
| 1122 | CD3DX12_NODE_MASK_SUBOBJECT& operator=(CD3DX12_NODE_MASK_SUBOBJECT&& other) = default; | ||
| 1123 | void SetNodeMask(UINT NodeMask) noexcept | ||
| 1124 | { | ||
| 1125 | m_Desc.NodeMask = NodeMask; | ||
| 1126 | } | ||
| 1127 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1128 | { | ||
| 1129 | return D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK; | ||
| 1130 | } | ||
| 1131 | operator const D3D12_NODE_MASK&() const noexcept { return m_Desc; } | ||
| 1132 | operator D3D12_NODE_MASK&() noexcept { return m_Desc; } | ||
| 1133 | private: | ||
| 1134 | void Init() noexcept | ||
| 1135 | { | ||
| 1136 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1137 | } | ||
| 1138 | void* Data() noexcept override { return &m_Desc; } | ||
| 1139 | D3D12_NODE_MASK m_Desc; | ||
| 1140 | }; | ||
| 1141 | |||
| 1142 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 1143 | //------------------------------------------------------------------------------------------------ | ||
| 1144 | class CD3DX12_STREAM_OUTPUT_SUBOBJECT | ||
| 1145 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1146 | { | ||
| 1147 | public: | ||
| 1148 | CD3DX12_STREAM_OUTPUT_SUBOBJECT() | ||
| 1149 | { | ||
| 1150 | Init(); | ||
| 1151 | } | ||
| 1152 | CD3DX12_STREAM_OUTPUT_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1153 | { | ||
| 1154 | Init(); | ||
| 1155 | AddToStateObject(ContainingStateObject); | ||
| 1156 | } | ||
| 1157 | void AddSODeclEntry(const D3D12_SO_DECLARATION_ENTRY &entry) | ||
| 1158 | { | ||
| 1159 | m_soDecalEntries.emplace_back(D3D12_SO_DECLARATION_ENTRY{ | ||
| 1160 | entry.Stream, | ||
| 1161 | m_Strings.LocalCopy(entry.SemanticName), | ||
| 1162 | entry.SemanticIndex, | ||
| 1163 | entry.StartComponent, | ||
| 1164 | entry.ComponentCount, | ||
| 1165 | entry.OutputSlot | ||
| 1166 | }); | ||
| 1167 | m_Desc.NumEntries++; | ||
| 1168 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 1169 | m_Desc.pSODeclaration = &m_soDecalEntries[0]; | ||
| 1170 | } | ||
| 1171 | void SetSODeclEntries(const D3D12_SO_DECLARATION_ENTRY* soDeclEntries, UINT numEntries) | ||
| 1172 | { | ||
| 1173 | m_soDecalEntries.resize(numEntries); | ||
| 1174 | for (UINT i = 0; i < numEntries; i++) | ||
| 1175 | { | ||
| 1176 | m_soDecalEntries[i] = D3D12_SO_DECLARATION_ENTRY{ | ||
| 1177 | soDeclEntries[i].Stream, | ||
| 1178 | m_Strings.LocalCopy(soDeclEntries[i].SemanticName), | ||
| 1179 | soDeclEntries[i].SemanticIndex, | ||
| 1180 | soDeclEntries[i].StartComponent, | ||
| 1181 | soDeclEntries[i].ComponentCount, | ||
| 1182 | soDeclEntries[i].OutputSlot | ||
| 1183 | }; | ||
| 1184 | } | ||
| 1185 | m_Desc.NumEntries = numEntries; | ||
| 1186 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 1187 | if (numEntries > 0) | ||
| 1188 | { | ||
| 1189 | m_Desc.pSODeclaration = &m_soDecalEntries[0]; | ||
| 1190 | } | ||
| 1191 | } | ||
| 1192 | void SetBufferStrides(const UINT* bufferStrides, UINT numStrides) | ||
| 1193 | { | ||
| 1194 | for (UINT i = 0; i < numStrides; ++i) | ||
| 1195 | { | ||
| 1196 | m_Strides[i] = bufferStrides[i]; | ||
| 1197 | } | ||
| 1198 | m_Desc.pBufferStrides = m_Strides; | ||
| 1199 | m_Desc.NumStrides = numStrides; | ||
| 1200 | } | ||
| 1201 | void SetRasterizedStream(UINT rasterizedStream) | ||
| 1202 | { | ||
| 1203 | m_Desc.RasterizedStream = rasterizedStream; | ||
| 1204 | } | ||
| 1205 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1206 | { | ||
| 1207 | return D3D12_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT; | ||
| 1208 | } | ||
| 1209 | operator const D3D12_STREAM_OUTPUT_DESC& () const noexcept { return m_Desc; } | ||
| 1210 | |||
| 1211 | private: | ||
| 1212 | void Init() | ||
| 1213 | { | ||
| 1214 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1215 | m_Desc = {}; | ||
| 1216 | } | ||
| 1217 | void* Data() noexcept override { return &m_Desc; } | ||
| 1218 | D3D12_STREAM_OUTPUT_DESC m_Desc; | ||
| 1219 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCSTR, std::string> m_Strings; | ||
| 1220 | std::vector<D3D12_SO_DECLARATION_ENTRY> m_soDecalEntries; | ||
| 1221 | UINT m_Strides[D3D12_SO_STREAM_COUNT]; | ||
| 1222 | }; | ||
| 1223 | |||
| 1224 | //------------------------------------------------------------------------------------------------ | ||
| 1225 | class CD3DX12_BLEND_SUBOBJECT | ||
| 1226 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1227 | { | ||
| 1228 | public: | ||
| 1229 | CD3DX12_BLEND_SUBOBJECT() | ||
| 1230 | : m_Desc(CD3DX12_BLEND_DESC(D3D12_DEFAULT)) | ||
| 1231 | { | ||
| 1232 | Init(); | ||
| 1233 | } | ||
| 1234 | CD3DX12_BLEND_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1235 | : m_Desc(CD3DX12_BLEND_DESC(D3D12_DEFAULT)) | ||
| 1236 | { | ||
| 1237 | Init(); | ||
| 1238 | AddToStateObject(ContainingStateObject); | ||
| 1239 | } | ||
| 1240 | CD3DX12_BLEND_SUBOBJECT(const D3D12_BLEND_DESC &desc) | ||
| 1241 | : m_Desc(desc) | ||
| 1242 | { | ||
| 1243 | Init(); | ||
| 1244 | } | ||
| 1245 | CD3DX12_BLEND_SUBOBJECT(const D3D12_BLEND_DESC &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1246 | : m_Desc(desc) | ||
| 1247 | { | ||
| 1248 | Init(); | ||
| 1249 | AddToStateObject(ContainingStateObject); | ||
| 1250 | } | ||
| 1251 | void SetAlphaToCoverageEnable(bool alphaToCoverageEnable) | ||
| 1252 | { | ||
| 1253 | m_Desc.AlphaToCoverageEnable = alphaToCoverageEnable; | ||
| 1254 | } | ||
| 1255 | void SetIndependentBlendEnable(bool independentBlendEnable) | ||
| 1256 | { | ||
| 1257 | m_Desc.IndependentBlendEnable = independentBlendEnable; | ||
| 1258 | } | ||
| 1259 | void SetRenderTarget(UINT renderTargetIndex, const D3D12_RENDER_TARGET_BLEND_DESC& renderTargetBlendDesc) | ||
| 1260 | { | ||
| 1261 | m_Desc.RenderTarget[renderTargetIndex].BlendEnable = renderTargetBlendDesc.BlendEnable; | ||
| 1262 | m_Desc.RenderTarget[renderTargetIndex].BlendOp = renderTargetBlendDesc.BlendOp; | ||
| 1263 | m_Desc.RenderTarget[renderTargetIndex].BlendOpAlpha = renderTargetBlendDesc.BlendOpAlpha; | ||
| 1264 | m_Desc.RenderTarget[renderTargetIndex].DestBlend = renderTargetBlendDesc.DestBlend; | ||
| 1265 | m_Desc.RenderTarget[renderTargetIndex].DestBlendAlpha = renderTargetBlendDesc.DestBlendAlpha; | ||
| 1266 | m_Desc.RenderTarget[renderTargetIndex].LogicOp = renderTargetBlendDesc.LogicOp; | ||
| 1267 | m_Desc.RenderTarget[renderTargetIndex].LogicOpEnable = renderTargetBlendDesc.LogicOpEnable; | ||
| 1268 | m_Desc.RenderTarget[renderTargetIndex].RenderTargetWriteMask = renderTargetBlendDesc.RenderTargetWriteMask; | ||
| 1269 | m_Desc.RenderTarget[renderTargetIndex].SrcBlend = renderTargetBlendDesc.SrcBlend; | ||
| 1270 | m_Desc.RenderTarget[renderTargetIndex].SrcBlendAlpha = renderTargetBlendDesc.SrcBlendAlpha; | ||
| 1271 | } | ||
| 1272 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1273 | { | ||
| 1274 | return D3D12_STATE_SUBOBJECT_TYPE_BLEND; | ||
| 1275 | } | ||
| 1276 | operator const D3D12_BLEND_DESC& () const noexcept { return m_Desc; } | ||
| 1277 | operator D3D12_BLEND_DESC& () noexcept { return m_Desc; } | ||
| 1278 | private: | ||
| 1279 | void Init() noexcept | ||
| 1280 | { | ||
| 1281 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1282 | } | ||
| 1283 | void* Data() noexcept override { return &m_Desc; } | ||
| 1284 | CD3DX12_BLEND_DESC m_Desc; | ||
| 1285 | }; | ||
| 1286 | |||
| 1287 | //------------------------------------------------------------------------------------------------ | ||
| 1288 | class CD3DX12_RASTERIZER_SUBOBJECT | ||
| 1289 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1290 | { | ||
| 1291 | public: | ||
| 1292 | CD3DX12_RASTERIZER_SUBOBJECT() | ||
| 1293 | : m_Desc(CD3DX12_RASTERIZER_DESC2(D3D12_DEFAULT)) | ||
| 1294 | { | ||
| 1295 | Init(); | ||
| 1296 | } | ||
| 1297 | CD3DX12_RASTERIZER_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1298 | : m_Desc(CD3DX12_RASTERIZER_DESC2(D3D12_DEFAULT)) | ||
| 1299 | { | ||
| 1300 | Init(); | ||
| 1301 | AddToStateObject(ContainingStateObject); | ||
| 1302 | } | ||
| 1303 | CD3DX12_RASTERIZER_SUBOBJECT(const D3D12_RASTERIZER_DESC2 &desc) | ||
| 1304 | : m_Desc(desc) | ||
| 1305 | { | ||
| 1306 | Init(); | ||
| 1307 | } | ||
| 1308 | CD3DX12_RASTERIZER_SUBOBJECT(const D3D12_RASTERIZER_DESC2 &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1309 | : m_Desc(desc) | ||
| 1310 | { | ||
| 1311 | Init(); | ||
| 1312 | AddToStateObject(ContainingStateObject); | ||
| 1313 | } | ||
| 1314 | void SetFillMode(D3D12_FILL_MODE fillMode) | ||
| 1315 | { | ||
| 1316 | m_Desc.FillMode = fillMode; | ||
| 1317 | } | ||
| 1318 | void SetCullMode(D3D12_CULL_MODE cullMode) | ||
| 1319 | { | ||
| 1320 | m_Desc.CullMode = cullMode; | ||
| 1321 | } | ||
| 1322 | void SetFrontCounterClockwise(BOOL frontCounterClockwise) | ||
| 1323 | { | ||
| 1324 | m_Desc.FrontCounterClockwise = frontCounterClockwise; | ||
| 1325 | } | ||
| 1326 | void SetDepthBias(FLOAT depthBias) | ||
| 1327 | { | ||
| 1328 | m_Desc.DepthBias = depthBias; | ||
| 1329 | } | ||
| 1330 | void SetDepthBiasClamp(FLOAT depthBiasClamp) | ||
| 1331 | { | ||
| 1332 | m_Desc.DepthBiasClamp = depthBiasClamp; | ||
| 1333 | } | ||
| 1334 | void SetSlopeScaledDepthBias(FLOAT slopeScaledDepthBias) | ||
| 1335 | { | ||
| 1336 | m_Desc.SlopeScaledDepthBias = slopeScaledDepthBias; | ||
| 1337 | } | ||
| 1338 | void SetDepthClipEnable(BOOL depthClipEnable) | ||
| 1339 | { | ||
| 1340 | m_Desc.DepthClipEnable = depthClipEnable; | ||
| 1341 | } | ||
| 1342 | void SetLineRasterizationMode(D3D12_LINE_RASTERIZATION_MODE lineRasterizationMode) | ||
| 1343 | { | ||
| 1344 | m_Desc.LineRasterizationMode = lineRasterizationMode; | ||
| 1345 | } | ||
| 1346 | void SetForcedSampleCount(UINT forcedSampleCount) | ||
| 1347 | { | ||
| 1348 | m_Desc.ForcedSampleCount = forcedSampleCount; | ||
| 1349 | } | ||
| 1350 | void SetConservativeRaster(D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) | ||
| 1351 | { | ||
| 1352 | m_Desc.ConservativeRaster = conservativeRaster; | ||
| 1353 | } | ||
| 1354 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1355 | { | ||
| 1356 | return D3D12_STATE_SUBOBJECT_TYPE_RASTERIZER; | ||
| 1357 | } | ||
| 1358 | operator const D3D12_RASTERIZER_DESC2& () const noexcept { return m_Desc; } | ||
| 1359 | operator D3D12_RASTERIZER_DESC2& () noexcept { return m_Desc; } | ||
| 1360 | private: | ||
| 1361 | void Init() noexcept | ||
| 1362 | { | ||
| 1363 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1364 | } | ||
| 1365 | void* Data() noexcept override { return &m_Desc; } | ||
| 1366 | CD3DX12_RASTERIZER_DESC2 m_Desc; | ||
| 1367 | }; | ||
| 1368 | |||
| 1369 | //------------------------------------------------------------------------------------------------ | ||
| 1370 | class CD3DX12_DEPTH_STENCIL2_SUBOBJECT | ||
| 1371 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1372 | { | ||
| 1373 | public: | ||
| 1374 | CD3DX12_DEPTH_STENCIL2_SUBOBJECT() | ||
| 1375 | : m_Desc(CD3DX12_DEPTH_STENCIL_DESC2(D3D12_DEFAULT)) | ||
| 1376 | { | ||
| 1377 | Init(); | ||
| 1378 | } | ||
| 1379 | CD3DX12_DEPTH_STENCIL2_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1380 | : m_Desc(CD3DX12_DEPTH_STENCIL_DESC2(D3D12_DEFAULT)) | ||
| 1381 | { | ||
| 1382 | Init(); | ||
| 1383 | AddToStateObject(ContainingStateObject); | ||
| 1384 | } | ||
| 1385 | CD3DX12_DEPTH_STENCIL2_SUBOBJECT(const D3D12_DEPTH_STENCIL_DESC2 &desc) | ||
| 1386 | : m_Desc(desc) | ||
| 1387 | { | ||
| 1388 | Init(); | ||
| 1389 | } | ||
| 1390 | CD3DX12_DEPTH_STENCIL2_SUBOBJECT(const D3D12_DEPTH_STENCIL_DESC2 &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1391 | : m_Desc(desc) | ||
| 1392 | { | ||
| 1393 | Init(); | ||
| 1394 | AddToStateObject(ContainingStateObject); | ||
| 1395 | } | ||
| 1396 | void SetDepthEnable(BOOL depthEnable) | ||
| 1397 | { | ||
| 1398 | m_Desc.DepthEnable = depthEnable; | ||
| 1399 | } | ||
| 1400 | void SetDepthWriteMask(D3D12_DEPTH_WRITE_MASK depthWriteMask) | ||
| 1401 | { | ||
| 1402 | m_Desc.DepthWriteMask = depthWriteMask; | ||
| 1403 | } | ||
| 1404 | void SetDepthFunc(D3D12_COMPARISON_FUNC depthFunc) | ||
| 1405 | { | ||
| 1406 | m_Desc.DepthFunc = depthFunc; | ||
| 1407 | } | ||
| 1408 | void SetStencilEnable(BOOL stencilEnable) | ||
| 1409 | { | ||
| 1410 | m_Desc.StencilEnable = stencilEnable; | ||
| 1411 | } | ||
| 1412 | void SetFrontFace(D3D12_DEPTH_STENCILOP_DESC1 frontFace) | ||
| 1413 | { | ||
| 1414 | m_Desc.FrontFace = { | ||
| 1415 | frontFace.StencilFailOp, | ||
| 1416 | frontFace.StencilDepthFailOp, | ||
| 1417 | frontFace.StencilPassOp, | ||
| 1418 | frontFace.StencilFunc, | ||
| 1419 | frontFace.StencilReadMask, | ||
| 1420 | frontFace.StencilWriteMask | ||
| 1421 | }; | ||
| 1422 | } | ||
| 1423 | void SetBackFace(D3D12_DEPTH_STENCILOP_DESC1 backFace) | ||
| 1424 | { | ||
| 1425 | m_Desc.BackFace = { | ||
| 1426 | backFace.StencilFailOp, | ||
| 1427 | backFace.StencilDepthFailOp, | ||
| 1428 | backFace.StencilPassOp, | ||
| 1429 | backFace.StencilFunc, | ||
| 1430 | backFace.StencilReadMask, | ||
| 1431 | backFace.StencilWriteMask | ||
| 1432 | }; | ||
| 1433 | } | ||
| 1434 | void SetDepthBoundsTestEnable(BOOL depthBoundsTestEnable) | ||
| 1435 | { | ||
| 1436 | m_Desc.DepthBoundsTestEnable = depthBoundsTestEnable; | ||
| 1437 | } | ||
| 1438 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1439 | { | ||
| 1440 | return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2; | ||
| 1441 | } | ||
| 1442 | operator const D3D12_DEPTH_STENCIL_DESC2& () const noexcept { return m_Desc; } | ||
| 1443 | operator D3D12_DEPTH_STENCIL_DESC2& () noexcept { return m_Desc; } | ||
| 1444 | private: | ||
| 1445 | void Init() noexcept | ||
| 1446 | { | ||
| 1447 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1448 | } | ||
| 1449 | void* Data() noexcept override { return &m_Desc; } | ||
| 1450 | CD3DX12_DEPTH_STENCIL_DESC2 m_Desc; | ||
| 1451 | }; | ||
| 1452 | |||
| 1453 | //------------------------------------------------------------------------------------------------ | ||
| 1454 | class CD3DX12_INPUT_LAYOUT_SUBOBJECT | ||
| 1455 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1456 | { | ||
| 1457 | public: | ||
| 1458 | CD3DX12_INPUT_LAYOUT_SUBOBJECT() | ||
| 1459 | { | ||
| 1460 | Init(); | ||
| 1461 | } | ||
| 1462 | CD3DX12_INPUT_LAYOUT_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1463 | { | ||
| 1464 | Init(); | ||
| 1465 | AddToStateObject(ContainingStateObject); | ||
| 1466 | } | ||
| 1467 | void AddInputLayoutElementDesc(D3D12_INPUT_ELEMENT_DESC inputLayoutElementDesc) | ||
| 1468 | { | ||
| 1469 | m_inputLayoutElements.emplace_back( | ||
| 1470 | D3D12_INPUT_ELEMENT_DESC{ | ||
| 1471 | m_Strings.LocalCopy(inputLayoutElementDesc.SemanticName), | ||
| 1472 | inputLayoutElementDesc.SemanticIndex, | ||
| 1473 | inputLayoutElementDesc.Format, | ||
| 1474 | inputLayoutElementDesc.InputSlot, | ||
| 1475 | inputLayoutElementDesc.AlignedByteOffset, | ||
| 1476 | inputLayoutElementDesc.InputSlotClass, | ||
| 1477 | inputLayoutElementDesc.InstanceDataStepRate | ||
| 1478 | }); | ||
| 1479 | ++m_Desc.NumElements; | ||
| 1480 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 1481 | m_Desc.pInputElementDescs = &m_inputLayoutElements[0]; | ||
| 1482 | } | ||
| 1483 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1484 | { | ||
| 1485 | return D3D12_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT; | ||
| 1486 | } | ||
| 1487 | operator const D3D12_INPUT_LAYOUT_DESC& () const noexcept { return m_Desc; } | ||
| 1488 | private: | ||
| 1489 | void Init() noexcept | ||
| 1490 | { | ||
| 1491 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1492 | m_Desc = {}; | ||
| 1493 | m_inputLayoutElements.clear(); | ||
| 1494 | } | ||
| 1495 | void* Data() noexcept override { return &m_Desc; } | ||
| 1496 | D3D12_INPUT_LAYOUT_DESC m_Desc; | ||
| 1497 | std::vector<D3D12_INPUT_ELEMENT_DESC> m_inputLayoutElements; | ||
| 1498 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCSTR, std::string> m_Strings; | ||
| 1499 | }; | ||
| 1500 | |||
| 1501 | //------------------------------------------------------------------------------------------------ | ||
| 1502 | class CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT | ||
| 1503 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1504 | { | ||
| 1505 | public: | ||
| 1506 | CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT() | ||
| 1507 | : m_Desc(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED) | ||
| 1508 | { | ||
| 1509 | Init(); | ||
| 1510 | } | ||
| 1511 | CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1512 | : m_Desc(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED) | ||
| 1513 | { | ||
| 1514 | Init(); | ||
| 1515 | AddToStateObject(ContainingStateObject); | ||
| 1516 | } | ||
| 1517 | CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE desc) | ||
| 1518 | : m_Desc(desc) | ||
| 1519 | { | ||
| 1520 | Init(); | ||
| 1521 | } | ||
| 1522 | CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1523 | : m_Desc(desc) | ||
| 1524 | { | ||
| 1525 | Init(); | ||
| 1526 | AddToStateObject(ContainingStateObject); | ||
| 1527 | } | ||
| 1528 | void SetIBStripCutValue(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ibStripCutValue) | ||
| 1529 | { | ||
| 1530 | m_Desc = ibStripCutValue; | ||
| 1531 | } | ||
| 1532 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1533 | { | ||
| 1534 | return D3D12_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE; | ||
| 1535 | } | ||
| 1536 | operator const D3D12_INDEX_BUFFER_STRIP_CUT_VALUE& () const noexcept { return m_Desc; } | ||
| 1537 | operator D3D12_INDEX_BUFFER_STRIP_CUT_VALUE& () noexcept { return m_Desc; } | ||
| 1538 | private: | ||
| 1539 | void Init() noexcept | ||
| 1540 | { | ||
| 1541 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1542 | } | ||
| 1543 | void* Data() noexcept override { return &m_Desc; } | ||
| 1544 | D3D12_INDEX_BUFFER_STRIP_CUT_VALUE m_Desc; | ||
| 1545 | }; | ||
| 1546 | |||
| 1547 | //------------------------------------------------------------------------------------------------ | ||
| 1548 | class CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT | ||
| 1549 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1550 | { | ||
| 1551 | public: | ||
| 1552 | CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT() | ||
| 1553 | : m_Desc(D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED) | ||
| 1554 | { | ||
| 1555 | Init(); | ||
| 1556 | } | ||
| 1557 | CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1558 | : m_Desc(D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED) | ||
| 1559 | { | ||
| 1560 | Init(); | ||
| 1561 | AddToStateObject(ContainingStateObject); | ||
| 1562 | } | ||
| 1563 | CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT(D3D12_PRIMITIVE_TOPOLOGY_TYPE desc) | ||
| 1564 | : m_Desc(desc) | ||
| 1565 | { | ||
| 1566 | Init(); | ||
| 1567 | } | ||
| 1568 | CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT(D3D12_PRIMITIVE_TOPOLOGY_TYPE desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1569 | : m_Desc(desc) | ||
| 1570 | { | ||
| 1571 | Init(); | ||
| 1572 | AddToStateObject(ContainingStateObject); | ||
| 1573 | } | ||
| 1574 | void SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE primitiveTopologytype) | ||
| 1575 | { | ||
| 1576 | m_Desc = primitiveTopologytype; | ||
| 1577 | } | ||
| 1578 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1579 | { | ||
| 1580 | return D3D12_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY; | ||
| 1581 | } | ||
| 1582 | operator const D3D12_PRIMITIVE_TOPOLOGY_TYPE& () const noexcept { return m_Desc; } | ||
| 1583 | operator D3D12_PRIMITIVE_TOPOLOGY_TYPE& () noexcept { return m_Desc; } | ||
| 1584 | private: | ||
| 1585 | void Init() noexcept | ||
| 1586 | { | ||
| 1587 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1588 | } | ||
| 1589 | void* Data() noexcept override { return &m_Desc; } | ||
| 1590 | D3D12_PRIMITIVE_TOPOLOGY_TYPE m_Desc; | ||
| 1591 | }; | ||
| 1592 | |||
| 1593 | //------------------------------------------------------------------------------------------------ | ||
| 1594 | class CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT | ||
| 1595 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1596 | { | ||
| 1597 | public: | ||
| 1598 | CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT() | ||
| 1599 | : m_Desc({}) | ||
| 1600 | { | ||
| 1601 | Init(); | ||
| 1602 | } | ||
| 1603 | CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1604 | : m_Desc({}) | ||
| 1605 | { | ||
| 1606 | Init(); | ||
| 1607 | AddToStateObject(ContainingStateObject); | ||
| 1608 | } | ||
| 1609 | CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT(const D3D12_RT_FORMAT_ARRAY &desc) | ||
| 1610 | : m_Desc(desc) | ||
| 1611 | { | ||
| 1612 | Init(); | ||
| 1613 | } | ||
| 1614 | CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT(const D3D12_RT_FORMAT_ARRAY &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1615 | : m_Desc(desc) | ||
| 1616 | { | ||
| 1617 | Init(); | ||
| 1618 | AddToStateObject(ContainingStateObject); | ||
| 1619 | } | ||
| 1620 | void SetNumRenderTargets(UINT numRenderTargets) | ||
| 1621 | { | ||
| 1622 | m_Desc.NumRenderTargets = numRenderTargets; | ||
| 1623 | } | ||
| 1624 | void SetRenderTargetFormat(UINT renderTarget, DXGI_FORMAT renderTargetFormat) | ||
| 1625 | { | ||
| 1626 | m_Desc.RTFormats[renderTarget] = renderTargetFormat; | ||
| 1627 | } | ||
| 1628 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1629 | { | ||
| 1630 | return D3D12_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS; | ||
| 1631 | } | ||
| 1632 | operator const D3D12_RT_FORMAT_ARRAY& () const noexcept { return m_Desc; } | ||
| 1633 | operator D3D12_RT_FORMAT_ARRAY& () noexcept { return m_Desc; } | ||
| 1634 | private: | ||
| 1635 | void Init() noexcept | ||
| 1636 | { | ||
| 1637 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1638 | } | ||
| 1639 | void* Data() noexcept override { return &m_Desc; } | ||
| 1640 | D3D12_RT_FORMAT_ARRAY m_Desc; | ||
| 1641 | }; | ||
| 1642 | |||
| 1643 | //------------------------------------------------------------------------------------------------ | ||
| 1644 | class CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT | ||
| 1645 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1646 | { | ||
| 1647 | public: | ||
| 1648 | CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT() | ||
| 1649 | : m_Desc(DXGI_FORMAT_UNKNOWN) | ||
| 1650 | { | ||
| 1651 | Init(); | ||
| 1652 | } | ||
| 1653 | CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1654 | : m_Desc(DXGI_FORMAT_UNKNOWN) | ||
| 1655 | { | ||
| 1656 | Init(); | ||
| 1657 | AddToStateObject(ContainingStateObject); | ||
| 1658 | } | ||
| 1659 | CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT(DXGI_FORMAT desc) | ||
| 1660 | : m_Desc(desc) | ||
| 1661 | { | ||
| 1662 | Init(); | ||
| 1663 | } | ||
| 1664 | CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT(DXGI_FORMAT desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1665 | : m_Desc(desc) | ||
| 1666 | { | ||
| 1667 | Init(); | ||
| 1668 | AddToStateObject(ContainingStateObject); | ||
| 1669 | } | ||
| 1670 | void SetDepthStencilFormat(DXGI_FORMAT depthStencilFormat) | ||
| 1671 | { | ||
| 1672 | m_Desc = depthStencilFormat; | ||
| 1673 | } | ||
| 1674 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1675 | { | ||
| 1676 | return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT; | ||
| 1677 | } | ||
| 1678 | operator const DXGI_FORMAT& () const noexcept { return m_Desc; } | ||
| 1679 | operator DXGI_FORMAT& () noexcept { return m_Desc; } | ||
| 1680 | private: | ||
| 1681 | void Init() noexcept | ||
| 1682 | { | ||
| 1683 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1684 | } | ||
| 1685 | void* Data() noexcept override { return &m_Desc; } | ||
| 1686 | DXGI_FORMAT m_Desc; | ||
| 1687 | }; | ||
| 1688 | |||
| 1689 | //------------------------------------------------------------------------------------------------ | ||
| 1690 | class CD3DX12_SAMPLE_DESC_SUBOBJECT | ||
| 1691 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1692 | { | ||
| 1693 | public: | ||
| 1694 | CD3DX12_SAMPLE_DESC_SUBOBJECT() | ||
| 1695 | : m_Desc({1, 0}) | ||
| 1696 | { | ||
| 1697 | Init(); | ||
| 1698 | } | ||
| 1699 | CD3DX12_SAMPLE_DESC_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1700 | : m_Desc({1, 0}) | ||
| 1701 | { | ||
| 1702 | Init(); | ||
| 1703 | AddToStateObject(ContainingStateObject); | ||
| 1704 | } | ||
| 1705 | CD3DX12_SAMPLE_DESC_SUBOBJECT(const DXGI_SAMPLE_DESC &desc) | ||
| 1706 | : m_Desc(desc) | ||
| 1707 | { | ||
| 1708 | Init(); | ||
| 1709 | } | ||
| 1710 | CD3DX12_SAMPLE_DESC_SUBOBJECT(const DXGI_SAMPLE_DESC &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1711 | : m_Desc(desc) | ||
| 1712 | { | ||
| 1713 | Init(); | ||
| 1714 | AddToStateObject(ContainingStateObject); | ||
| 1715 | } | ||
| 1716 | void SetCount(UINT count) | ||
| 1717 | { | ||
| 1718 | m_Desc.Count = count; | ||
| 1719 | } | ||
| 1720 | void SetQuality(UINT quality) | ||
| 1721 | { | ||
| 1722 | m_Desc.Quality = quality; | ||
| 1723 | } | ||
| 1724 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1725 | { | ||
| 1726 | return D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_DESC; | ||
| 1727 | } | ||
| 1728 | operator const DXGI_SAMPLE_DESC& () const noexcept { return m_Desc; } | ||
| 1729 | operator DXGI_SAMPLE_DESC& () noexcept { return m_Desc; } | ||
| 1730 | private: | ||
| 1731 | void Init() noexcept | ||
| 1732 | { | ||
| 1733 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1734 | m_Desc = {}; | ||
| 1735 | } | ||
| 1736 | void* Data() noexcept override { return &m_Desc; } | ||
| 1737 | DXGI_SAMPLE_DESC m_Desc; | ||
| 1738 | }; | ||
| 1739 | |||
| 1740 | //------------------------------------------------------------------------------------------------ | ||
| 1741 | class CD3DX12_FLAGS_SUBOBJECT | ||
| 1742 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1743 | { | ||
| 1744 | public: | ||
| 1745 | CD3DX12_FLAGS_SUBOBJECT() | ||
| 1746 | : m_Desc(D3D12_PIPELINE_STATE_FLAG_NONE) | ||
| 1747 | { | ||
| 1748 | Init(); | ||
| 1749 | } | ||
| 1750 | CD3DX12_FLAGS_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1751 | : m_Desc(D3D12_PIPELINE_STATE_FLAG_NONE) | ||
| 1752 | { | ||
| 1753 | Init(); | ||
| 1754 | AddToStateObject(ContainingStateObject); | ||
| 1755 | } | ||
| 1756 | CD3DX12_FLAGS_SUBOBJECT(D3D12_PIPELINE_STATE_FLAGS desc) | ||
| 1757 | : m_Desc(desc) | ||
| 1758 | { | ||
| 1759 | Init(); | ||
| 1760 | } | ||
| 1761 | CD3DX12_FLAGS_SUBOBJECT(D3D12_PIPELINE_STATE_FLAGS desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1762 | : m_Desc(desc) | ||
| 1763 | { | ||
| 1764 | Init(); | ||
| 1765 | AddToStateObject(ContainingStateObject); | ||
| 1766 | } | ||
| 1767 | void SetFlags(D3D12_PIPELINE_STATE_FLAGS flags) | ||
| 1768 | { | ||
| 1769 | m_Desc = flags; | ||
| 1770 | } | ||
| 1771 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1772 | { | ||
| 1773 | return D3D12_STATE_SUBOBJECT_TYPE_FLAGS; | ||
| 1774 | } | ||
| 1775 | operator const D3D12_PIPELINE_STATE_FLAGS& () const noexcept { return m_Desc; } | ||
| 1776 | operator D3D12_PIPELINE_STATE_FLAGS& () noexcept { return m_Desc; } | ||
| 1777 | private: | ||
| 1778 | void Init() noexcept | ||
| 1779 | { | ||
| 1780 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1781 | } | ||
| 1782 | void* Data() noexcept override { return &m_Desc; } | ||
| 1783 | D3D12_PIPELINE_STATE_FLAGS m_Desc; | ||
| 1784 | }; | ||
| 1785 | |||
| 1786 | //------------------------------------------------------------------------------------------------ | ||
| 1787 | class CD3DX12_VIEW_INSTANCING_SUBOBJECT | ||
| 1788 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1789 | { | ||
| 1790 | public: | ||
| 1791 | CD3DX12_VIEW_INSTANCING_SUBOBJECT() | ||
| 1792 | { | ||
| 1793 | Init(); | ||
| 1794 | } | ||
| 1795 | CD3DX12_VIEW_INSTANCING_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1796 | { | ||
| 1797 | Init(); | ||
| 1798 | AddToStateObject(ContainingStateObject); | ||
| 1799 | } | ||
| 1800 | void AddViewInstanceLocation(D3D12_VIEW_INSTANCE_LOCATION viewInstanceLocation) | ||
| 1801 | { | ||
| 1802 | m_Desc.ViewInstanceCount++; | ||
| 1803 | m_viewInstanceLocations.emplace_back( | ||
| 1804 | D3D12_VIEW_INSTANCE_LOCATION | ||
| 1805 | { | ||
| 1806 | viewInstanceLocation.ViewportArrayIndex, | ||
| 1807 | viewInstanceLocation.RenderTargetArrayIndex | ||
| 1808 | } | ||
| 1809 | ); | ||
| 1810 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 1811 | m_Desc.pViewInstanceLocations = &m_viewInstanceLocations[0]; | ||
| 1812 | } | ||
| 1813 | void SetFlags(D3D12_VIEW_INSTANCING_FLAGS flags) | ||
| 1814 | { | ||
| 1815 | m_Desc.Flags = flags; | ||
| 1816 | } | ||
| 1817 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1818 | { | ||
| 1819 | return D3D12_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING; | ||
| 1820 | } | ||
| 1821 | operator const D3D12_VIEW_INSTANCING_DESC& () const noexcept { return m_Desc; } | ||
| 1822 | private: | ||
| 1823 | void Init() noexcept | ||
| 1824 | { | ||
| 1825 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1826 | m_Desc = CD3DX12_VIEW_INSTANCING_DESC(D3D12_DEFAULT); | ||
| 1827 | m_viewInstanceLocations.clear(); | ||
| 1828 | } | ||
| 1829 | void* Data() noexcept override { return &m_Desc; } | ||
| 1830 | CD3DX12_VIEW_INSTANCING_DESC m_Desc; | ||
| 1831 | std::vector<D3D12_VIEW_INSTANCE_LOCATION> m_viewInstanceLocations; | ||
| 1832 | }; | ||
| 1833 | |||
| 1834 | //------------------------------------------------------------------------------------------------ | ||
| 1835 | class CD3DX12_DEPTH_STENCIL_SUBOBJECT | ||
| 1836 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1837 | { | ||
| 1838 | public: | ||
| 1839 | CD3DX12_DEPTH_STENCIL_SUBOBJECT() | ||
| 1840 | : m_Desc(CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT)) | ||
| 1841 | { | ||
| 1842 | Init(); | ||
| 1843 | } | ||
| 1844 | CD3DX12_DEPTH_STENCIL_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1845 | : m_Desc(CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT)) | ||
| 1846 | { | ||
| 1847 | Init(); | ||
| 1848 | AddToStateObject(ContainingStateObject); | ||
| 1849 | } | ||
| 1850 | CD3DX12_DEPTH_STENCIL_SUBOBJECT(const D3D12_DEPTH_STENCIL_DESC &desc) | ||
| 1851 | : m_Desc(desc) | ||
| 1852 | { | ||
| 1853 | Init(); | ||
| 1854 | } | ||
| 1855 | CD3DX12_DEPTH_STENCIL_SUBOBJECT(const D3D12_DEPTH_STENCIL_DESC &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1856 | : m_Desc(desc) | ||
| 1857 | { | ||
| 1858 | Init(); | ||
| 1859 | AddToStateObject(ContainingStateObject); | ||
| 1860 | } | ||
| 1861 | void SetDepthEnable(BOOL depthEnable) | ||
| 1862 | { | ||
| 1863 | m_Desc.DepthEnable = depthEnable; | ||
| 1864 | } | ||
| 1865 | void SetDepthWriteMask(D3D12_DEPTH_WRITE_MASK depthWriteMask) | ||
| 1866 | { | ||
| 1867 | m_Desc.DepthWriteMask = depthWriteMask; | ||
| 1868 | } | ||
| 1869 | void SetDepthFunc(D3D12_COMPARISON_FUNC depthFunc) | ||
| 1870 | { | ||
| 1871 | m_Desc.DepthFunc = depthFunc; | ||
| 1872 | } | ||
| 1873 | void SetStencilEnable(BOOL stencilEnable) | ||
| 1874 | { | ||
| 1875 | m_Desc.StencilEnable = stencilEnable; | ||
| 1876 | } | ||
| 1877 | void SetStencilReadMask(UINT8 stencilReadMask) | ||
| 1878 | { | ||
| 1879 | m_Desc.StencilReadMask = stencilReadMask; | ||
| 1880 | } | ||
| 1881 | void SetStencilWriteMask(UINT8 stencilWriteMask) | ||
| 1882 | { | ||
| 1883 | m_Desc.StencilWriteMask = stencilWriteMask; | ||
| 1884 | } | ||
| 1885 | void SetFrontFace(D3D12_DEPTH_STENCILOP_DESC frontFace) | ||
| 1886 | { | ||
| 1887 | m_Desc.FrontFace = { | ||
| 1888 | frontFace.StencilFailOp, | ||
| 1889 | frontFace.StencilDepthFailOp, | ||
| 1890 | frontFace.StencilPassOp, | ||
| 1891 | frontFace.StencilFunc | ||
| 1892 | }; | ||
| 1893 | } | ||
| 1894 | void SetBackFace(D3D12_DEPTH_STENCILOP_DESC backFace) | ||
| 1895 | { | ||
| 1896 | m_Desc.BackFace = { | ||
| 1897 | backFace.StencilFailOp, | ||
| 1898 | backFace.StencilDepthFailOp, | ||
| 1899 | backFace.StencilPassOp, | ||
| 1900 | backFace.StencilFunc | ||
| 1901 | }; | ||
| 1902 | } | ||
| 1903 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1904 | { | ||
| 1905 | return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL; | ||
| 1906 | } | ||
| 1907 | operator const D3D12_DEPTH_STENCIL_DESC& () const noexcept { return m_Desc; } | ||
| 1908 | operator D3D12_DEPTH_STENCIL_DESC& () noexcept { return m_Desc; } | ||
| 1909 | private: | ||
| 1910 | void Init() noexcept | ||
| 1911 | { | ||
| 1912 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 1913 | } | ||
| 1914 | void* Data() noexcept override { return &m_Desc; } | ||
| 1915 | CD3DX12_DEPTH_STENCIL_DESC m_Desc; | ||
| 1916 | }; | ||
| 1917 | |||
| 1918 | //------------------------------------------------------------------------------------------------ | ||
| 1919 | class CD3DX12_DEPTH_STENCIL1_SUBOBJECT | ||
| 1920 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 1921 | { | ||
| 1922 | public: | ||
| 1923 | CD3DX12_DEPTH_STENCIL1_SUBOBJECT() | ||
| 1924 | : m_Desc(CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEFAULT)) | ||
| 1925 | { | ||
| 1926 | Init(); | ||
| 1927 | } | ||
| 1928 | CD3DX12_DEPTH_STENCIL1_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1929 | : m_Desc(CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEFAULT)) | ||
| 1930 | { | ||
| 1931 | Init(); | ||
| 1932 | AddToStateObject(ContainingStateObject); | ||
| 1933 | } | ||
| 1934 | CD3DX12_DEPTH_STENCIL1_SUBOBJECT(const D3D12_DEPTH_STENCIL_DESC1 &desc) | ||
| 1935 | : m_Desc(desc) | ||
| 1936 | { | ||
| 1937 | Init(); | ||
| 1938 | } | ||
| 1939 | CD3DX12_DEPTH_STENCIL1_SUBOBJECT(const D3D12_DEPTH_STENCIL_DESC1 &desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 1940 | : m_Desc(desc) | ||
| 1941 | { | ||
| 1942 | Init(); | ||
| 1943 | AddToStateObject(ContainingStateObject); | ||
| 1944 | } | ||
| 1945 | void SetDepthEnable(BOOL depthEnable) | ||
| 1946 | { | ||
| 1947 | m_Desc.DepthEnable = depthEnable; | ||
| 1948 | } | ||
| 1949 | void SetDepthWriteMask(D3D12_DEPTH_WRITE_MASK depthWriteMask) | ||
| 1950 | { | ||
| 1951 | m_Desc.DepthWriteMask = depthWriteMask; | ||
| 1952 | } | ||
| 1953 | void SetDepthFunc(D3D12_COMPARISON_FUNC depthFunc) | ||
| 1954 | { | ||
| 1955 | m_Desc.DepthFunc = depthFunc; | ||
| 1956 | } | ||
| 1957 | void SetStencilEnable(BOOL stencilEnable) | ||
| 1958 | { | ||
| 1959 | m_Desc.StencilEnable = stencilEnable; | ||
| 1960 | } | ||
| 1961 | void SetStencilReadMask(UINT8 stencilReadMask) | ||
| 1962 | { | ||
| 1963 | m_Desc.StencilReadMask = stencilReadMask; | ||
| 1964 | } | ||
| 1965 | void SetStencilWriteMask(UINT8 stencilWriteMask) | ||
| 1966 | { | ||
| 1967 | m_Desc.StencilWriteMask = stencilWriteMask; | ||
| 1968 | } | ||
| 1969 | void SetFrontFace(D3D12_DEPTH_STENCILOP_DESC frontFace) | ||
| 1970 | { | ||
| 1971 | m_Desc.FrontFace = { | ||
| 1972 | frontFace.StencilFailOp, | ||
| 1973 | frontFace.StencilDepthFailOp, | ||
| 1974 | frontFace.StencilPassOp, | ||
| 1975 | frontFace.StencilFunc | ||
| 1976 | }; | ||
| 1977 | } | ||
| 1978 | void SetBackFace(D3D12_DEPTH_STENCILOP_DESC backFace) | ||
| 1979 | { | ||
| 1980 | m_Desc.BackFace = { | ||
| 1981 | backFace.StencilFailOp, | ||
| 1982 | backFace.StencilDepthFailOp, | ||
| 1983 | backFace.StencilPassOp, | ||
| 1984 | backFace.StencilFunc | ||
| 1985 | }; | ||
| 1986 | } | ||
| 1987 | void SetDepthBoundsTestEnable(BOOL depthBoundsTestEnable) | ||
| 1988 | { | ||
| 1989 | m_Desc.DepthBoundsTestEnable = depthBoundsTestEnable; | ||
| 1990 | } | ||
| 1991 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 1992 | { | ||
| 1993 | return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1; | ||
| 1994 | } | ||
| 1995 | operator const D3D12_DEPTH_STENCIL_DESC1& () const noexcept { return m_Desc; } | ||
| 1996 | operator D3D12_DEPTH_STENCIL_DESC1& () noexcept { return m_Desc; } | ||
| 1997 | private: | ||
| 1998 | void Init() noexcept | ||
| 1999 | { | ||
| 2000 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 2001 | } | ||
| 2002 | void* Data() noexcept override { return &m_Desc; } | ||
| 2003 | CD3DX12_DEPTH_STENCIL_DESC1 m_Desc; | ||
| 2004 | }; | ||
| 2005 | |||
| 2006 | //------------------------------------------------------------------------------------------------ | ||
| 2007 | class CD3DX12_SAMPLE_MASK_SUBOBJECT | ||
| 2008 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 2009 | { | ||
| 2010 | public: | ||
| 2011 | CD3DX12_SAMPLE_MASK_SUBOBJECT() | ||
| 2012 | : m_Desc(0xffffffffu) | ||
| 2013 | { | ||
| 2014 | Init(); | ||
| 2015 | } | ||
| 2016 | CD3DX12_SAMPLE_MASK_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 2017 | : m_Desc(0xffffffffu) | ||
| 2018 | { | ||
| 2019 | Init(); | ||
| 2020 | AddToStateObject(ContainingStateObject); | ||
| 2021 | } | ||
| 2022 | CD3DX12_SAMPLE_MASK_SUBOBJECT(UINT desc) | ||
| 2023 | : m_Desc(desc) | ||
| 2024 | { | ||
| 2025 | Init(); | ||
| 2026 | } | ||
| 2027 | CD3DX12_SAMPLE_MASK_SUBOBJECT(UINT desc, CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 2028 | : m_Desc(desc) | ||
| 2029 | { | ||
| 2030 | Init(); | ||
| 2031 | AddToStateObject(ContainingStateObject); | ||
| 2032 | } | ||
| 2033 | void SetSampleMask(UINT sampleMask) | ||
| 2034 | { | ||
| 2035 | m_Desc = sampleMask; | ||
| 2036 | } | ||
| 2037 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 2038 | { | ||
| 2039 | return D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_MASK; | ||
| 2040 | } | ||
| 2041 | operator const UINT& () const noexcept { return m_Desc; } | ||
| 2042 | operator UINT& () noexcept { return m_Desc; } | ||
| 2043 | private: | ||
| 2044 | void Init() noexcept | ||
| 2045 | { | ||
| 2046 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 2047 | } | ||
| 2048 | void* Data() noexcept override { return &m_Desc; } | ||
| 2049 | UINT m_Desc; | ||
| 2050 | }; | ||
| 2051 | |||
| 2052 | //------------------------------------------------------------------------------------------------ | ||
| 2053 | class CD3DX12_GENERIC_PROGRAM_SUBOBJECT | ||
| 2054 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 2055 | { | ||
| 2056 | public: | ||
| 2057 | CD3DX12_GENERIC_PROGRAM_SUBOBJECT() | ||
| 2058 | { | ||
| 2059 | Init(); | ||
| 2060 | } | ||
| 2061 | CD3DX12_GENERIC_PROGRAM_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 2062 | { | ||
| 2063 | Init(); | ||
| 2064 | AddToStateObject(ContainingStateObject); | ||
| 2065 | } | ||
| 2066 | void SetProgramName(LPCWSTR ProgramName) | ||
| 2067 | { | ||
| 2068 | m_Desc.ProgramName = m_Strings.LocalCopy(ProgramName); | ||
| 2069 | } | ||
| 2070 | void AddExport(LPCWSTR exportName) | ||
| 2071 | { | ||
| 2072 | m_Exports.emplace_back(m_Strings.LocalCopy(exportName)); | ||
| 2073 | m_Desc.NumExports++; | ||
| 2074 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 2075 | m_Desc.pExports = &m_Exports[0]; | ||
| 2076 | } | ||
| 2077 | void AddSubobject(const D3D12_STATE_SUBOBJECT& subobject) | ||
| 2078 | { | ||
| 2079 | m_Subobjects.emplace_back(&subobject); | ||
| 2080 | m_Desc.NumSubobjects++; | ||
| 2081 | // Below: using ugly way to get pointer in case .data() is not defined | ||
| 2082 | m_Desc.ppSubobjects = &m_Subobjects[0]; | ||
| 2083 | } | ||
| 2084 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 2085 | { | ||
| 2086 | return D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM; | ||
| 2087 | } | ||
| 2088 | operator const D3D12_GENERIC_PROGRAM_DESC& () const noexcept { return m_Desc; } | ||
| 2089 | private: | ||
| 2090 | void Init() noexcept | ||
| 2091 | { | ||
| 2092 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 2093 | m_Desc = {}; | ||
| 2094 | } | ||
| 2095 | void* Data() noexcept override { return &m_Desc; } | ||
| 2096 | D3D12_GENERIC_PROGRAM_DESC m_Desc; | ||
| 2097 | std::vector<LPCWSTR> m_Exports; | ||
| 2098 | std::vector<D3D12_STATE_SUBOBJECT const*> m_Subobjects; | ||
| 2099 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 2100 | }; | ||
| 2101 | |||
| 2102 | //------------------------------------------------------------------------------------------------ | ||
| 2103 | class CD3DX12_NODE_OUTPUT_OVERRIDES | ||
| 2104 | { | ||
| 2105 | public: | ||
| 2106 | CD3DX12_NODE_OUTPUT_OVERRIDES(const D3D12_NODE_OUTPUT_OVERRIDES** ppOwner, UINT* pNumOutputOverrides) noexcept | ||
| 2107 | { | ||
| 2108 | m_Desc.clear(); | ||
| 2109 | m_ppOwner = ppOwner; | ||
| 2110 | *m_ppOwner = nullptr; | ||
| 2111 | m_pNumOutputOverrides = pNumOutputOverrides; | ||
| 2112 | *m_pNumOutputOverrides = 0; | ||
| 2113 | } | ||
| 2114 | void NewOutputOverride() | ||
| 2115 | { | ||
| 2116 | m_Desc.emplace_back(D3D12_NODE_OUTPUT_OVERRIDES{}); | ||
| 2117 | *m_ppOwner = m_Desc.data(); | ||
| 2118 | (*m_pNumOutputOverrides)++; | ||
| 2119 | } | ||
| 2120 | void OutputIndex(UINT index) | ||
| 2121 | { | ||
| 2122 | m_Desc.back().OutputIndex = index; | ||
| 2123 | } | ||
| 2124 | void NewName(LPCWSTR Name, UINT ArrayIndex = 0) | ||
| 2125 | { | ||
| 2126 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(Name),ArrayIndex }); | ||
| 2127 | m_Desc.back().pNewName = &m_NodeIDs.front(); | ||
| 2128 | } | ||
| 2129 | void AllowSparseNodes(BOOL bAllow) | ||
| 2130 | { | ||
| 2131 | m_UINTs.emplace_front((UINT)bAllow); | ||
| 2132 | m_Desc.back().pAllowSparseNodes = (BOOL*)&m_UINTs.front(); | ||
| 2133 | } | ||
| 2134 | void MaxOutputRecords(UINT maxOutputRecords) noexcept | ||
| 2135 | { | ||
| 2136 | m_UINTs.emplace_front(maxOutputRecords); | ||
| 2137 | m_Desc.back().pMaxRecords = &m_UINTs.front(); | ||
| 2138 | } | ||
| 2139 | void MaxOutputRecordsSharedWith(UINT outputIndex) noexcept | ||
| 2140 | { | ||
| 2141 | m_UINTs.emplace_front(outputIndex); | ||
| 2142 | m_Desc.back().pMaxRecordsSharedWithOutputIndex = &m_UINTs.front(); | ||
| 2143 | } | ||
| 2144 | private: | ||
| 2145 | std::vector<D3D12_NODE_OUTPUT_OVERRIDES> m_Desc; | ||
| 2146 | // Cached parameters | ||
| 2147 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 2148 | std::forward_list<UINT> m_UINTs; | ||
| 2149 | std::forward_list<D3D12_NODE_ID> m_NodeIDs; | ||
| 2150 | const D3D12_NODE_OUTPUT_OVERRIDES** m_ppOwner; | ||
| 2151 | UINT* m_pNumOutputOverrides; | ||
| 2152 | }; | ||
| 2153 | |||
| 2154 | //------------------------------------------------------------------------------------------------ | ||
| 2155 | class CD3DX12_WORK_GRAPH_SUBOBJECT; | ||
| 2156 | |||
| 2157 | //------------------------------------------------------------------------------------------------ | ||
| 2158 | class CD3DX12_NODE_HELPER_BASE | ||
| 2159 | { | ||
| 2160 | protected: | ||
| 2161 | struct Backreference | ||
| 2162 | { | ||
| 2163 | CD3DX12_WORK_GRAPH_SUBOBJECT *m_pGraph; | ||
| 2164 | UINT m_NodeIndex; | ||
| 2165 | }; | ||
| 2166 | public: | ||
| 2167 | CD3DX12_NODE_HELPER_BASE(const Backreference &BackRef) | ||
| 2168 | : m_BackRef(BackRef) | ||
| 2169 | { | ||
| 2170 | } | ||
| 2171 | virtual ~CD3DX12_NODE_HELPER_BASE() = default; | ||
| 2172 | protected: | ||
| 2173 | D3D12_NODE *GetNode() const; | ||
| 2174 | const Backreference m_BackRef; | ||
| 2175 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 2176 | }; | ||
| 2177 | |||
| 2178 | //------------------------------------------------------------------------------------------------ | ||
| 2179 | class CD3DX12_SHADER_NODE // Not specifying launch mode. | ||
| 2180 | // Don't need to distinguish if no parameter overriding is happening | ||
| 2181 | : public CD3DX12_NODE_HELPER_BASE | ||
| 2182 | { | ||
| 2183 | public: | ||
| 2184 | CD3DX12_SHADER_NODE( | ||
| 2185 | const Backreference &BackRef, | ||
| 2186 | LPCWSTR _Shader = nullptr) | ||
| 2187 | : CD3DX12_NODE_HELPER_BASE(BackRef) | ||
| 2188 | { | ||
| 2189 | GetNode()->NodeType = D3D12_NODE_TYPE_SHADER; | ||
| 2190 | Shader(_Shader); | ||
| 2191 | } | ||
| 2192 | void Shader(LPCWSTR _Shader) | ||
| 2193 | { | ||
| 2194 | GetNode()->Shader.Shader = m_Strings.LocalCopy(_Shader); | ||
| 2195 | } | ||
| 2196 | LPCWSTR GetShaderName() const { return GetNode()->Shader.Shader; } | ||
| 2197 | }; | ||
| 2198 | |||
| 2199 | #endif // D3D12_SDK_VERSION >= 612 | ||
| 2200 | |||
| 2201 | |||
| 2202 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 2203 | |||
| 2204 | //------------------------------------------------------------------------------------------------ | ||
| 2205 | // Use this class when defining a broadcasting launch node where configuration parameters | ||
| 2206 | // need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE | ||
| 2207 | class CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES | ||
| 2208 | : public CD3DX12_NODE_HELPER_BASE | ||
| 2209 | { | ||
| 2210 | public: | ||
| 2211 | CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES( | ||
| 2212 | const Backreference &BackRef, | ||
| 2213 | LPCWSTR _Shader = nullptr) : | ||
| 2214 | CD3DX12_NODE_HELPER_BASE(BackRef), | ||
| 2215 | m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) | ||
| 2216 | { | ||
| 2217 | Overrides = {}; | ||
| 2218 | D3D12_NODE *pNode = GetNode(); | ||
| 2219 | pNode->NodeType = D3D12_NODE_TYPE_SHADER; | ||
| 2220 | pNode->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_BROADCASTING_LAUNCH; | ||
| 2221 | pNode->Shader.pBroadcastingLaunchOverrides = &Overrides; | ||
| 2222 | Shader(_Shader); | ||
| 2223 | } | ||
| 2224 | void Shader(LPCWSTR _Shader) | ||
| 2225 | { | ||
| 2226 | GetNode()->Shader.Shader = m_Strings.LocalCopy(_Shader); | ||
| 2227 | } | ||
| 2228 | LPCWSTR GetShaderName() const { return GetNode()->Shader.Shader; } | ||
| 2229 | void LocalRootArgumentsTableIndex(UINT index) | ||
| 2230 | { | ||
| 2231 | m_UINTs.emplace_front(index); | ||
| 2232 | Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); | ||
| 2233 | } | ||
| 2234 | void ProgramEntry(BOOL bIsProgramEntry) | ||
| 2235 | { | ||
| 2236 | m_UINTs.emplace_front(bIsProgramEntry); | ||
| 2237 | Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); | ||
| 2238 | } | ||
| 2239 | void NewName(D3D12_NODE_ID NodeID) | ||
| 2240 | { | ||
| 2241 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2242 | Overrides.pNewName = &m_NodeIDs.front(); | ||
| 2243 | } | ||
| 2244 | void ShareInputOf(D3D12_NODE_ID NodeID) | ||
| 2245 | { | ||
| 2246 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2247 | Overrides.pShareInputOf = &m_NodeIDs.front(); | ||
| 2248 | } | ||
| 2249 | void DispatchGrid(UINT x, UINT y, UINT z) | ||
| 2250 | { | ||
| 2251 | m_UINT3s.emplace_front(UINT3{ x,y,z }); | ||
| 2252 | Overrides.pDispatchGrid = (UINT*)&m_UINT3s.front(); | ||
| 2253 | } | ||
| 2254 | void MaxDispatchGrid(UINT x, UINT y, UINT z) | ||
| 2255 | { | ||
| 2256 | m_UINT3s.emplace_front(UINT3{x,y,z}); | ||
| 2257 | Overrides.pMaxDispatchGrid = (UINT*)&m_UINT3s.front(); | ||
| 2258 | } | ||
| 2259 | CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() | ||
| 2260 | { | ||
| 2261 | return m_NodeOutputOverrides; | ||
| 2262 | } | ||
| 2263 | D3D12_BROADCASTING_LAUNCH_OVERRIDES Overrides; | ||
| 2264 | private: | ||
| 2265 | // Cached parameters | ||
| 2266 | std::forward_list<UINT> m_UINTs; | ||
| 2267 | struct UINT3 | ||
| 2268 | { | ||
| 2269 | UINT x; | ||
| 2270 | UINT y; | ||
| 2271 | UINT z; | ||
| 2272 | }; | ||
| 2273 | std::forward_list<UINT3> m_UINT3s; | ||
| 2274 | std::forward_list<D3D12_NODE_ID> m_NodeIDs; | ||
| 2275 | CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; | ||
| 2276 | }; | ||
| 2277 | |||
| 2278 | //------------------------------------------------------------------------------------------------ | ||
| 2279 | // Use this class when defining a coalescing launch node where configuration parameters | ||
| 2280 | // need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE | ||
| 2281 | class CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES | ||
| 2282 | : public CD3DX12_NODE_HELPER_BASE | ||
| 2283 | { | ||
| 2284 | public: | ||
| 2285 | CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES( | ||
| 2286 | const Backreference &BackRef, | ||
| 2287 | LPCWSTR _Shader = nullptr) : | ||
| 2288 | CD3DX12_NODE_HELPER_BASE(BackRef), | ||
| 2289 | m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) | ||
| 2290 | { | ||
| 2291 | Overrides = {}; | ||
| 2292 | D3D12_NODE *pNode = GetNode(); | ||
| 2293 | pNode->NodeType = D3D12_NODE_TYPE_SHADER; | ||
| 2294 | pNode->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_COALESCING_LAUNCH; | ||
| 2295 | pNode->Shader.pCoalescingLaunchOverrides = &Overrides; | ||
| 2296 | Shader(_Shader); | ||
| 2297 | } | ||
| 2298 | void Shader(LPCWSTR _Shader) | ||
| 2299 | { | ||
| 2300 | GetNode()->Shader.Shader = m_Strings.LocalCopy(_Shader); | ||
| 2301 | } | ||
| 2302 | LPCWSTR GetShaderName() const { return GetNode()->Shader.Shader; } | ||
| 2303 | void LocalRootArgumentsTableIndex(UINT index) | ||
| 2304 | { | ||
| 2305 | m_UINTs.emplace_front(index); | ||
| 2306 | Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); | ||
| 2307 | } | ||
| 2308 | void ProgramEntry(BOOL bIsProgramEntry) | ||
| 2309 | { | ||
| 2310 | m_UINTs.emplace_front(bIsProgramEntry); | ||
| 2311 | Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); | ||
| 2312 | } | ||
| 2313 | void NewName(D3D12_NODE_ID NodeID) | ||
| 2314 | { | ||
| 2315 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2316 | Overrides.pNewName = &m_NodeIDs.front(); | ||
| 2317 | } | ||
| 2318 | void ShareInputOf(D3D12_NODE_ID NodeID) | ||
| 2319 | { | ||
| 2320 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2321 | Overrides.pShareInputOf = &m_NodeIDs.front(); | ||
| 2322 | } | ||
| 2323 | CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() | ||
| 2324 | { | ||
| 2325 | return m_NodeOutputOverrides; | ||
| 2326 | } | ||
| 2327 | D3D12_COALESCING_LAUNCH_OVERRIDES Overrides; | ||
| 2328 | private: | ||
| 2329 | // Cached parameters | ||
| 2330 | std::forward_list<UINT> m_UINTs; | ||
| 2331 | struct UINT3 | ||
| 2332 | { | ||
| 2333 | UINT x; | ||
| 2334 | UINT y; | ||
| 2335 | UINT z; | ||
| 2336 | }; | ||
| 2337 | std::forward_list<UINT3> m_UINT3s; | ||
| 2338 | std::forward_list<D3D12_NODE_ID> m_NodeIDs; | ||
| 2339 | CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; | ||
| 2340 | }; | ||
| 2341 | |||
| 2342 | //------------------------------------------------------------------------------------------------ | ||
| 2343 | // Use this class when defining a thread launch node where configuration parameters | ||
| 2344 | // need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE | ||
| 2345 | class CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES | ||
| 2346 | : public CD3DX12_NODE_HELPER_BASE | ||
| 2347 | { | ||
| 2348 | public: | ||
| 2349 | CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES( | ||
| 2350 | const Backreference &BackRef, | ||
| 2351 | LPCWSTR _Shader = nullptr) : | ||
| 2352 | CD3DX12_NODE_HELPER_BASE(BackRef), | ||
| 2353 | m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) | ||
| 2354 | { | ||
| 2355 | Overrides = {}; | ||
| 2356 | D3D12_NODE *pNode = GetNode(); | ||
| 2357 | pNode->NodeType = D3D12_NODE_TYPE_SHADER; | ||
| 2358 | pNode->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_THREAD_LAUNCH; | ||
| 2359 | pNode->Shader.pThreadLaunchOverrides = &Overrides; | ||
| 2360 | Shader(_Shader); | ||
| 2361 | } | ||
| 2362 | void Shader(LPCWSTR _Shader) | ||
| 2363 | { | ||
| 2364 | GetNode()->Shader.Shader = m_Strings.LocalCopy(_Shader); | ||
| 2365 | } | ||
| 2366 | LPCWSTR GetShaderName() const { return GetNode()->Shader.Shader; } | ||
| 2367 | void LocalRootArgumentsTableIndex(UINT index) | ||
| 2368 | { | ||
| 2369 | m_UINTs.emplace_front(index); | ||
| 2370 | Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); | ||
| 2371 | } | ||
| 2372 | void ProgramEntry(BOOL bIsProgramEntry) | ||
| 2373 | { | ||
| 2374 | m_UINTs.emplace_front(bIsProgramEntry); | ||
| 2375 | Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); | ||
| 2376 | } | ||
| 2377 | void NewName(D3D12_NODE_ID NodeID) | ||
| 2378 | { | ||
| 2379 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2380 | Overrides.pNewName = &m_NodeIDs.front(); | ||
| 2381 | } | ||
| 2382 | void ShareInputOf(D3D12_NODE_ID NodeID) | ||
| 2383 | { | ||
| 2384 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2385 | Overrides.pShareInputOf = &m_NodeIDs.front(); | ||
| 2386 | } | ||
| 2387 | CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() | ||
| 2388 | { | ||
| 2389 | return m_NodeOutputOverrides; | ||
| 2390 | } | ||
| 2391 | D3D12_THREAD_LAUNCH_OVERRIDES Overrides; | ||
| 2392 | private: | ||
| 2393 | // Cached parameters | ||
| 2394 | std::forward_list<UINT> m_UINTs; | ||
| 2395 | std::forward_list<D3D12_NODE_ID> m_NodeIDs; | ||
| 2396 | CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; | ||
| 2397 | }; | ||
| 2398 | |||
| 2399 | //------------------------------------------------------------------------------------------------ | ||
| 2400 | // Use this class when defining a node where configuration parameters | ||
| 2401 | // need to be overridden for parameters that are common to all launch node types. | ||
| 2402 | // This option is a convenience if you don't want to determine what the launch mode is | ||
| 2403 | // and just want to override a setting that isn't specific to launch mode. | ||
| 2404 | // If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE | ||
| 2405 | class CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES | ||
| 2406 | : public CD3DX12_NODE_HELPER_BASE | ||
| 2407 | { | ||
| 2408 | public: | ||
| 2409 | CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES( | ||
| 2410 | const Backreference &BackRef, | ||
| 2411 | LPCWSTR _Shader = nullptr) : | ||
| 2412 | CD3DX12_NODE_HELPER_BASE(BackRef), | ||
| 2413 | m_NodeOutputOverrides(&Overrides.pOutputOverrides, &Overrides.NumOutputOverrides) | ||
| 2414 | { | ||
| 2415 | Overrides = {}; | ||
| 2416 | D3D12_NODE *pNode = GetNode(); | ||
| 2417 | pNode->NodeType = D3D12_NODE_TYPE_SHADER; | ||
| 2418 | pNode->Shader.OverridesType = D3D12_NODE_OVERRIDES_TYPE_COMMON_COMPUTE; | ||
| 2419 | pNode->Shader.pThreadLaunchOverrides = &Overrides; | ||
| 2420 | Shader(_Shader); | ||
| 2421 | } | ||
| 2422 | void Shader(LPCWSTR _Shader) | ||
| 2423 | { | ||
| 2424 | GetNode()->Shader.Shader = m_Strings.LocalCopy(_Shader); | ||
| 2425 | } | ||
| 2426 | LPCWSTR GetShaderName() const { return GetNode()->Shader.Shader; } | ||
| 2427 | void LocalRootArgumentsTableIndex(UINT index) | ||
| 2428 | { | ||
| 2429 | m_UINTs.emplace_front(index); | ||
| 2430 | Overrides.pLocalRootArgumentsTableIndex = &m_UINTs.front(); | ||
| 2431 | } | ||
| 2432 | void ProgramEntry(BOOL bIsProgramEntry) | ||
| 2433 | { | ||
| 2434 | m_UINTs.emplace_front(bIsProgramEntry); | ||
| 2435 | Overrides.pProgramEntry = (BOOL*)&m_UINTs.front(); | ||
| 2436 | } | ||
| 2437 | void NewName(D3D12_NODE_ID NodeID) | ||
| 2438 | { | ||
| 2439 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2440 | Overrides.pNewName = &m_NodeIDs.front(); | ||
| 2441 | } | ||
| 2442 | void ShareInputOf(D3D12_NODE_ID NodeID) | ||
| 2443 | { | ||
| 2444 | m_NodeIDs.emplace_front(D3D12_NODE_ID{ m_Strings.LocalCopy(NodeID.Name),NodeID.ArrayIndex }); | ||
| 2445 | Overrides.pShareInputOf = &m_NodeIDs.front(); | ||
| 2446 | } | ||
| 2447 | CD3DX12_NODE_OUTPUT_OVERRIDES& NodeOutputOverrides() | ||
| 2448 | { | ||
| 2449 | return m_NodeOutputOverrides; | ||
| 2450 | } | ||
| 2451 | D3D12_THREAD_LAUNCH_OVERRIDES Overrides; | ||
| 2452 | private: | ||
| 2453 | // Cached parameters | ||
| 2454 | std::forward_list<UINT> m_UINTs; | ||
| 2455 | std::forward_list<D3D12_NODE_ID> m_NodeIDs; | ||
| 2456 | CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides; | ||
| 2457 | }; | ||
| 2458 | |||
| 2459 | //------------------------------------------------------------------------------------------------ | ||
| 2460 | class CD3DX12_WORK_GRAPH_SUBOBJECT | ||
| 2461 | : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE | ||
| 2462 | { | ||
| 2463 | public: | ||
| 2464 | CD3DX12_WORK_GRAPH_SUBOBJECT() noexcept | ||
| 2465 | { | ||
| 2466 | Init(); | ||
| 2467 | } | ||
| 2468 | CD3DX12_WORK_GRAPH_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) | ||
| 2469 | { | ||
| 2470 | Init(); | ||
| 2471 | AddToStateObject(ContainingStateObject); | ||
| 2472 | } | ||
| 2473 | D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override | ||
| 2474 | { | ||
| 2475 | return D3D12_STATE_SUBOBJECT_TYPE_WORK_GRAPH; | ||
| 2476 | } | ||
| 2477 | void IncludeAllAvailableNodes() | ||
| 2478 | { | ||
| 2479 | m_Desc.Flags |= D3D12_WORK_GRAPH_FLAG_INCLUDE_ALL_AVAILABLE_NODES; | ||
| 2480 | } | ||
| 2481 | |||
| 2482 | |||
| 2483 | void SetProgramName(LPCWSTR ProgramName) | ||
| 2484 | { | ||
| 2485 | m_Desc.ProgramName = m_Strings.LocalCopy(ProgramName); | ||
| 2486 | } | ||
| 2487 | void AddEntrypoint(D3D12_NODE_ID Entrypoint) | ||
| 2488 | { | ||
| 2489 | m_Entrypoints.emplace_back(D3D12_NODE_ID{ m_Strings.LocalCopy(Entrypoint.Name),Entrypoint.ArrayIndex }); | ||
| 2490 | m_Desc.NumEntrypoints++; | ||
| 2491 | m_Desc.pEntrypoints = m_Entrypoints.data(); | ||
| 2492 | } | ||
| 2493 | |||
| 2494 | template<typename T> | ||
| 2495 | T* CreateNode() | ||
| 2496 | { | ||
| 2497 | m_NodeDescs.push_back({}); | ||
| 2498 | m_Desc.NumExplicitlyDefinedNodes++; | ||
| 2499 | m_Desc.pExplicitlyDefinedNodes = m_NodeDescs.data(); | ||
| 2500 | T* pNodeHelper = new T({this, (UINT)m_NodeDescs.size() - 1}); | ||
| 2501 | m_OwnedNodeHelpers.emplace_back(pNodeHelper); | ||
| 2502 | return pNodeHelper; | ||
| 2503 | } | ||
| 2504 | CD3DX12_SHADER_NODE* CreateShaderNode(LPCWSTR Shader = nullptr) | ||
| 2505 | { | ||
| 2506 | auto pNode = CreateNode<CD3DX12_SHADER_NODE>(); | ||
| 2507 | pNode->Shader(Shader); | ||
| 2508 | return pNode; | ||
| 2509 | } | ||
| 2510 | CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES* CreateBroadcastingLaunchNodeOverrides(LPCWSTR Shader = nullptr) | ||
| 2511 | { | ||
| 2512 | auto pNode = CreateNode<CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES>(); | ||
| 2513 | pNode->Shader(Shader); | ||
| 2514 | return pNode; | ||
| 2515 | } | ||
| 2516 | CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES* CreateCoalescingLaunchNodeOverrides(LPCWSTR Shader = nullptr) | ||
| 2517 | { | ||
| 2518 | auto pNode = CreateNode<CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES>(); | ||
| 2519 | pNode->Shader(Shader); | ||
| 2520 | return pNode; | ||
| 2521 | } | ||
| 2522 | CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES* CreateThreadLaunchNodeOverrides(LPCWSTR Shader = nullptr) | ||
| 2523 | { | ||
| 2524 | auto pNode = CreateNode<CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES>(); | ||
| 2525 | pNode->Shader(Shader); | ||
| 2526 | return pNode; | ||
| 2527 | } | ||
| 2528 | CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES* CreateCommonComputeNodeOverrides(LPCWSTR Shader = nullptr) | ||
| 2529 | { | ||
| 2530 | auto pNode = CreateNode<CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES>(); | ||
| 2531 | pNode->Shader(Shader); | ||
| 2532 | return pNode; | ||
| 2533 | } | ||
| 2534 | #endif // D3D12_SDK_VERSION >= 612 | ||
| 2535 | |||
| 2536 | |||
| 2537 | #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612) | ||
| 2538 | |||
| 2539 | operator const D3D12_WORK_GRAPH_DESC& () noexcept | ||
| 2540 | { | ||
| 2541 | return m_Desc; | ||
| 2542 | } | ||
| 2543 | private: | ||
| 2544 | void Init() noexcept | ||
| 2545 | { | ||
| 2546 | SUBOBJECT_HELPER_BASE::Init(); | ||
| 2547 | m_Desc = {}; | ||
| 2548 | m_Entrypoints.clear(); | ||
| 2549 | m_NodeDescs.clear(); | ||
| 2550 | } | ||
| 2551 | void* Data() noexcept override { return &m_Desc; } | ||
| 2552 | D3D12_WORK_GRAPH_DESC m_Desc; | ||
| 2553 | std::vector<D3D12_NODE_ID> m_Entrypoints; | ||
| 2554 | std::vector<D3D12_NODE> m_NodeDescs; | ||
| 2555 | CD3DX12_STATE_OBJECT_DESC::StringContainer<LPCWSTR, std::wstring> m_Strings; | ||
| 2556 | std::vector<std::unique_ptr<const CD3DX12_NODE_HELPER_BASE>> m_OwnedNodeHelpers; | ||
| 2557 | friend class CD3DX12_NODE_HELPER_BASE; | ||
| 2558 | }; | ||
| 2559 | |||
| 2560 | inline D3D12_NODE * CD3DX12_NODE_HELPER_BASE::GetNode() const | ||
| 2561 | { | ||
| 2562 | return &m_BackRef.m_pGraph->m_NodeDescs[m_BackRef.m_NodeIndex]; | ||
| 2563 | } | ||
| 2564 | #endif // D3D12_SDK_VERSION >= 612 | ||
| 2565 | |||
| 2566 | #undef D3DX12_COM_PTR | ||
| 2567 | #undef D3DX12_COM_PTR_GET | ||
| 2568 | #undef D3DX12_COM_PTR_ADDRESSOF | ||
| 2569 | |||
| 2570 | |||
