mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-24 22:54:19 +01:00
[dxvk] Implement per-submission resource relocation
This commit is contained in:
parent
a858305900
commit
ddf858d1cf
@ -103,6 +103,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::flushCommandList(DxvkSubmitStatus* status) {
|
void DxvkContext::flushCommandList(DxvkSubmitStatus* status) {
|
||||||
|
relocateQueuedResources();
|
||||||
|
|
||||||
m_device->submitCommandList(
|
m_device->submitCommandList(
|
||||||
this->endRecording(), status);
|
this->endRecording(), status);
|
||||||
|
|
||||||
@ -6475,6 +6477,54 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkContext::relocateQueuedResources() {
|
||||||
|
auto resourceList = m_common->memoryManager().pollRelocationList();
|
||||||
|
|
||||||
|
if (resourceList.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::vector<DxvkRelocateBufferInfo> bufferInfos;
|
||||||
|
std::vector<DxvkRelocateImageInfo> imageInfos;
|
||||||
|
|
||||||
|
// Iterate over resource list and try to create and assign new allocations
|
||||||
|
// for them based on the mode selected by the allocator. Failures here are
|
||||||
|
// not fatal, but may lead to weird behaviour down the line - ignore for now.
|
||||||
|
for (const auto& e : resourceList) {
|
||||||
|
auto storage = e.resource->relocateStorage(e.mode);
|
||||||
|
|
||||||
|
if (!storage)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Rc<DxvkImage> image = dynamic_cast<DxvkImage*>(e.resource.ptr());
|
||||||
|
Rc<DxvkBuffer> buffer = dynamic_cast<DxvkBuffer*>(e.resource.ptr());
|
||||||
|
|
||||||
|
if (image) {
|
||||||
|
auto& e = imageInfos.emplace_back();
|
||||||
|
e.image = std::move(image);
|
||||||
|
e.storage = std::move(storage);
|
||||||
|
} else if (buffer) {
|
||||||
|
auto& e = bufferInfos.emplace_back();
|
||||||
|
e.buffer = std::move(buffer);
|
||||||
|
e.storage = std::move(storage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bufferInfos.empty() && imageInfos.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If there are any resources to relocate, we have to stall the transfer
|
||||||
|
// queue so that subsequent resource uploads do not overlap with resource
|
||||||
|
// copies on the graphics timeline.
|
||||||
|
this->spillRenderPass(true);
|
||||||
|
|
||||||
|
relocateResources(
|
||||||
|
bufferInfos.size(), bufferInfos.data(),
|
||||||
|
imageInfos.size(), imageInfos.data());
|
||||||
|
|
||||||
|
m_cmd->setSubmissionBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Rc<DxvkSampler> DxvkContext::createBlitSampler(
|
Rc<DxvkSampler> DxvkContext::createBlitSampler(
|
||||||
VkFilter filter) {
|
VkFilter filter) {
|
||||||
DxvkSamplerKey samplerKey;
|
DxvkSamplerKey samplerKey;
|
||||||
|
@ -1757,6 +1757,8 @@ namespace dxvk {
|
|||||||
size_t imageCount,
|
size_t imageCount,
|
||||||
const DxvkRelocateImageInfo* imageInfos);
|
const DxvkRelocateImageInfo* imageInfos);
|
||||||
|
|
||||||
|
void relocateQueuedResources();
|
||||||
|
|
||||||
Rc<DxvkSampler> createBlitSampler(
|
Rc<DxvkSampler> createBlitSampler(
|
||||||
VkFilter filter);
|
VkFilter filter);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user