mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
d3d12: Use another sampler heap when using more than 2048 samplers
This commit is contained in:
parent
d2edeafffe
commit
38a809b483
3 changed files with 22 additions and 9 deletions
|
@ -78,6 +78,8 @@ void D3D12GSRender::ResourceStorage::Reset()
|
|||
m_currentTextureIndex = 0;
|
||||
m_frameFinishedFence = nullptr;
|
||||
m_frameFinishedHandle = 0;
|
||||
m_currentSamplerIndex = 0;
|
||||
m_samplerDescriptorHeapIndex = 0;
|
||||
|
||||
m_commandAllocator->Reset();
|
||||
m_textureUploadCommandAllocator->Reset();
|
||||
|
@ -117,7 +119,8 @@ void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device)
|
|||
|
||||
textureDescriptorDesc.NumDescriptors = 2048; // For safety
|
||||
textureDescriptorDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;
|
||||
check(device->CreateDescriptorHeap(&textureDescriptorDesc, IID_PPV_ARGS(&m_samplerDescriptorHeap)));
|
||||
check(device->CreateDescriptorHeap(&textureDescriptorDesc, IID_PPV_ARGS(&m_samplerDescriptorHeap[0])));
|
||||
check(device->CreateDescriptorHeap(&textureDescriptorDesc, IID_PPV_ARGS(&m_samplerDescriptorHeap[1])));
|
||||
}
|
||||
|
||||
void D3D12GSRender::ResourceStorage::Release()
|
||||
|
@ -126,7 +129,8 @@ void D3D12GSRender::ResourceStorage::Release()
|
|||
m_constantsBufferDescriptorsHeap->Release();
|
||||
m_scaleOffsetDescriptorHeap->Release();
|
||||
m_textureDescriptorsHeap->Release();
|
||||
m_samplerDescriptorHeap->Release();
|
||||
m_samplerDescriptorHeap[0]->Release();
|
||||
m_samplerDescriptorHeap[1]->Release();
|
||||
for (auto &tmp : m_inflightCommandList)
|
||||
tmp->Release();
|
||||
m_commandAllocator->Release();
|
||||
|
@ -578,8 +582,8 @@ void D3D12GSRender::ExecCMD()
|
|||
samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
m_device->CreateSampler(&samplerDesc,
|
||||
getCPUDescriptorHandle(getCurrentResourceStorage().m_samplerDescriptorHeap,
|
||||
(getCurrentResourceStorage().m_currentTextureIndex + usedTexture) * g_descriptorStrideSamplers)
|
||||
getCPUDescriptorHandle(getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex],
|
||||
(getCurrentResourceStorage().m_currentSamplerIndex + usedTexture) * g_descriptorStrideSamplers)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -589,13 +593,14 @@ void D3D12GSRender::ExecCMD()
|
|||
getCurrentResourceStorage().m_currentTextureIndex * g_descriptorStrideSRVCBVUAV)
|
||||
);
|
||||
|
||||
commandList->SetDescriptorHeaps(1, &getCurrentResourceStorage().m_samplerDescriptorHeap);
|
||||
commandList->SetDescriptorHeaps(1, &getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex]);
|
||||
commandList->SetGraphicsRootDescriptorTable(3,
|
||||
getGPUDescriptorHandle(getCurrentResourceStorage().m_samplerDescriptorHeap,
|
||||
getGPUDescriptorHandle(getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex],
|
||||
getCurrentResourceStorage().m_currentTextureIndex * g_descriptorStrideSamplers)
|
||||
);
|
||||
|
||||
getCurrentResourceStorage().m_currentTextureIndex += usedTexture;
|
||||
getCurrentResourceStorage().m_currentSamplerIndex += usedTexture;
|
||||
std::chrono::time_point<std::chrono::system_clock> endTextureTime = std::chrono::system_clock::now();
|
||||
m_timers.m_textureUploadDuration += std::chrono::duration_cast<std::chrono::microseconds>(endTextureTime - startTextureTime).count();
|
||||
}
|
||||
|
|
|
@ -310,7 +310,9 @@ private:
|
|||
// Texture storage
|
||||
ID3D12CommandAllocator *m_textureUploadCommandAllocator;
|
||||
ID3D12DescriptorHeap *m_textureDescriptorsHeap;
|
||||
ID3D12DescriptorHeap *m_samplerDescriptorHeap;
|
||||
ID3D12DescriptorHeap *m_samplerDescriptorHeap[2];
|
||||
size_t m_samplerDescriptorHeapIndex;
|
||||
size_t m_currentSamplerIndex;
|
||||
size_t m_currentTextureIndex;
|
||||
|
||||
ID3D12Resource *m_RAMFramebuffer;
|
||||
|
|
|
@ -876,13 +876,19 @@ size_t D3D12GSRender::UploadTextures()
|
|||
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
break;
|
||||
}
|
||||
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE Handle = getCurrentResourceStorage().m_textureDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
Handle.ptr += (getCurrentResourceStorage().m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
m_device->CreateShaderResourceView(vramTexture, &srvDesc, Handle);
|
||||
|
||||
if (getCurrentResourceStorage().m_currentSamplerIndex + 16 > 2048)
|
||||
{
|
||||
getCurrentResourceStorage().m_samplerDescriptorHeapIndex = 1;
|
||||
getCurrentResourceStorage().m_currentSamplerIndex = 0;
|
||||
}
|
||||
|
||||
Handle = getCurrentResourceStorage().m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
Handle.ptr += (getCurrentResourceStorage().m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
|
||||
Handle = getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex]->GetCPUDescriptorHandleForHeapStart();
|
||||
Handle.ptr += (getCurrentResourceStorage().m_currentSamplerIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
|
||||
m_device->CreateSampler(&getSamplerDesc(m_textures[i]), Handle);
|
||||
|
||||
usedTexture++;
|
||||
|
|
Loading…
Add table
Reference in a new issue