diff --git a/src/dxvk/dxvk_memory.cpp b/src/dxvk/dxvk_memory.cpp index a0006831b..95fb335c5 100644 --- a/src/dxvk/dxvk_memory.cpp +++ b/src/dxvk/dxvk_memory.cpp @@ -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 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 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 DxvkMemoryAllocator::allocateMemory( const VkMemoryRequirements& requirements, VkMemoryPropertyFlags properties) { diff --git a/src/dxvk/dxvk_memory.h b/src/dxvk/dxvk_memory.h index 588ac8741..581f29e39 100644 --- a/src/dxvk/dxvk_memory.h +++ b/src/dxvk/dxvk_memory.h @@ -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 * @@ -452,9 +431,9 @@ namespace dxvk { */ class alignas(CACHE_LINE_SIZE) DxvkResourceAllocation { friend DxvkMemoryAllocator; + friend class DxvkLocalAllocationCache; friend class DxvkSharedAllocationCache; - friend class DxvkMemory; public: 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&& 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(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 allocation; - }; - - /** * \brief Local allocation cache * @@ -1045,7 +929,6 @@ namespace dxvk { * Memory objects will be destroyed automatically. */ class DxvkMemoryAllocator { - friend DxvkMemory; friend DxvkResourceAllocation; friend DxvkLocalAllocationCache; friend DxvkSharedAllocationCache; @@ -1067,18 +950,6 @@ namespace dxvk { 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 *