Diligent Engine  v.2.4.g
D3D12TypeConversions.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include "GraphicsTypes.h"
34 #include "RenderPass.h"
35 #include "DepthStencilState.h"
36 #include "RasterizerState.h"
37 #include "BlendState.h"
38 #include "InputLayout.h"
39 #include "Texture.h"
40 #include "TextureView.h"
41 #include "Buffer.h"
42 #include "BufferView.h"
43 #include "Shader.h"
44 #include "DeviceContext.h"
45 
46 namespace Diligent
47 {
48 
50 D3D12_FILTER FilterTypeToD3D12Filter(FILTER_TYPE MinFilter, FILTER_TYPE MagFilter, FILTER_TYPE MipFilter);
51 D3D12_TEXTURE_ADDRESS_MODE TexAddressModeToD3D12AddressMode(TEXTURE_ADDRESS_MODE Mode);
52 D3D12_PRIMITIVE_TOPOLOGY TopologyToD3D12Topology(PRIMITIVE_TOPOLOGY Topology);
53 
55  D3D12_DEPTH_STENCIL_DESC& d3d12DSSDesc);
57  D3D12_RASTERIZER_DESC& d3d11RSDesc);
59  D3D12_BLEND_DESC& d3d12BlendDesc);
60 
62  std::vector<D3D12_INPUT_ELEMENT_DESC, STDAllocatorRawMem<D3D12_INPUT_ELEMENT_DESC>>& d3d12InputElements);
63 
64 // clang-format off
65 void TextureViewDesc_to_D3D12_SRV_DESC(const TextureViewDesc& SRVDesc, D3D12_SHADER_RESOURCE_VIEW_DESC &D3D12SRVDesc, Uint32 SampleCount);
66 void TextureViewDesc_to_D3D12_RTV_DESC(const TextureViewDesc& RTVDesc, D3D12_RENDER_TARGET_VIEW_DESC &D3D12RTVDesc, Uint32 SampleCount);
67 void TextureViewDesc_to_D3D12_DSV_DESC(const TextureViewDesc& DSVDesc, D3D12_DEPTH_STENCIL_VIEW_DESC &D3D12DSVDesc, Uint32 SampleCount);
68 void TextureViewDesc_to_D3D12_UAV_DESC(const TextureViewDesc& UAVDesc, D3D12_UNORDERED_ACCESS_VIEW_DESC &D3D12UAVDesc);
69 // clang-format on
70 
71 void BufferViewDesc_to_D3D12_SRV_DESC(const BufferDesc& BuffDesc,
72  const BufferViewDesc& SRVDesc,
73  D3D12_SHADER_RESOURCE_VIEW_DESC& D3D12SRVDesc);
74 void BufferViewDesc_to_D3D12_UAV_DESC(const BufferDesc& BuffDesc,
75  const BufferViewDesc& UAVDesc,
76  D3D12_UNORDERED_ACCESS_VIEW_DESC& D3D12UAVDesc);
77 
78 D3D12_STATIC_BORDER_COLOR BorderColorToD3D12StaticBorderColor(const Float32 BorderColor[]);
79 D3D12_RESOURCE_STATES ResourceStateFlagsToD3D12ResourceStates(RESOURCE_STATE StateFlags);
80 RESOURCE_STATE D3D12ResourceStatesToResourceStateFlags(D3D12_RESOURCE_STATES StateFlags);
81 
82 D3D12_QUERY_HEAP_TYPE QueryTypeToD3D12QueryHeapType(QUERY_TYPE QueryType);
83 D3D12_QUERY_TYPE QueryTypeToD3D12QueryType(QUERY_TYPE QueryType);
84 
85 D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE AttachmentLoadOpToD3D12BeginningAccessType(ATTACHMENT_LOAD_OP LoadOp);
86 D3D12_RENDER_PASS_ENDING_ACCESS_TYPE AttachmentStoreOpToD3D12EndingAccessType(ATTACHMENT_STORE_OP StoreOp);
87 
89 SHADER_TYPE D3D12ShaderVisibilityToShaderType(D3D12_SHADER_VISIBILITY ShaderVisibility);
90 
92 
95 
96 D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS BuildASFlagsToD3D12ASBuildFlags(RAYTRACING_BUILD_AS_FLAGS Flags);
97 D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE CopyASModeToD3D12ASCopyMode(COPY_AS_MODE Mode);
98 
99 DXGI_FORMAT TypeToRayTracingVertexFormat(VALUE_TYPE ValueType, Uint32 ComponentCount);
100 
101 D3D12_DESCRIPTOR_RANGE_TYPE ResourceTypeToD3D12DescriptorRangeType(SHADER_RESOURCE_TYPE ResType);
102 
103 D3D12_DESCRIPTOR_HEAP_TYPE D3D12DescriptorRangeTypeToD3D12HeapType(D3D12_DESCRIPTOR_RANGE_TYPE RangeType);
104 
105 D3D12_SHADER_VISIBILITY ShaderStagesToD3D12ShaderVisibility(SHADER_TYPE Stages);
106 
107 } // namespace Diligent
Diligent::ShaderStagesToD3D12ShaderVisibility
D3D12_SHADER_VISIBILITY ShaderStagesToD3D12ShaderVisibility(SHADER_TYPE Stages)
Definition: D3D12TypeConversions.cpp:797
Texture.h
Diligent::CopyASModeToD3D12ASCopyMode
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE CopyASModeToD3D12ASCopyMode(COPY_AS_MODE Mode)
Definition: D3D12TypeConversions.cpp:685
Diligent::QueryTypeToD3D12QueryType
D3D12_QUERY_TYPE QueryTypeToD3D12QueryType(QUERY_TYPE QueryType)
Definition: D3D12TypeConversions.cpp:476
TextureView.h
Diligent::DepthStencilStateDesc_To_D3D12_DEPTH_STENCIL_DESC
void DepthStencilStateDesc_To_D3D12_DEPTH_STENCIL_DESC(const DepthStencilStateDesc &DepthStencilDesc, D3D12_DEPTH_STENCIL_DESC &d3d12DSSDesc)
Definition: D3D12TypeConversions.cpp:60
Diligent::ATTACHMENT_STORE_OP
ATTACHMENT_STORE_OP
Render pass attachment store operation Vulkan counterpart: VkAttachmentStoreOp. D3D12 counterpart: D3...
Definition: RenderPass.h:71
Diligent::D3D12ShaderVisibilityToShaderType
SHADER_TYPE D3D12ShaderVisibilityToShaderType(D3D12_SHADER_VISIBILITY ShaderVisibility)
Definition: D3D12TypeConversions.cpp:576
Diligent::COPY_AS_MODE
COPY_AS_MODE
Defines acceleration structure copy mode.
Definition: DeviceContext.h:795
Diligent::SHADER_TYPE
SHADER_TYPE
Describes the shader type.
Definition: GraphicsTypes.h:65
Diligent::SHADER_RESOURCE_TYPE
SHADER_RESOURCE_TYPE
Describes shader resource type.
Definition: Shader.h:356
Diligent::TEXTURE_ADDRESS_MODE
TEXTURE_ADDRESS_MODE
Texture address mode.
Definition: GraphicsTypes.h:889
Diligent::TopologyToD3D12Topology
D3D12_PRIMITIVE_TOPOLOGY TopologyToD3D12Topology(PRIMITIVE_TOPOLOGY Topology)
Definition: D3D12TypeConversions.cpp:147
Flags
Uint32 Flags
Definition: DXBCUtils.cpp:71
Shader.h
Diligent::D3D12ResourceStatesToResourceStateFlags
RESOURCE_STATE D3D12ResourceStatesToResourceStateFlags(D3D12_RESOURCE_STATES StateFlags)
Definition: D3D12TypeConversions.cpp:458
Diligent::BuildASFlagsToD3D12ASBuildFlags
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS BuildASFlagsToD3D12ASBuildFlags(RAYTRACING_BUILD_AS_FLAGS Flags)
Definition: D3D12TypeConversions.cpp:660
Diligent::TexAddressModeToD3D12AddressMode
D3D12_TEXTURE_ADDRESS_MODE TexAddressModeToD3D12AddressMode(TEXTURE_ADDRESS_MODE Mode)
Definition: D3D12TypeConversions.cpp:55
Diligent::Float32
float Float32
32-bit float
Definition: BasicTypes.h:43
Diligent::FILTER_TYPE
FILTER_TYPE
Filter type.
Definition: GraphicsTypes.h:864
Diligent::PRIMITIVE_TOPOLOGY
PRIMITIVE_TOPOLOGY
Input primitive topology.
Definition: GraphicsTypes.h:989
Diligent::RAYTRACING_INSTANCE_FLAGS
RAYTRACING_INSTANCE_FLAGS
TLAS instance flags that are used in IDeviceContext::BuildTLAS().
Definition: DeviceContext.h:767
DeviceContext.h
Diligent::ResourceTypeToD3D12DescriptorRangeType
D3D12_DESCRIPTOR_RANGE_TYPE ResourceTypeToD3D12DescriptorRangeType(SHADER_RESOURCE_TYPE ResType)
Definition: D3D12TypeConversions.cpp:756
Diligent::AttachmentLoadOpToD3D12BeginningAccessType
D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE AttachmentLoadOpToD3D12BeginningAccessType(ATTACHMENT_LOAD_OP LoadOp)
Definition: D3D12TypeConversions.cpp:514
Diligent::ShaderTypeToD3D12ShaderVisibility
D3D12_SHADER_VISIBILITY ShaderTypeToD3D12ShaderVisibility(SHADER_TYPE ShaderType)
Definition: D3D12TypeConversions.cpp:545
Diligent::AttachmentStoreOpToD3D12EndingAccessType
D3D12_RENDER_PASS_ENDING_ACCESS_TYPE AttachmentStoreOpToD3D12EndingAccessType(ATTACHMENT_STORE_OP StoreOp)
Definition: D3D12TypeConversions.cpp:530
Diligent::ResourceStateFlagsToD3D12ResourceStates
D3D12_RESOURCE_STATES ResourceStateFlagsToD3D12ResourceStates(RESOURCE_STATE StateFlags)
Definition: D3D12TypeConversions.cpp:389
Diligent::D3D12DescriptorRangeTypeToD3D12HeapType
D3D12_DESCRIPTOR_HEAP_TYPE D3D12DescriptorRangeTypeToD3D12HeapType(D3D12_DESCRIPTOR_RANGE_TYPE RangeType)
Definition: D3D12TypeConversions.cpp:778
BlendState.h
Diligent::RasterizerStateDesc_To_D3D12_RASTERIZER_DESC
void RasterizerStateDesc_To_D3D12_RASTERIZER_DESC(const RasterizerStateDesc &RasterizerDesc, D3D12_RASTERIZER_DESC &d3d11RSDesc)
Definition: D3D12TypeConversions.cpp:66
Diligent::InputLayoutDesc
struct InputLayoutDesc InputLayoutDesc
Definition: InputLayout.h:239
Diligent::LayoutElements_To_D3D12_INPUT_ELEMENT_DESCs
void LayoutElements_To_D3D12_INPUT_ELEMENT_DESCs(const InputLayoutDesc &InputLayout, std::vector< D3D12_INPUT_ELEMENT_DESC, STDAllocatorRawMem< D3D12_INPUT_ELEMENT_DESC >> &d3d12InputElements)
Definition: D3D12TypeConversions.cpp:141
RasterizerState.h
InputLayout.h
Diligent::ComparisonFuncToD3D12ComparisonFunc
D3D12_COMPARISON_FUNC ComparisonFuncToD3D12ComparisonFunc(COMPARISON_FUNCTION Func)
Definition: D3D12TypeConversions.cpp:45
Diligent::VALUE_TYPE
VALUE_TYPE
Value type.
Definition: GraphicsTypes.h:49
Diligent::ATTACHMENT_LOAD_OP
ATTACHMENT_LOAD_OP
Render pass attachment load operation Vulkan counterpart: VkAttachmentLoadOp. D3D12 counterpart: D3D1...
Definition: RenderPass.h:47
Diligent::BufferDesc
struct BufferDesc BufferDesc
Definition: Buffer.h:152
Diligent::ValueTypeToIndexType
DXGI_FORMAT ValueTypeToIndexType(VALUE_TYPE Type)
Definition: D3D12TypeConversions.cpp:599
Diligent::GeometryFlagsToD3D12RTGeometryFlags
D3D12_RAYTRACING_GEOMETRY_FLAGS GeometryFlagsToD3D12RTGeometryFlags(RAYTRACING_GEOMETRY_FLAGS Flags)
Definition: D3D12TypeConversions.cpp:614
Diligent::TextureViewDesc_to_D3D12_UAV_DESC
void TextureViewDesc_to_D3D12_UAV_DESC(const TextureViewDesc &UAVDesc, D3D12_UNORDERED_ACCESS_VIEW_DESC &D3D12UAVDesc)
Definition: D3D12TypeConversions.cpp:258
Type
const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type
Definition: PipelineStateD3D12Impl.cpp:69
Diligent::TextureViewDesc
struct TextureViewDesc TextureViewDesc
Definition: TextureView.h:183
Diligent::BlendStateDesc
struct BlendStateDesc BlendStateDesc
Definition: BlendState.h:431
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Buffer.h
Diligent::RAYTRACING_BUILD_AS_FLAGS
RAYTRACING_BUILD_AS_FLAGS
Defines acceleration structures build flags.
Definition: BottomLevelAS.h:114
Diligent::BorderColorToD3D12StaticBorderColor
D3D12_STATIC_BORDER_COLOR BorderColorToD3D12StaticBorderColor(const Float32 BorderColor[])
Definition: D3D12TypeConversions.cpp:315
RenderPass.h
Diligent::COMPARISON_FUNCTION
COMPARISON_FUNCTION
Comparison function.
Definition: GraphicsTypes.h:931
Diligent::TextureViewDesc_to_D3D12_SRV_DESC
void TextureViewDesc_to_D3D12_SRV_DESC(const TextureViewDesc &SRVDesc, D3D12_SHADER_RESOURCE_VIEW_DESC &D3D12SRVDesc, Uint32 SampleCount)
Definition: D3D12TypeConversions.cpp:154
Diligent::BlendStateDesc_To_D3D12_BLEND_DESC
void BlendStateDesc_To_D3D12_BLEND_DESC(const BlendStateDesc &BSDesc, D3D12_BLEND_DESC &d3d12BlendDesc)
Definition: D3D12TypeConversions.cpp:126
BufferView.h
Diligent::DepthStencilStateDesc
struct DepthStencilStateDesc DepthStencilStateDesc
Definition: DepthStencilState.h:233
Diligent::FilterTypeToD3D12Filter
D3D12_FILTER FilterTypeToD3D12Filter(FILTER_TYPE MinFilter, FILTER_TYPE MagFilter, FILTER_TYPE MipFilter)
Definition: D3D12TypeConversions.cpp:50
Diligent::QueryTypeToD3D12QueryHeapType
D3D12_QUERY_HEAP_TYPE QueryTypeToD3D12QueryHeapType(QUERY_TYPE QueryType)
Definition: D3D12TypeConversions.cpp:495
Diligent::QUERY_TYPE
QUERY_TYPE
Query type.
Definition: GraphicsTypes.h:1446
DepthStencilState.h
Diligent::BufferViewDesc
struct BufferViewDesc BufferViewDesc
Definition: BufferView.h:140
Diligent::BufferViewDesc_to_D3D12_UAV_DESC
void BufferViewDesc_to_D3D12_UAV_DESC(const BufferDesc &BuffDesc, const BufferViewDesc &UAVDesc, D3D12_UNORDERED_ACCESS_VIEW_DESC &D3D12UAVDesc)
Definition: D3D12TypeConversions.cpp:305
GraphicsTypes.h
Diligent::TextureViewDesc_to_D3D12_DSV_DESC
void TextureViewDesc_to_D3D12_DSV_DESC(const TextureViewDesc &DSVDesc, D3D12_DEPTH_STENCIL_VIEW_DESC &D3D12DSVDesc, Uint32 SampleCount)
Definition: D3D12TypeConversions.cpp:250
Diligent::RESOURCE_STATE
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
Diligent::RAYTRACING_GEOMETRY_FLAGS
RAYTRACING_GEOMETRY_FLAGS
Defines geometry flags for ray tracing.
Definition: DeviceContext.h:812
Diligent::InstanceFlagsToD3D12RTInstanceFlags
D3D12_RAYTRACING_INSTANCE_FLAGS InstanceFlagsToD3D12RTInstanceFlags(RAYTRACING_INSTANCE_FLAGS Flags)
Definition: D3D12TypeConversions.cpp:636
ShaderType
Uint16 ShaderType
Definition: DXBCUtils.cpp:70
Diligent::TextureViewDesc_to_D3D12_RTV_DESC
void TextureViewDesc_to_D3D12_RTV_DESC(const TextureViewDesc &RTVDesc, D3D12_RENDER_TARGET_VIEW_DESC &D3D12RTVDesc, Uint32 SampleCount)
Definition: D3D12TypeConversions.cpp:209
Diligent::BufferViewDesc_to_D3D12_SRV_DESC
void BufferViewDesc_to_D3D12_SRV_DESC(const BufferDesc &BuffDesc, const BufferViewDesc &SRVDesc, D3D12_SHADER_RESOURCE_VIEW_DESC &D3D12SRVDesc)
Definition: D3D12TypeConversions.cpp:287
Diligent::RasterizerStateDesc
struct RasterizerStateDesc RasterizerStateDesc
Definition: RasterizerState.h:184
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::TypeToRayTracingVertexFormat
DXGI_FORMAT TypeToRayTracingVertexFormat(VALUE_TYPE ValueType, Uint32 ComponentCount)
Definition: D3D12TypeConversions.cpp:702