diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 381068c31..45dec829e 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -3313,6 +3313,14 @@ data.NumQualityLevels = 0; _gpuHandle = m_gpuHandle; } + void ScratchBufferD3D12::allocEmpty(D3D12_GPU_DESCRIPTOR_HANDLE& _gpuHandle) + { + m_cpuHandle.ptr += m_incrementSize; + + _gpuHandle = m_gpuHandle; + m_gpuHandle.ptr += m_incrementSize; + } + void* ScratchBufferD3D12::allocCbv(D3D12_GPU_VIRTUAL_ADDRESS& _gpuAddress, uint32_t _size) { _gpuAddress = m_gpuVA + m_pos; @@ -5954,7 +5962,7 @@ data.NumQualityLevels = 0; { TextureD3D12& texture = m_textures[bind.m_idx]; texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ); - scratchBuffer.allocSrv(srvHandle[numSet], texture); + scratchBuffer.allocSrv(srvHandle[stage], texture); samplerFlags[stage] = (0 == (BGFX_TEXTURE_INTERNAL_DEFAULT_SAMPLER & bind.m_un.m_draw.m_textureFlags) ? bind.m_un.m_draw.m_textureFlags : texture.m_flags @@ -5978,12 +5986,12 @@ data.NumQualityLevels = 0; if (Access::Read != bind.m_un.m_compute.m_access) { buffer.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - scratchBuffer.allocUav(srvHandle[numSet], buffer); + scratchBuffer.allocUav(srvHandle[stage], buffer); } else { buffer.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ); - scratchBuffer.allocSrv(srvHandle[numSet], buffer); + scratchBuffer.allocSrv(srvHandle[stage], buffer); } ++numSet; @@ -5993,6 +6001,7 @@ data.NumQualityLevels = 0; } else { + scratchBuffer.allocEmpty(srvHandle[stage]); samplerFlags[stage] = 0; } } diff --git a/src/renderer_d3d12.h b/src/renderer_d3d12.h index 2a0dd3be6..a5aa341cb 100644 --- a/src/renderer_d3d12.h +++ b/src/renderer_d3d12.h @@ -121,6 +121,8 @@ namespace bgfx { namespace d3d12 void destroy(); void reset(D3D12_GPU_DESCRIPTOR_HANDLE& _gpuHandle); + void allocEmpty(D3D12_GPU_DESCRIPTOR_HANDLE& _gpuHandle); + void* allocCbv(D3D12_GPU_VIRTUAL_ADDRESS& _gpuAddress, uint32_t _size); void allocSrv(D3D12_GPU_DESCRIPTOR_HANDLE& _gpuHandle, struct TextureD3D12& _texture, uint8_t _mip = 0);