Commit ac88d875 authored by Emircan Uysaler's avatar Emircan Uysaler Committed by Commit Bot

[Fuchsia] Use vkGetDeviceQueue2 for protected

vkGetDeviceQueue2 is the prefferred way to pass flags to queue creation.

Bug: 982922
Change-Id: I6320c17b5b9d345b3d4a312f0b91c09618bfdb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1817098Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Emircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699610}
parent 2558c706
...@@ -150,6 +150,7 @@ VULKAN_DEVICE_FUNCTIONS = [ ...@@ -150,6 +150,7 @@ VULKAN_DEVICE_FUNCTIONS = [
{ {
'min_api_version': 'VK_API_VERSION_1_1', 'min_api_version': 'VK_API_VERSION_1_1',
'functions': [ 'functions': [
'vkGetDeviceQueue2',
'vkGetImageMemoryRequirements2', 'vkGetImageMemoryRequirements2',
] ]
}, },
......
...@@ -171,7 +171,6 @@ bool VulkanDeviceQueue::Initialize( ...@@ -171,7 +171,6 @@ bool VulkanDeviceQueue::Initialize(
enabled_device_features_2_.pNext = &sampler_ycbcr_conversion_features_; enabled_device_features_2_.pNext = &sampler_ycbcr_conversion_features_;
#endif // defined(OS_ANDROID) || defined(OS_FUCHSIA) #endif // defined(OS_ANDROID) || defined(OS_FUCHSIA)
#if defined(OS_FUCHSIA)
if (allow_protected_memory) { if (allow_protected_memory) {
if (device_api_version < VK_MAKE_VERSION(1, 1, 0)) { if (device_api_version < VK_MAKE_VERSION(1, 1, 0)) {
DLOG(ERROR) << "Vulkan 1.1 is required for protected memory"; DLOG(ERROR) << "Vulkan 1.1 is required for protected memory";
...@@ -194,7 +193,6 @@ bool VulkanDeviceQueue::Initialize( ...@@ -194,7 +193,6 @@ bool VulkanDeviceQueue::Initialize(
protected_memory_features_.pNext = enabled_device_features_2_.pNext; protected_memory_features_.pNext = enabled_device_features_2_.pNext;
enabled_device_features_2_.pNext = &protected_memory_features_; enabled_device_features_2_.pNext = &protected_memory_features_;
} }
#endif // defined(OS_FUCHSIA)
// Disable all physical device features by default. // Disable all physical device features by default.
enabled_device_features_2_.features = {}; enabled_device_features_2_.features = {};
...@@ -227,7 +225,16 @@ bool VulkanDeviceQueue::Initialize( ...@@ -227,7 +225,16 @@ bool VulkanDeviceQueue::Initialize(
vk_device_ = owned_vk_device_; vk_device_ = owned_vk_device_;
vkGetDeviceQueue(vk_device_, queue_index, 0, &vk_queue_); if (allow_protected_memory) {
VkDeviceQueueInfo2 queue_info2 = {};
queue_info2.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2;
queue_info2.flags = VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT;
queue_info2.queueFamilyIndex = queue_index;
queue_info2.queueIndex = 0;
vkGetDeviceQueue2(vk_device_, &queue_info2, &vk_queue_);
} else {
vkGetDeviceQueue(vk_device_, queue_index, 0, &vk_queue_);
}
cleanup_helper_ = std::make_unique<VulkanFenceHelper>(this); cleanup_helper_ = std::make_unique<VulkanFenceHelper>(this);
......
...@@ -115,10 +115,8 @@ class VULKAN_EXPORT VulkanDeviceQueue { ...@@ -115,10 +115,8 @@ class VULKAN_EXPORT VulkanDeviceQueue {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES}; VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES};
#endif // defined(OS_ANDROID) || defined(OS_FUCHSIA) #endif // defined(OS_ANDROID) || defined(OS_FUCHSIA)
#if defined(OS_FUCHSIA)
VkPhysicalDeviceProtectedMemoryFeatures protected_memory_features_ = { VkPhysicalDeviceProtectedMemoryFeatures protected_memory_features_ = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES}; VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES};
#endif // defined(OS_FUCHSIA)
DISALLOW_COPY_AND_ASSIGN(VulkanDeviceQueue); DISALLOW_COPY_AND_ASSIGN(VulkanDeviceQueue);
}; };
......
...@@ -728,6 +728,14 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers( ...@@ -728,6 +728,14 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(
} }
if (api_version >= VK_API_VERSION_1_1) { if (api_version >= VK_API_VERSION_1_1) {
vkGetDeviceQueue2Fn = reinterpret_cast<PFN_vkGetDeviceQueue2>(
vkGetDeviceProcAddrFn(vk_device, "vkGetDeviceQueue2"));
if (!vkGetDeviceQueue2Fn) {
DLOG(WARNING) << "Failed to bind vulkan entrypoint: "
<< "vkGetDeviceQueue2";
return false;
}
vkGetImageMemoryRequirements2Fn = vkGetImageMemoryRequirements2Fn =
reinterpret_cast<PFN_vkGetImageMemoryRequirements2>( reinterpret_cast<PFN_vkGetImageMemoryRequirements2>(
vkGetDeviceProcAddrFn(vk_device, "vkGetImageMemoryRequirements2")); vkGetDeviceProcAddrFn(vk_device, "vkGetImageMemoryRequirements2"));
......
...@@ -168,6 +168,7 @@ struct VulkanFunctionPointers { ...@@ -168,6 +168,7 @@ struct VulkanFunctionPointers {
PFN_vkUpdateDescriptorSets vkUpdateDescriptorSetsFn = nullptr; PFN_vkUpdateDescriptorSets vkUpdateDescriptorSetsFn = nullptr;
PFN_vkWaitForFences vkWaitForFencesFn = nullptr; PFN_vkWaitForFences vkWaitForFencesFn = nullptr;
PFN_vkGetDeviceQueue2 vkGetDeviceQueue2Fn = nullptr;
PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2Fn = nullptr; PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2Fn = nullptr;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -359,6 +360,7 @@ struct VulkanFunctionPointers { ...@@ -359,6 +360,7 @@ struct VulkanFunctionPointers {
gpu::GetVulkanFunctionPointers()->vkUpdateDescriptorSetsFn gpu::GetVulkanFunctionPointers()->vkUpdateDescriptorSetsFn
#define vkWaitForFences gpu::GetVulkanFunctionPointers()->vkWaitForFencesFn #define vkWaitForFences gpu::GetVulkanFunctionPointers()->vkWaitForFencesFn
#define vkGetDeviceQueue2 gpu::GetVulkanFunctionPointers()->vkGetDeviceQueue2Fn
#define vkGetImageMemoryRequirements2 \ #define vkGetImageMemoryRequirements2 \
gpu::GetVulkanFunctionPointers()->vkGetImageMemoryRequirements2Fn gpu::GetVulkanFunctionPointers()->vkGetImageMemoryRequirements2Fn
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment