Skip to content

Commit

Permalink
[Fuchsia] Use vkGetDeviceQueue2 for protected
Browse files Browse the repository at this point in the history
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/+/1817098
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
Commit-Queue: Emircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699610}
  • Loading branch information
uysalere authored and Commit Bot committed Sep 25, 2019
1 parent 2558c70 commit ac88d87
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions gpu/vulkan/generate_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
{
'min_api_version': 'VK_API_VERSION_1_1',
'functions': [
'vkGetDeviceQueue2',
'vkGetImageMemoryRequirements2',
]
},
Expand Down
13 changes: 10 additions & 3 deletions gpu/vulkan/vulkan_device_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ bool VulkanDeviceQueue::Initialize(
enabled_device_features_2_.pNext = &sampler_ycbcr_conversion_features_;
#endif // defined(OS_ANDROID) || defined(OS_FUCHSIA)

#if defined(OS_FUCHSIA)
if (allow_protected_memory) {
if (device_api_version < VK_MAKE_VERSION(1, 1, 0)) {
DLOG(ERROR) << "Vulkan 1.1 is required for protected memory";
Expand All @@ -194,7 +193,6 @@ bool VulkanDeviceQueue::Initialize(
protected_memory_features_.pNext = enabled_device_features_2_.pNext;
enabled_device_features_2_.pNext = &protected_memory_features_;
}
#endif // defined(OS_FUCHSIA)

// Disable all physical device features by default.
enabled_device_features_2_.features = {};
Expand Down Expand Up @@ -227,7 +225,16 @@ bool VulkanDeviceQueue::Initialize(

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);

Expand Down
2 changes: 0 additions & 2 deletions gpu/vulkan/vulkan_device_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ class VULKAN_EXPORT VulkanDeviceQueue {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES};
#endif // defined(OS_ANDROID) || defined(OS_FUCHSIA)

#if defined(OS_FUCHSIA)
VkPhysicalDeviceProtectedMemoryFeatures protected_memory_features_ = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES};
#endif // defined(OS_FUCHSIA)

DISALLOW_COPY_AND_ASSIGN(VulkanDeviceQueue);
};
Expand Down
8 changes: 8 additions & 0 deletions gpu/vulkan/vulkan_function_pointers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(
}

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 =
reinterpret_cast<PFN_vkGetImageMemoryRequirements2>(
vkGetDeviceProcAddrFn(vk_device, "vkGetImageMemoryRequirements2"));
Expand Down
2 changes: 2 additions & 0 deletions gpu/vulkan/vulkan_function_pointers.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct VulkanFunctionPointers {
PFN_vkUpdateDescriptorSets vkUpdateDescriptorSetsFn = nullptr;
PFN_vkWaitForFences vkWaitForFencesFn = nullptr;

PFN_vkGetDeviceQueue2 vkGetDeviceQueue2Fn = nullptr;
PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2Fn = nullptr;

#if defined(OS_ANDROID)
Expand Down Expand Up @@ -359,6 +360,7 @@ struct VulkanFunctionPointers {
gpu::GetVulkanFunctionPointers()->vkUpdateDescriptorSetsFn
#define vkWaitForFences gpu::GetVulkanFunctionPointers()->vkWaitForFencesFn

#define vkGetDeviceQueue2 gpu::GetVulkanFunctionPointers()->vkGetDeviceQueue2Fn
#define vkGetImageMemoryRequirements2 \
gpu::GetVulkanFunctionPointers()->vkGetImageMemoryRequirements2Fn

Expand Down

0 comments on commit ac88d87

Please sign in to comment.