summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-16 05:31:46 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-16 05:31:46 +0000
commit05d9bfb4dd6d94d4ef80f582305aa383da295483 (patch)
tree62773b4ea6a96883cba2322dd11d8001178d1365 /Graphics/GraphicsEngineD3D12
parentreadme: added codacy bage (diff)
downloadDiligentCore-05d9bfb4dd6d94d4ef80f582305aa383da295483.tar.gz
DiligentCore-05d9bfb4dd6d94d4ef80f582305aa383da295483.zip
Added testing framework for rendering commands. Added initial draw command test in D3D11 and D3D12
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp26
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp8
-rw-r--r--Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp21
3 files changed, 32 insertions, 23 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 5e3b9bd1..5b5b10cb 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -1350,31 +1350,31 @@ void DeviceContextD3D12Impl::CopyTextureRegion(ID3D12Resource* pd
D3D12_TEXTURE_COPY_LOCATION SrcLocation;
SrcLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
SrcLocation.pResource = pd3d12Buffer;
- D3D12_PLACED_SUBRESOURCE_FOOTPRINT& Footpring = SrcLocation.PlacedFootprint;
- Footpring.Offset = SrcOffset;
- Footpring.Footprint.Width = static_cast<UINT>(DstBox.MaxX - DstBox.MinX);
- Footpring.Footprint.Height = static_cast<UINT>(DstBox.MaxY - DstBox.MinY);
- Footpring.Footprint.Depth = static_cast<UINT>(DstBox.MaxZ - DstBox.MinZ); // Depth cannot be 0
- Footpring.Footprint.Format = TexFormatToDXGI_Format(TexDesc.Format);
+ D3D12_PLACED_SUBRESOURCE_FOOTPRINT& Footprint = SrcLocation.PlacedFootprint;
+ Footprint.Offset = SrcOffset;
+ Footprint.Footprint.Width = static_cast<UINT>(DstBox.MaxX - DstBox.MinX);
+ Footprint.Footprint.Height = static_cast<UINT>(DstBox.MaxY - DstBox.MinY);
+ Footprint.Footprint.Depth = static_cast<UINT>(DstBox.MaxZ - DstBox.MinZ); // Depth cannot be 0
+ Footprint.Footprint.Format = TexFormatToDXGI_Format(TexDesc.Format);
- Footpring.Footprint.RowPitch = static_cast<UINT>(SrcStride);
+ Footprint.Footprint.RowPitch = static_cast<UINT>(SrcStride);
#ifdef _DEBUG
{
const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
- const Uint32 RowCount = std::max((Footpring.Footprint.Height / FmtAttribs.BlockHeight), 1u);
- VERIFY(BufferSize >= Footpring.Footprint.RowPitch * RowCount * Footpring.Footprint.Depth, "Buffer is not large enough");
- VERIFY(Footpring.Footprint.Depth == 1 || static_cast<UINT>(SrcDepthStride) == Footpring.Footprint.RowPitch * RowCount, "Depth stride must be equal to the size of 2D plane");
+ const Uint32 RowCount = std::max((Footprint.Footprint.Height / FmtAttribs.BlockHeight), 1u);
+ VERIFY(BufferSize >= Footprint.Footprint.RowPitch * RowCount * Footprint.Footprint.Depth, "Buffer is not large enough");
+ VERIFY(Footprint.Footprint.Depth == 1 || static_cast<UINT>(SrcDepthStride) == Footprint.Footprint.RowPitch * RowCount, "Depth stride must be equal to the size of 2D plane");
}
#endif
D3D12_BOX D3D12SrcBox;
D3D12SrcBox.left = 0;
- D3D12SrcBox.right = Footpring.Footprint.Width;
+ D3D12SrcBox.right = Footprint.Footprint.Width;
D3D12SrcBox.top = 0;
- D3D12SrcBox.bottom = Footpring.Footprint.Height;
+ D3D12SrcBox.bottom = Footprint.Footprint.Height;
D3D12SrcBox.front = 0;
- D3D12SrcBox.back = Footpring.Footprint.Depth;
+ D3D12SrcBox.back = Footprint.Footprint.Depth;
CmdCtx.GetCommandList()->CopyTextureRegion(&DstLocation,
static_cast<UINT>(DstBox.MinX),
static_cast<UINT>(DstBox.MinY),
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
index be8e06b9..ef997858 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
@@ -282,8 +282,12 @@ PipelineStateD3D12Impl ::PipelineStateD3D12Impl(IReferenceCounters* pRefCou
std::array<size_t, MaxShadersInPipeline> ShaderVarMgrDataSizes = {};
for (Uint32 s = 0; s < m_NumShaders; ++s)
{
- std::array<SHADER_RESOURCE_VARIABLE_TYPE, 2> AllowedVarTypes = {SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE, SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC};
- Uint32 NumVariablesUnused = 0;
+ std::array<SHADER_RESOURCE_VARIABLE_TYPE, 2> AllowedVarTypes =
+ {
+ SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE,
+ SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC //
+ };
+ Uint32 NumVariablesUnused = 0;
ShaderVarMgrDataSizes[s] = ShaderVariableManagerD3D12::GetRequiredMemorySize(m_pShaderResourceLayouts[s], AllowedVarTypes.data(), static_cast<Uint32>(AllowedVarTypes.size()), NumVariablesUnused);
}
diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
index 433608fc..b5159a3f 100644
--- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
@@ -147,7 +147,7 @@ TextureD3D12Impl ::TextureD3D12Impl(IReferenceCounters* pRefCounters,
auto* pd3d12Device = pRenderDeviceD3D12->GetD3D12Device();
if (m_Desc.Usage == USAGE_STATIC || m_Desc.Usage == USAGE_DEFAULT || m_Desc.Usage == USAGE_DYNAMIC)
{
- D3D12_CLEAR_VALUE ClearValue;
+ D3D12_CLEAR_VALUE ClearValue = {};
D3D12_CLEAR_VALUE* pClearValue = nullptr;
if (Desc.Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL))
{
@@ -172,7 +172,8 @@ TextureD3D12Impl ::TextureD3D12Impl(IReferenceCounters* pRefCounters,
pClearValue = &ClearValue;
}
- D3D12_HEAP_PROPERTIES HeapProps;
+ D3D12_HEAP_PROPERTIES HeapProps = {};
+
HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT;
HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
@@ -183,8 +184,9 @@ TextureD3D12Impl ::TextureD3D12Impl(IReferenceCounters* pRefCounters,
auto InitialState = bInitializeTexture ? RESOURCE_STATE_COPY_DEST : RESOURCE_STATE_UNDEFINED;
SetState(InitialState);
auto D3D12State = ResourceStateFlagsToD3D12ResourceStates(InitialState);
- auto hr = pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
- &Desc, D3D12State, pClearValue, __uuidof(m_pd3d12Resource), reinterpret_cast<void**>(static_cast<ID3D12Resource**>(&m_pd3d12Resource)));
+ auto hr =
+ pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &Desc, D3D12State, pClearValue, __uuidof(m_pd3d12Resource),
+ reinterpret_cast<void**>(static_cast<ID3D12Resource**>(&m_pd3d12Resource)));
if (FAILED(hr))
LOG_ERROR_AND_THROW("Failed to create D3D12 texture");
@@ -200,14 +202,16 @@ TextureD3D12Impl ::TextureD3D12Impl(IReferenceCounters* pRefCounters,
UINT64 uploadBufferSize = 0;
pd3d12Device->GetCopyableFootprints(&Desc, 0, pInitData->NumSubresources, 0, nullptr, nullptr, nullptr, &uploadBufferSize);
- D3D12_HEAP_PROPERTIES UploadHeapProps;
+ D3D12_HEAP_PROPERTIES UploadHeapProps = {};
+
UploadHeapProps.Type = D3D12_HEAP_TYPE_UPLOAD;
UploadHeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
UploadHeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
UploadHeapProps.CreationNodeMask = 1;
UploadHeapProps.VisibleNodeMask = 1;
- D3D12_RESOURCE_DESC BufferDesc;
+ D3D12_RESOURCE_DESC BufferDesc = {};
+
BufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
BufferDesc.Alignment = 0;
BufferDesc.Width = uploadBufferSize;
@@ -273,7 +277,7 @@ TextureD3D12Impl ::TextureD3D12Impl(IReferenceCounters* pRefCounters,
else if (m_Desc.Usage == USAGE_STAGING)
{
// Create staging buffer
- D3D12_HEAP_PROPERTIES StaginHeapProps;
+ D3D12_HEAP_PROPERTIES StaginHeapProps = {};
DEV_CHECK_ERR((m_Desc.CPUAccessFlags & (CPU_ACCESS_READ | CPU_ACCESS_WRITE)) == CPU_ACCESS_READ ||
(m_Desc.CPUAccessFlags & (CPU_ACCESS_READ | CPU_ACCESS_WRITE)) == CPU_ACCESS_WRITE,
"Exactly one of CPU_ACCESS_READ or CPU_ACCESS_WRITE flags must be specified");
@@ -306,7 +310,8 @@ TextureD3D12Impl ::TextureD3D12Impl(IReferenceCounters* pRefCounters,
pd3d12Device->GetCopyableFootprints(&Desc, 0, NumSubresources, 0, m_StagingFootprints, nullptr, nullptr, &stagingBufferSize);
m_StagingFootprints[NumSubresources] = D3D12_PLACED_SUBRESOURCE_FOOTPRINT{stagingBufferSize};
- D3D12_RESOURCE_DESC BufferDesc;
+ D3D12_RESOURCE_DESC BufferDesc = {};
+
BufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
BufferDesc.Alignment = 0;
BufferDesc.Width = stagingBufferSize;