diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-04-09 00:16:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-09 00:16:26 +0200 |
commit | 23d786d6fbcd374f464155c5f17f1951a664ece9 (patch) | |
tree | 689d5fdef20ddf5a9bb82e2fe9347fa2d473b4af /drivers | |
parent | b3310a00743d65d8baa2b5730ecfaed8bf8842a6 (diff) | |
parent | e167af37373dd14e9d1fe888bcc482d0bd071951 (diff) |
Merge pull request #36919 from nekomatata/android-vulkan-rendering
Vulkan rendering support on Android
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/vulkan/SCsub | 12 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.cpp | 12 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.h | 2 | ||||
-rw-r--r-- | drivers/vulkan/vulkan_context.h | 4 |
4 files changed, 24 insertions, 6 deletions
diff --git a/drivers/vulkan/SCsub b/drivers/vulkan/SCsub index 7ffdac27d5..35c2d61530 100644 --- a/drivers/vulkan/SCsub +++ b/drivers/vulkan/SCsub @@ -4,7 +4,17 @@ Import("env") env.add_source_files(env.drivers_sources, "*.cpp") -if env["builtin_vulkan"]: +if env["platform"] == "android": + # Use NDK Vulkan headers + thirdparty_dir = env["ANDROID_NDK_ROOT"] + "/sources/third_party/vulkan/src" + thirdparty_includes = [ + thirdparty_dir, + thirdparty_dir + "/include", + thirdparty_dir + "/layers", + thirdparty_dir + "/layers/generated", + ] + env.Prepend(CPPPATH=thirdparty_includes) +elif env["builtin_vulkan"]: # Use bundled Vulkan headers thirdparty_dir = "#thirdparty/vulkan" env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include", thirdparty_dir + "/loader"]) diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 01da97cfd5..09f10ef8b1 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1565,15 +1565,20 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T image_create_info.pNext = nullptr; image_create_info.flags = 0; - VkImageFormatListCreateInfoKHR format_list_create_info; - Vector<VkFormat> allowed_formats; - +#ifndef _MSC_VER +#warning TODO check for support via RenderingDevice to enable on mobile when possible +#endif + // vkCreateImage fails with format list on Android (VK_ERROR_OUT_OF_HOST_MEMORY) +#ifndef ANDROID_ENABLED if (p_format.shareable_formats.size()) { image_create_info.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; + + Vector<VkFormat> allowed_formats; for (int i = 0; i < p_format.shareable_formats.size(); i++) { allowed_formats.push_back(vulkan_formats[p_format.shareable_formats[i]]); } + VkImageFormatListCreateInfoKHR format_list_create_info; format_list_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR; format_list_create_info.pNext = nullptr; format_list_create_info.viewFormatCount = allowed_formats.size(); @@ -1585,6 +1590,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T ERR_FAIL_COND_V_MSG(p_view.format_override != DATA_FORMAT_MAX && p_format.shareable_formats.find(p_view.format_override) == -1, RID(), "If supplied a list of shareable formats, the current view format override must be present in the list"); } +#endif if (p_format.type == TEXTURE_TYPE_CUBE || p_format.type == TEXTURE_TYPE_CUBE_ARRAY) { image_create_info.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; } diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index a46b80e2f4..88a12c7e44 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -37,8 +37,10 @@ #include "servers/rendering/rendering_device.h" #ifdef DEBUG_ENABLED +#ifndef _DEBUG #define _DEBUG #endif +#endif #include "vk_mem_alloc.h" #include <vulkan/vulkan.h> //todo: diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index 2f10fbfdef..e587104e3c 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -45,8 +45,6 @@ class VulkanContext { FRAME_LAG = 2 }; - bool use_validation_layers; - VkInstance inst; VkSurfaceKHR surface; VkPhysicalDevice gpu; @@ -181,6 +179,8 @@ protected: bool buffers_prepared; + bool use_validation_layers; + public: VkDevice get_device(); VkPhysicalDevice get_physical_device(); |