3 ResourceScope deviceScope = ResourceScope.newSharedScope();
5 static final MethodHandle vkAllocateCommandBuffers$FH = Memory.downcall(
6 "vkAllocateCommandBuffers",
9 Memory.POINTER.withName("device"),
10 Memory.POINTER.withName("pAllocateInfo"),
11 Memory.POINTER.withName("pCommandBuffers")));
13 * VkResult vkAllocateCommandBuffers ( VkDevice const VkCommandBufferAllocateInfo* VkCommandBuffer* )
14 * Success Codes: VK_SUCCESS
15 * Error Codes: VK_ERROR_OUT_OF_HOST_MEMORY,VK_ERROR_OUT_OF_DEVICE_MEMORY
17 public Memory.HandleArray<VkCommandBuffer> vkAllocateCommandBuffers(VkCommandBufferAllocateInfo pAllocateInfo)throws Exception {
20 Memory.HandleArray<VkCommandBuffer> pCommandBuffers =
21 new Memory.HandleArray<>((addr)->new VkCommandBuffer(addr, instanceDispatch, deviceDispatch),
22 MemorySegment.allocateNative(pAllocateInfo.getCommandBufferCount() * Memory.POINTER.byteSize(), Memory.POINTER.bitAlignment(), deviceScope));
24 res$code = (int)vkAllocateCommandBuffers$FH.invokeExact(
25 (Addressable)address(),
26 (Addressable)Memory.address(pAllocateInfo),
27 (Addressable)Memory.address(pCommandBuffers));
28 if (res$code == VkResult.VK_SUCCESS) return pCommandBuffers;
29 } catch (Throwable t) { throw new RuntimeException(t); }
30 throw new Exception(String.format("failcode %d", res$code));
33 static final MethodHandle vkMapMemory$FH = Memory.downcall(
35 FunctionDescriptor.of(
37 Memory.POINTER.withName("device"),
38 Memory.POINTER.withName("memory"),
39 Memory.LONG.withName("offset"),
40 Memory.LONG.withName("size"),
41 Memory.INT.withName("flags"),
42 Memory.POINTER.withName("ppData")));
44 * VkResult vkMapMemory ( VkDevice VkDeviceMemory VkDeviceSize VkDeviceSize VkMemoryMapFlags void** )
45 * Success Codes: VK_SUCCESS
46 * Error Codes: VK_ERROR_OUT_OF_HOST_MEMORY,VK_ERROR_OUT_OF_DEVICE_MEMORY,VK_ERROR_MEMORY_MAP_FAILED
48 public MemorySegment vkMapMemory(VkDeviceMemory memory, long offset, long size, int flags, ResourceScope scope)throws Exception {
50 try (Frame frame = Memory.createFrame()) {
51 MemorySegment ppData = frame.allocatePointer();
52 res$code = (int)vkMapMemory$FH.invokeExact(
53 (Addressable)address(),
54 (Addressable)Memory.address(memory),
58 (Addressable)Memory.address(ppData));
59 if (res$code == VkResult.VK_SUCCESS) return MemorySegment.ofAddress(ppData.getAtIndex(Memory.POINTER, 0), size, scope);
60 } catch (Throwable t) { throw new RuntimeException(t); }
61 throw new Exception(String.format("failcode %d", res$code));