mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
d3d12: Use ring like heap for vertex and fragment constants too
This commit is contained in:
parent
59aca7566e
commit
f721f2cbaa
@ -432,14 +432,13 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
|
|||||||
memcpy((char*)vertexConstantShadowCopy + offset, vector, 4 * sizeof(float));
|
memcpy((char*)vertexConstantShadowCopy + offset, vector, 4 * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t constantBuffersHeapOffset = m_perFrameStorage.m_constantsBuffersHeapFreeSpace;
|
assert(m_constantsData.canAlloc(512 * 4 * sizeof(float)));
|
||||||
// 65536 alignment
|
size_t heapOffset = m_constantsData.alloc(512 * 4 * sizeof(float));
|
||||||
constantBuffersHeapOffset = (constantBuffersHeapOffset + 65536 - 1) & ~65535;
|
|
||||||
|
|
||||||
ID3D12Resource *constantsBuffer;
|
ID3D12Resource *constantsBuffer;
|
||||||
check(m_device->CreatePlacedResource(
|
check(m_device->CreatePlacedResource(
|
||||||
m_perFrameStorage.m_constantsBuffersHeap,
|
m_constantsData.m_heap,
|
||||||
constantBuffersHeapOffset,
|
heapOffset,
|
||||||
&getBufferResourceDesc(512 * 4 * sizeof(float)),
|
&getBufferResourceDesc(512 * 4 * sizeof(float)),
|
||||||
D3D12_RESOURCE_STATE_GENERIC_READ,
|
D3D12_RESOURCE_STATE_GENERIC_READ,
|
||||||
nullptr,
|
nullptr,
|
||||||
@ -457,8 +456,7 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
|
|||||||
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_perFrameStorage.m_constantsBufferDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
|
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_perFrameStorage.m_constantsBufferDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
|
||||||
Handle.ptr += m_perFrameStorage.m_constantsBufferIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
Handle.ptr += m_perFrameStorage.m_constantsBufferIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||||
m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle);
|
m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle);
|
||||||
m_perFrameStorage.m_constantsBuffersHeapFreeSpace = constantBuffersHeapOffset + 512 * 4 * sizeof(float);
|
m_constantsData.m_resourceStoredSinceLastSync.push_back(std::make_tuple(heapOffset, 512 * 4 * sizeof(float), constantsBuffer));
|
||||||
m_perFrameStorage.m_inflightResources.push_back(constantsBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D12GSRender::FillPixelShaderConstantsBuffer()
|
void D3D12GSRender::FillPixelShaderConstantsBuffer()
|
||||||
@ -469,14 +467,13 @@ void D3D12GSRender::FillPixelShaderConstantsBuffer()
|
|||||||
// Multiple of 256 never 0
|
// Multiple of 256 never 0
|
||||||
bufferSize = (bufferSize + 255) & ~255;
|
bufferSize = (bufferSize + 255) & ~255;
|
||||||
|
|
||||||
size_t constantBuffersHeapOffset = m_perFrameStorage.m_constantsBuffersHeapFreeSpace;
|
assert(m_constantsData.canAlloc(bufferSize));
|
||||||
// 65536 alignment
|
size_t heapOffset = m_constantsData.alloc(bufferSize);
|
||||||
constantBuffersHeapOffset = (constantBuffersHeapOffset + 65536 - 1) & ~65535;
|
|
||||||
|
|
||||||
ID3D12Resource *constantsBuffer;
|
ID3D12Resource *constantsBuffer;
|
||||||
check(m_device->CreatePlacedResource(
|
check(m_device->CreatePlacedResource(
|
||||||
m_perFrameStorage.m_constantsBuffersHeap,
|
m_constantsData.m_heap,
|
||||||
constantBuffersHeapOffset,
|
heapOffset,
|
||||||
&getBufferResourceDesc(bufferSize),
|
&getBufferResourceDesc(bufferSize),
|
||||||
D3D12_RESOURCE_STATE_GENERIC_READ,
|
D3D12_RESOURCE_STATE_GENERIC_READ,
|
||||||
nullptr,
|
nullptr,
|
||||||
@ -532,8 +529,7 @@ void D3D12GSRender::FillPixelShaderConstantsBuffer()
|
|||||||
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_perFrameStorage.m_constantsBufferDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
|
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_perFrameStorage.m_constantsBufferDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
|
||||||
Handle.ptr += m_perFrameStorage.m_constantsBufferIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
Handle.ptr += m_perFrameStorage.m_constantsBufferIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||||
m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle);
|
m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle);
|
||||||
m_perFrameStorage.m_constantsBuffersHeapFreeSpace = constantBuffersHeapOffset + bufferSize;
|
m_constantsData.m_resourceStoredSinceLastSync.push_back(std::make_tuple(heapOffset, bufferSize, constantsBuffer));
|
||||||
m_perFrameStorage.m_inflightResources.push_back(constantsBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ void D3D12GSRender::ResourceStorage::Reset()
|
|||||||
m_vertexIndexBuffersHeapFreeSpace = 0;
|
m_vertexIndexBuffersHeapFreeSpace = 0;
|
||||||
m_constantsBufferIndex = 0;
|
m_constantsBufferIndex = 0;
|
||||||
m_currentScaleOffsetBufferIndex = 0;
|
m_currentScaleOffsetBufferIndex = 0;
|
||||||
m_constantsBuffersHeapFreeSpace = 0;
|
|
||||||
m_currentStorageOffset = 0;
|
m_currentStorageOffset = 0;
|
||||||
m_currentTextureIndex = 0;
|
m_currentTextureIndex = 0;
|
||||||
|
|
||||||
@ -113,7 +112,6 @@ void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device)
|
|||||||
vertexBufferHeapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
|
vertexBufferHeapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
|
||||||
vertexBufferHeapDesc.Properties.Type = D3D12_HEAP_TYPE_UPLOAD;
|
vertexBufferHeapDesc.Properties.Type = D3D12_HEAP_TYPE_UPLOAD;
|
||||||
check(device->CreateHeap(&vertexBufferHeapDesc, IID_PPV_ARGS(&m_vertexIndexBuffersHeap)));
|
check(device->CreateHeap(&vertexBufferHeapDesc, IID_PPV_ARGS(&m_vertexIndexBuffersHeap)));
|
||||||
check(device->CreateHeap(&vertexBufferHeapDesc, IID_PPV_ARGS(&m_constantsBuffersHeap)));
|
|
||||||
|
|
||||||
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {};
|
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {};
|
||||||
descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
||||||
@ -156,7 +154,6 @@ void D3D12GSRender::ResourceStorage::Release()
|
|||||||
|
|
||||||
m_constantsBufferDescriptorsHeap->Release();
|
m_constantsBufferDescriptorsHeap->Release();
|
||||||
m_scaleOffsetDescriptorHeap->Release();
|
m_scaleOffsetDescriptorHeap->Release();
|
||||||
m_constantsBuffersHeap->Release();
|
|
||||||
m_vertexIndexBuffersHeap->Release();
|
m_vertexIndexBuffersHeap->Release();
|
||||||
for (auto tmp : m_inflightResources)
|
for (auto tmp : m_inflightResources)
|
||||||
tmp->Release();
|
tmp->Release();
|
||||||
|
@ -91,8 +91,6 @@ private:
|
|||||||
ID3D12Heap *m_vertexIndexBuffersHeap;
|
ID3D12Heap *m_vertexIndexBuffersHeap;
|
||||||
|
|
||||||
// Constants storage
|
// Constants storage
|
||||||
ID3D12Heap *m_constantsBuffersHeap;
|
|
||||||
size_t m_constantsBuffersHeapFreeSpace;
|
|
||||||
ID3D12DescriptorHeap *m_constantsBufferDescriptorsHeap;
|
ID3D12DescriptorHeap *m_constantsBufferDescriptorsHeap;
|
||||||
size_t m_constantsBufferIndex;
|
size_t m_constantsBufferIndex;
|
||||||
ID3D12DescriptorHeap *m_scaleOffsetDescriptorHeap;
|
ID3D12DescriptorHeap *m_scaleOffsetDescriptorHeap;
|
||||||
@ -113,6 +111,7 @@ private:
|
|||||||
|
|
||||||
ResourceStorage m_perFrameStorage;
|
ResourceStorage m_perFrameStorage;
|
||||||
|
|
||||||
|
// Constants storage
|
||||||
DataHeap m_constantsData;
|
DataHeap m_constantsData;
|
||||||
|
|
||||||
struct UAVHeap
|
struct UAVHeap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user