浏览代码

D3D12: Fixed texture bindings.

Branimir Karadžić 8 年之前
父节点
当前提交
0dd6f82a4e
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 12 3
      src/renderer_d3d12.cpp
  2. 2 0
      src/renderer_d3d12.h

+ 12 - 3
src/renderer_d3d12.cpp

@@ -3313,6 +3313,14 @@ data.NumQualityLevels = 0;
 		_gpuHandle = m_gpuHandle;
 		_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)
 	void* ScratchBufferD3D12::allocCbv(D3D12_GPU_VIRTUAL_ADDRESS& _gpuAddress, uint32_t _size)
 	{
 	{
 		_gpuAddress = m_gpuVA + m_pos;
 		_gpuAddress = m_gpuVA + m_pos;
@@ -5954,7 +5962,7 @@ data.NumQualityLevels = 0;
 											{
 											{
 												TextureD3D12& texture = m_textures[bind.m_idx];
 												TextureD3D12& texture = m_textures[bind.m_idx];
 												texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
 												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)
 												samplerFlags[stage] = (0 == (BGFX_TEXTURE_INTERNAL_DEFAULT_SAMPLER & bind.m_un.m_draw.m_textureFlags)
 													? bind.m_un.m_draw.m_textureFlags
 													? bind.m_un.m_draw.m_textureFlags
 													: texture.m_flags
 													: texture.m_flags
@@ -5978,12 +5986,12 @@ data.NumQualityLevels = 0;
 												if (Access::Read != bind.m_un.m_compute.m_access)
 												if (Access::Read != bind.m_un.m_compute.m_access)
 												{
 												{
 													buffer.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
 													buffer.setState(m_commandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
-													scratchBuffer.allocUav(srvHandle[numSet], buffer);
+													scratchBuffer.allocUav(srvHandle[stage], buffer);
 												}
 												}
 												else
 												else
 												{
 												{
 													buffer.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
 													buffer.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
-													scratchBuffer.allocSrv(srvHandle[numSet], buffer);
+													scratchBuffer.allocSrv(srvHandle[stage], buffer);
 												}
 												}
 
 
 												++numSet;
 												++numSet;
@@ -5993,6 +6001,7 @@ data.NumQualityLevels = 0;
 									}
 									}
 									else
 									else
 									{
 									{
+										scratchBuffer.allocEmpty(srvHandle[stage]);
 										samplerFlags[stage] = 0;
 										samplerFlags[stage] = 0;
 									}
 									}
 								}
 								}

+ 2 - 0
src/renderer_d3d12.h

@@ -121,6 +121,8 @@ namespace bgfx { namespace d3d12
 		void destroy();
 		void destroy();
 		void reset(D3D12_GPU_DESCRIPTOR_HANDLE& _gpuHandle);
 		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* allocCbv(D3D12_GPU_VIRTUAL_ADDRESS& _gpuAddress, uint32_t _size);
 
 
 		void  allocSrv(D3D12_GPU_DESCRIPTOR_HANDLE& _gpuHandle, struct TextureD3D12& _texture, uint8_t _mip = 0);
 		void  allocSrv(D3D12_GPU_DESCRIPTOR_HANDLE& _gpuHandle, struct TextureD3D12& _texture, uint8_t _mip = 0);