diff options
| author | Yong He <yonghe@outlook.com> | 2024-04-15 23:28:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-15 23:28:28 -0700 |
| commit | 3192f34f57abd3245995342a0a5971ebbbbd945c (patch) | |
| tree | dc139be9fe9f4995bac96513571cc9e0526ce547 /tools/gfx/d3d12/d3d12-shader-object.cpp | |
| parent | 030d7f45726187b5b23a3cfb9743166aa60fae30 (diff) | |
[GFX] Fix d3d12 buffer view creation logic for StructuredBuffers. (#3954)
Diffstat (limited to 'tools/gfx/d3d12/d3d12-shader-object.cpp')
| -rw-r--r-- | tools/gfx/d3d12/d3d12-shader-object.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/gfx/d3d12/d3d12-shader-object.cpp b/tools/gfx/d3d12/d3d12-shader-object.cpp index 1b7b51106..3d38df5ab 100644 --- a/tools/gfx/d3d12/d3d12-shader-object.cpp +++ b/tools/gfx/d3d12/d3d12-shader-object.cpp @@ -939,6 +939,8 @@ Result ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView* } ResourceViewInternalImpl* internalResourceView = nullptr; + auto resourceViewImpl = static_cast<ResourceViewImpl*>(resourceView); + switch (resourceView->getViewDesc()->type) { #if SLANG_GFX_HAS_DXR_SUPPORT @@ -953,7 +955,6 @@ Result ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView* #endif default: { - auto resourceViewImpl = static_cast<ResourceViewImpl*>(resourceView); // Hold a reference to the resource to prevent its destruction. const auto resourceOffset = bindingRange.baseIndex + offset.bindingArrayIndex; m_boundResources[resourceOffset] = resourceViewImpl->m_resource; @@ -964,13 +965,21 @@ Result ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView* } auto descriptorSlotIndex = bindingRange.baseIndex + (int32_t)offset.bindingArrayIndex; - if (internalResourceView->m_descriptor.cpuHandle.ptr) + D3D12Descriptor srcDescriptor = {}; + + SLANG_RETURN_ON_FAIL(internalResourceView->getBufferDescriptorForBinding( + static_cast<DeviceImpl*>(m_device.get()), + resourceViewImpl, + bindingRange.bufferElementStride, + srcDescriptor)); + + if (srcDescriptor.cpuHandle.ptr) { d3dDevice->CopyDescriptorsSimple( 1, m_descriptorSet.resourceTable.getCpuHandle( bindingRange.baseIndex + (int32_t)offset.bindingArrayIndex), - internalResourceView->m_descriptor.cpuHandle, + srcDescriptor.cpuHandle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); } else |
