mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 12:21:39 +00:00
Rework the logic for the GPU Upload Heap fallback.
This commit is contained in:
parent
6a24d35dec
commit
2c710f4115
2 changed files with 8 additions and 6 deletions
|
|
@ -2631,7 +2631,7 @@ namespace plume {
|
||||||
|
|
||||||
// D3D12Pool
|
// D3D12Pool
|
||||||
|
|
||||||
D3D12Pool::D3D12Pool(D3D12Device *device, const RenderPoolDesc &desc) {
|
D3D12Pool::D3D12Pool(D3D12Device *device, const RenderPoolDesc &desc, bool gpuUploadHeapFallback) {
|
||||||
assert(device != nullptr);
|
assert(device != nullptr);
|
||||||
|
|
||||||
this->device = device;
|
this->device = device;
|
||||||
|
|
@ -2640,7 +2640,7 @@ namespace plume {
|
||||||
D3D12MA::POOL_DESC poolDesc = {};
|
D3D12MA::POOL_DESC poolDesc = {};
|
||||||
|
|
||||||
// When using an UMA architecture without explicit support for GPU Upload heaps, we instead just make a custom heap with the same properties as Upload heaps.
|
// When using an UMA architecture without explicit support for GPU Upload heaps, we instead just make a custom heap with the same properties as Upload heaps.
|
||||||
if (desc.heapType == RenderHeapType::GPU_UPLOAD && device->capabilities.uma && !device->capabilities.gpuUploadHeap) {
|
if ((desc.heapType == RenderHeapType::GPU_UPLOAD) && gpuUploadHeapFallback) {
|
||||||
poolDesc.HeapProperties = device->d3d->GetCustomHeapProperties(0, D3D12_HEAP_TYPE_UPLOAD);
|
poolDesc.HeapProperties = device->d3d->GetCustomHeapProperties(0, D3D12_HEAP_TYPE_UPLOAD);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -3446,6 +3446,7 @@ namespace plume {
|
||||||
|
|
||||||
// Pretend GPU Upload heaps are supported if UMA is supported, as the backend has a workaround using a custom pool for it.
|
// Pretend GPU Upload heaps are supported if UMA is supported, as the backend has a workaround using a custom pool for it.
|
||||||
capabilities.gpuUploadHeap = uma || gpuUploadHeapOption;
|
capabilities.gpuUploadHeap = uma || gpuUploadHeapOption;
|
||||||
|
gpuUploadHeapFallback = uma && !gpuUploadHeapOption;
|
||||||
|
|
||||||
description.name = deviceName;
|
description.name = deviceName;
|
||||||
description.dedicatedVideoMemory = adapterDesc.DedicatedVideoMemory;
|
description.dedicatedVideoMemory = adapterDesc.DedicatedVideoMemory;
|
||||||
|
|
@ -3545,10 +3546,10 @@ namespace plume {
|
||||||
depthTargetHeapAllocator = std::make_unique<D3D12DescriptorHeapAllocator>(this, TargetDescriptorHeapSize, D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
depthTargetHeapAllocator = std::make_unique<D3D12DescriptorHeapAllocator>(this, TargetDescriptorHeapSize, D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
||||||
|
|
||||||
// Create the custom upload pool that will be used as the fallback when using an UMA architecture without explicit support for GPU Upload heaps.
|
// Create the custom upload pool that will be used as the fallback when using an UMA architecture without explicit support for GPU Upload heaps.
|
||||||
if (capabilities.uma && !capabilities.gpuUploadHeap) {
|
if (gpuUploadHeapFallback) {
|
||||||
RenderPoolDesc poolDesc;
|
RenderPoolDesc poolDesc;
|
||||||
poolDesc.heapType = RenderHeapType::GPU_UPLOAD;
|
poolDesc.heapType = RenderHeapType::GPU_UPLOAD;
|
||||||
customUploadPool = std::make_unique<D3D12Pool>(this, poolDesc);
|
customUploadPool = std::make_unique<D3D12Pool>(this, poolDesc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a command queue only for retrieving the timestamp frequency. Delete it immediately afterwards.
|
// Create a command queue only for retrieving the timestamp frequency. Delete it immediately afterwards.
|
||||||
|
|
@ -3617,7 +3618,7 @@ namespace plume {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<RenderPool> D3D12Device::createPool(const RenderPoolDesc &desc) {
|
std::unique_ptr<RenderPool> D3D12Device::createPool(const RenderPoolDesc &desc) {
|
||||||
return std::make_unique<D3D12Pool>(this, desc);
|
return std::make_unique<D3D12Pool>(this, desc, gpuUploadHeapFallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<RenderPipelineLayout> D3D12Device::createPipelineLayout(const RenderPipelineLayoutDesc &desc) {
|
std::unique_ptr<RenderPipelineLayout> D3D12Device::createPipelineLayout(const RenderPipelineLayoutDesc &desc) {
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ namespace plume {
|
||||||
D3D12Device *device = nullptr;
|
D3D12Device *device = nullptr;
|
||||||
RenderPoolDesc desc;
|
RenderPoolDesc desc;
|
||||||
|
|
||||||
D3D12Pool(D3D12Device *device, const RenderPoolDesc &desc);
|
D3D12Pool(D3D12Device *device, const RenderPoolDesc &desc, bool gpuUploadHeapFallback);
|
||||||
~D3D12Pool() override;
|
~D3D12Pool() override;
|
||||||
std::unique_ptr<RenderBuffer> createBuffer(const RenderBufferDesc &desc) override;
|
std::unique_ptr<RenderBuffer> createBuffer(const RenderBufferDesc &desc) override;
|
||||||
std::unique_ptr<RenderTexture> createTexture(const RenderTextureDesc &desc) override;
|
std::unique_ptr<RenderTexture> createTexture(const RenderTextureDesc &desc) override;
|
||||||
|
|
@ -434,6 +434,7 @@ namespace plume {
|
||||||
RenderDeviceCapabilities capabilities;
|
RenderDeviceCapabilities capabilities;
|
||||||
RenderDeviceDescription description;
|
RenderDeviceDescription description;
|
||||||
uint64_t timestampFrequency = 1;
|
uint64_t timestampFrequency = 1;
|
||||||
|
bool gpuUploadHeapFallback = false;
|
||||||
|
|
||||||
D3D12Device(D3D12Interface *renderInterface, const std::string &preferredDeviceName);
|
D3D12Device(D3D12Interface *renderInterface, const std::string &preferredDeviceName);
|
||||||
~D3D12Device() override;
|
~D3D12Device() override;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue