summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorTapani Pälli <[email protected]>2018-11-08 10:02:42 +0200
committerTapani Pälli <[email protected]>2018-12-19 09:38:41 +0200
commit884fc90fdebaad93986c80752df3723b7f8f1392 (patch)
tree6cc30a4cafc212070eea3f6a497ea3f93ef966b6 /src/intel
parent1e6a44400aa2bf8d169a876ffb339418a5bdc3a0 (diff)
anv: add anv_ahw_usage_from_vk_usage helper function
v2: rebase to b43f955037c changes Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_android.c31
-rw-r--r--src/intel/vulkan/anv_android.h2
-rw-r--r--src/intel/vulkan/anv_android_stubs.c7
3 files changed, 40 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_android.c b/src/intel/vulkan/anv_android.c
index 1288b330a84..7b7e214379f 100644
--- a/src/intel/vulkan/anv_android.c
+++ b/src/intel/vulkan/anv_android.c
@@ -215,6 +215,37 @@ anv_GetAndroidHardwareBufferPropertiesANDROID(
return VK_SUCCESS;
}
+/* Construct ahw usage mask from image usage bits, see
+ * 'AHardwareBuffer Usage Equivalence' in Vulkan spec.
+ */
+uint64_t
+anv_ahw_usage_from_vk_usage(const VkImageCreateFlags vk_create,
+ const VkImageUsageFlags vk_usage)
+{
+ uint64_t ahw_usage = 0;
+
+ if (vk_usage & VK_IMAGE_USAGE_SAMPLED_BIT)
+ ahw_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
+
+ if (vk_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)
+ ahw_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
+
+ if (vk_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
+ ahw_usage |= AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
+
+ if (vk_create & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)
+ ahw_usage |= AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP;
+
+ if (vk_create & VK_IMAGE_CREATE_PROTECTED_BIT)
+ ahw_usage |= AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT;
+
+ /* No usage bits set - set at least one GPU usage. */
+ if (ahw_usage == 0)
+ ahw_usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
+
+ return ahw_usage;
+}
+
VkResult
anv_image_from_gralloc(VkDevice device_h,
const VkImageCreateInfo *base_info,
diff --git a/src/intel/vulkan/anv_android.h b/src/intel/vulkan/anv_android.h
index a27c364471b..8d748cecc39 100644
--- a/src/intel/vulkan/anv_android.h
+++ b/src/intel/vulkan/anv_android.h
@@ -34,4 +34,6 @@ VkResult anv_image_from_gralloc(VkDevice device_h,
const VkAllocationCallbacks *alloc,
VkImage *pImage);
+uint64_t anv_ahw_usage_from_vk_usage(const VkImageCreateFlags vk_create,
+ const VkImageUsageFlags vk_usage);
#endif /* ANV_ANDROID_H */
diff --git a/src/intel/vulkan/anv_android_stubs.c b/src/intel/vulkan/anv_android_stubs.c
index a6fe5a5e6b3..0671d5635ee 100644
--- a/src/intel/vulkan/anv_android_stubs.c
+++ b/src/intel/vulkan/anv_android_stubs.c
@@ -32,3 +32,10 @@ anv_image_from_gralloc(VkDevice device_h,
{
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
+
+uint64_t
+anv_ahw_usage_from_vk_usage(const VkImageCreateFlags vk_create,
+ const VkImageUsageFlags vk_usage)
+{
+ return 0;
+}