Browse Source
Merge pull request #3756 from ReinUsesLisp/integrated-devices
vk_memory_manager: Remove unified memory model flag
pull/15/merge
Fernando Sahmkow
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
6 additions and
35 deletions
-
src/video_core/renderer_vulkan/vk_device.h
-
src/video_core/renderer_vulkan/vk_memory_manager.cpp
-
src/video_core/renderer_vulkan/vk_memory_manager.h
-
src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp
-
src/video_core/renderer_vulkan/vk_staging_buffer_pool.h
|
|
|
@ -82,11 +82,6 @@ public: |
|
|
|
return present_family; |
|
|
|
} |
|
|
|
|
|
|
|
/// Returns true if the device is integrated with the host CPU. |
|
|
|
bool IsIntegrated() const { |
|
|
|
return properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU; |
|
|
|
} |
|
|
|
|
|
|
|
/// Returns the current Vulkan API version provided in Vulkan-formatted version numbers. |
|
|
|
u32 GetApiVersion() const { |
|
|
|
return properties.apiVersion; |
|
|
|
|
|
|
|
@ -118,8 +118,7 @@ private: |
|
|
|
}; |
|
|
|
|
|
|
|
VKMemoryManager::VKMemoryManager(const VKDevice& device) |
|
|
|
: device{device}, properties{device.GetPhysical().GetMemoryProperties()}, |
|
|
|
is_memory_unified{GetMemoryUnified(properties)} {} |
|
|
|
: device{device}, properties{device.GetPhysical().GetMemoryProperties()} {} |
|
|
|
|
|
|
|
VKMemoryManager::~VKMemoryManager() = default; |
|
|
|
|
|
|
|
@ -209,16 +208,6 @@ VKMemoryCommit VKMemoryManager::TryAllocCommit(const VkMemoryRequirements& requi |
|
|
|
return {}; |
|
|
|
} |
|
|
|
|
|
|
|
bool VKMemoryManager::GetMemoryUnified(const VkPhysicalDeviceMemoryProperties& properties) { |
|
|
|
for (u32 heap_index = 0; heap_index < properties.memoryHeapCount; ++heap_index) { |
|
|
|
if (!(properties.memoryHeaps[heap_index].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)) { |
|
|
|
// Memory is considered unified when heaps are device local only.
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
VKMemoryCommitImpl::VKMemoryCommitImpl(const VKDevice& device, VKMemoryAllocation* allocation, |
|
|
|
const vk::DeviceMemory& memory, u64 begin, u64 end) |
|
|
|
: device{device}, memory{memory}, interval{begin, end}, allocation{allocation} {} |
|
|
|
|
|
|
|
@ -40,11 +40,6 @@ public: |
|
|
|
/// Commits memory required by the image and binds it. |
|
|
|
VKMemoryCommit Commit(const vk::Image& image, bool host_visible); |
|
|
|
|
|
|
|
/// Returns true if the memory allocations are done always in host visible and coherent memory. |
|
|
|
bool IsMemoryUnified() const { |
|
|
|
return is_memory_unified; |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
/// Allocates a chunk of memory. |
|
|
|
bool AllocMemory(VkMemoryPropertyFlags wanted_properties, u32 type_mask, u64 size); |
|
|
|
@ -53,12 +48,8 @@ private: |
|
|
|
VKMemoryCommit TryAllocCommit(const VkMemoryRequirements& requirements, |
|
|
|
VkMemoryPropertyFlags wanted_properties); |
|
|
|
|
|
|
|
/// Returns true if the device uses an unified memory model. |
|
|
|
static bool GetMemoryUnified(const VkPhysicalDeviceMemoryProperties& properties); |
|
|
|
|
|
|
|
const VKDevice& device; ///< Device handler. |
|
|
|
const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties. |
|
|
|
const bool is_memory_unified; ///< True if memory model is unified. |
|
|
|
const VKDevice& device; ///< Device handler. |
|
|
|
const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties. |
|
|
|
std::vector<std::unique_ptr<VKMemoryAllocation>> allocations; ///< Current allocations. |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@ -39,8 +39,7 @@ VKStagingBufferPool::StagingBuffer& VKStagingBufferPool::StagingBuffer::operator |
|
|
|
|
|
|
|
VKStagingBufferPool::VKStagingBufferPool(const VKDevice& device, VKMemoryManager& memory_manager, |
|
|
|
VKScheduler& scheduler) |
|
|
|
: device{device}, memory_manager{memory_manager}, scheduler{scheduler}, |
|
|
|
is_device_integrated{device.IsIntegrated()} {} |
|
|
|
: device{device}, memory_manager{memory_manager}, scheduler{scheduler} {} |
|
|
|
|
|
|
|
VKStagingBufferPool::~VKStagingBufferPool() = default; |
|
|
|
|
|
|
|
@ -56,9 +55,7 @@ void VKStagingBufferPool::TickFrame() { |
|
|
|
current_delete_level = (current_delete_level + 1) % NumLevels; |
|
|
|
|
|
|
|
ReleaseCache(true); |
|
|
|
if (!is_device_integrated) { |
|
|
|
ReleaseCache(false); |
|
|
|
} |
|
|
|
ReleaseCache(false); |
|
|
|
} |
|
|
|
|
|
|
|
VKBuffer* VKStagingBufferPool::TryGetReservedBuffer(std::size_t size, bool host_visible) { |
|
|
|
@ -95,7 +92,7 @@ VKBuffer& VKStagingBufferPool::CreateStagingBuffer(std::size_t size, bool host_v |
|
|
|
} |
|
|
|
|
|
|
|
VKStagingBufferPool::StagingBuffersCache& VKStagingBufferPool::GetCache(bool host_visible) { |
|
|
|
return is_device_integrated || host_visible ? host_staging_buffers : device_staging_buffers; |
|
|
|
return host_visible ? host_staging_buffers : device_staging_buffers; |
|
|
|
} |
|
|
|
|
|
|
|
void VKStagingBufferPool::ReleaseCache(bool host_visible) { |
|
|
|
|
|
|
|
@ -71,7 +71,6 @@ private: |
|
|
|
const VKDevice& device; |
|
|
|
VKMemoryManager& memory_manager; |
|
|
|
VKScheduler& scheduler; |
|
|
|
const bool is_device_integrated; |
|
|
|
|
|
|
|
StagingBuffersCache host_staging_buffers; |
|
|
|
StagingBuffersCache device_staging_buffers; |
|
|
|
|