mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-11 13:09:06 +01:00
Only reallocate MegaBuffer
on usage
Certain submissions might not utilize megabuffering but reserve a `MegaBuffer` regardless, this is not optimal since it can inflate the allocations and waste memory. This commit addresses the issue by eliding the allocation given the current submission doesn't utilize them.
This commit is contained in:
parent
2366f81443
commit
7b209c54a2
@ -119,6 +119,14 @@ namespace skyline::gpu {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool MegaBuffer::WasUsed() {
|
||||
return freeRegion != slot->backing.subspan(PAGE_SIZE);
|
||||
}
|
||||
|
||||
void MegaBuffer::ReplaceCycle(const std::shared_ptr<FenceCycle> &cycle) {
|
||||
slot->cycle = cycle;
|
||||
}
|
||||
|
||||
void MegaBuffer::Reset() {
|
||||
freeRegion = slot->backing.subspan(PAGE_SIZE);
|
||||
}
|
||||
|
@ -91,6 +91,17 @@ namespace skyline::gpu {
|
||||
|
||||
MegaBuffer &operator=(MegaBuffer &&other);
|
||||
|
||||
/**
|
||||
* @return If any allocations into the megabuffer were done at the time of the call
|
||||
*/
|
||||
bool WasUsed();
|
||||
|
||||
/**
|
||||
* @brief Replaces the cycle associated with the underlying megabuffer with the supplied cycle
|
||||
* @note The megabuffer must **NOT** have any dependencies that aren't conveyed by the supplied cycle
|
||||
*/
|
||||
void ReplaceCycle(const std::shared_ptr<FenceCycle> &cycle);
|
||||
|
||||
/**
|
||||
* @brief Resets the free region of the megabuffer to its initial state, data is left intact but may be overwritten
|
||||
*/
|
||||
|
@ -321,7 +321,10 @@ namespace skyline::gpu::interconnect {
|
||||
SubmitInternal();
|
||||
activeCommandBuffer = gpu.scheduler.AllocateCommandBuffer();
|
||||
cycle = activeCommandBuffer.GetFenceCycle();
|
||||
megaBuffer = gpu.buffer.AcquireMegaBuffer(cycle);
|
||||
if (megaBuffer.WasUsed())
|
||||
megaBuffer = gpu.buffer.AcquireMegaBuffer(cycle);
|
||||
else
|
||||
megaBuffer.ReplaceCycle(cycle);
|
||||
}
|
||||
ResetInternal();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user