Skip to content

Commit 7d2e082

Browse files
committed
Check for physical device features before using them
This is not complete, but silences some validation warnings. Before all features were being turned off! Signed-off-by: Charlie Turner <cturner@igalia.com>
1 parent d0fb28e commit 7d2e082

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

vk_video_decoder/libs/VkCodecUtils/VulkanDeviceContext.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,47 @@ VkResult VulkanDeviceContext::CreateVulkanDevice(int32_t numDecodeQueues,
517517
devInfo.enabledExtensionCount = static_cast<uint32_t>(m_reqDeviceExtensions.size());
518518
devInfo.ppEnabledExtensionNames = m_reqDeviceExtensions.data();
519519

520-
// disable all features
521-
VkPhysicalDeviceFeatures features = {};
522-
devInfo.pEnabledFeatures = &features;
520+
VkPhysicalDeviceDescriptorBufferFeaturesEXT descriptorBufferFeature = {};
521+
descriptorBufferFeature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT;
522+
523+
VkPhysicalDeviceVulkan13Features features_13 = {
524+
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
525+
.pNext = &descriptorBufferFeature,
526+
};
527+
VkPhysicalDeviceVulkan12Features features_12 = {
528+
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
529+
.pNext = &features_13,
530+
};
531+
VkPhysicalDeviceVulkan11Features features_11 = {
532+
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
533+
.pNext = &features_12,
534+
};
535+
VkPhysicalDeviceFeatures2 devFeatures = {
536+
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
537+
.pNext = &features_11,
538+
};
539+
540+
GetPhysicalDeviceFeatures2(m_physDevice, &devFeatures);
541+
542+
VkPhysicalDeviceVulkan13Features chosen13 = {};
543+
chosen13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
544+
VkPhysicalDeviceVulkan12Features chosen12 = {};
545+
chosen12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
546+
chosen12.pNext = &chosen13;
547+
VkPhysicalDeviceVulkan11Features chosen11 = {};
548+
chosen11.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
549+
chosen11.pNext = &chosen12;
550+
551+
// TODO: Review all the usages of features and ensure they are checked here. Descriptor buffers, samplers, lots of things probably...
552+
// if presenting: assert sampler conversion...
553+
chosen11.samplerYcbcrConversion = features_11.samplerYcbcrConversion;
554+
assert(features_13.synchronization2);
555+
chosen13.synchronization2 = features_13.synchronization2;
556+
557+
// Use all the supported core features, probably we should trim this down a bit.
558+
devFeatures.pNext = &chosen11;
559+
devInfo.pEnabledFeatures = nullptr; // use features2
560+
devInfo.pNext = &devFeatures;
523561

524562
VkResult result = CreateDevice(m_physDevice, &devInfo, nullptr, &m_device);
525563
if (result != VK_SUCCESS) {

0 commit comments

Comments
 (0)