From 17e981f360be4d3102a05a1f26811590913d16bc Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 21 Mar 2018 04:56:33 +0100 Subject: [PATCH] [dxvk] Increase UAV slot count to 64 for the graphics pipeline D3D11 raised this limit from 8 UAVs in the fragment shader to 64 UAVs in all graphics stages combined. --- src/d3d11/d3d11_context.cpp | 9 ++++----- src/d3d11/d3d11_context.h | 3 +-- src/dxbc/dxbc_util.cpp | 15 +++++++-------- src/dxvk/dxvk_limits.h | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 522a6206d..918b47ecc 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -2682,8 +2682,8 @@ namespace dxvk { RestoreShaderResources(DxbcProgramType::PixelShader, m_state.ps.shaderResources); RestoreShaderResources(DxbcProgramType::ComputeShader, m_state.cs.shaderResources); - RestoreUnorderedAccessViews(DxbcProgramType::PixelShader, m_state.ps.unorderedAccessViews, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT); - RestoreUnorderedAccessViews(DxbcProgramType::ComputeShader, m_state.cs.unorderedAccessViews, D3D11_1_UAV_SLOT_COUNT); + RestoreUnorderedAccessViews(DxbcProgramType::PixelShader, m_state.ps.unorderedAccessViews); + RestoreUnorderedAccessViews(DxbcProgramType::ComputeShader, m_state.cs.unorderedAccessViews); } @@ -2722,15 +2722,14 @@ namespace dxvk { void D3D11DeviceContext::RestoreUnorderedAccessViews( DxbcProgramType Stage, - D3D11UnorderedAccessBindings& Bindings, - UINT SlotCount) { + D3D11UnorderedAccessBindings& Bindings) { const uint32_t uavSlotId = computeResourceSlotId( Stage, DxbcBindingType::UnorderedAccessView, 0); const uint32_t ctrSlotId = computeResourceSlotId( Stage, DxbcBindingType::UavCounter, 0); - for (uint32_t i = 0; i < SlotCount; i++) { + for (uint32_t i = 0; i < Bindings.size(); i++) { BindUnorderedAccessView( uavSlotId + i, ctrSlotId + i, Bindings[i].ptr()); diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 7f6d79b2a..6b7bef9e8 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -767,8 +767,7 @@ namespace dxvk { void RestoreUnorderedAccessViews( DxbcProgramType Stage, - D3D11UnorderedAccessBindings& Bindings, - UINT SlotCount); + D3D11UnorderedAccessBindings& Bindings); DxvkDataSlice AllocUpdateBufferSlice(size_t Size); diff --git a/src/dxbc/dxbc_util.cpp b/src/dxbc/dxbc_util.cpp index 1c42e0bfc..6197992c1 100644 --- a/src/dxbc/dxbc_util.cpp +++ b/src/dxbc/dxbc_util.cpp @@ -6,13 +6,14 @@ namespace dxvk { DxbcProgramType shaderStage, DxbcBindingType bindingType, uint32_t bindingIndex) { + // First resource slot index for per-stage resources + const uint32_t stageOffset = 132 + 158 * static_cast(shaderStage); + if (shaderStage == DxbcProgramType::ComputeShader) { // 0 - 13: Constant buffers // 14 - 29: Samplers // 30 - 157: Shader resources - // 158 - 221: Uniform access views - const uint32_t stageOffset = 20 + 158 * 5; - + // 158 - 221: Unordered access views switch (bindingType) { case DxbcBindingType::ConstantBuffer: return bindingIndex + stageOffset + 0; case DxbcBindingType::ImageSampler: return bindingIndex + stageOffset + 14; @@ -23,15 +24,13 @@ namespace dxvk { } } else { // Global resource slots - // 0 - 7: Unordered access views - // 8 - 15: UAV counter buffers - // 16 - 19: Stream output buffers + // 0 - 3: Stream output buffers + // 4 - 67: Unordered access views + // 68 - 131: UAV counter buffers // Per-stage resource slots: // 0 - 13: Constant buffers // 14 - 29: Samplers // 30 - 157: Shader resources - const uint32_t stageOffset = 20 + 158 * static_cast(shaderStage); - switch (bindingType) { case DxbcBindingType::UnorderedAccessView:return bindingIndex + 0; case DxbcBindingType::UavCounter: return bindingIndex + 8; diff --git a/src/dxvk/dxvk_limits.h b/src/dxvk/dxvk_limits.h index 0ea5143dc..7c77e2d03 100644 --- a/src/dxvk/dxvk_limits.h +++ b/src/dxvk/dxvk_limits.h @@ -10,7 +10,7 @@ namespace dxvk { MaxNumVertexBindings = 32, MaxNumOutputStreams = 4, MaxNumViewports = 16, - MaxNumResourceSlots = 1096, + MaxNumResourceSlots = 1208, MaxNumActiveBindings = 128, MaxNumQueuedCommandBuffers = 8, MaxNumQueryCountPerPool = 128,