1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-24 13:54:17 +01:00

[dxvk] Add allocation flag for moveable resources

This commit is contained in:
Philip Rebohle 2024-10-17 23:53:56 +02:00
parent 456485f176
commit fb896efc24
2 changed files with 12 additions and 4 deletions

View File

@ -1123,6 +1123,10 @@ namespace dxvk {
VkDeviceSize offset = address & DxvkPageAllocator::ChunkAddressMask; VkDeviceSize offset = address & DxvkPageAllocator::ChunkAddressMask;
auto allocation = m_allocationPool.create(this, &type); auto allocation = m_allocationPool.create(this, &type);
if (!(allocationInfo.properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && allocationInfo.resourceCookie)
allocation->m_flags.set(DxvkAllocationFlag::CanMove);
allocation->m_resourceCookie = allocationInfo.resourceCookie; allocation->m_resourceCookie = allocationInfo.resourceCookie;
allocation->m_memory = chunk.memory.memory; allocation->m_memory = chunk.memory.memory;
allocation->m_address = address; allocation->m_address = address;
@ -1165,6 +1169,9 @@ namespace dxvk {
if (memory.buffer) if (memory.buffer)
allocation->m_flags.set(DxvkAllocationFlag::OwnsBuffer); allocation->m_flags.set(DxvkAllocationFlag::OwnsBuffer);
if (!(allocationInfo.properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && allocationInfo.resourceCookie)
allocation->m_flags.set(DxvkAllocationFlag::CanMove);
allocation->m_resourceCookie = allocationInfo.resourceCookie; allocation->m_resourceCookie = allocationInfo.resourceCookie;
allocation->m_memory = memory.memory; allocation->m_memory = memory.memory;
allocation->m_address = DedicatedChunkAddress; allocation->m_address = DedicatedChunkAddress;
@ -1190,7 +1197,7 @@ namespace dxvk {
void DxvkMemoryAllocator::freeAllocation( void DxvkMemoryAllocator::freeAllocation(
DxvkResourceAllocation* allocation) { DxvkResourceAllocation* allocation) {
if (allocation->m_flags.test(DxvkAllocationFlag::Cacheable)) { if (allocation->m_flags.test(DxvkAllocationFlag::CanCache)) {
// Return cacheable allocations to the shared cache // Return cacheable allocations to the shared cache
allocation->destroyBufferViews(); allocation->destroyBufferViews();
@ -1445,7 +1452,7 @@ namespace dxvk {
// so it will get recycled as-is after use. // so it will get recycled as-is after use.
allocation = createAllocation(memoryType, memoryPool, allocation = createAllocation(memoryType, memoryPool,
address, allocationSize, DxvkAllocationInfo()); address, allocationSize, DxvkAllocationInfo());
allocation->m_flags.set(DxvkAllocationFlag::Cacheable); allocation->m_flags.set(DxvkAllocationFlag::CanCache);
if (tail) { if (tail) {
tail->m_nextCached = allocation; tail->m_nextCached = allocation;

View File

@ -448,8 +448,9 @@ namespace dxvk {
OwnsMemory = 0, OwnsMemory = 0,
OwnsBuffer = 1, OwnsBuffer = 1,
OwnsImage = 2, OwnsImage = 2,
Cacheable = 3, CanCache = 3,
Imported = 4, CanMove = 4,
Imported = 5,
}; };
using DxvkAllocationFlags = Flags<DxvkAllocationFlag>; using DxvkAllocationFlags = Flags<DxvkAllocationFlag>;