Commit 5a0eb728 authored by Vikas Soni's avatar Vikas Soni Committed by Commit Bot

Add android platform specific functions.

Update generate_bindings.py to generate android platform specific device
functions.

Bug: 891060
Change-Id: I88f5b6149c4e955613b64e56c403caf2a970dd6f
Reviewed-on: https://chromium-review.googlesource.com/c/1344223Reviewed-by: default avatarChris Blume <cblume@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: vikas soni <vikassoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609792}
parent edf87778
...@@ -71,6 +71,11 @@ VULKAN_DEVICE_FUNCTIONS = [ ...@@ -71,6 +71,11 @@ VULKAN_DEVICE_FUNCTIONS = [
{ 'name': 'vkWaitForFences' }, { 'name': 'vkWaitForFences' },
] ]
VULKAN_DEVICE_FUNCTIONS_ANDROID = [
{ 'name': 'vkImportSemaphoreFdKHR' },
{ 'name': 'vkGetSemaphoreFdKHR' },
]
VULKAN_QUEUE_FUNCTIONS = [ VULKAN_QUEUE_FUNCTIONS = [
{ 'name': 'vkQueueSubmit' }, { 'name': 'vkQueueSubmit' },
{ 'name': 'vkQueueWaitIdle' }, { 'name': 'vkQueueWaitIdle' },
...@@ -123,8 +128,8 @@ def WriteMacros(file, functions): ...@@ -123,8 +128,8 @@ def WriteMacros(file, functions):
def GenerateHeaderFile(file, unassociated_functions, instance_functions, def GenerateHeaderFile(file, unassociated_functions, instance_functions,
physical_device_functions, device_functions, physical_device_functions, device_functions,
queue_functions, command_buffer_functions, device_functions_android, queue_functions,
swapchain_functions): command_buffer_functions, swapchain_functions):
"""Generates gpu/vulkan/vulkan_function_pointers.h""" """Generates gpu/vulkan/vulkan_function_pointers.h"""
file.write(LICENSE_AND_HEADER + file.write(LICENSE_AND_HEADER +
...@@ -136,6 +141,7 @@ def GenerateHeaderFile(file, unassociated_functions, instance_functions, ...@@ -136,6 +141,7 @@ def GenerateHeaderFile(file, unassociated_functions, instance_functions,
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "base/native_library.h" #include "base/native_library.h"
#include "build/build_config.h"
#include "gpu/vulkan/vulkan_export.h" #include "gpu/vulkan/vulkan_export.h"
namespace gpu { namespace gpu {
...@@ -196,6 +202,18 @@ struct VulkanFunctionPointers { ...@@ -196,6 +202,18 @@ struct VulkanFunctionPointers {
file.write("""\ file.write("""\
// Android only device functions.
#if defined(OS_ANDROID)
""")
WriteFunctionDeclarations(file, device_functions_android)
file.write("""\
#endif
""")
file.write("""\
// Queue functions // Queue functions
""") """)
...@@ -255,6 +273,17 @@ struct VulkanFunctionPointers { ...@@ -255,6 +273,17 @@ struct VulkanFunctionPointers {
file.write("""\ file.write("""\
#if defined(OS_ANDROID)
""")
WriteMacros(file, device_functions_android)
file.write("""\
#endif
""")
file.write("""\
// Queue functions // Queue functions
""") """)
...@@ -305,8 +334,8 @@ def WriteDeviceFunctionPointerInitialization(file, functions): ...@@ -305,8 +334,8 @@ def WriteDeviceFunctionPointerInitialization(file, functions):
def GenerateSourceFile(file, unassociated_functions, instance_functions, def GenerateSourceFile(file, unassociated_functions, instance_functions,
physical_device_functions, device_functions, physical_device_functions, device_functions,
queue_functions, command_buffer_functions, device_functions_android, queue_functions,
swapchain_functions): command_buffer_functions, swapchain_functions):
"""Generates gpu/vulkan/vulkan_function_pointers.cc""" """Generates gpu/vulkan/vulkan_function_pointers.cc"""
file.write(LICENSE_AND_HEADER + file.write(LICENSE_AND_HEADER +
...@@ -374,6 +403,18 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(VkDevice vk_device) { ...@@ -374,6 +403,18 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(VkDevice vk_device) {
file.write("""\ file.write("""\
#if defined(OS_ANDROID)
""")
WriteDeviceFunctionPointerInitialization(file, device_functions_android)
file.write("""\
#endif
""")
file.write("""\
// Queue functions // Queue functions
""") """)
WriteDeviceFunctionPointerInitialization(file, queue_functions) WriteDeviceFunctionPointerInitialization(file, queue_functions)
...@@ -425,6 +466,7 @@ def main(argv): ...@@ -425,6 +466,7 @@ def main(argv):
GenerateHeaderFile(header_file, VULKAN_UNASSOCIATED_FUNCTIONS, GenerateHeaderFile(header_file, VULKAN_UNASSOCIATED_FUNCTIONS,
VULKAN_INSTANCE_FUNCTIONS, VULKAN_INSTANCE_FUNCTIONS,
VULKAN_PHYSICAL_DEVICE_FUNCTIONS, VULKAN_DEVICE_FUNCTIONS, VULKAN_PHYSICAL_DEVICE_FUNCTIONS, VULKAN_DEVICE_FUNCTIONS,
VULKAN_DEVICE_FUNCTIONS_ANDROID,
VULKAN_QUEUE_FUNCTIONS, VULKAN_COMMAND_BUFFER_FUNCTIONS, VULKAN_QUEUE_FUNCTIONS, VULKAN_COMMAND_BUFFER_FUNCTIONS,
VULKAN_SWAPCHAIN_FUNCTIONS) VULKAN_SWAPCHAIN_FUNCTIONS)
header_file.close() header_file.close()
...@@ -435,6 +477,7 @@ def main(argv): ...@@ -435,6 +477,7 @@ def main(argv):
GenerateSourceFile(source_file, VULKAN_UNASSOCIATED_FUNCTIONS, GenerateSourceFile(source_file, VULKAN_UNASSOCIATED_FUNCTIONS,
VULKAN_INSTANCE_FUNCTIONS, VULKAN_INSTANCE_FUNCTIONS,
VULKAN_PHYSICAL_DEVICE_FUNCTIONS, VULKAN_DEVICE_FUNCTIONS, VULKAN_PHYSICAL_DEVICE_FUNCTIONS, VULKAN_DEVICE_FUNCTIONS,
VULKAN_DEVICE_FUNCTIONS_ANDROID,
VULKAN_QUEUE_FUNCTIONS, VULKAN_COMMAND_BUFFER_FUNCTIONS, VULKAN_QUEUE_FUNCTIONS, VULKAN_COMMAND_BUFFER_FUNCTIONS,
VULKAN_SWAPCHAIN_FUNCTIONS) VULKAN_SWAPCHAIN_FUNCTIONS)
source_file.close() source_file.close()
......
...@@ -263,6 +263,20 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(VkDevice vk_device) { ...@@ -263,6 +263,20 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers(VkDevice vk_device) {
if (!vkWaitForFencesFn) if (!vkWaitForFencesFn)
return false; return false;
#if defined(OS_ANDROID)
vkImportSemaphoreFdKHRFn = reinterpret_cast<PFN_vkImportSemaphoreFdKHR>(
vkGetDeviceProcAddrFn(vk_device, "vkImportSemaphoreFdKHR"));
if (!vkImportSemaphoreFdKHRFn)
return false;
vkGetSemaphoreFdKHRFn = reinterpret_cast<PFN_vkGetSemaphoreFdKHR>(
vkGetDeviceProcAddrFn(vk_device, "vkGetSemaphoreFdKHR"));
if (!vkGetSemaphoreFdKHRFn)
return false;
#endif
// Queue functions // Queue functions
vkQueueSubmitFn = reinterpret_cast<PFN_vkQueueSubmit>( vkQueueSubmitFn = reinterpret_cast<PFN_vkQueueSubmit>(
vkGetDeviceProcAddrFn(vk_device, "vkQueueSubmit")); vkGetDeviceProcAddrFn(vk_device, "vkQueueSubmit"));
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "base/native_library.h" #include "base/native_library.h"
#include "build/build_config.h"
#include "gpu/vulkan/vulkan_export.h" #include "gpu/vulkan/vulkan_export.h"
namespace gpu { namespace gpu {
...@@ -99,6 +100,12 @@ struct VulkanFunctionPointers { ...@@ -99,6 +100,12 @@ struct VulkanFunctionPointers {
PFN_vkUpdateDescriptorSets vkUpdateDescriptorSetsFn = nullptr; PFN_vkUpdateDescriptorSets vkUpdateDescriptorSetsFn = nullptr;
PFN_vkWaitForFences vkWaitForFencesFn = nullptr; PFN_vkWaitForFences vkWaitForFencesFn = nullptr;
// Android only device functions.
#if defined(OS_ANDROID)
PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHRFn = nullptr;
PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHRFn = nullptr;
#endif
// Queue functions // Queue functions
PFN_vkQueueSubmit vkQueueSubmitFn = nullptr; PFN_vkQueueSubmit vkQueueSubmitFn = nullptr;
PFN_vkQueueWaitIdle vkQueueWaitIdleFn = nullptr; PFN_vkQueueWaitIdle vkQueueWaitIdleFn = nullptr;
...@@ -207,6 +214,13 @@ struct VulkanFunctionPointers { ...@@ -207,6 +214,13 @@ struct VulkanFunctionPointers {
gpu::GetVulkanFunctionPointers()->vkUpdateDescriptorSetsFn gpu::GetVulkanFunctionPointers()->vkUpdateDescriptorSetsFn
#define vkWaitForFences gpu::GetVulkanFunctionPointers()->vkWaitForFencesFn #define vkWaitForFences gpu::GetVulkanFunctionPointers()->vkWaitForFencesFn
#if defined(OS_ANDROID)
#define vkImportSemaphoreFdKHR \
gpu::GetVulkanFunctionPointers()->vkImportSemaphoreFdKHRFn
#define vkGetSemaphoreFdKHR \
gpu::GetVulkanFunctionPointers()->vkGetSemaphoreFdKHRFn
#endif
// Queue functions // Queue functions
#define vkQueueSubmit gpu::GetVulkanFunctionPointers()->vkQueueSubmitFn #define vkQueueSubmit gpu::GetVulkanFunctionPointers()->vkQueueSubmitFn
#define vkQueueWaitIdle gpu::GetVulkanFunctionPointers()->vkQueueWaitIdleFn #define vkQueueWaitIdle gpu::GetVulkanFunctionPointers()->vkQueueWaitIdleFn
......
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