summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-08-19 14:47:39 +0000
committerazhirnov <zh1dron@gmail.com>2020-08-19 14:47:39 +0000
commitc7c51b0f61b9427ed9cf56c163ee451fdda0ff02 (patch)
tree613255cd5020831d3c96be0fd06ce6b8a88ec35b /Graphics/GraphicsEngineD3D12
parentAdded mesh shader (diff)
downloadDiligentCore-c7c51b0f61b9427ed9cf56c163ee451fdda0ff02.tar.gz
DiligentCore-c7c51b0f61b9427ed9cf56c163ee451fdda0ff02.zip
formatting
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/CMakeLists.txt8
-rw-r--r--Graphics/GraphicsEngineD3D12/include/CommandContext.hpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp4
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp70
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp15
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp8
6 files changed, 55 insertions, 52 deletions
diff --git a/Graphics/GraphicsEngineD3D12/CMakeLists.txt b/Graphics/GraphicsEngineD3D12/CMakeLists.txt
index 4fe2a6c3..8a13c37d 100644
--- a/Graphics/GraphicsEngineD3D12/CMakeLists.txt
+++ b/Graphics/GraphicsEngineD3D12/CMakeLists.txt
@@ -90,9 +90,9 @@ set(SRC
if(PLATFORM_WIN32)
list(APPEND INCLUDE include/D3D12Loader.hpp)
list(APPEND SRC src/D3D12Loader.cpp)
- set(USE_D3D12_LOADER 1)
+ set(USE_D3D12_LOADER 1)
else()
- set(USE_D3D12_LOADER 0)
+ set(USE_D3D12_LOADER 0)
endif()
set(SHADERS
@@ -158,8 +158,8 @@ PUBLIC
target_compile_definitions(Diligent-GraphicsEngineD3D12-static PRIVATE USE_D3D12_LOADER=${USE_D3D12_LOADER})
if(NOT ${USE_D3D12_LOADER})
- # Link with d3d12.lib if we don't use d3d12 loader
- target_link_libraries(Diligent-GraphicsEngineD3D12-static PRIVATE d3d12.lib)
+ # Link with d3d12.lib if we don't use d3d12 loader
+ target_link_libraries(Diligent-GraphicsEngineD3D12-static PRIVATE d3d12.lib)
endif()
target_link_libraries(Diligent-GraphicsEngineD3D12-shared
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp b/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp
index f5e3e681..97e8354d 100644
--- a/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp
@@ -345,7 +345,7 @@ public:
#ifdef D12_H_HAS_MESH_SHADER
FlushResourceBarriers();
CComPtr<ID3D12GraphicsCommandList6> CmdList;
- if (SUCCEEDED(m_pCommandList->QueryInterface(__uuidof(CmdList), reinterpret_cast<void **>(&CmdList))))
+ if (SUCCEEDED(m_pCommandList->QueryInterface(__uuidof(CmdList), reinterpret_cast<void**>(&CmdList))))
CmdList->DispatchMesh(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
#else
UNSUPPORTED("DrawMesh is not supported in current D3D12 header");
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index b351713c..168708c3 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -557,10 +557,10 @@ void DeviceContextD3D12Impl::DrawMeshIndirect(const DrawMeshIndirectAttribs& Att
{
if (!DvpVerifyDrawMeshIndirectArguments(Attribs, pAttribsBuffer))
return;
-
+
auto& GraphCtx = GetCmdContext().AsGraphicsContext();
PrepareForDraw(GraphCtx, Attribs.Flags);
-
+
ID3D12Resource* pd3d12ArgsBuff;
Uint64 BuffDataStartByteOffset;
PrepareDrawIndirectBuffer(GraphCtx, pAttribsBuffer, Attribs.IndirectAttribsBufferStateTransitionMode, pd3d12ArgsBuff, BuffDataStartByteOffset);
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
index bf6c3ae5..79ae0eec 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
@@ -43,27 +43,31 @@ namespace Diligent
namespace
{
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable: 4324)
+# pragma warning(push)
+# pragma warning(disable : 4324)
#endif
- template <typename InnerStructType, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubObjType>
- struct alignas(void*) PSS_SubObject
- {
- const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type {SubObjType};
- InnerStructType Obj {};
+template <typename InnerStructType, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubObjType>
+struct alignas(void*) PSS_SubObject
+{
+ const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type{SubObjType};
+ InnerStructType Obj{};
- PSS_SubObject() {}
+ PSS_SubObject() {}
- PSS_SubObject& operator= (const InnerStructType &obj) { Obj = obj; return *this; }
+ PSS_SubObject& operator=(const InnerStructType& obj)
+ {
+ Obj = obj;
+ return *this;
+ }
- InnerStructType* operator-> () { return &Obj; }
- InnerStructType* operator& () { return &Obj; }
- InnerStructType& operator* () { return Obj; }
- };
+ InnerStructType* operator->() { return &Obj; }
+ InnerStructType* operator&() { return &Obj; }
+ InnerStructType& operator*() { return Obj; }
+};
#ifdef _MSC_VER
-# pragma warning(pop)
+# pragma warning(pop)
#endif
} // namespace
@@ -306,31 +310,31 @@ PipelineStateD3D12Impl::PipelineStateD3D12Impl(IReferenceCounters* pR
LOG_ERROR_AND_THROW("Failed to create pipeline state");
break;
}
-
+
#ifdef D12_H_HAS_MESH_SHADER
case MESH_PIPELINE:
{
const auto& GraphicsPipeline = m_Desc.GraphicsPipeline;
-
+
struct MESH_SHADER_PIPELINE_STATE_DESC
{
- PSS_SubObject<D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> Flags;
- PSS_SubObject<UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> NodeMask;
- PSS_SubObject<ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> pRootSignature;
- PSS_SubObject<D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> PS;
- PSS_SubObject<D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS> AS;
- PSS_SubObject<D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS> MS;
- PSS_SubObject<D3D12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND> BlendState;
- PSS_SubObject<D3D12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL> DepthStencilState;
- PSS_SubObject<D3D12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER> RasterizerState;
- PSS_SubObject<DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC> SampleDesc;
- PSS_SubObject<UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK> SampleMask;
- PSS_SubObject<DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> DSVFormat;
- PSS_SubObject<D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> RTVFormatArray;
- PSS_SubObject<D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CachedPSO;
+ PSS_SubObject<D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> Flags;
+ PSS_SubObject<UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> NodeMask;
+ PSS_SubObject<ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> pRootSignature;
+ PSS_SubObject<D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> PS;
+ PSS_SubObject<D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS> AS;
+ PSS_SubObject<D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS> MS;
+ PSS_SubObject<D3D12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND> BlendState;
+ PSS_SubObject<D3D12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL> DepthStencilState;
+ PSS_SubObject<D3D12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER> RasterizerState;
+ PSS_SubObject<DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC> SampleDesc;
+ PSS_SubObject<UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK> SampleMask;
+ PSS_SubObject<DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> DSVFormat;
+ PSS_SubObject<D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> RTVFormatArray;
+ PSS_SubObject<D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CachedPSO;
};
MESH_SHADER_PIPELINE_STATE_DESC d3d12PSODesc = {};
-
+
for (Uint32 s = 0; s < m_NumShaders; ++s)
{
auto* pShaderD3D12 = GetShader<ShaderD3D12Impl>(s);
@@ -351,7 +355,7 @@ PipelineStateD3D12Impl::PipelineStateD3D12Impl(IReferenceCounters* pR
pd3d12ShaderBytecode->pShaderBytecode = pByteCode->GetBufferPointer();
pd3d12ShaderBytecode->BytecodeLength = pByteCode->GetBufferSize();
}
-
+
d3d12PSODesc.pRootSignature = m_RootSig.GetD3D12RootSignature();
BlendStateDesc_To_D3D12_BLEND_DESC(GraphicsPipeline.BlendDesc, *d3d12PSODesc.BlendState);
@@ -387,7 +391,7 @@ PipelineStateD3D12Impl::PipelineStateD3D12Impl(IReferenceCounters* pR
streamDesc.pPipelineStateSubobjectStream = &d3d12PSODesc;
CComPtr<ID3D12Device2> device2;
- HRESULT hr = pd3d12Device->QueryInterface(IID_PPV_ARGS(&device2));
+ HRESULT hr = pd3d12Device->QueryInterface(IID_PPV_ARGS(&device2));
if (FAILED(hr))
LOG_ERROR_AND_THROW("Failed to get ID3D12Device2");
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index 2f061df3..ede51ca8 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -68,10 +68,9 @@ D3D_SHADER_MODEL RenderDeviceD3D12Impl::GetShaderModel() const
#ifdef HAS_DXIL_COMPILER
// Header may not have constants for D3D_SHADER_MODEL_6_5 and above.
const D3D_SHADER_MODEL Models[] = {
- D3D_SHADER_MODEL(0x65), // for mesh shader
+ D3D_SHADER_MODEL(0x65), // for mesh shader
D3D_SHADER_MODEL(0x64),
- D3D_SHADER_MODEL(0x60)
- };
+ D3D_SHADER_MODEL(0x60)};
// Get maximum supported shader model
D3D12_FEATURE_DATA_SHADER_MODEL ShaderModel = {};
@@ -85,7 +84,7 @@ D3D_SHADER_MODEL RenderDeviceD3D12Impl::GetShaderModel() const
}
}
#endif
-
+
// Direct3D12 supports shader model 5.1 on all feature levels.
// https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels#feature-level-support
return D3D_SHADER_MODEL_5_1;
@@ -208,15 +207,15 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo
m_DeviceCaps.Features.BindlessResources = True;
m_DeviceCaps.Features.VertexPipelineUAVWritesAndAtomics = True;
-
+
const D3D_SHADER_MODEL ShaderModel = GetShaderModel();
// Check if mesh shader is supported.
#ifdef D12_H_HAS_MESH_SHADER
{
- D3D12_FEATURE_DATA_D3D12_OPTIONS7 FeatureData = {};
- bool SupportsMeshShader = SUCCEEDED(m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &FeatureData, sizeof(FeatureData))) &&
- FeatureData.MeshShaderTier != D3D12_MESH_SHADER_TIER_NOT_SUPPORTED;
+ D3D12_FEATURE_DATA_D3D12_OPTIONS7 FeatureData = {};
+ bool SupportsMeshShader = SUCCEEDED(m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &FeatureData, sizeof(FeatureData))) &&
+ FeatureData.MeshShaderTier != D3D12_MESH_SHADER_TIER_NOT_SUPPORTED;
m_DeviceCaps.Features.MeshShaders = (ShaderModel >= D3D_SHADER_MODEL_6_5 && SupportsMeshShader);
}
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp
index 8c7d554c..4d858503 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp
@@ -33,7 +33,7 @@
#include "ShaderBase.hpp"
#ifdef HAS_DXIL_COMPILER
-#include "dxcapi.h"
+# include "dxcapi.h"
#endif
namespace Diligent
@@ -55,7 +55,7 @@ ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, bool isDXI
void OnNewTexSRV (const D3DShaderResourceAttribs& TexAttribs) {}
// clang-format on
};
-
+
CComPtr<ID3D12ShaderReflection> pShaderReflection;
HRESULT hr;
@@ -63,9 +63,9 @@ ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, bool isDXI
if (isDXIL)
{
#ifdef HAS_DXIL_COMPILER
- const uint32_t DFCC_DXIL = uint32_t('D') | (uint32_t('X') << 8) | (uint32_t('I') << 16) | (uint32_t('L') << 24);
+ const uint32_t DFCC_DXIL = uint32_t('D') | (uint32_t('X') << 8) | (uint32_t('I') << 16) | (uint32_t('L') << 24);
CComPtr<IDxcContainerReflection> pReflection;
- UINT32 shaderIdx;
+ UINT32 shaderIdx;
DxcCreateInstance(CLSID_DxcContainerReflection, IID_PPV_ARGS(&pReflection));
hr = pReflection->Load(reinterpret_cast<IDxcBlob*>(pShaderBytecode));
CHECK_D3D_RESULT_THROW(hr, "Failed to create shader reflection instance");