mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-12 04:54:17 +01:00
[dxvk] Pass resource cookie to allocation objects
This commit is contained in:
parent
efebceecbe
commit
bb05f123db
@ -34,13 +34,16 @@ namespace dxvk {
|
|||||||
m_shaderStages (util::shaderStages(createInfo.stages)),
|
m_shaderStages (util::shaderStages(createInfo.stages)),
|
||||||
m_sharingMode (device->getSharingMode()),
|
m_sharingMode (device->getSharingMode()),
|
||||||
m_info (createInfo) {
|
m_info (createInfo) {
|
||||||
|
DxvkAllocationInfo allocationInfo = { };
|
||||||
|
allocationInfo.resourceCookie = cookie();
|
||||||
|
|
||||||
VkBufferCreateInfo info = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
VkBufferCreateInfo info = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||||
info.flags = m_info.flags;
|
info.flags = m_info.flags;
|
||||||
info.usage = m_info.usage;
|
info.usage = m_info.usage;
|
||||||
info.size = m_info.size;
|
info.size = m_info.size;
|
||||||
m_sharingMode.fill(info);
|
m_sharingMode.fill(info);
|
||||||
|
|
||||||
assignStorage(allocator.importBufferResource(info, importInfo));
|
assignStorage(allocator.importBufferResource(info, allocationInfo, importInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,6 +313,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
Rc<DxvkResourceAllocation> allocateStorage(DxvkLocalAllocationCache* cache) {
|
Rc<DxvkResourceAllocation> allocateStorage(DxvkLocalAllocationCache* cache) {
|
||||||
DxvkAllocationInfo allocationInfo = { };
|
DxvkAllocationInfo allocationInfo = { };
|
||||||
|
allocationInfo.resourceCookie = cookie();
|
||||||
allocationInfo.properties = m_properties;
|
allocationInfo.properties = m_properties;
|
||||||
|
|
||||||
VkBufferCreateInfo info = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
VkBufferCreateInfo info = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||||
|
@ -47,8 +47,11 @@ namespace dxvk {
|
|||||||
copyFormatList(createInfo.viewFormatCount, createInfo.viewFormats);
|
copyFormatList(createInfo.viewFormatCount, createInfo.viewFormats);
|
||||||
|
|
||||||
// Create backing storage for existing image resource
|
// Create backing storage for existing image resource
|
||||||
|
DxvkAllocationInfo allocationInfo = { };
|
||||||
|
allocationInfo.resourceCookie = cookie();
|
||||||
|
|
||||||
VkImageCreateInfo imageInfo = getImageCreateInfo(DxvkImageUsageInfo());
|
VkImageCreateInfo imageInfo = getImageCreateInfo(DxvkImageUsageInfo());
|
||||||
assignStorage(m_allocator->importImageResource(imageInfo, imageHandle));
|
assignStorage(m_allocator->importImageResource(imageInfo, allocationInfo, imageHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,6 +177,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DxvkAllocationInfo allocationInfo = { };
|
DxvkAllocationInfo allocationInfo = { };
|
||||||
|
allocationInfo.resourceCookie = cookie();
|
||||||
allocationInfo.properties = m_properties;
|
allocationInfo.properties = m_properties;
|
||||||
|
|
||||||
return m_allocator->createImageResource(imageInfo,
|
return m_allocator->createImageResource(imageInfo,
|
||||||
|
@ -524,7 +524,7 @@ namespace dxvk {
|
|||||||
int64_t address = selectedPool.alloc(size, requirements.alignment);
|
int64_t address = selectedPool.alloc(size, requirements.alignment);
|
||||||
|
|
||||||
if (likely(address >= 0))
|
if (likely(address >= 0))
|
||||||
return createAllocation(type, selectedPool, address, size);
|
return createAllocation(type, selectedPool, address, size, allocationInfo);
|
||||||
|
|
||||||
// If the memory type is host-visible, try to find an existing chunk
|
// If the memory type is host-visible, try to find an existing chunk
|
||||||
// in the other memory pool of the memory type and move over.
|
// in the other memory pool of the memory type and move over.
|
||||||
@ -549,7 +549,7 @@ namespace dxvk {
|
|||||||
address = selectedPool.alloc(size, requirements.alignment);
|
address = selectedPool.alloc(size, requirements.alignment);
|
||||||
|
|
||||||
if (likely(address >= 0))
|
if (likely(address >= 0))
|
||||||
return createAllocation(type, selectedPool, address, size);
|
return createAllocation(type, selectedPool, address, size, allocationInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ namespace dxvk {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
mapDeviceMemory(memory, allocationInfo.properties);
|
mapDeviceMemory(memory, allocationInfo.properties);
|
||||||
return createAllocation(type, memory);
|
return createAllocation(type, memory, allocationInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to allocate a new chunk that is large enough to hold
|
// Try to allocate a new chunk that is large enough to hold
|
||||||
@ -584,7 +584,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (allocateChunkInPool(type, selectedPool, allocationInfo.properties, size, desiredSize)) {
|
if (allocateChunkInPool(type, selectedPool, allocationInfo.properties, size, desiredSize)) {
|
||||||
address = selectedPool.alloc(size, requirements.alignment);
|
address = selectedPool.alloc(size, requirements.alignment);
|
||||||
return createAllocation(type, selectedPool, address, size);
|
return createAllocation(type, selectedPool, address, size, allocationInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (likely(memory.memory != VK_NULL_HANDLE)) {
|
if (likely(memory.memory != VK_NULL_HANDLE)) {
|
||||||
mapDeviceMemory(memory, allocationInfo.properties);
|
mapDeviceMemory(memory, allocationInfo.properties);
|
||||||
return createAllocation(type, memory);
|
return createAllocation(type, memory, allocationInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +716,9 @@ namespace dxvk {
|
|||||||
logMemoryStats();
|
logMemoryStats();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
allocation = createAllocation(new DxvkSparsePageTable(m_device, createInfo, buffer));
|
allocation = createAllocation(
|
||||||
|
new DxvkSparsePageTable(m_device, createInfo, buffer),
|
||||||
|
allocationInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allocation) {
|
if (!allocation) {
|
||||||
@ -853,7 +855,7 @@ namespace dxvk {
|
|||||||
allocation->m_sparsePageTable = pageTable.release();
|
allocation->m_sparsePageTable = pageTable.release();
|
||||||
} else {
|
} else {
|
||||||
// Just need a page table, but no memory
|
// Just need a page table, but no memory
|
||||||
allocation = createAllocation(pageTable.release());
|
allocation = createAllocation(pageTable.release(), allocationInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,9 +930,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<DxvkResourceAllocation> DxvkMemoryAllocator::importBufferResource(
|
Rc<DxvkResourceAllocation> DxvkMemoryAllocator::importBufferResource(
|
||||||
const VkBufferCreateInfo& createInfo,
|
const VkBufferCreateInfo& createInfo,
|
||||||
|
const DxvkAllocationInfo& allocationInfo,
|
||||||
const DxvkBufferImportInfo& importInfo) {
|
const DxvkBufferImportInfo& importInfo) {
|
||||||
Rc<DxvkResourceAllocation> allocation = m_allocationPool.create(this, nullptr);
|
Rc<DxvkResourceAllocation> allocation = m_allocationPool.create(this, nullptr);
|
||||||
allocation->m_flags.set(DxvkAllocationFlag::Imported);
|
allocation->m_flags.set(DxvkAllocationFlag::Imported);
|
||||||
|
allocation->m_resourceCookie = allocation->m_resourceCookie;
|
||||||
allocation->m_size = createInfo.size;
|
allocation->m_size = createInfo.size;
|
||||||
allocation->m_mapPtr = importInfo.mapPtr;
|
allocation->m_mapPtr = importInfo.mapPtr;
|
||||||
allocation->m_buffer = importInfo.buffer;
|
allocation->m_buffer = importInfo.buffer;
|
||||||
@ -945,9 +949,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<DxvkResourceAllocation> DxvkMemoryAllocator::importImageResource(
|
Rc<DxvkResourceAllocation> DxvkMemoryAllocator::importImageResource(
|
||||||
const VkImageCreateInfo& createInfo,
|
const VkImageCreateInfo& createInfo,
|
||||||
|
const DxvkAllocationInfo& allocationInfo,
|
||||||
VkImage imageHandle) {
|
VkImage imageHandle) {
|
||||||
Rc<DxvkResourceAllocation> allocation = m_allocationPool.create(this, nullptr);
|
Rc<DxvkResourceAllocation> allocation = m_allocationPool.create(this, nullptr);
|
||||||
allocation->m_flags.set(DxvkAllocationFlag::Imported);
|
allocation->m_flags.set(DxvkAllocationFlag::Imported);
|
||||||
|
allocation->m_resourceCookie = allocation->m_resourceCookie;
|
||||||
allocation->m_image = imageHandle;
|
allocation->m_image = imageHandle;
|
||||||
|
|
||||||
return allocation;
|
return allocation;
|
||||||
@ -1103,7 +1109,8 @@ namespace dxvk {
|
|||||||
DxvkMemoryType& type,
|
DxvkMemoryType& type,
|
||||||
DxvkMemoryPool& pool,
|
DxvkMemoryPool& pool,
|
||||||
VkDeviceSize address,
|
VkDeviceSize address,
|
||||||
VkDeviceSize size) {
|
VkDeviceSize size,
|
||||||
|
const DxvkAllocationInfo& allocationInfo) {
|
||||||
type.stats.memoryUsed += size;
|
type.stats.memoryUsed += size;
|
||||||
|
|
||||||
uint32_t chunkIndex = address >> DxvkPageAllocator::ChunkAddressBits;
|
uint32_t chunkIndex = address >> DxvkPageAllocator::ChunkAddressBits;
|
||||||
@ -1114,6 +1121,7 @@ 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);
|
||||||
|
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;
|
||||||
allocation->m_size = size;
|
allocation->m_size = size;
|
||||||
@ -1133,8 +1141,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
DxvkResourceAllocation* DxvkMemoryAllocator::createAllocation(
|
DxvkResourceAllocation* DxvkMemoryAllocator::createAllocation(
|
||||||
DxvkSparsePageTable* sparsePageTable) {
|
DxvkSparsePageTable* sparsePageTable,
|
||||||
|
const DxvkAllocationInfo& allocationInfo) {
|
||||||
auto allocation = m_allocationPool.create(this, nullptr);
|
auto allocation = m_allocationPool.create(this, nullptr);
|
||||||
|
allocation->m_resourceCookie = allocationInfo.resourceCookie;
|
||||||
allocation->m_sparsePageTable = sparsePageTable;
|
allocation->m_sparsePageTable = sparsePageTable;
|
||||||
|
|
||||||
return allocation;
|
return allocation;
|
||||||
@ -1143,7 +1153,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkResourceAllocation* DxvkMemoryAllocator::createAllocation(
|
DxvkResourceAllocation* DxvkMemoryAllocator::createAllocation(
|
||||||
DxvkMemoryType& type,
|
DxvkMemoryType& type,
|
||||||
const DxvkDeviceMemory& memory) {
|
const DxvkDeviceMemory& memory,
|
||||||
|
const DxvkAllocationInfo& allocationInfo) {
|
||||||
type.stats.memoryUsed += memory.size;
|
type.stats.memoryUsed += memory.size;
|
||||||
|
|
||||||
auto allocation = m_allocationPool.create(this, &type);
|
auto allocation = m_allocationPool.create(this, &type);
|
||||||
@ -1152,6 +1163,7 @@ namespace dxvk {
|
|||||||
if (memory.buffer)
|
if (memory.buffer)
|
||||||
allocation->m_flags.set(DxvkAllocationFlag::OwnsBuffer);
|
allocation->m_flags.set(DxvkAllocationFlag::OwnsBuffer);
|
||||||
|
|
||||||
|
allocation->m_resourceCookie = allocationInfo.resourceCookie;
|
||||||
allocation->m_memory = memory.memory;
|
allocation->m_memory = memory.memory;
|
||||||
allocation->m_address = DedicatedChunkAddress;
|
allocation->m_address = DedicatedChunkAddress;
|
||||||
allocation->m_size = memory.size;
|
allocation->m_size = memory.size;
|
||||||
@ -1440,7 +1452,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Add allocation to the list and mark it as cacheable,
|
// Add allocation to the list and mark it as cacheable,
|
||||||
// so it will get recycled as-is after use.
|
// so it will get recycled as-is after use.
|
||||||
allocation = createAllocation(memoryType, memoryPool, address, allocationSize);
|
allocation = createAllocation(memoryType, memoryPool,
|
||||||
|
address, allocationSize, DxvkAllocationInfo());
|
||||||
allocation->m_flags.set(DxvkAllocationFlag::Cacheable);
|
allocation->m_flags.set(DxvkAllocationFlag::Cacheable);
|
||||||
|
|
||||||
if (tail) {
|
if (tail) {
|
||||||
|
@ -921,6 +921,8 @@ namespace dxvk {
|
|||||||
* \brief Allocation properties
|
* \brief Allocation properties
|
||||||
*/
|
*/
|
||||||
struct DxvkAllocationInfo {
|
struct DxvkAllocationInfo {
|
||||||
|
/// Virtual resource cookie for the allocation
|
||||||
|
uint64_t resourceCookie = 0u;
|
||||||
/// Desired memory property flags
|
/// Desired memory property flags
|
||||||
VkMemoryPropertyFlags properties = 0u;
|
VkMemoryPropertyFlags properties = 0u;
|
||||||
};
|
};
|
||||||
@ -1040,6 +1042,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
Rc<DxvkResourceAllocation> importBufferResource(
|
Rc<DxvkResourceAllocation> importBufferResource(
|
||||||
const VkBufferCreateInfo& createInfo,
|
const VkBufferCreateInfo& createInfo,
|
||||||
|
const DxvkAllocationInfo& allocationInfo,
|
||||||
const DxvkBufferImportInfo& importInfo);
|
const DxvkBufferImportInfo& importInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1051,6 +1054,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
Rc<DxvkResourceAllocation> importImageResource(
|
Rc<DxvkResourceAllocation> importImageResource(
|
||||||
const VkImageCreateInfo& createInfo,
|
const VkImageCreateInfo& createInfo,
|
||||||
|
const DxvkAllocationInfo& allocationInfo,
|
||||||
VkImage imageHandle);
|
VkImage imageHandle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1195,14 +1199,17 @@ namespace dxvk {
|
|||||||
DxvkMemoryType& type,
|
DxvkMemoryType& type,
|
||||||
DxvkMemoryPool& pool,
|
DxvkMemoryPool& pool,
|
||||||
VkDeviceSize address,
|
VkDeviceSize address,
|
||||||
VkDeviceSize size);
|
VkDeviceSize size,
|
||||||
|
const DxvkAllocationInfo& allocationInfo);
|
||||||
|
|
||||||
DxvkResourceAllocation* createAllocation(
|
DxvkResourceAllocation* createAllocation(
|
||||||
DxvkMemoryType& type,
|
DxvkMemoryType& type,
|
||||||
const DxvkDeviceMemory& memory);
|
const DxvkDeviceMemory& memory,
|
||||||
|
const DxvkAllocationInfo& allocationInfo);
|
||||||
|
|
||||||
DxvkResourceAllocation* createAllocation(
|
DxvkResourceAllocation* createAllocation(
|
||||||
DxvkSparsePageTable* sparsePageTable);
|
DxvkSparsePageTable* sparsePageTable,
|
||||||
|
const DxvkAllocationInfo& allocationInfo);
|
||||||
|
|
||||||
bool refillAllocationCache(
|
bool refillAllocationCache(
|
||||||
DxvkLocalAllocationCache* cache,
|
DxvkLocalAllocationCache* cache,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user