Skip to content

Commit 54da9eb

Browse files
Vulkan: only enable host image copy on UMA devices
1 parent 1c5ebdf commit 54da9eb

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

Graphics/GraphicsEngine/include/RenderDeviceBase.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ DeviceFeatures EnableDeviceFeatures(const DeviceFeatures& SupportedFeatures,
7373
const DeviceFeatures& RequestedFeatures) noexcept(false);
7474

7575
DeviceFeaturesVk EnableDeviceFeaturesVk(const DeviceFeaturesVk& SupportedFeatures,
76-
const DeviceFeaturesVk& RequestedFeatures) noexcept(false);
76+
const DeviceFeaturesVk& RequestedFeatures,
77+
bool IsUMA) noexcept(false);
7778

7879
/// Checks sparse texture format support and returns the component type
7980
COMPONENT_TYPE CheckSparseTextureFormatSupport(TEXTURE_FORMAT TexFormat,

Graphics/GraphicsEngine/src/RenderDeviceBase.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,23 @@ DeviceFeatures EnableDeviceFeatures(const DeviceFeatures& SupportedFeatures,
128128
}
129129

130130
DeviceFeaturesVk EnableDeviceFeaturesVk(const DeviceFeaturesVk& SupportedFeatures,
131-
const DeviceFeaturesVk& RequestedFeatures) noexcept(false)
131+
const DeviceFeaturesVk& RequestedFeatures,
132+
bool IsUMA) noexcept(false)
132133
{
133134
DeviceFeaturesVk EnabledFeatures;
134135

135136
ENABLE_FEATURE(DynamicRendering, "VK_KHR_dynamic_rendering is");
136-
ENABLE_FEATURE(HostImageCopy, "VK_EXT_host_image_copy is");
137+
if (RequestedFeatures.HostImageCopy == DEVICE_FEATURE_STATE_OPTIONAL && SupportedFeatures.HostImageCopy != DEVICE_FEATURE_STATE_DISABLED)
138+
{
139+
// Only enable VK_EXT_host_image_copy if the device is UMA.
140+
// On discrete GPUs, textures with VK_IMAGE_USAGE_HOST_TRANSFER_BIT usage are allocated in a host-visible
141+
// device local memory that is very scarce.
142+
EnabledFeatures.HostImageCopy = IsUMA ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED;
143+
}
144+
else
145+
{
146+
ENABLE_FEATURE(HostImageCopy, "VK_EXT_host_image_copy is");
147+
}
137148

138149
ASSERT_SIZEOF(DeviceFeaturesVk, 2, "Did you add a new feature to DeviceFeaturesVk? Please handle its status here (if necessary).");
139150

Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ class VulkanPhysicalDevice
129129
VkFormatProperties GetPhysicalDeviceFormatProperties(VkFormat imageFormat, VkFormatProperties3* Properties3 = nullptr) const;
130130
const std::vector<VkQueueFamilyProperties>& GetQueueProperties() const { return m_QueueFamilyProperties; }
131131

132+
bool IsUMA() const;
133+
132134
private:
133135
VulkanPhysicalDevice(const CreateInfo& CI);
134136

Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En
754754
VerifyEngineCreateInfo(EngineCI, AdapterInfo);
755755
const DeviceFeatures EnabledFeatures = EnableDeviceFeatures(AdapterInfo.Features, EngineCI.Features);
756756
const DeviceFeaturesVk AdapterFeaturesVk = PhysicalDeviceFeaturesToDeviceFeaturesVk(PhysicalDevice->GetExtFeatures(), DEVICE_FEATURE_STATE_OPTIONAL);
757-
const DeviceFeaturesVk EnabledFeaturesVk = EnableDeviceFeaturesVk(AdapterFeaturesVk, EngineCI.FeaturesVk);
757+
const DeviceFeaturesVk EnabledFeaturesVk = EnableDeviceFeaturesVk(AdapterFeaturesVk, EngineCI.FeaturesVk, PhysicalDevice->IsUMA());
758758

759759
std::vector<VkDeviceQueueGlobalPriorityCreateInfoEXT> QueueGlobalPriority;
760760
std::vector<VkDeviceQueueCreateInfo> QueueInfos;

Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,4 +566,9 @@ VkFormatProperties VulkanPhysicalDevice::GetPhysicalDeviceFormatProperties(VkFor
566566
}
567567
}
568568

569+
bool VulkanPhysicalDevice::IsUMA() const
570+
{
571+
return m_MemoryProperties.memoryHeapCount == 1;
572+
}
573+
569574
} // namespace VulkanUtilities

0 commit comments

Comments
 (0)