summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12/d3d12-shader-table.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-22 21:54:16 -0700
committerGitHub <noreply@github.com>2022-09-22 21:54:16 -0700
commitbd11629739ae2b0619699c765354894ff32dacf1 (patch)
tree4f72313bc33ed34dd96d16cec6623ca9b0a8292e /tools/gfx/d3d12/d3d12-shader-table.cpp
parenta6fcb3b0ed2b185723afde750bd4491b5b4113eb (diff)
GFX: improve d3d12 performance. (#2408)
Diffstat (limited to 'tools/gfx/d3d12/d3d12-shader-table.cpp')
-rw-r--r--tools/gfx/d3d12/d3d12-shader-table.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/tools/gfx/d3d12/d3d12-shader-table.cpp b/tools/gfx/d3d12/d3d12-shader-table.cpp
index 2773578b8..3e49350ab 100644
--- a/tools/gfx/d3d12/d3d12-shader-table.cpp
+++ b/tools/gfx/d3d12/d3d12-shader-table.cpp
@@ -31,6 +31,7 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer(
IBufferResource::Desc bufferDesc = {};
bufferDesc.memoryType = gfx::MemoryType::DeviceLocal;
bufferDesc.defaultState = ResourceState::General;
+ bufferDesc.allowedStates.add(ResourceState::NonPixelShaderResource);
bufferDesc.type = IResource::Type::Buffer;
bufferDesc.sizeInBytes = tableSize;
m_device->createBufferResource(bufferDesc, nullptr, bufferResource.writeRef());
@@ -57,10 +58,6 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer(
void* shaderId = stateObjectProperties->GetShaderIdentifier(name.toWString().begin());
memcpy(dest, shaderId, D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES);
}
- else
- {
- memset(dest, 0, D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES);
- }
if (overwrite.size)
{
memcpy((uint8_t*)dest + overwrite.offset, overwrite.data, overwrite.size);
@@ -68,6 +65,8 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer(
};
uint8_t* stagingBufferPtr = (uint8_t*)stagingPtr + stagingBufferOffset;
+ memset(stagingBufferPtr, 0, tableSize);
+
for (uint32_t i = 0; i < m_rayGenShaderCount; i++)
{
copyShaderIdInto(
@@ -96,7 +95,7 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer(
1,
bufferResource.readRef(),
gfx::ResourceState::CopyDestination,
- gfx::ResourceState::ShaderResource);
+ gfx::ResourceState::NonPixelShaderResource);
RefPtr<BufferResource> resultPtr = static_cast<BufferResource*>(bufferResource.get());
return _Move(resultPtr);
}