Skip to content

Commit aaad743

Browse files
committed
KHR_swapchain
1 parent 432cbbb commit aaad743

File tree

9 files changed

+194
-84
lines changed

9 files changed

+194
-84
lines changed

src/main/kotlin/vkk/_10/api/Device_vk10.kt

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ interface Device_vk10 : Pointer {
2020

2121
val capabilities: CapabilitiesDevice
2222

23-
// --- [ vkAcquireNextImageKHR ] ---
24-
25-
fun MemoryStack.acquireNextImageKHR(swapchain: VkSwapchainKHR, timeout: Long = -1L, semaphore: VkSemaphore, fence: VkFence = VkFence.NULL, check: (VkResult) -> Unit = ::defaultCheck): Int =
26-
framed { this.intAdr { check(nAcquireNextImageKHR(swapchain, timeout, semaphore, fence, it)) } }
27-
28-
fun acquireNextImageKHR(swapchain: VkSwapchainKHR, timeout: Long = -1L, semaphore: VkSemaphore, fence: VkFence = VkFence.NULL, check: (VkResult) -> Unit = ::defaultCheck): Int =
29-
stak { it.acquireNextImageKHR(swapchain, timeout, semaphore, fence, check) }
30-
3123
// --- [ vkAllocateDescriptorSets ] ---
3224

3325
infix fun MemoryStack.allocateDescriptorSets(allocateInfo: DescriptorSetAllocateInfo): VkDescriptorSet_Array =
@@ -286,14 +278,6 @@ interface Device_vk10 : Pointer {
286278
infix fun createShaderModule(createInfo: ShaderModuleCreateInfo): VkShaderModule =
287279
stak { it createShaderModule createInfo }
288280

289-
// --- [ vkCreateSwapchainKHR ] ---
290-
291-
infix fun MemoryStack.createSwapchainKHR(createInfo: SwapchainCreateInfoKHR): VkSwapchainKHR =
292-
framed { VkSwapchainKHR(this.longAdr { VK_CHECK_RESULT(callPPPPI(adr, createInfo write this, NULL, it, capabilities.vkCreateSwapchainKHR)) }) }
293-
294-
infix fun createSwapchainKHR(createInfo: SwapchainCreateInfoKHR): VkSwapchainKHR =
295-
stak { it createSwapchainKHR createInfo }
296-
297281
// --- [ vkDestroyBuffer ] ---
298282
infix fun destroy(buffer: VkBuffer) =
299283
callPJPV(adr, buffer.L, NULL, capabilities.vkDestroyBuffer)
@@ -370,10 +354,6 @@ interface Device_vk10 : Pointer {
370354
infix fun destroy(shaderModule: VkShaderModule) =
371355
callPJPV(adr, shaderModule.L, NULL, capabilities.vkDestroyShaderModule)
372356

373-
// --- [ vkDestroySwapchainKHR ] ---
374-
infix fun destroy(swapchain: VkSwapchainKHR) =
375-
callPJPV(adr, swapchain.L, NULL, capabilities.vkDestroySwapchainKHR)
376-
377357
// --- [ vkDeviceWaitIdle ] ---
378358
fun waitIdle(): VkResult =
379359
VkResult(callPI(adr, capabilities.vkDeviceWaitIdle))
@@ -510,28 +490,6 @@ interface Device_vk10 : Pointer {
510490
fun getQueryPoolResults(queryPool: VkQueryPool, firstQuery: Int, queryCount: Int, dataSize: Int, pData: Ptr, stride: VkDeviceSize, flags: VkQueryResultFlags): VkResult =
511491
VkResult(callPJPPJI(adr, queryPool.L, firstQuery, queryCount, dataSize.L, pData, stride.L, flags, capabilities.vkGetQueryPoolResults))
512492

513-
// --- [ vkGetSwapchainImagesKHR ] ---
514-
515-
infix fun MemoryStack.getSwapchainImagesKHR(swapchain: VkSwapchainKHR): VkImage_Array =
516-
framed {
517-
var pSwapchainImages = LongPtr.NULL
518-
val pSwapchainImageCount = this.mInt()
519-
var swapchainImageCount: Int
520-
var result: VkResult
521-
do {
522-
result = nGetSwapchainImagesKHR(swapchain, pSwapchainImageCount.adr)
523-
swapchainImageCount = pSwapchainImageCount[0]
524-
if (result == VkResult.SUCCESS && swapchainImageCount != 0) {
525-
pSwapchainImages = this.mLong(swapchainImageCount)
526-
result = nGetSwapchainImagesKHR(swapchain, pSwapchainImageCount.adr, pSwapchainImages.adr)
527-
}
528-
} while (result == VkResult.INCOMPLETE)
529-
VkImage_Array(swapchainImageCount) { VkImage(pSwapchainImages[it]) }
530-
}
531-
532-
infix fun getSwapchainImagesKHR(swapchain: VkSwapchainKHR): VkImage_Array =
533-
stak { it getSwapchainImagesKHR swapchain }
534-
535493
// --- [ vkInvalidateMappedMemoryRanges ] ---
536494

537495
infix fun MemoryStack.invalidateMappedMemoryRanges(memoryRanges: Array<MappedMemoryRange>): VkResult =
@@ -638,9 +596,6 @@ interface Device_vk10 : Pointer {
638596
stak { it.waitForFences(fence, waitAll, timeout) }
639597
}
640598

641-
inline fun Device_vk10.nAcquireNextImageKHR(swapchain: VkSwapchainKHR, timeout: Long = -1L, semaphore: VkSemaphore, fence: VkFence = VkFence.NULL, pImage: Ptr): VkResult =
642-
VkResult(callPJJJJPI(adr, swapchain.L, timeout, semaphore.L, fence.L, pImage, capabilities.vkAcquireNextImageKHR))
643-
644599
inline fun Device_vk10.nAllocateDescriptorSets(pAllocateInfo: Ptr, pDescriptorSets: Ptr): VkResult =
645600
VkResult(callPPPI(adr, pAllocateInfo, pDescriptorSets, capabilities.vkAllocateDescriptorSets))
646601

@@ -698,9 +653,6 @@ inline fun Device_vk10.nGetImageSparseMemoryRequirements(image: VkImage, pSparse
698653
inline fun Device_vk10.nGetPipelineCacheData(pipelineCache: VkPipelineCache, pDataSize: IntPtr, pData: Ptr = NULL): VkResult =
699654
VkResult(callPJPPI(adr, pipelineCache.L, pDataSize.adr, pData, capabilities.vkGetPipelineCacheData))
700655

701-
inline fun Device_vk10.nGetSwapchainImagesKHR(swapchain: VkSwapchainKHR, pSwapchainImageCount: Ptr, pSwapchainImages: Ptr = NULL): VkResult =
702-
VkResult(callPJPPI(adr, swapchain.L, pSwapchainImageCount, pSwapchainImages, capabilities.vkGetSwapchainImagesKHR))
703-
704656
inline fun Device_vk10.nInvalidateMappedMemoryRanges(memoryRangeCount: Int, pMemoryRanges: Ptr): VkResult =
705657
VkResult(callPPI(adr, memoryRangeCount, pMemoryRanges, capabilities.vkInvalidateMappedMemoryRanges))
706658

src/main/kotlin/vkk/_10/api/Queue_vk10.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package vkk._10.api
22

3-
import vkk.identifiers.CapabilitiesDevice
43
import kool.adr
5-
import org.lwjgl.system.JNI.*
4+
import org.lwjgl.system.JNI.callPI
5+
import org.lwjgl.system.JNI.callPPJI
66
import org.lwjgl.system.MemoryStack
77
import org.lwjgl.system.Pointer
88
import vkk.VkResult
99
import vkk._10.structs.BindSparseInfo
1010
import vkk._10.structs.SubmitInfo
1111
import vkk._10.structs.write
1212
import vkk.entities.VkFence
13-
import vkk.extensions.PresentInfoKHR
1413
import vkk.framed
14+
import vkk.identifiers.CapabilitiesDevice
1515
import vkk.stak
1616

1717
interface Queue_vk10 : Pointer {
@@ -26,14 +26,6 @@ interface Queue_vk10 : Pointer {
2626
fun bindSparse(bindInfos: Array<BindSparseInfo>, fence: VkFence = VkFence.NULL): VkResult =
2727
stak { it.bindSparse(bindInfos, fence) }
2828

29-
// --- [ vkQueuePresentKHR ] ---
30-
31-
infix fun MemoryStack.presentKHR(presentInfo: PresentInfoKHR): VkResult =
32-
framed { presentInfo.native(this) { pPresentInfo -> VkResult(callPPI(adr, pPresentInfo, capabilities.vkQueuePresentKHR)).andCheck() } }
33-
34-
infix fun presentKHR(presentInfo: PresentInfoKHR): VkResult =
35-
stak { it presentKHR presentInfo }
36-
3729
// --- [ vkQueueSubmit ] ---
3830

3931
fun MemoryStack.submit(submit: SubmitInfo, fence: VkFence = VkFence.NULL): VkResult =

src/main/kotlin/vkk/_10/structs/Offset2D.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package vkk._10.structs
22

33
import glm_.vec2.Vec2i
4+
import kool.IntPtr
45
import kool.Ptr
56
import org.lwjgl.vulkan.VkOffset2D.nx
67
import org.lwjgl.vulkan.VkOffset2D.ny
@@ -29,6 +30,7 @@ class Offset2D(
2930
) {
3031

3132
constructor(v: Vec2i) : this(v.x, v.y)
33+
constructor(ptr: IntPtr) : this(ptr[0], ptr[1])
3234

3335
infix fun write(ptr: Ptr) {
3436
nx(ptr, x)

src/main/kotlin/vkk/_10/structs/Rect2D.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package vkk._10.structs
22

33
import glm_.vec2.Vec2i
44
import kool.Adr
5+
import kool.BytePtr
6+
import kool.IntPtr
57
import kool.Ptr
68
import org.lwjgl.system.MemoryStack
79
import org.lwjgl.vulkan.VkRect2D.*
@@ -31,6 +33,8 @@ class Rect2D(
3133

3234
constructor(size: Vec2i) : this(extent = Extent2D(size))
3335

36+
constructor(ptr: IntPtr) : this(Offset2D(ptr), Extent2D(ptr + 2))
37+
3438
infix fun write(stack: MemoryStack): Adr =
3539
stack.ncalloc(ALIGNOF, 1, SIZEOF).also { write(it) }
3640

0 commit comments

Comments
 (0)