File tree 2 files changed +22
-0
lines changed
filament/backend/src/vulkan
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,10 @@ struct VulkanContext {
142
142
return mPortabilitySubsetFeatures .imageView2DOn3DImage == VK_TRUE;
143
143
}
144
144
145
+ inline bool isUnifiedMemoryArchitecture () const noexcept {
146
+ return mIsUnifiedMemoryArchitecture ;
147
+ }
148
+
145
149
private:
146
150
VkPhysicalDeviceMemoryProperties mMemoryProperties = {};
147
151
VkPhysicalDeviceProperties2 mPhysicalDeviceProperties = {
@@ -164,6 +168,7 @@ struct VulkanContext {
164
168
bool mDebugUtilsSupported = false ;
165
169
bool mLazilyAllocatedMemorySupported = false ;
166
170
bool mProtectedMemorySupported = false ;
171
+ bool mIsUnifiedMemoryArchitecture = false ;
167
172
168
173
fvkutils::VkFormatList mDepthStencilFormats ;
169
174
fvkutils::VkFormatList mBlittableDepthStencilFormats ;
Original file line number Diff line number Diff line change @@ -631,6 +631,21 @@ fvkutils::VkFormatList findBlittableDepthStencilFormats(VkPhysicalDevice device)
631
631
return ret;
632
632
}
633
633
634
+ /* *
635
+ * Check if the GPU has a unified memory architecture.
636
+ */
637
+ bool hasUnifiedMemoryArchitecture (VkPhysicalDeviceMemoryProperties memoryProperties) noexcept {
638
+ // Try to identify if the platform is running on a Unified Memory Architecture by inspecting the
639
+ // memory heap flags, if they are all VK_MEMORY_HEAP_DEVICE_LOCAL_BIT it's UMA, otherwise not
640
+ // enough information to make a decision, so default to false.
641
+ for (uint32_t i = 0 ; i < memoryProperties.memoryHeapCount ; ++i) {
642
+ if ((memoryProperties.memoryHeaps [i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0 ) {
643
+ return false ;
644
+ }
645
+ }
646
+ return true ;
647
+ }
648
+
634
649
}// anonymous namespace
635
650
636
651
using SwapChainPtr = VulkanPlatform::SwapChainPtr;
@@ -864,6 +879,8 @@ Driver* VulkanPlatform::createDriver(void* sharedContext,
864
879
}
865
880
}
866
881
882
+ context.mIsUnifiedMemoryArchitecture = hasUnifiedMemoryArchitecture (context.mMemoryProperties );
883
+
867
884
#ifdef NDEBUG
868
885
// If we are in release build, we should not have turned on debug extensions
869
886
FILAMENT_CHECK_POSTCONDITION (!context.mDebugUtilsSupported && !context.mDebugMarkersSupported )
You can’t perform that action at this time.
0 commit comments