summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12/render-d3d12.cpp
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2021-12-16 14:48:04 -0800
committerGitHub <noreply@github.com>2021-12-16 14:48:04 -0800
commitac88374136ae0c9e83d3350ca3113f4bce893911 (patch)
tree0e8e839eff6cddae41a8e4af2a013ea7e0cfe5a7 /tools/gfx/d3d12/render-d3d12.cpp
parentf024d7299831c0312877e315e8d78b920aaafbaf (diff)
gfx: Add tests for instanced, indexed instanced, and indirect draw calls (#2060)
* Implemented instancing for the drawInstanced test and confirmed that test values taken at specific pixel location match expected values * Removed writeImage() helper function as this is for debugging only * Factored out shared test code and wrapped tests inside a base class with derived structs for each individual draw call variant; Added a test for indexed, instanced draws but test is currently not working correctly * Indexed instancing test finish and working; Further refactor to move code that fills the test result array and creates the vertex and color buffers to the base test class * Commented out image dump helper function at the top as it may still be needed for the remaining draw tests * Added a new struct derived from the base test class for testing indirect but non-indexed draws; Moved required command signatures for indirect draws into D3D12Device to ensure they continue to exist outside of their respective draw calls; Moved command signature creation into D3D12Device::initialize(); Small consistency cleanup changes * Added working indexed indirect draw call test * Moved expectedResult and compareComputeResult() call into getTestResults() and renamed to checkTestResults() * Rerun tests
Diffstat (limited to 'tools/gfx/d3d12/render-d3d12.cpp')
-rw-r--r--tools/gfx/d3d12/render-d3d12.cpp71
1 files changed, 39 insertions, 32 deletions
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp
index 3daddc73f..aab260cd1 100644
--- a/tools/gfx/d3d12/render-d3d12.cpp
+++ b/tools/gfx/d3d12/render-d3d12.cpp
@@ -3425,26 +3425,15 @@ public:
{
prepareDraw();
- D3D12_INDIRECT_ARGUMENT_DESC args[1];
- args[0].Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW;
-
- D3D12_COMMAND_SIGNATURE_DESC desc;
- desc.ByteStride = 36;
- desc.NumArgumentDescs = 1;
- desc.pArgumentDescs = args;
-
- ComPtr<ID3D12CommandSignature> cmdSignature = nullptr;
- if (FAILED(m_device->CreateCommandSignature(&desc, nullptr, IID_PPV_ARGS(cmdSignature.writeRef()))))
- {
- return;
- }
+ auto argBufferImpl = static_cast<BufferResourceImpl*>(argBuffer);
+ auto countBufferImpl = static_cast<BufferResourceImpl*>(countBuffer);
m_d3dCmdList->ExecuteIndirect(
- cmdSignature,
+ m_renderer->drawIndirectCmdSignature,
maxDrawCount,
- (ID3D12Resource*)argBuffer,
+ argBufferImpl->m_resource,
argOffset,
- (ID3D12Resource*)countBuffer,
+ countBufferImpl->m_resource,
countOffset);
}
@@ -3457,26 +3446,15 @@ public:
{
prepareDraw();
- D3D12_INDIRECT_ARGUMENT_DESC args[1];
- args[0].Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED;
-
- D3D12_COMMAND_SIGNATURE_DESC desc;
- desc.ByteStride = 36;
- desc.NumArgumentDescs = 1;
- desc.pArgumentDescs = args;
-
- ComPtr<ID3D12CommandSignature> cmdSignature = nullptr;
- if (FAILED(m_device->CreateCommandSignature(&desc, nullptr, IID_PPV_ARGS(cmdSignature.writeRef()))))
- {
- return;
- }
+ auto argBufferImpl = static_cast<BufferResourceImpl*>(argBuffer);
+ auto countBufferImpl = static_cast<BufferResourceImpl*>(countBuffer);
m_d3dCmdList->ExecuteIndirect(
- cmdSignature,
+ m_renderer->drawIndexedIndirectCmdSignature,
maxDrawCount,
- (ID3D12Resource*)argBuffer,
+ argBufferImpl->m_resource,
argOffset,
- (ID3D12Resource*)countBuffer,
+ countBufferImpl->m_resource,
countOffset);
}
@@ -4549,6 +4527,9 @@ public:
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE m_D3D12SerializeRootSignature = nullptr;
bool m_nvapi = false;
+
+ ComPtr<ID3D12CommandSignature> drawIndirectCmdSignature;
+ ComPtr<ID3D12CommandSignature> drawIndexedIndirectCmdSignature;
};
SLANG_NO_THROW Result SLANG_MCALL D3D12Device::TransientResourceHeapImpl::synchronizeAndReset()
@@ -5328,6 +5309,32 @@ Result D3D12Device::initialize(const Desc& desc)
profileName,
makeArray(slang::PreprocessorMacroDesc{"__D3D12__", "1"}).getView()));
+ {
+ D3D12_INDIRECT_ARGUMENT_DESC args[1];
+ args[0].Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW;
+
+ D3D12_COMMAND_SIGNATURE_DESC desc;
+ desc.ByteStride = 36;
+ desc.NumArgumentDescs = 1;
+ desc.pArgumentDescs = args;
+ desc.NodeMask = 0;
+
+ SLANG_RETURN_ON_FAIL(m_device->CreateCommandSignature(&desc, nullptr, IID_PPV_ARGS(drawIndirectCmdSignature.writeRef())));
+ }
+
+ {
+ D3D12_INDIRECT_ARGUMENT_DESC args[1];
+ args[0].Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED;
+
+ D3D12_COMMAND_SIGNATURE_DESC desc;
+ desc.ByteStride = 36;
+ desc.NumArgumentDescs = 1;
+ desc.pArgumentDescs = args;
+ desc.NodeMask = 0;
+
+ SLANG_RETURN_ON_FAIL(m_device->CreateCommandSignature(&desc, nullptr, IID_PPV_ARGS(drawIndexedIndirectCmdSignature.writeRef())));
+ }
+
m_isInitialized = true;
return SLANG_OK;
}