mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-22 18:47:11 -04:00
Add support for mods that use Vulkan for rendering
TODO: remove dependence of libc++_shared.so
This commit is contained in:
@@ -105,4 +105,5 @@ Any code change should be submitted as a pull request. The description should ex
|
||||
- [xHook](https://github.com/iqiyi/xHook) (Used for exit code trapping): [MIT and BSD-style licenses](https://github.com/iqiyi/xHook/blob/master/LICENSE).
|
||||
- [libepoxy](https://github.com/anholt/libepoxy): [MIT License](https://github.com/anholt/libepoxy/blob/master/COPYING).
|
||||
- [virglrenderer](https://github.com/PojavLauncherTeam/virglrenderer): [MIT License](https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/COPYING).
|
||||
- [shaderc](https://github.com/google/shaderc) (used by mods that use Vulkan for rendering): [Apache 2.0 License](https://github.com/google/shaderc/blob/main/LICENSE).
|
||||
- Thanks to [MCHeads](https://mc-heads.net) for providing Minecraft avatars.
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
1654610266310
|
||||
1654854646022
|
||||
@@ -21,6 +21,12 @@
|
||||
#include <android/rect.h>
|
||||
#include <string.h>
|
||||
#include "utils.h"
|
||||
|
||||
#define GLFW_CLIENT_API 0x22001
|
||||
/* Consider GLFW_NO_API as Vulkan API */
|
||||
#define GLFW_NO_API 0
|
||||
#define GLFW_OPENGL_API 0x30001
|
||||
|
||||
// region OSMESA internals
|
||||
|
||||
struct pipe_screen;
|
||||
@@ -628,6 +634,7 @@ EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
|
||||
int (*vtest_main_p) (int argc, char** argv);
|
||||
void (*vtest_swap_buffers_p) (void);
|
||||
|
||||
#define RENDERER_VULKAN 0
|
||||
#define RENDERER_GL4ES 1
|
||||
#define RENDERER_VK_ZINK 2
|
||||
#define RENDERER_VIRGL 3
|
||||
@@ -801,6 +808,10 @@ int pojavInit() {
|
||||
savedHeight = ANativeWindow_getHeight(potatoBridge.androidWindow);
|
||||
ANativeWindow_setBuffersGeometry(potatoBridge.androidWindow,savedWidth,savedHeight,AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM);
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
jboolean pojavInit_OpenGL() {
|
||||
// NOTE: Override for now.
|
||||
const char *renderer = getenv("POJAV_RENDERER");
|
||||
if (strncmp("opengles3_virgl", renderer, 15) == 0) {
|
||||
@@ -929,6 +940,24 @@ int pojavInit() {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pojavSetWindowHint(int hint, int value) {
|
||||
if (hint != GLFW_CLIENT_API) return;
|
||||
switch (value) {
|
||||
case GLFW_NO_API:
|
||||
config_renderer = RENDERER_VULKAN;
|
||||
/* Nothing to do: initialization is handled in Java-side */
|
||||
// pojavInit_Vulkan();
|
||||
break;
|
||||
case GLFW_OPENGL_API:
|
||||
pojavInit_OpenGL();
|
||||
break;
|
||||
default:
|
||||
printf("GLFW: Unimplemented API 0x%x\n", value);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
ANativeWindow_Buffer buf;
|
||||
int32_t stride;
|
||||
bool stopSwapBuffers;
|
||||
@@ -945,7 +974,7 @@ void pojavSwapBuffers() {
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
|
||||
case RENDERER_VIRGL: {
|
||||
glFinish_p();
|
||||
vtest_swap_buffers_p();
|
||||
@@ -954,7 +983,7 @@ void pojavSwapBuffers() {
|
||||
case RENDERER_VK_ZINK: {
|
||||
OSMesaContext ctx = OSMesaGetCurrentContext_p();
|
||||
if(ctx == NULL) {
|
||||
printf("Zink: attempted to swap buffers without context!");
|
||||
printf("Zink: attempted to swap buffers without context!\n");
|
||||
break;
|
||||
}
|
||||
OSMesaMakeCurrent_p(ctx,buf.bits,GL_UNSIGNED_BYTE,savedWidth,savedHeight);
|
||||
@@ -1077,6 +1106,10 @@ Java_org_lwjgl_glfw_GLFW_nativeEglDetachOnCurrentThread(JNIEnv *env, jclass claz
|
||||
*/
|
||||
|
||||
void* pojavCreateContext(void* contextSrc) {
|
||||
if (config_renderer == RENDERER_VULKAN) {
|
||||
return (void *)potatoBridge.androidWindow;
|
||||
}
|
||||
|
||||
if (config_renderer == RENDERER_GL4ES) {
|
||||
const EGLint ctx_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, atoi(getenv("LIBGL_ES")),
|
||||
|
||||
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/libc++_shared.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/libc++_shared.so
Normal file
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/liblwjgl_vma.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/liblwjgl_vma.so
Normal file
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/libshaderc.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/libshaderc.so
Normal file
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/libc++_shared.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/libc++_shared.so
Normal file
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/liblwjgl_vma.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/liblwjgl_vma.so
Normal file
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/libshaderc.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/libshaderc.so
Normal file
Binary file not shown.
BIN
jre_lwjgl3glfw/libs/lwjgl-shaderc.jar
Normal file
BIN
jre_lwjgl3glfw/libs/lwjgl-shaderc.jar
Normal file
Binary file not shown.
BIN
jre_lwjgl3glfw/libs/lwjgl-vma.jar
Normal file
BIN
jre_lwjgl3glfw/libs/lwjgl-vma.jar
Normal file
Binary file not shown.
BIN
jre_lwjgl3glfw/libs/lwjgl-vulkan.jar
Normal file
BIN
jre_lwjgl3glfw/libs/lwjgl-vulkan.jar
Normal file
Binary file not shown.
@@ -611,6 +611,7 @@ public class GLFW
|
||||
//DetachOnCurrentThread = apiGetFunctionAddress(GLFW, "pojavDetachOnCurrentThread"),
|
||||
MakeContextCurrent = apiGetFunctionAddress(GLFW, "pojavMakeCurrent"),
|
||||
Terminate = apiGetFunctionAddress(GLFW, "pojavTerminate"),
|
||||
SetWindowHint = apiGetFunctionAddress(GLFW, "pojavSetWindowHint"),
|
||||
SwapBuffers = apiGetFunctionAddress(GLFW, "pojavSwapBuffers"),
|
||||
SwapInterval = apiGetFunctionAddress(GLFW, "pojavSwapInterval");
|
||||
}
|
||||
@@ -1039,7 +1040,12 @@ public class GLFW
|
||||
public static void glfwShowWindow(long window) {
|
||||
nglfwSetShowingWindow(window);
|
||||
}
|
||||
public static void glfwWindowHint(int hint, int value) {}
|
||||
|
||||
public static void glfwWindowHint(int hint, int value) {
|
||||
long __functionAddress = Functions.SetWindowHint;
|
||||
invokeV(hint, value, __functionAddress);
|
||||
}
|
||||
|
||||
public static void glfwWindowHintString(int hint, @NativeType("const char *") ByteBuffer value) {}
|
||||
public static void glfwWindowHintString(int hint, @NativeType("const char *") CharSequence value) {}
|
||||
|
||||
|
||||
279
jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWVulkan.java
Normal file
279
jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWVulkan.java
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright LWJGL. All rights reserved.
|
||||
* License terms: https://www.lwjgl.org/license
|
||||
* MACHINE GENERATED FILE, DO NOT EDIT
|
||||
*/
|
||||
package org.lwjgl.glfw;
|
||||
|
||||
import javax.annotation.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import org.lwjgl.*;
|
||||
|
||||
import org.lwjgl.system.*;
|
||||
|
||||
import static org.lwjgl.system.APIUtil.*;
|
||||
import static org.lwjgl.system.Checks.*;
|
||||
import static org.lwjgl.system.JNI.*;
|
||||
import static org.lwjgl.system.MemoryStack.*;
|
||||
import static org.lwjgl.system.MemoryUtil.*;
|
||||
import static org.lwjgl.vulkan.EXTMetalSurface.*;
|
||||
import static org.lwjgl.vulkan.KHRAndroidSurface.*;
|
||||
|
||||
import org.lwjgl.vulkan.*;
|
||||
|
||||
/** Native bindings to the GLFW library's Vulkan functions. */
|
||||
public class GLFWVulkan {
|
||||
|
||||
protected GLFWVulkan() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
static {
|
||||
//invokeV(Functions.Init);
|
||||
|
||||
|
||||
/*
|
||||
if (Platform.get() == Platform.MACOSX) {
|
||||
// Force GLFW to initialize Vulkan using the same library used by LWJGL.
|
||||
FunctionProvider fp = VK.getFunctionProvider();
|
||||
if (fp instanceof SharedLibrary) {
|
||||
String path = ((SharedLibrary)fp).getPath();
|
||||
if (path != null) {
|
||||
try (MemoryStack stack = stackPush()) {
|
||||
long _glfw_vulkan_library = apiGetFunctionAddress(GLFW.getLibrary(), "_glfw_vulkan_library");
|
||||
|
||||
memPutAddress(_glfw_vulkan_library, memAddress(stack.UTF8(path)));
|
||||
glfwVulkanSupported();
|
||||
memPutAddress(_glfw_vulkan_library, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// --- [ glfwVulkanSupported ] ---
|
||||
|
||||
/**
|
||||
* Returns whether the Vulkan loader has been found. This check is performed by {@link GLFW#glfwInit Init}.
|
||||
*
|
||||
* <p>The availability of a Vulkan loader does not by itself guarantee that window surface creation or even device creation is possible. Call
|
||||
* {@link #glfwGetRequiredInstanceExtensions GetRequiredInstanceExtensions} to check whether the extensions necessary for Vulkan surface creation are available and
|
||||
* {@link #glfwGetPhysicalDevicePresentationSupport GetPhysicalDevicePresentationSupport} to check whether a queue family of a physical device supports image presentation.</p>
|
||||
*
|
||||
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}.</p>
|
||||
*
|
||||
* <p>This function may be called from any thread.</p>
|
||||
*
|
||||
* @return {@link GLFW#GLFW_TRUE TRUE} if Vulkan is available, or {@link GLFW#GLFW_FALSE FALSE} otherwise
|
||||
*
|
||||
* @since version 3.2
|
||||
*/
|
||||
@NativeType("int")
|
||||
public static boolean glfwVulkanSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- [ glfwGetRequiredInstanceExtensions ] ---
|
||||
|
||||
/**
|
||||
* Returns an array of names of Vulkan instance extensions required by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the list will
|
||||
* always contain {@code VK_KHR_surface}, so if you don't require any additional extensions you can pass this list directly to the {@link VkInstanceCreateInfo}
|
||||
* struct.
|
||||
*
|
||||
* <p>If Vulkan is not available on the machine, this function returns {@code NULL} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether
|
||||
* Vulkan is available.</p>
|
||||
*
|
||||
* <p>If Vulkan is available but no set of extensions allowing window surface creation was found, this function returns {@code NULL}. You may still use Vulkan for
|
||||
* off-screen rendering and compute work.</p>
|
||||
*
|
||||
* <p>Additional extensions may be required by future versions of GLFW. You should check if any extensions you wish to enable are already in the returned
|
||||
* array, as it is an error to specify an extension more than once in the {@code VkInstanceCreateInfo} struct.</p>
|
||||
*
|
||||
* <p>The returned array is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the library is terminated.</p>
|
||||
*
|
||||
* <p>This function may be called from any thread.</p>
|
||||
*
|
||||
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED} and {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}.</p>
|
||||
*
|
||||
* @return an array of ASCII encoded extension names, or {@code NULL} if an error occurred
|
||||
*
|
||||
* @since version 3.2
|
||||
*/
|
||||
@Nullable
|
||||
@NativeType("char const **")
|
||||
public static PointerBuffer glfwGetRequiredInstanceExtensions() {
|
||||
MemoryStack stack = MemoryStack.stackPush();
|
||||
String platformSurface;
|
||||
if (Platform.get() == Platform.MACOSX) {
|
||||
platformSurface = "VK_EXT_metal_surface";
|
||||
} else {
|
||||
platformSurface = "VK_KHR_android_surface";
|
||||
}
|
||||
return stack.pointers(stack.UTF8(KHRSurface.VK_KHR_SURFACE_EXTENSION_NAME), stack.UTF8(platformSurface));
|
||||
}
|
||||
|
||||
// --- [ glfwGetInstanceProcAddress ] ---
|
||||
|
||||
/**
|
||||
* Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to {@code NULL} it can return any
|
||||
* function exported from the Vulkan loader, including at least the following functions:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link VK10#vkEnumerateInstanceExtensionProperties}</li>
|
||||
* <li>{@link VK10#vkEnumerateInstanceLayerProperties}</li>
|
||||
* <li>{@link VK10#vkCreateInstance}</li>
|
||||
* <li>{@link VK10#vkGetInstanceProcAddr}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>If Vulkan is not available on the machine, this function returns {@code NULL} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether
|
||||
* Vulkan is available.</p>
|
||||
*
|
||||
* <p>This function is equivalent to calling {@link VK10#vkGetInstanceProcAddr} with a platform-specific query of the Vulkan loader as a fallback.</p>
|
||||
*
|
||||
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED} and {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}.</p>
|
||||
*
|
||||
* <p>The returned function pointer is valid until the library is terminated.</p>
|
||||
*
|
||||
* <p>This function may be called from any thread.</p>
|
||||
*
|
||||
* @param instance the Vulkan instance to query, or {@code NULL} to retrieve functions related to instance creation
|
||||
* @param procname the ASCII encoded name of the function
|
||||
*
|
||||
* @return the address of the function, or {@code NULL} if an error occurred
|
||||
*
|
||||
* @since version 3.2
|
||||
*/
|
||||
@NativeType("GLFWvkproc")
|
||||
public static long glfwGetInstanceProcAddress(@Nullable VkInstance instance, @NativeType("char const *") ByteBuffer procname) {
|
||||
return VK10.vkGetInstanceProcAddr(instance, procname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to {@code NULL} it can return any
|
||||
* function exported from the Vulkan loader, including at least the following functions:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link VK10#vkEnumerateInstanceExtensionProperties}</li>
|
||||
* <li>{@link VK10#vkEnumerateInstanceLayerProperties}</li>
|
||||
* <li>{@link VK10#vkCreateInstance}</li>
|
||||
* <li>{@link VK10#vkGetInstanceProcAddr}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>If Vulkan is not available on the machine, this function returns {@code NULL} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether
|
||||
* Vulkan is available.</p>
|
||||
*
|
||||
* <p>This function is equivalent to calling {@link VK10#vkGetInstanceProcAddr} with a platform-specific query of the Vulkan loader as a fallback.</p>
|
||||
*
|
||||
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED} and {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}.</p>
|
||||
*
|
||||
* <p>The returned function pointer is valid until the library is terminated.</p>
|
||||
*
|
||||
* <p>This function may be called from any thread.</p>
|
||||
*
|
||||
* @param instance the Vulkan instance to query, or {@code NULL} to retrieve functions related to instance creation
|
||||
* @param procname the ASCII encoded name of the function
|
||||
*
|
||||
* @return the address of the function, or {@code NULL} if an error occurred
|
||||
*
|
||||
* @since version 3.2
|
||||
*/
|
||||
@NativeType("GLFWvkproc")
|
||||
public static long glfwGetInstanceProcAddress(@Nullable VkInstance instance, @NativeType("char const *") CharSequence procname) {
|
||||
return VK10.vkGetInstanceProcAddr(instance, procname);
|
||||
}
|
||||
|
||||
// --- [ glfwGetPhysicalDevicePresentationSupport ] ---
|
||||
|
||||
/**
|
||||
* Returns whether the specified queue family of the specified physical device supports presentation to the platform GLFW was built for.
|
||||
*
|
||||
* <p>If Vulkan or the required window surface creation instance extensions are not available on the machine, or if the specified instance was not created
|
||||
* with the required extensions, this function returns {@link GLFW#GLFW_FALSE FALSE} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwVulkanSupported VulkanSupported} to check whether Vulkan is
|
||||
* available and {@link #glfwGetRequiredInstanceExtensions GetRequiredInstanceExtensions} to check what instance extensions are required.</p>
|
||||
*
|
||||
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}, {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} and {@link GLFW#GLFW_PLATFORM_ERROR PLATFORM_ERROR}.</p>
|
||||
*
|
||||
* <p>This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.</p>
|
||||
*
|
||||
* @param instance the instance that the physical device belongs to
|
||||
* @param device the physical device that the queue family belongs to
|
||||
* @param queuefamily the index of the queue family to query
|
||||
*
|
||||
* @return {@link GLFW#GLFW_TRUE TRUE} if the queue family supports presentation, or {@link GLFW#GLFW_FALSE FALSE} otherwise
|
||||
*
|
||||
* @since version 3.2
|
||||
*/
|
||||
@NativeType("int")
|
||||
public static boolean glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, @NativeType("uint32_t") int queuefamily) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- [ glfwCreateWindowSurface ] ---
|
||||
|
||||
/**
|
||||
* Creates a Vulkan surface for the specified window.
|
||||
*
|
||||
* <p>If the Vulkan loader was not found at initialization, this function returns {@link VK10#VK_ERROR_INITIALIZATION_FAILED} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error.
|
||||
* Call {@link #glfwVulkanSupported VulkanSupported} to check whether the Vulkan loader was found.</p>
|
||||
*
|
||||
* <p>If the required window surface creation instance extensions are not available or if the specified instance was not created with these extensions
|
||||
* enabled, this function returns {@link VK10#VK_ERROR_EXTENSION_NOT_PRESENT} and generates a {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE} error. Call {@link #glfwGetRequiredInstanceExtensions GetRequiredInstanceExtensions} to
|
||||
* check what instance extensions are required.</p>
|
||||
*
|
||||
* <p>The window surface cannot be shared with another API so the window must have been created with the client api hint set to {@link GLFW#GLFW_NO_API NO_API} otherwise it
|
||||
* generates a {@link GLFW#GLFW_INVALID_VALUE INVALID_VALUE} error and returns {@link KHRSurface#VK_ERROR_NATIVE_WINDOW_IN_USE_KHR}.</p>
|
||||
*
|
||||
* <p>The window surface must be destroyed before the specified Vulkan instance. It is the responsibility of the caller to destroy the window surface. GLFW
|
||||
* does not destroy it for you. Call {@link KHRSurface#vkDestroySurfaceKHR} to destroy the surface.</p>
|
||||
*
|
||||
* <p>Possible errors include {@link GLFW#GLFW_NOT_INITIALIZED NOT_INITIALIZED}, {@link GLFW#GLFW_API_UNAVAILABLE API_UNAVAILABLE}, {@link GLFW#GLFW_PLATFORM_ERROR PLATFORM_ERROR} and {@link GLFW#GLFW_INVALID_VALUE INVALID_VALUE}.</p>
|
||||
*
|
||||
* <p>If an error occurs before the creation call is made, GLFW returns the Vulkan error code most appropriate for the error. Appropriate use of
|
||||
* {@link #glfwVulkanSupported VulkanSupported} and {@link #glfwGetRequiredInstanceExtensions GetRequiredInstanceExtensions} should eliminate almost all occurrences of these errors.</p>
|
||||
*
|
||||
* <p>This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.</p>
|
||||
*
|
||||
* @param instance the Vulkan instance to create the surface in
|
||||
* @param window the window to create the surface for
|
||||
* @param allocator the allocator to use, or {@code NULL} to use the default allocator.
|
||||
* @param surface where to store the handle of the surface. This is set to {@link VK10#VK_NULL_HANDLE} if an error occurred.
|
||||
*
|
||||
* @return {@link VK10#VK_SUCCESS} if successful, or a Vulkan error code if an error occurred
|
||||
*
|
||||
* @since version 3.2
|
||||
*/
|
||||
@NativeType("VkResult")
|
||||
public static int glfwCreateWindowSurface(VkInstance instance, @NativeType("GLFWwindow *") long window, @Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks allocator, @NativeType("VkSurfaceKHR *") LongBuffer surface) {
|
||||
if (CHECKS) {
|
||||
check(surface, 1);
|
||||
}
|
||||
/* Since LWJGL didn't generate Android stuff, we have to lend Metal's one to call */
|
||||
if (Platform.get() == Platform.MACOSX) {
|
||||
VkMetalSurfaceCreateInfoEXT pCreateInfo = VkMetalSurfaceCreateInfoEXT
|
||||
.calloc()
|
||||
.sType(VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT)
|
||||
.pLayer(PointerBuffer.create(window, 1));
|
||||
return vkCreateMetalSurfaceEXT(instance, pCreateInfo, null, surface);
|
||||
} else {
|
||||
VkAndroidSurfaceCreateInfoKHR pCreateInfo = VkAndroidSurfaceCreateInfoKHR
|
||||
.calloc()
|
||||
.sType(VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR)
|
||||
.pWindow(PointerBuffer.create(window, 1));
|
||||
return vkCreateAndroidSurfaceKHR(instance, pCreateInfo, null, surface);
|
||||
}
|
||||
}
|
||||
|
||||
/** Array version of: {@link #glfwCreateWindowSurface CreateWindowSurface} */
|
||||
@NativeType("VkResult")
|
||||
public static int glfwCreateWindowSurface(VkInstance instance, @NativeType("GLFWwindow *") long window, @Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks allocator, @NativeType("VkSurfaceKHR *") long[] surface) {
|
||||
MemoryStack stack = stackGet();
|
||||
LongBuffer pSurface = stack.mallocLong(1);
|
||||
int result = glfwCreateWindowSurface(instance, window, allocator, pSurface);
|
||||
surface[0] = pSurface.get(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright LWJGL. All rights reserved.
|
||||
* License terms: https://www.lwjgl.org/license
|
||||
* MACHINE GENERATED FILE, DO NOT EDIT
|
||||
*/
|
||||
package org.lwjgl.vulkan;
|
||||
|
||||
import javax.annotation.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import org.lwjgl.system.*;
|
||||
|
||||
import static org.lwjgl.system.Checks.*;
|
||||
import static org.lwjgl.system.JNI.*;
|
||||
import static org.lwjgl.system.MemoryUtil.*;
|
||||
|
||||
/**
|
||||
* The {@code VK_KHR_android_surface} extension is an instance extension. It provides a mechanism to create a {@code VkSurfaceKHR} object (defined by the {@code VK_KHR_surface} extension) that refers to an {@code ANativeWindow}, Android's native surface type. The {@code ANativeWindow} represents the producer endpoint of any buffer queue, regardless of consumer endpoint. Common consumer endpoints for {@code ANativeWindows} are the system window compositor, video encoders, and application-specific compositors importing the images through a SurfaceTexture.
|
||||
* <dl>
|
||||
* <dt><b>Name String</b></dt>
|
||||
* <dd>VK_KHR_android_surface</dd>
|
||||
* <dt><b>Extension Type</b></dt>
|
||||
* <dd>Instance extension</dd>
|
||||
* <dt><b>Registered Extension Number</b></dt>
|
||||
* <dd>9</dd>
|
||||
* <dt><b>Last Modified Date</b></dt>
|
||||
* <dd>2016-01-14</dd>
|
||||
* <dt><b>Revision</b></dt>
|
||||
* <dd>6</dd>
|
||||
* <dt><b>IP Status</b></dt>
|
||||
* <dd>No known IP claims.</dd>
|
||||
* <dt><b>Dependencies</b></dt>
|
||||
* <dd><ul>
|
||||
* <li>This extension is written against version 1.0 of the Vulkan API.</li>
|
||||
* <li>Requires VK_KHR_surface.</li>
|
||||
* </ul></dd>
|
||||
* <dt><b>Contributors</b></dt>
|
||||
* <dd><ul>
|
||||
* <li>Patrick Doane, Blizzard</li>
|
||||
* <li>Jason Ekstrand, Intel</li>
|
||||
* <li>Ian Elliott, LunarG</li>
|
||||
* <li>Courtney Goeltzenleuchter, LunarG</li>
|
||||
* <li>Jesse Hall, Google</li>
|
||||
* <li>James Jones, NVIDIA</li>
|
||||
* <li>Antoine Labour, Google</li>
|
||||
* <li>Jon Leech, Khronos</li>
|
||||
* <li>David Mao, AMD</li>
|
||||
* <li>Norbert Nopper, Freescale</li>
|
||||
* <li>Alon Or-bach, Samsung</li>
|
||||
* <li>Daniel Rakos, AMD</li>
|
||||
* <li>Graham Sellers, AMD</li>
|
||||
* <li>Ray Smith, ARM</li>
|
||||
* <li>Jeff Vigil, Qualcomm</li>
|
||||
* <li>Chia-I Wu, LunarG</li>
|
||||
* </ul></dd>
|
||||
* <dt><b>Contacts</b></dt>
|
||||
* <dd><ul>
|
||||
* <li>Jesse Hall, Google</li>
|
||||
* </ul></dd>
|
||||
* </dl>
|
||||
*/
|
||||
public class KHRAndroidSurface {
|
||||
|
||||
/** The extension specification version. */
|
||||
public static final int VK_KHR_ANDROID_SURFACE_SPEC_VERSION = 6;
|
||||
|
||||
/** The extension name. */
|
||||
public static final String VK_KHR_ANDROID_SURFACE_EXTENSION_NAME = "VK_KHR_android_surface";
|
||||
|
||||
/** Extends {@code VkStructureType}. */
|
||||
public static final int VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000;
|
||||
|
||||
protected KHRAndroidSurface() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
static boolean checkCapsInstance(FunctionProvider provider, java.util.Map<String, Long> caps, java.util.Set<String> ext) {
|
||||
return ext.contains("VK_KHR_android_surface") && VK.checkExtension("VK_KHR_android_surface",
|
||||
VK.isSupported(provider, "vkCreateAndroidSurfaceKHR", caps)
|
||||
);
|
||||
}
|
||||
|
||||
// --- [ vkCreateAndroidSurfaceKHR ] ---
|
||||
|
||||
/** Unsafe version of: {@link #vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR} */
|
||||
public static int nvkCreateAndroidSurfaceKHR(VkInstance instance, long pCreateInfo, long pAllocator, long pSurface) {
|
||||
long __functionAddress = VK10.vkGetInstanceProcAddr(instance, "vkCreateAndroidSurfaceKHR");
|
||||
//instance.getCapabilities().vkCreateAndroidSurfaceKHR;
|
||||
if (CHECKS) {
|
||||
check(__functionAddress);
|
||||
VkAndroidSurfaceCreateInfoKHR.validate(pCreateInfo);
|
||||
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
|
||||
}
|
||||
return callPPPPI(instance.address(), pCreateInfo, pAllocator, pSurface, __functionAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a VkSurfaceKHR object for ANativeWindow.
|
||||
*
|
||||
* <h5>C Specification</h5>
|
||||
*
|
||||
* <p>To create a {@code VkSurfaceKHR} object for a dlink:ANativeWindow, call:</p>
|
||||
*
|
||||
* <pre><code>
|
||||
* VkResult vkCreateAndroidSurfaceKHR(
|
||||
* VkInstance instance,
|
||||
* const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
|
||||
* const VkAllocationCallbacks* pAllocator,
|
||||
* VkSurfaceKHR* pSurface);</code></pre>
|
||||
*
|
||||
* <h5>Valid Usage (Implicit)</h5>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code instance} <b>must</b> be a valid {@code VkInstance} handle</li>
|
||||
* <li>{@code pCreateInfo} <b>must</b> be a valid pointer to a valid {@link VkAndroidSurfaceCreateInfoKHR} structure</li>
|
||||
* <li>If {@code pAllocator} is not {@code NULL}, {@code pAllocator} <b>must</b> be a valid pointer to a valid {@link VkAllocationCallbacks} structure</li>
|
||||
* <li>{@code pSurface} <b>must</b> be a valid pointer to a {@code VkSurfaceKHR} handle</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h5>Return Codes</h5>
|
||||
*
|
||||
* <dl>
|
||||
* <dt>On success, this command returns</dt>
|
||||
* <dd><ul>
|
||||
* <li>{@link VK10#VK_SUCCESS SUCCESS}</li>
|
||||
* </ul></dd>
|
||||
* <dt>On failure, this command returns</dt>
|
||||
* <dd><ul>
|
||||
* <li>{@link VK10#VK_ERROR_OUT_OF_HOST_MEMORY ERROR_OUT_OF_HOST_MEMORY}</li>
|
||||
* <li>{@link VK10#VK_ERROR_OUT_OF_DEVICE_MEMORY ERROR_OUT_OF_DEVICE_MEMORY}</li>
|
||||
* <li>{@link KHRSurface#VK_ERROR_NATIVE_WINDOW_IN_USE_KHR ERROR_NATIVE_WINDOW_IN_USE_KHR}</li>
|
||||
* </ul></dd>
|
||||
* </dl>
|
||||
*
|
||||
* <h5>See Also</h5>
|
||||
*
|
||||
* <p>{@link VkAllocationCallbacks}, {@link VkAndroidSurfaceCreateInfoKHR}</p>
|
||||
*
|
||||
* @param instance the instance with which to associate the surface.
|
||||
* @param pCreateInfo a pointer to an instance of the {@link VkAndroidSurfaceCreateInfoKHR} structure containing the parameters affecting the creation of the surface object.
|
||||
* @param pAllocator the allocator used for host memory allocated for the surface object when there is no more specific allocator available (see <a target="_blank" href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#memory-allocation">Memory Allocation</a>).
|
||||
* @param pSurface points to a {@code VkSurfaceKHR} handle in which the created surface object is returned.
|
||||
*/
|
||||
@NativeType("VkResult")
|
||||
public static int vkCreateAndroidSurfaceKHR(VkInstance instance, @NativeType("VkAndroidSurfaceCreateInfoKHR const *") VkAndroidSurfaceCreateInfoKHR pCreateInfo, @Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks pAllocator, @NativeType("VkSurfaceKHR *") LongBuffer pSurface) {
|
||||
if (CHECKS) {
|
||||
check(pSurface, 1);
|
||||
}
|
||||
return nvkCreateAndroidSurfaceKHR(instance, pCreateInfo.address(), memAddressSafe(pAllocator), memAddress(pSurface));
|
||||
}
|
||||
|
||||
/** Array version of: {@link #vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR} */
|
||||
@NativeType("VkResult")
|
||||
public static int vkCreateAndroidSurfaceKHR(VkInstance instance, @NativeType("VkAndroidSurfaceCreateInfoKHR const *") VkAndroidSurfaceCreateInfoKHR pCreateInfo, @Nullable @NativeType("VkAllocationCallbacks const *") VkAllocationCallbacks pAllocator, @NativeType("VkSurfaceKHR *") long[] pSurface) {
|
||||
long __functionAddress = VK10.vkGetInstanceProcAddr(instance, "vkCreateAndroidSurfaceKHR");
|
||||
//instance.getCapabilities().vkCreateAndroidSurfaceKHR;
|
||||
if (CHECKS) {
|
||||
check(__functionAddress);
|
||||
check(pSurface, 1);
|
||||
VkAndroidSurfaceCreateInfoKHR.validate(pCreateInfo.address());
|
||||
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
|
||||
}
|
||||
return callPPPPI(instance.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pSurface, __functionAddress);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
/*
|
||||
* Copyright LWJGL. All rights reserved.
|
||||
* License terms: https://www.lwjgl.org/license
|
||||
* MACHINE GENERATED FILE, DO NOT EDIT
|
||||
*/
|
||||
package org.lwjgl.vulkan;
|
||||
|
||||
import javax.annotation.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import org.lwjgl.*;
|
||||
import org.lwjgl.system.*;
|
||||
|
||||
import static org.lwjgl.system.Checks.*;
|
||||
import static org.lwjgl.system.MemoryUtil.*;
|
||||
import static org.lwjgl.system.MemoryStack.*;
|
||||
|
||||
/**
|
||||
* Structure specifying parameters of a newly created Android surface object.
|
||||
*
|
||||
* <h5>Description</h5>
|
||||
*
|
||||
* <h5>Valid Usage (Implicit)</h5>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code sType} <b>must</b> be {@link KHRAndroidSurface#VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR}</li>
|
||||
* <li>{@code pNext} <b>must</b> be {@code NULL}</li>
|
||||
* <li>{@code flags} <b>must</b> be 0</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h5>See Also</h5>
|
||||
*
|
||||
* <p>{@link KHRAndroidSurface#vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR}</p>
|
||||
*
|
||||
* <h3>Member documentation</h3>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code sType} – the type of this structure.</li>
|
||||
* <li>{@code pNext} – {@code NULL} or a pointer to an extension-specific structure.</li>
|
||||
* <li>{@code flags} – reserved for future use.</li>
|
||||
* <li>{@code pWindow} – a reference to a {@code ANativeWindow} object that represents a renderable surface.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Layout</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* struct VkAndroidSurfaceCreateInfoKHR {
|
||||
* VkStructureType sType;
|
||||
* void const * pNext;
|
||||
* VkAndroidSurfaceCreateFlagsKHR flags;
|
||||
* ANativeWindow const * pWindow;
|
||||
* }</code></pre>
|
||||
*/
|
||||
public class VkAndroidSurfaceCreateInfoKHR extends Struct implements NativeResource {
|
||||
|
||||
/** The struct size in bytes. */
|
||||
public static final int SIZEOF;
|
||||
|
||||
/** The struct alignment in bytes. */
|
||||
public static final int ALIGNOF;
|
||||
|
||||
/** The struct member offsets. */
|
||||
public static final int
|
||||
STYPE,
|
||||
PNEXT,
|
||||
FLAGS,
|
||||
PWINDOW;
|
||||
|
||||
static {
|
||||
Layout layout = __struct(
|
||||
__member(4),
|
||||
__member(POINTER_SIZE),
|
||||
__member(4),
|
||||
__member(POINTER_SIZE)
|
||||
);
|
||||
|
||||
SIZEOF = layout.getSize();
|
||||
ALIGNOF = layout.getAlignment();
|
||||
|
||||
STYPE = layout.offsetof(0);
|
||||
PNEXT = layout.offsetof(1);
|
||||
FLAGS = layout.offsetof(2);
|
||||
PWINDOW = layout.offsetof(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code VkAndroidSurfaceCreateInfoKHR} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be
|
||||
* visible to the struct instance and vice versa.
|
||||
*
|
||||
* <p>The created instance holds a strong reference to the container object.</p>
|
||||
*/
|
||||
public VkAndroidSurfaceCreateInfoKHR(ByteBuffer container) {
|
||||
super(memAddress(container), __checkContainer(container, SIZEOF));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sizeof() { return SIZEOF; }
|
||||
|
||||
/** Returns the value of the {@code sType} field. */
|
||||
@NativeType("VkStructureType")
|
||||
public int sType() { return nsType(address()); }
|
||||
/** Returns the value of the {@code pNext} field. */
|
||||
@NativeType("void const *")
|
||||
public long pNext() { return npNext(address()); }
|
||||
/** Returns the value of the {@code flags} field. */
|
||||
@NativeType("VkAndroidSurfaceCreateFlagsKHR")
|
||||
public int flags() { return nflags(address()); }
|
||||
/**
|
||||
* Returns a {@link PointerBuffer} view of the data pointed to by the {@code pWindow} field.
|
||||
*
|
||||
* @param capacity the number of elements in the returned buffer
|
||||
*/
|
||||
@NativeType("ANativeWindow const *")
|
||||
public PointerBuffer pWindow(int capacity) { return npWindow(address(), capacity); }
|
||||
|
||||
/** Sets the specified value to the {@code sType} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR sType(@NativeType("VkStructureType") int value) { nsType(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code pNext} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR pNext(@NativeType("void const *") long value) { npNext(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code flags} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR flags(@NativeType("VkAndroidSurfaceCreateFlagsKHR") int value) { nflags(address(), value); return this; }
|
||||
/** Sets the address of the specified {@link PointerBuffer} to the {@code pWindow} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR pWindow(@NativeType("ANativeWindow const *") PointerBuffer value) { npWindow(address(), value); return this; }
|
||||
|
||||
/** Initializes this struct with the specified values. */
|
||||
public VkAndroidSurfaceCreateInfoKHR set(
|
||||
int sType,
|
||||
long pNext,
|
||||
int flags,
|
||||
PointerBuffer pWindow
|
||||
) {
|
||||
sType(sType);
|
||||
pNext(pNext);
|
||||
flags(flags);
|
||||
pWindow(pWindow);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the specified struct data to this struct.
|
||||
*
|
||||
* @param src the source struct
|
||||
*
|
||||
* @return this struct
|
||||
*/
|
||||
public VkAndroidSurfaceCreateInfoKHR set(VkAndroidSurfaceCreateInfoKHR src) {
|
||||
memCopy(src.address(), address(), SIZEOF);
|
||||
return this;
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
|
||||
public static VkAndroidSurfaceCreateInfoKHR malloc() {
|
||||
return wrap(VkAndroidSurfaceCreateInfoKHR.class, nmemAllocChecked(SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
|
||||
public static VkAndroidSurfaceCreateInfoKHR calloc() {
|
||||
return wrap(VkAndroidSurfaceCreateInfoKHR.class, nmemCallocChecked(1, SIZEOF));
|
||||
}
|
||||
|
||||
/** Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance allocated with {@link BufferUtils}. */
|
||||
public static VkAndroidSurfaceCreateInfoKHR create() {
|
||||
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
|
||||
return wrap(VkAndroidSurfaceCreateInfoKHR.class, memAddress(container), container);
|
||||
}
|
||||
|
||||
/** Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance for the specified memory address. */
|
||||
public static VkAndroidSurfaceCreateInfoKHR create(long address) {
|
||||
return wrap(VkAndroidSurfaceCreateInfoKHR.class, address);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static VkAndroidSurfaceCreateInfoKHR createSafe(long address) {
|
||||
return address == NULL ? null : wrap(VkAndroidSurfaceCreateInfoKHR.class, address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer malloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer calloc(int capacity) {
|
||||
return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance allocated with {@link BufferUtils}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer create(int capacity) {
|
||||
ByteBuffer container = __create(capacity, SIZEOF);
|
||||
return wrap(Buffer.class, memAddress(container), capacity, container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance at the specified memory.
|
||||
*
|
||||
* @param address the memory address
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer create(long address, int capacity) {
|
||||
return wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer createSafe(long address, int capacity) {
|
||||
return address == NULL ? null : wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance allocated on the thread-local {@link MemoryStack}. */
|
||||
public static VkAndroidSurfaceCreateInfoKHR mallocStack() {
|
||||
return mallocStack(stackGet());
|
||||
}
|
||||
|
||||
/** Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero. */
|
||||
public static VkAndroidSurfaceCreateInfoKHR callocStack() {
|
||||
return callocStack(stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR mallocStack(MemoryStack stack) {
|
||||
return wrap(VkAndroidSurfaceCreateInfoKHR.class, stack.nmalloc(ALIGNOF, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@code VkAndroidSurfaceCreateInfoKHR} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR callocStack(MemoryStack stack) {
|
||||
return wrap(VkAndroidSurfaceCreateInfoKHR.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance allocated on the thread-local {@link MemoryStack}.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer mallocStack(int capacity) {
|
||||
return mallocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance allocated on the thread-local {@link MemoryStack} and initializes all its bits to zero.
|
||||
*
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer callocStack(int capacity) {
|
||||
return callocStack(capacity, stackGet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance allocated on the specified {@link MemoryStack}.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer mallocStack(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link VkAndroidSurfaceCreateInfoKHR.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
|
||||
*
|
||||
* @param stack the stack from which to allocate
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static VkAndroidSurfaceCreateInfoKHR.Buffer callocStack(int capacity, MemoryStack stack) {
|
||||
return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Unsafe version of {@link #sType}. */
|
||||
public static int nsType(long struct) { return UNSAFE.getInt(null, struct + VkAndroidSurfaceCreateInfoKHR.STYPE); }
|
||||
/** Unsafe version of {@link #pNext}. */
|
||||
public static long npNext(long struct) { return memGetAddress(struct + VkAndroidSurfaceCreateInfoKHR.PNEXT); }
|
||||
/** Unsafe version of {@link #flags}. */
|
||||
public static int nflags(long struct) { return UNSAFE.getInt(null, struct + VkAndroidSurfaceCreateInfoKHR.FLAGS); }
|
||||
/** Unsafe version of {@link #pWindow(int) pWindow}. */
|
||||
public static PointerBuffer npWindow(long struct, int capacity) { return memPointerBuffer(memGetAddress(struct + VkAndroidSurfaceCreateInfoKHR.PWINDOW), capacity); }
|
||||
|
||||
/** Unsafe version of {@link #sType(int) sType}. */
|
||||
public static void nsType(long struct, int value) { UNSAFE.putInt(null, struct + VkAndroidSurfaceCreateInfoKHR.STYPE, value); }
|
||||
/** Unsafe version of {@link #pNext(long) pNext}. */
|
||||
public static void npNext(long struct, long value) { memPutAddress(struct + VkAndroidSurfaceCreateInfoKHR.PNEXT, value); }
|
||||
/** Unsafe version of {@link #flags(int) flags}. */
|
||||
public static void nflags(long struct, int value) { UNSAFE.putInt(null, struct + VkAndroidSurfaceCreateInfoKHR.FLAGS, value); }
|
||||
/** Unsafe version of {@link #pWindow(PointerBuffer) pWindow}. */
|
||||
public static void npWindow(long struct, PointerBuffer value) { memPutAddress(struct + VkAndroidSurfaceCreateInfoKHR.PWINDOW, memAddress(value)); }
|
||||
|
||||
/**
|
||||
* Validates pointer members that should not be {@code NULL}.
|
||||
*
|
||||
* @param struct the struct to validate
|
||||
*/
|
||||
public static void validate(long struct) {
|
||||
check(memGetAddress(struct + VkAndroidSurfaceCreateInfoKHR.PWINDOW));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #validate(long)} for each struct contained in the specified struct array.
|
||||
*
|
||||
* @param array the struct array to validate
|
||||
* @param count the number of structs in {@code array}
|
||||
*/
|
||||
public static void validate(long array, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
validate(array + Integer.toUnsignedLong(i) * SIZEOF);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** An array of {@link VkAndroidSurfaceCreateInfoKHR} structs. */
|
||||
public static class Buffer extends StructBuffer<VkAndroidSurfaceCreateInfoKHR, Buffer> implements NativeResource {
|
||||
|
||||
private static final VkAndroidSurfaceCreateInfoKHR ELEMENT_FACTORY = VkAndroidSurfaceCreateInfoKHR.create(-1L);
|
||||
|
||||
/**
|
||||
* Creates a new {@code VkAndroidSurfaceCreateInfoKHR.Buffer} instance backed by the specified container.
|
||||
*
|
||||
* Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
|
||||
* will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
|
||||
* by {@link VkAndroidSurfaceCreateInfoKHR#SIZEOF}, and its mark will be undefined.
|
||||
*
|
||||
* <p>The created buffer instance holds a strong reference to the container object.</p>
|
||||
*/
|
||||
public Buffer(ByteBuffer container) {
|
||||
super(container, container.remaining() / SIZEOF);
|
||||
}
|
||||
|
||||
public Buffer(long address, int cap) {
|
||||
super(address, null, -1, 0, cap, cap);
|
||||
}
|
||||
|
||||
Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
|
||||
super(address, container, mark, pos, lim, cap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Buffer self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VkAndroidSurfaceCreateInfoKHR getElementFactory() {
|
||||
return ELEMENT_FACTORY;
|
||||
}
|
||||
|
||||
/** Returns the value of the {@code sType} field. */
|
||||
@NativeType("VkStructureType")
|
||||
public int sType() { return VkAndroidSurfaceCreateInfoKHR.nsType(address()); }
|
||||
/** Returns the value of the {@code pNext} field. */
|
||||
@NativeType("void const *")
|
||||
public long pNext() { return VkAndroidSurfaceCreateInfoKHR.npNext(address()); }
|
||||
/** Returns the value of the {@code flags} field. */
|
||||
@NativeType("VkAndroidSurfaceCreateFlagsKHR")
|
||||
public int flags() { return VkAndroidSurfaceCreateInfoKHR.nflags(address()); }
|
||||
/**
|
||||
* Returns a {@link PointerBuffer} view of the data pointed to by the {@code pWindow} field.
|
||||
*
|
||||
* @param capacity the number of elements in the returned buffer
|
||||
*/
|
||||
@NativeType("ANativeWindow const *")
|
||||
public PointerBuffer pWindow(int capacity) { return VkAndroidSurfaceCreateInfoKHR.npWindow(address(), capacity); }
|
||||
|
||||
/** Sets the specified value to the {@code sType} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR.Buffer sType(@NativeType("VkStructureType") int value) { VkAndroidSurfaceCreateInfoKHR.nsType(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code pNext} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR.Buffer pNext(@NativeType("void const *") long value) { VkAndroidSurfaceCreateInfoKHR.npNext(address(), value); return this; }
|
||||
/** Sets the specified value to the {@code flags} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR.Buffer flags(@NativeType("VkAndroidSurfaceCreateFlagsKHR") int value) { VkAndroidSurfaceCreateInfoKHR.nflags(address(), value); return this; }
|
||||
/** Sets the address of the specified {@link PointerBuffer} to the {@code pWindow} field. */
|
||||
public VkAndroidSurfaceCreateInfoKHR.Buffer pWindow(@NativeType("ANativeWindow const *") PointerBuffer value) { VkAndroidSurfaceCreateInfoKHR.npWindow(address(), value); return this; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user