mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 14:52:10 +01:00
[dxvk] Remove legacy DxvkMemory class
This commit is contained in:
parent
25076d9220
commit
347925c8b7
@ -497,56 +497,6 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkMemory DxvkMemoryAllocator::alloc(
|
|
||||||
DxvkMemoryRequirements req,
|
|
||||||
const DxvkMemoryProperties& info) {
|
|
||||||
// Enforce that tiled images do not overlap with buffers in memory.
|
|
||||||
// Only changes anything for small images on older Nvidia hardware.
|
|
||||||
if (req.tiling == VK_IMAGE_TILING_OPTIMAL) {
|
|
||||||
req.core.memoryRequirements.alignment = std::max(req.core.memoryRequirements.alignment,
|
|
||||||
m_device->properties().core.properties.limits.bufferImageGranularity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If requested, try to create a dedicated allocation. If this
|
|
||||||
// fails, we may still fall back to a suballocation unless a
|
|
||||||
// dedicated allocation is explicitly required.
|
|
||||||
if (unlikely(info.dedicated.buffer || info.dedicated.image)) {
|
|
||||||
Rc<DxvkResourceAllocation> allocation = allocateDedicatedMemory(
|
|
||||||
req.core.memoryRequirements, info.flags, &info.dedicated);
|
|
||||||
|
|
||||||
if (allocation)
|
|
||||||
return DxvkMemory(std::move(allocation));
|
|
||||||
|
|
||||||
if (req.dedicated.requiresDedicatedAllocation && (info.flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
|
|
||||||
allocation = allocateDedicatedMemory(req.core.memoryRequirements,
|
|
||||||
info.flags & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &info.dedicated);
|
|
||||||
|
|
||||||
if (unlikely(!allocation)) {
|
|
||||||
logMemoryError(req.core.memoryRequirements);
|
|
||||||
logMemoryStats();
|
|
||||||
}
|
|
||||||
|
|
||||||
return DxvkMemory(std::move(allocation));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Suballocate memory from an existing chunk
|
|
||||||
Rc<DxvkResourceAllocation> allocation = allocateMemory(req.core.memoryRequirements, info.flags);
|
|
||||||
|
|
||||||
if (unlikely(!allocation) && (info.flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
|
|
||||||
allocation = allocateMemory(req.core.memoryRequirements,
|
|
||||||
info.flags & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
|
||||||
|
|
||||||
if (unlikely(!allocation)) {
|
|
||||||
logMemoryError(req.core.memoryRequirements);
|
|
||||||
logMemoryStats();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DxvkMemory(std::move(allocation));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Rc<DxvkResourceAllocation> DxvkMemoryAllocator::allocateMemory(
|
Rc<DxvkResourceAllocation> DxvkMemoryAllocator::allocateMemory(
|
||||||
const VkMemoryRequirements& requirements,
|
const VkMemoryRequirements& requirements,
|
||||||
VkMemoryPropertyFlags properties) {
|
VkMemoryPropertyFlags properties) {
|
||||||
|
@ -211,27 +211,6 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Memory requirement info
|
|
||||||
*/
|
|
||||||
struct DxvkMemoryRequirements {
|
|
||||||
VkImageTiling tiling;
|
|
||||||
VkMemoryDedicatedRequirements dedicated;
|
|
||||||
VkMemoryRequirements2 core;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Memory allocation info
|
|
||||||
*/
|
|
||||||
struct DxvkMemoryProperties {
|
|
||||||
VkExportMemoryAllocateInfo sharedExport;
|
|
||||||
VkImportMemoryWin32HandleInfoKHR sharedImportWin32;
|
|
||||||
VkMemoryDedicatedAllocateInfo dedicated;
|
|
||||||
VkMemoryPropertyFlags flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Buffer view key
|
* \brief Buffer view key
|
||||||
*
|
*
|
||||||
@ -452,9 +431,9 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
class alignas(CACHE_LINE_SIZE) DxvkResourceAllocation {
|
class alignas(CACHE_LINE_SIZE) DxvkResourceAllocation {
|
||||||
friend DxvkMemoryAllocator;
|
friend DxvkMemoryAllocator;
|
||||||
|
|
||||||
friend class DxvkLocalAllocationCache;
|
friend class DxvkLocalAllocationCache;
|
||||||
friend class DxvkSharedAllocationCache;
|
friend class DxvkSharedAllocationCache;
|
||||||
friend class DxvkMemory;
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DxvkResourceAllocation(
|
DxvkResourceAllocation(
|
||||||
@ -716,101 +695,6 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Memory slice
|
|
||||||
*
|
|
||||||
* Represents a slice of memory that has
|
|
||||||
* been sub-allocated from a bigger chunk.
|
|
||||||
*/
|
|
||||||
struct DxvkMemory {
|
|
||||||
DxvkMemory() = default;
|
|
||||||
|
|
||||||
explicit DxvkMemory(Rc<DxvkResourceAllocation>&& allocation_)
|
|
||||||
: allocation(std::move(allocation_)) { }
|
|
||||||
|
|
||||||
DxvkMemory(DxvkMemory&& other) = default;
|
|
||||||
DxvkMemory& operator = (DxvkMemory&& other) = default;
|
|
||||||
|
|
||||||
~DxvkMemory() = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Memory object
|
|
||||||
*
|
|
||||||
* This information is required when
|
|
||||||
* binding memory to Vulkan objects.
|
|
||||||
* \returns Memory object
|
|
||||||
*/
|
|
||||||
VkDeviceMemory memory() const {
|
|
||||||
return allocation ? allocation->m_memory : VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Buffer object
|
|
||||||
*
|
|
||||||
* Global buffer covering the entire memory allocation.
|
|
||||||
* \returns Buffer object
|
|
||||||
*/
|
|
||||||
VkBuffer buffer() const {
|
|
||||||
return allocation ? allocation->m_buffer : VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Offset into device memory
|
|
||||||
*
|
|
||||||
* This information is required when
|
|
||||||
* binding memory to Vulkan objects.
|
|
||||||
* \returns Offset into device memory
|
|
||||||
*/
|
|
||||||
VkDeviceSize offset() const {
|
|
||||||
return allocation
|
|
||||||
? allocation->m_address & DxvkPageAllocator::ChunkAddressMask
|
|
||||||
: 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Pointer to mapped data
|
|
||||||
*
|
|
||||||
* \param [in] offset Byte offset
|
|
||||||
* \returns Pointer to mapped data
|
|
||||||
*/
|
|
||||||
void* mapPtr(VkDeviceSize offset) const {
|
|
||||||
return allocation && allocation->m_mapPtr
|
|
||||||
? reinterpret_cast<char*>(allocation->m_mapPtr) + offset
|
|
||||||
: nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Returns length of memory allocated
|
|
||||||
* \returns Memory size
|
|
||||||
*/
|
|
||||||
VkDeviceSize length() const {
|
|
||||||
return allocation ? allocation->m_size : 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Checks whether the memory slice is defined
|
|
||||||
*
|
|
||||||
* \returns \c true if this slice points to actual device
|
|
||||||
* memory, and \c false if it is undefined.
|
|
||||||
*/
|
|
||||||
explicit operator bool () const {
|
|
||||||
return bool(allocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Queries global buffer usage flags
|
|
||||||
* \returns Global buffer usage flags, if any
|
|
||||||
*/
|
|
||||||
VkBufferUsageFlags getBufferUsage() const {
|
|
||||||
return allocation && allocation->m_type
|
|
||||||
? allocation->m_type->bufferUsage
|
|
||||||
: 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rc<DxvkResourceAllocation> allocation;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Local allocation cache
|
* \brief Local allocation cache
|
||||||
*
|
*
|
||||||
@ -1045,7 +929,6 @@ namespace dxvk {
|
|||||||
* Memory objects will be destroyed automatically.
|
* Memory objects will be destroyed automatically.
|
||||||
*/
|
*/
|
||||||
class DxvkMemoryAllocator {
|
class DxvkMemoryAllocator {
|
||||||
friend DxvkMemory;
|
|
||||||
friend DxvkResourceAllocation;
|
friend DxvkResourceAllocation;
|
||||||
friend DxvkLocalAllocationCache;
|
friend DxvkLocalAllocationCache;
|
||||||
friend DxvkSharedAllocationCache;
|
friend DxvkSharedAllocationCache;
|
||||||
@ -1067,18 +950,6 @@ namespace dxvk {
|
|||||||
return m_device;
|
return m_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Allocates device memory
|
|
||||||
*
|
|
||||||
* Legacy interface for memory allocation, to be removed.
|
|
||||||
* \param [in] req Memory requirements
|
|
||||||
* \param [in] info Memory properties
|
|
||||||
* \returns Allocated memory slice
|
|
||||||
*/
|
|
||||||
DxvkMemory alloc(
|
|
||||||
DxvkMemoryRequirements req,
|
|
||||||
const DxvkMemoryProperties& info);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Allocates memory for a regular resource
|
* \brief Allocates memory for a regular resource
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user