summaryrefslogtreecommitdiff
path: root/platform/android/vulkan
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2020-03-05 19:00:28 +0100
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2020-04-03 11:18:59 +0200
commitaf424b1c7ca5e09156d3e5b9bd914848ee0fed86 (patch)
tree456bccbced37fa99bad77b36fb3352cdb416d94e /platform/android/vulkan
parentd9a560d7832af7f1ff845ed2b3a81b65741f9abe (diff)
Vulkan rendering for Android
Diffstat (limited to 'platform/android/vulkan')
-rw-r--r--platform/android/vulkan/vulkan_context_android.cpp (renamed from platform/android/vulkan/vk_renderer_jni.cpp)46
-rw-r--r--platform/android/vulkan/vulkan_context_android.h (renamed from platform/android/vulkan/vk_renderer_jni.h)31
2 files changed, 45 insertions, 32 deletions
diff --git a/platform/android/vulkan/vk_renderer_jni.cpp b/platform/android/vulkan/vulkan_context_android.cpp
index 3026e7daad..4c255340da 100644
--- a/platform/android/vulkan/vk_renderer_jni.cpp
+++ b/platform/android/vulkan/vulkan_context_android.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* vk_renderer_jni.cpp */
+/* vulkan_context_android.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,31 +28,41 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "vk_renderer_jni.h"
+#include "vulkan_context_android.h"
+#include <vulkan/vulkan_android.h>
-extern "C" {
+#define VMA_IMPLEMENTATION
+#ifdef DEBUG_ENABLED
+#ifndef _MSC_VER
+#define _DEBUG
+#endif
+#endif
+#include <vk_mem_alloc.h>
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkSurfaceCreated(JNIEnv *env, jobject obj, jobject j_surface) {
- // TODO: complete
+const char *VulkanContextAndroid::_get_platform_surface_extension() const {
+ return VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkSurfaceChanged(JNIEnv *env, jobject object, jobject j_surface, jint width, jint height) {
- // TODO: complete
-}
+int VulkanContextAndroid::window_create(ANativeWindow *p_window, int p_width, int p_height) {
+ VkAndroidSurfaceCreateInfoKHR createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.window = p_window;
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkResume(JNIEnv *env, jobject obj) {
- // TODO: complete
-}
+ VkSurfaceKHR surface;
+ VkResult err = vkCreateAndroidSurfaceKHR(_get_instance(), &createInfo, NULL, &surface);
+ if (err != VK_SUCCESS) {
+ ERR_FAIL_V_MSG(-1, "vkCreateAndroidSurfaceKHR failed with error " + itos(err));
+ }
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkDrawFrame(JNIEnv *env, jobject obj) {
- // TODO: complete
+ return _window_create(surface, p_width, p_height);
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkPause(JNIEnv *env, jobject obj) {
- // TODO: complete
+VulkanContextAndroid::VulkanContextAndroid() {
+ // TODO: fix validation layers
+ use_validation_layers = false;
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkDestroy(JNIEnv *env, jobject obj) {
- // TODO: complete
-}
+VulkanContextAndroid::~VulkanContextAndroid() {
}
diff --git a/platform/android/vulkan/vk_renderer_jni.h b/platform/android/vulkan/vulkan_context_android.h
index 017766fea2..7e698ada4f 100644
--- a/platform/android/vulkan/vk_renderer_jni.h
+++ b/platform/android/vulkan/vulkan_context_android.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* vk_renderer_jni.h */
+/* vulkan_context_android.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,19 +28,22 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VK_RENDERER_JNI_H
-#define VK_RENDERER_JNI_H
+#ifndef VULKAN_CONTEXT_ANDROID_H
+#define VULKAN_CONTEXT_ANDROID_H
-#include <android/log.h>
-#include <jni.h>
+#include "drivers/vulkan/vulkan_context.h"
-extern "C" {
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkSurfaceCreated(JNIEnv *env, jobject obj, jobject j_surface);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkSurfaceChanged(JNIEnv *env, jobject object, jobject j_surface, jint width, jint height);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkResume(JNIEnv *env, jobject obj);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkDrawFrame(JNIEnv *env, jobject obj);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkPause(JNIEnv *env, jobject obj);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_vulkan_VkRenderer_nativeOnVkDestroy(JNIEnv *env, jobject obj);
-}
+struct ANativeWindow;
-#endif // VK_RENDERER_JNI_H
+class VulkanContextAndroid : public VulkanContext {
+
+ virtual const char *_get_platform_surface_extension() const;
+
+public:
+ int window_create(ANativeWindow *p_window, int p_width, int p_height);
+
+ VulkanContextAndroid();
+ ~VulkanContextAndroid();
+};
+
+#endif // VULKAN_CONTEXT_ANDROID_H