Java Code Examples for org.lwjgl.PointerBuffer#put()
The following examples show how to use
org.lwjgl.PointerBuffer#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VkUtil.java From oreon-engine with GNU General Public License v3.0 | 6 votes |
public static PointerBuffer createPointerBuffer(Collection<CommandBuffer> commandBuffers){ if (commandBuffers.size() == 0){ log.info("createPointerBuffer: commandBuffers empty"); return null; } PointerBuffer cmdBuffersPointer = memAllocPointer(commandBuffers.size()); for (CommandBuffer cmdBuffer : commandBuffers){ cmdBuffersPointer.put(cmdBuffer.getHandlePointer()); } cmdBuffersPointer.flip(); return cmdBuffersPointer; }
Example 2
Source File: LwjglKernel.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void RunNoEvent(CommandQueue queue) { Utils.pointerBuffers[1].rewind(); Utils.pointerBuffers[1].put(globalWorkSize.getSizes()); Utils.pointerBuffers[1].position(0); PointerBuffer p2 = null; if (workGroupSize.getSizes()[0] > 0) { p2 = Utils.pointerBuffers[2].rewind(); p2.put(workGroupSize.getSizes()); p2.position(0); } long q = ((LwjglCommandQueue) queue).getQueue(); int ret = CL10.clEnqueueNDRangeKernel(q, kernel, globalWorkSize.getDimension(), null, Utils.pointerBuffers[1], p2, null, null); Utils.checkError(ret, "clEnqueueNDRangeKernel"); }
Example 3
Source File: LwjglKernel.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Event Run(CommandQueue queue) { Utils.pointerBuffers[0].rewind(); Utils.pointerBuffers[1].rewind(); Utils.pointerBuffers[1].put(globalWorkSize.getSizes()); Utils.pointerBuffers[1].position(0); PointerBuffer p2 = null; if (workGroupSize.getSizes()[0] > 0) { p2 = Utils.pointerBuffers[2].rewind(); p2.put(workGroupSize.getSizes()); p2.position(0); } long q = ((LwjglCommandQueue) queue).getQueue(); int ret = CL10.clEnqueueNDRangeKernel(q, kernel, globalWorkSize.getDimension(), null, Utils.pointerBuffers[1], p2, null, Utils.pointerBuffers[0]); Utils.checkError(ret, "clEnqueueNDRangeKernel"); return new LwjglEvent(Utils.pointerBuffers[0].get(0)); }
Example 4
Source File: LwjglProgram.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void build(String args, Device... devices) throws KernelCompilationException { PointerBuffer deviceList = null; if (devices != null) { deviceList = PointerBuffer.allocateDirect(devices.length); deviceList.rewind(); for (Device d : devices) { deviceList.put(((LwjglDevice) d).getDevice()); } deviceList.flip(); } int ret = CL10.clBuildProgram(program, deviceList, args, null, 0); if (ret != CL10.CL_SUCCESS) { String log = Log(); LOG.log(Level.WARNING, "Unable to compile program:\n{0}", log); if (ret == CL10.CL_BUILD_PROGRAM_FAILURE) { throw new KernelCompilationException("Failed to build program", ret, log); } else { Utils.checkError(ret, "clBuildProgram"); } } else { LOG.log(Level.INFO, "Program compiled:\n{0}", Log()); } }
Example 5
Source File: LwjglKernel.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void RunNoEvent(CommandQueue queue) { Utils.pointerBuffers[1].rewind(); Utils.pointerBuffers[1].put(globalWorkSize.getSizes()); Utils.pointerBuffers[1].position(0); PointerBuffer p2 = null; if (workGroupSize.getSizes()[0] > 0) { p2 = Utils.pointerBuffers[2].rewind(); p2.put(workGroupSize.getSizes()); p2.position(0); } CLCommandQueue q = ((LwjglCommandQueue) queue).getQueue(); int ret = CL10.clEnqueueNDRangeKernel(q, kernel, globalWorkSize.getDimension(), null, Utils.pointerBuffers[1], p2, null, null); Utils.checkError(ret, "clEnqueueNDRangeKernel"); }
Example 6
Source File: LwjglProgram.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void build(String args, Device... devices) throws KernelCompilationException { PointerBuffer deviceList = null; if (devices != null) { deviceList = PointerBuffer.allocateDirect(devices.length); deviceList.rewind(); for (Device d : devices) { deviceList.put(((LwjglDevice) d).device.getPointer()); } deviceList.flip(); } int ret = CL10.clBuildProgram(program, deviceList, args, null); if (ret != CL10.CL_SUCCESS) { String log = Log(); LOG.log(Level.WARNING, "Unable to compile program:\n{0}", log); if (ret == CL10.CL_BUILD_PROGRAM_FAILURE) { throw new KernelCompilationException("Failed to build program", ret, log); } else { Utils.checkError(ret, "clBuildProgram"); } } else { LOG.log(Level.INFO, "Program compiled:\n{0}", Log()); } }
Example 7
Source File: LWJGUIDialog.java From LWJGUI with MIT License | 6 votes |
/** * Opens a file open dialog. * * @param title window title * @param defaultPath default file path * @param filterDescription description of the accepted file extension(s) * @param acceptedFileExtension the first accepted file extension (example: "txt", use * for all) * @param additionalAcceptedFileExtensions any additional accepted file extensions * * @return the selected file */ public static File showOpenFileDialog(String title, File defaultPath, String filterDescription, String acceptedFileExtension, String... additionalAcceptedFileExtensions){ MemoryStack stack = MemoryStack.stackPush(); PointerBuffer filters = stack.mallocPointer(1 + additionalAcceptedFileExtensions.length); filters.put(stack.UTF8("*." + acceptedFileExtension)); for(int i = 0; i < additionalAcceptedFileExtensions.length; i++){ filters.put(stack.UTF8("*." + additionalAcceptedFileExtensions[i])); } filters.flip(); defaultPath = defaultPath.getAbsoluteFile(); String defaultString = defaultPath.getAbsolutePath(); if(defaultPath.isDirectory() && !defaultString.endsWith(File.separator)){ defaultString += File.separator; } String result = TinyFileDialogs.tinyfd_openFileDialog(title, defaultString, filters, filterDescription, false); stack.pop(); return result != null ? new File(result) : null; }
Example 8
Source File: VkUtil.java From oreon-engine with GNU General Public License v3.0 | 5 votes |
public static PointerBuffer getValidationLayerNames(boolean validation, ByteBuffer[] layers){ PointerBuffer ppEnabledLayerNames = memAllocPointer(layers.length); for (int i = 0; validation && i < layers.length; i++) ppEnabledLayerNames.put(layers[i]); ppEnabledLayerNames.flip(); return ppEnabledLayerNames; }
Example 9
Source File: SimpleDemo.java From lwjgl3-swt with MIT License | 5 votes |
/** * Create a Vulkan instance using LWJGL 3. * * @return the VkInstance handle */ private static VkInstance createInstance() { VkApplicationInfo appInfo = VkApplicationInfo.calloc() .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO) .pApplicationName(memUTF8("SWT Vulkan Demo")) .pEngineName(memUTF8("")) .apiVersion(VK_MAKE_VERSION(1, 0, 2)); ByteBuffer VK_KHR_SURFACE_EXTENSION = memUTF8(VK_KHR_SURFACE_EXTENSION_NAME); ByteBuffer VK_KHR_OS_SURFACE_EXTENSION; if (Platform.get() == Platform.WINDOWS) VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); else VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); PointerBuffer ppEnabledExtensionNames = memAllocPointer(2); ppEnabledExtensionNames.put(VK_KHR_SURFACE_EXTENSION); ppEnabledExtensionNames.put(VK_KHR_OS_SURFACE_EXTENSION); ppEnabledExtensionNames.flip(); VkInstanceCreateInfo pCreateInfo = VkInstanceCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO) .pNext(0L) .pApplicationInfo(appInfo); if (ppEnabledExtensionNames.remaining() > 0) { pCreateInfo.ppEnabledExtensionNames(ppEnabledExtensionNames); } PointerBuffer pInstance = MemoryUtil.memAllocPointer(1); int err = vkCreateInstance(pCreateInfo, null, pInstance); if (err != VK_SUCCESS) { throw new RuntimeException("Failed to create VkInstance: " + translateVulkanResult(err)); } long instance = pInstance.get(0); memFree(pInstance); VkInstance ret = new VkInstance(instance, pCreateInfo); memFree(ppEnabledExtensionNames); memFree(VK_KHR_OS_SURFACE_EXTENSION); memFree(VK_KHR_SURFACE_EXTENSION); appInfo.free(); return ret; }
Example 10
Source File: DesktopLauncher.java From skin-composer with MIT License | 5 votes |
@Override public File saveDialog(String title, String defaultPath, String[] filterPatterns, String filterDescription) { String result = null; //fix file path characters if (Utils.isWindows()) { defaultPath = defaultPath.replace("/", "\\"); } else { defaultPath = defaultPath.replace("\\", "/"); } if (filterPatterns != null && filterPatterns.length > 0) { try (var stack = stackPush()) { PointerBuffer pointerBuffer = null; pointerBuffer = stack.mallocPointer(filterPatterns.length); for (String filterPattern : filterPatterns) { pointerBuffer.put(stack.UTF8(filterPattern)); } pointerBuffer.flip(); result = org.lwjgl.util.tinyfd.TinyFileDialogs.tinyfd_saveFileDialog(title, defaultPath, pointerBuffer, filterDescription); } } else { result = org.lwjgl.util.tinyfd.TinyFileDialogs.tinyfd_saveFileDialog(title, defaultPath, null, filterDescription); } if (result != null) { return new File(result); } else { return null; } }
Example 11
Source File: LwjglProgram.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public ByteBuffer getBinary(Device d) { //throw new UnsupportedOperationException("Not supported yet, would crash the JVM"); LwjglDevice device = (LwjglDevice) d; int numDevices = Info.clGetProgramInfoInt(program, CL10.CL_PROGRAM_NUM_DEVICES); PointerBuffer devices = PointerBuffer.allocateDirect(numDevices); int ret = CL10.clGetProgramInfo(program, CL10.CL_PROGRAM_DEVICES, devices, null); Utils.checkError(ret, "clGetProgramInfo: CL_PROGRAM_DEVICES"); int index = -1; for (int i=0; i<numDevices; ++i) { if (devices.get(i) == device.getDevice()) { index = i; } } if (index == -1) { throw new com.jme3.opencl.OpenCLException("Program was not built against the specified device "+device); } PointerBuffer sizes = PointerBuffer.allocateDirect(numDevices); ret = CL10.clGetProgramInfo(program, CL10.CL_PROGRAM_BINARY_SIZES, sizes, null); Utils.checkError(ret, "clGetProgramInfo: CL_PROGRAM_BINARY_SIZES"); int size = (int) sizes.get(index); PointerBuffer binaryPointers = PointerBuffer.allocateDirect(numDevices); for (int i=0; i<binaryPointers.capacity(); ++i) { binaryPointers.put(0L); } binaryPointers.rewind(); ByteBuffer binaries = ByteBuffer.allocateDirect(size); binaryPointers.put(index, binaries); //Fixme: why the hell does this line throw a segfault ?!? ret = CL10.clGetProgramInfo(program, CL10.CL_PROGRAM_BINARIES, binaryPointers, null); Utils.checkError(ret, "clGetProgramInfo: CL_PROGRAM_BINARIES"); return binaries; }
Example 12
Source File: DesktopLauncher.java From skin-composer with MIT License | 5 votes |
@Override public File openDialog(String title, String defaultPath, String[] filterPatterns, String filterDescription) { String result = null; //fix file path characters if (Utils.isWindows()) { defaultPath = defaultPath.replace("/", "\\"); } else { defaultPath = defaultPath.replace("\\", "/"); } if (filterPatterns != null && filterPatterns.length > 0) { try (MemoryStack stack = stackPush()) { PointerBuffer pointerBuffer = stack.mallocPointer(filterPatterns.length); for (String filterPattern : filterPatterns) { pointerBuffer.put(stack.UTF8(filterPattern)); } pointerBuffer.flip(); result = org.lwjgl.util.tinyfd.TinyFileDialogs.tinyfd_openFileDialog(title, defaultPath, pointerBuffer, filterDescription, false); } } else { result = org.lwjgl.util.tinyfd.TinyFileDialogs.tinyfd_openFileDialog(title, defaultPath, null, filterDescription, false); } if (result != null) { return new File(result); } else { return null; } }
Example 13
Source File: SimpleDemo.java From lwjgl3-awt with MIT License | 5 votes |
/** * Create a Vulkan instance using LWJGL 3. * * @return the VkInstance handle */ private static VkInstance createInstance() { VkApplicationInfo appInfo = VkApplicationInfo.calloc() .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO) .pApplicationName(memUTF8("AWT Vulkan Demo")) .pEngineName(memUTF8("")) .apiVersion(VK_MAKE_VERSION(1, 0, 2)); ByteBuffer VK_KHR_SURFACE_EXTENSION = memUTF8(VK_KHR_SURFACE_EXTENSION_NAME); ByteBuffer VK_KHR_OS_SURFACE_EXTENSION; if (Platform.get() == Platform.WINDOWS) VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); else VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); PointerBuffer ppEnabledExtensionNames = memAllocPointer(2); ppEnabledExtensionNames.put(VK_KHR_SURFACE_EXTENSION); ppEnabledExtensionNames.put(VK_KHR_OS_SURFACE_EXTENSION); ppEnabledExtensionNames.flip(); VkInstanceCreateInfo pCreateInfo = VkInstanceCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO) .pNext(0L) .pApplicationInfo(appInfo); if (ppEnabledExtensionNames.remaining() > 0) { pCreateInfo.ppEnabledExtensionNames(ppEnabledExtensionNames); } PointerBuffer pInstance = MemoryUtil.memAllocPointer(1); int err = vkCreateInstance(pCreateInfo, null, pInstance); if (err != VK_SUCCESS) { throw new RuntimeException("Failed to create VkInstance: " + translateVulkanResult(err)); } long instance = pInstance.get(0); memFree(pInstance); VkInstance ret = new VkInstance(instance, pCreateInfo); memFree(ppEnabledExtensionNames); memFree(VK_KHR_OS_SURFACE_EXTENSION); memFree(VK_KHR_SURFACE_EXTENSION); appInfo.free(); return ret; }
Example 14
Source File: VulkanInstance.java From oreon-engine with GNU General Public License v3.0 | 4 votes |
public VulkanInstance(PointerBuffer ppEnabledLayerNames) { PointerBuffer requiredExtensions = glfwGetRequiredInstanceExtensions(); if (requiredExtensions == null) { throw new AssertionError("Failed to find list of required Vulkan extensions"); } ByteBuffer VK_EXT_DEBUG_REPORT_EXTENSION = memUTF8(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); // +1 due to VK_EXT_DEBUG_REPORT_EXTENSION PointerBuffer ppEnabledExtensionNames = memAllocPointer(requiredExtensions.remaining() + 1); ppEnabledExtensionNames.put(requiredExtensions); ppEnabledExtensionNames.put(VK_EXT_DEBUG_REPORT_EXTENSION); ppEnabledExtensionNames.flip(); VkApplicationInfo appInfo = VkApplicationInfo.calloc() .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO) .pApplicationName(memUTF8("Vulkan Demo")) .pEngineName(memUTF8("OREON ENGINE")) .apiVersion(VK_MAKE_VERSION(1, 1, 77)); VkInstanceCreateInfo pCreateInfo = VkInstanceCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO) .pNext(0) .pApplicationInfo(appInfo) .ppEnabledExtensionNames(ppEnabledExtensionNames) .ppEnabledLayerNames(ppEnabledLayerNames); PointerBuffer pInstance = memAllocPointer(1); int err = vkCreateInstance(pCreateInfo, null, pInstance); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create VkInstance: " + VkUtil.translateVulkanResult(err)); } handle = new VkInstance(pInstance.get(0), pCreateInfo); pCreateInfo.free(); memFree(pInstance); memFree(VK_EXT_DEBUG_REPORT_EXTENSION); memFree(ppEnabledExtensionNames); memFree(appInfo.pApplicationName()); memFree(appInfo.pEngineName()); appInfo.free(); VkDebugReportCallbackEXT debugCallback = new VkDebugReportCallbackEXT() { public int invoke(int flags, int objectType, long object, long location, int messageCode, long pLayerPrefix, long pMessage, long pUserData) { System.err.println("ERROR OCCURED: " + VkDebugReportCallbackEXT.getString(pMessage)); return 0; } }; debugCallbackHandle = setupDebugging(handle, VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT, debugCallback); }
Example 15
Source File: VkUtil.java From oreon-engine with GNU General Public License v3.0 | 4 votes |
public static PointerBuffer createPointerBuffer(List<CommandBuffer> commandBuffers){ if (commandBuffers.size() == 0){ log.error("createPointerBuffer: commandBuffers empty"); } PointerBuffer cmdBuffersPointer = memAllocPointer(commandBuffers.size()); for (CommandBuffer cmdBuffer : commandBuffers){ cmdBuffersPointer.put(cmdBuffer.getHandlePointer()); } cmdBuffersPointer.flip(); return cmdBuffersPointer; }
Example 16
Source File: ClearScreenDemo.java From lwjgl3-swt with MIT License | 4 votes |
private static DeviceAndGraphicsQueueFamily createDeviceAndGetGraphicsQueueFamily(VkPhysicalDevice physicalDevice) { IntBuffer pQueueFamilyPropertyCount = memAllocInt(1); vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, null); int queueCount = pQueueFamilyPropertyCount.get(0); VkQueueFamilyProperties.Buffer queueProps = VkQueueFamilyProperties.calloc(queueCount); vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, queueProps); memFree(pQueueFamilyPropertyCount); int graphicsQueueFamilyIndex; for (graphicsQueueFamilyIndex = 0; graphicsQueueFamilyIndex < queueCount; graphicsQueueFamilyIndex++) { if ((queueProps.get(graphicsQueueFamilyIndex).queueFlags() & VK_QUEUE_GRAPHICS_BIT) != 0) break; } queueProps.free(); FloatBuffer pQueuePriorities = memAllocFloat(1).put(0.0f); pQueuePriorities.flip(); VkDeviceQueueCreateInfo.Buffer queueCreateInfo = VkDeviceQueueCreateInfo.calloc(1) .sType(VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO) .queueFamilyIndex(graphicsQueueFamilyIndex) .pQueuePriorities(pQueuePriorities); PointerBuffer extensions = memAllocPointer(1); ByteBuffer VK_KHR_SWAPCHAIN_EXTENSION = memUTF8(VK_KHR_SWAPCHAIN_EXTENSION_NAME); extensions.put(VK_KHR_SWAPCHAIN_EXTENSION); extensions.flip(); PointerBuffer ppEnabledLayerNames = memAllocPointer(layers.length); for (int i = 0; validation && i < layers.length; i++) ppEnabledLayerNames.put(layers[i]); ppEnabledLayerNames.flip(); VkDeviceCreateInfo deviceCreateInfo = VkDeviceCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO) .pNext(NULL) .pQueueCreateInfos(queueCreateInfo) .ppEnabledExtensionNames(extensions) .ppEnabledLayerNames(ppEnabledLayerNames); PointerBuffer pDevice = memAllocPointer(1); int err = vkCreateDevice(physicalDevice, deviceCreateInfo, null, pDevice); long device = pDevice.get(0); memFree(pDevice); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create device: " + translateVulkanResult(err)); } DeviceAndGraphicsQueueFamily ret = new DeviceAndGraphicsQueueFamily(); ret.device = new VkDevice(device, physicalDevice, deviceCreateInfo); ret.queueFamilyIndex = graphicsQueueFamilyIndex; deviceCreateInfo.free(); memFree(ppEnabledLayerNames); memFree(VK_KHR_SWAPCHAIN_EXTENSION); memFree(extensions); memFree(pQueuePriorities); return ret; }
Example 17
Source File: LwjglContext.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private long createContext(final long platform, final long[] devices, long window) { try (MemoryStack stack = MemoryStack.stackPush()) { final int propertyCount = 2 + 4 + 1; final PointerBuffer properties = stack.callocPointer(propertyCount + devices.length); // set sharing properties // https://github.com/glfw/glfw/issues/104 // https://github.com/LWJGL/lwjgl3/blob/master/modules/core/src/test/java/org/lwjgl/demo/opencl/Mandelbrot.java // TODO: test on Linux and MacOSX switch (Platform.get()) { case WINDOWS: properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR) .put(org.lwjgl.glfw.GLFWNativeWGL.glfwGetWGLContext(window)) .put(KHRGLSharing.CL_WGL_HDC_KHR) .put(org.lwjgl.opengl.WGL.wglGetCurrentDC()); break; case LINUX: properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR) .put(org.lwjgl.glfw.GLFWNativeGLX.glfwGetGLXContext(window)) .put(KHRGLSharing.CL_GLX_DISPLAY_KHR) .put(org.lwjgl.glfw.GLFWNativeX11.glfwGetX11Display()); break; case MACOSX: properties.put(APPLEGLSharing.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE) .put(org.lwjgl.opengl.CGL.CGLGetShareGroup(org.lwjgl.opengl.CGL.CGLGetCurrentContext())); } properties.put(CL_CONTEXT_PLATFORM).put(platform); properties.put(0); properties.flip(); final IntBuffer error = stack.callocInt(1); final PointerBuffer deviceBuffer = stack.callocPointer(devices.length); for (final long deviceId : devices) { deviceBuffer.put(deviceId); } deviceBuffer.flip(); long context = CL10.clCreateContext(properties, deviceBuffer, null, 0, error); Utils.checkError(error, "clCreateContext"); return context; } }
Example 18
Source File: ClearScreenDemo.java From lwjgl3-swt with MIT License | 4 votes |
/** * Create a Vulkan {@link VkInstance} using LWJGL 3. * <p> * The {@link VkInstance} represents a handle to the Vulkan API and we need that instance for about everything we do. * * @return the VkInstance handle */ private static VkInstance createInstance() { VkApplicationInfo appInfo = VkApplicationInfo.calloc() .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO) .pApplicationName(memUTF8("SWT Vulkan Demo")) .pEngineName(memUTF8("")) .apiVersion(VK_MAKE_VERSION(1, 0, 2)); ByteBuffer VK_KHR_SURFACE_EXTENSION = memUTF8(VK_KHR_SURFACE_EXTENSION_NAME); ByteBuffer VK_EXT_DEBUG_REPORT_EXTENSION = memUTF8(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); ByteBuffer VK_KHR_OS_SURFACE_EXTENSION; if (Platform.get() == Platform.WINDOWS) VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); else VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); PointerBuffer ppEnabledExtensionNames = memAllocPointer(3) .put(VK_KHR_SURFACE_EXTENSION) .put(VK_KHR_OS_SURFACE_EXTENSION) .put(VK_EXT_DEBUG_REPORT_EXTENSION) .flip(); PointerBuffer ppEnabledLayerNames = memAllocPointer(layers.length); for (int i = 0; validation && i < layers.length; i++) ppEnabledLayerNames.put(layers[i]); ppEnabledLayerNames.flip(); VkInstanceCreateInfo pCreateInfo = VkInstanceCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO) .pNext(NULL) .pApplicationInfo(appInfo) .ppEnabledExtensionNames(ppEnabledExtensionNames) .ppEnabledLayerNames(ppEnabledLayerNames); PointerBuffer pInstance = memAllocPointer(1); int err = vkCreateInstance(pCreateInfo, null, pInstance); long instance = pInstance.get(0); memFree(pInstance); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create VkInstance: " + translateVulkanResult(err)); } VkInstance ret = new VkInstance(instance, pCreateInfo); pCreateInfo.free(); memFree(ppEnabledLayerNames); memFree(ppEnabledExtensionNames); memFree(VK_KHR_OS_SURFACE_EXTENSION); memFree(VK_EXT_DEBUG_REPORT_EXTENSION); memFree(VK_KHR_SURFACE_EXTENSION); appInfo.free(); return ret; }
Example 19
Source File: APIBuffer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Ensures space for an additional pointer value, sets the specified value * at the allocated offset and returns that offset. */ public int pointerParam(long value) { int offset = pointerParam(); PointerBuffer.put(buffer, offset, value); return offset; }
Example 20
Source File: APIBuffer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Sets a pointer value at the specified index of the pointer buffer that * starts at the specified offset. */ public void pointerParam(int offset, int index, long value) { PointerBuffer.put(buffer, offset + (index << POINTER_SHIFT), value); }