Skip to content

Commit 4ac8eee

Browse files
committed
up, broken
1 parent d88af62 commit 4ac8eee

18 files changed

+790
-587
lines changed

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

Lines changed: 475 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package vkk._10.api
2+
3+
import glm_.vec3.Vec3i
4+
import identifiers.CapabilitiesDevice
5+
import kool.adr
6+
import org.lwjgl.system.JNI.callPV
7+
import org.lwjgl.system.Pointer
8+
9+
interface CommandBuffer_vk11 : Pointer {
10+
11+
val capabilities: CapabilitiesDevice
12+
13+
// --- [ vkCmdSetDeviceMask ] ---
14+
infix fun setDeviceMask(deviceMask: Int) =
15+
callPV(adr, deviceMask, capabilities.vkCmdSetDeviceMask)
16+
17+
// --- [ vkCmdDispatchBase ] ---
18+
19+
fun dispatchBase(baseGroupX: Int, baseGroupY: Int, baseGroupZ: Int, groupCountX: Int, groupCountY: Int, groupCountZ: Int) =
20+
nDispatchBase(baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ)
21+
22+
fun dispatchBase(baseGroup: Vec3i, groupCount: Vec3i) =
23+
nDispatchBase(baseGroup.x, baseGroup.y, baseGroup.z, groupCount.x, groupCount.y, groupCount.z)
24+
}
25+
26+
inline fun CommandBuffer_vk11.nDispatchBase(baseGroupX: Int, baseGroupY: Int, baseGroupZ: Int, groupCountX: Int, groupCountY: Int, groupCountZ: Int) =
27+
callPV(adr, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ, capabilities.vkCmdDispatchBase)
Lines changed: 126 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package vkk._10.api
22

3+
import glm_.bool
34
import identifiers.CapabilitiesInstance
45
import kool.*
56
import org.lwjgl.system.JNI.*
67
import org.lwjgl.system.MemoryStack
7-
import org.lwjgl.system.MemoryUtil
8+
import org.lwjgl.system.MemoryUtil.NULL
89
import org.lwjgl.system.Pointer
9-
import org.lwjgl.vulkan.VkExtensionProperties
10-
import org.lwjgl.vulkan.VkLayerProperties
10+
import org.lwjgl.vulkan.*
1111
import vkk.*
1212
import vkk._10.structs.*
13+
import vkk.entities.VkPresentModeKHR_Array
14+
import vkk.entities.VkSurfaceKHR
1315

1416
interface PhysicalDevice_vk10 : Pointer {
1517

@@ -19,8 +21,8 @@ interface PhysicalDevice_vk10 : Pointer {
1921

2022
fun MemoryStack.enumerateDeviceExtensionProperties(layerName: String? = null): Array<ExtensionProperties> =
2123
framed {
22-
val pLayerName = layerName?.let { this.utf8Adr(it) } ?: MemoryUtil.NULL
23-
var properties: Ptr = MemoryUtil.NULL
24+
val pLayerName = layerName?.let { this.utf8Adr(it) } ?: NULL
25+
var properties: Ptr = NULL
2426
val pPropertyCount = this.mInt()
2527
var propertyCount: Int
2628
var result: VkResult
@@ -32,7 +34,7 @@ interface PhysicalDevice_vk10 : Pointer {
3234
result = nEnumerateDeviceExtensionProperties(pLayerName, pPropertyCount, properties)
3335
}
3436
} while (result == VkResult.INCOMPLETE)
35-
return Array(propertyCount) {
37+
Array(propertyCount) {
3638
ExtensionProperties(BytePtr(properties + it * VkExtensionProperties.SIZEOF))
3739
}
3840
}
@@ -43,7 +45,7 @@ interface PhysicalDevice_vk10 : Pointer {
4345
// --- [ vkEnumerateDeviceLayerProperties ] ---
4446

4547
fun MemoryStack.enumerateDeviceLayerProperties(): Array<LayerProperties> = framed {
46-
var properties: Ptr = MemoryUtil.NULL
48+
var properties: Ptr = NULL
4749
var propertyCount: Int
4850
val pPropertyCount = this.mInt()
4951
var result: VkResult
@@ -55,7 +57,7 @@ interface PhysicalDevice_vk10 : Pointer {
5557
result = nEnumerateDeviceLayerProperties(pPropertyCount, properties)
5658
}
5759
} while (result == VkResult.INCOMPLETE)
58-
return Array(propertyCount) {
60+
Array(propertyCount) {
5961
LayerProperties(BytePtr(properties + it * VkLayerProperties.SIZEOF))
6062
}
6163
}
@@ -66,50 +68,152 @@ interface PhysicalDevice_vk10 : Pointer {
6668
// --- [ vkGetPhysicalDeviceFeatures ] ---
6769

6870
val MemoryStack.features: PhysicalDeviceFeatures
69-
get() = PhysicalDeviceFeatures.read(this) { nGetFeatures(it) }
71+
get() = PhysicalDeviceFeatures.read(this) { callPPV(adr, it, capabilities.vkGetPhysicalDeviceFeatures) }
7072

7173
val features: PhysicalDeviceFeatures
7274
get() = stak { it.features }
7375

7476
// --- [ vkGetPhysicalDeviceFormatProperties ] ---
7577

7678
infix fun MemoryStack.getFormatProperties(format: VkFormat): FormatProperties =
77-
framed { FormatProperties.read(this) { nGetFormatProperties(format, it) } }
79+
framed { FormatProperties.read(this) { callPPV(adr, format.i, it, capabilities.vkGetPhysicalDeviceFormatProperties) } }
7880

7981
infix fun getFormatProperties(format: VkFormat): FormatProperties =
8082
stak { it getFormatProperties format }
8183

8284
// --- [ vkGetPhysicalDeviceImageFormatProperties ] ---
8385

8486
fun MemoryStack.getImageFormatProperties(format: VkFormat, type: VkImageType, tiling: VkImageTiling, usage: VkImageUsageFlags, flags: VkImageCreateFlags): ImageFormatProperties =
85-
framed { ImageFormatProperties.read(this) { nGetImageFormatProperties(format, type, tiling, usage, flags, it) } }
87+
framed { ImageFormatProperties.read(this) { VK_CHECK_RESULT(callPPI(adr, format.i, type.i, tiling.i, usage, flags, it, capabilities.vkGetPhysicalDeviceImageFormatProperties)) } }
8688

8789
fun getImageFormatProperties(format: VkFormat, type: VkImageType, tiling: VkImageTiling, usage: VkImageUsageFlags, flags: VkImageCreateFlags): ImageFormatProperties =
8890
stak { it.getImageFormatProperties(format, type, tiling, usage, flags) }
8991

9092
// --- [ vkGetPhysicalDeviceProperties ] ---
9193

9294
val MemoryStack.properties: PhysicalDeviceProperties
93-
get() = framed { PhysicalDeviceProperties.read(this) { nGetProperties(it) } }
95+
get() = framed { PhysicalDeviceProperties.read(this) { callPPV(adr, it, capabilities.vkGetPhysicalDeviceProperties) } }
9496

9597
val properties: PhysicalDeviceProperties
9698
get() = stak { it.properties }
99+
100+
// --- [ vkGetPhysicalDeviceSparseImageFormatProperties ] ---
101+
102+
fun MemoryStack.getSparseImageFormatProperties(format: VkFormat, type: VkImageType, samples: VkSampleCount, usage: VkImageUsageFlags, tiling: VkImageTiling): Array<SparseImageFormatProperties> =
103+
framed {
104+
val pPropertyCount = this.mInt()
105+
nGetSparseImageFormatProperties(format, type, samples, usage, tiling, pPropertyCount)
106+
val propertyCount = pPropertyCount[0]
107+
val properties = this.ncalloc(VkSparseImageFormatProperties.ALIGNOF, propertyCount, VkSparseImageFormatProperties.SIZEOF)
108+
nGetSparseImageFormatProperties(format, type, samples, usage, tiling, pPropertyCount, properties)
109+
Array(propertyCount) {
110+
SparseImageFormatProperties(BytePtr(properties + it * VkSparseImageFormatProperties.SIZEOF))
111+
}
112+
}
113+
114+
fun getSparseImageFormatProperties(format: VkFormat, type: VkImageType, samples: VkSampleCount, usage: VkImageUsageFlags, tiling: VkImageTiling): Array<SparseImageFormatProperties> =
115+
stak { it.getSparseImageFormatProperties(format, type, samples, usage, tiling) }
116+
117+
// --- [ vkGetPhysicalDeviceSurfaceFormatsKHR ] ---
118+
119+
infix fun MemoryStack.getSurfaceFormatsKHR(surface: VkSurfaceKHR): MutableList<SurfaceFormatKHR> =
120+
framed {
121+
val pCount = this.mInt()
122+
nGetSurfaceFormatsKHR(surface, pCount.adr).check()
123+
val count = pCount[0]
124+
assert(count > 0)
125+
val pSurfaceFormats = this.ncalloc(VkSurfaceFormatKHR.ALIGNOF, count, VkSurfaceFormatKHR.SIZEOF)
126+
nGetSurfaceFormatsKHR(surface, pCount.adr, pSurfaceFormats).check()
127+
MutableList(count) { SurfaceFormatKHR(IntPtr(pSurfaceFormats + VkSurfaceFormatKHR.SIZEOF * it)) }
128+
}
129+
130+
infix fun getSurfaceFormatsKHR(surface: VkSurfaceKHR): MutableList<SurfaceFormatKHR> =
131+
stak { it getSurfaceFormatsKHR surface }
132+
133+
// --- [ vkGetPhysicalDeviceSurfaceSupportKHR ] ---
134+
135+
fun MemoryStack.getSurfaceSupportKHR(queueFamilySize: Int, surface: VkSurfaceKHR): BooleanArray =
136+
framed {
137+
val supported = this.mInt()
138+
BooleanArray(queueFamilySize) {
139+
VK_CHECK_RESULT(callPJPI(adr, it, surface.L, supported.adr, capabilities.vkGetPhysicalDeviceSurfaceSupportKHR))
140+
supported[0].bool
141+
}
142+
}
143+
144+
fun getSurfaceSupportKHR(queueFamilySize: Int, surface: VkSurfaceKHR): BooleanArray =
145+
stak { it.getSurfaceSupportKHR(queueFamilySize, surface) }
146+
147+
// --- [ vkGetPhysicalDeviceMemoryProperties ] ---
148+
149+
val MemoryStack.memoryProperties: PhysicalDeviceMemoryProperties
150+
get() = framed { PhysicalDeviceMemoryProperties.read(this) { callPPV(adr, it, capabilities.vkGetPhysicalDeviceMemoryProperties) } }
151+
152+
val memoryProperties: PhysicalDeviceMemoryProperties
153+
get() = stak { it.memoryProperties }
154+
155+
// --- [ vkGetPhysicalDeviceQueueFamilyProperties ] ---
156+
157+
val MemoryStack.queueFamilyProperties: Array<QueueFamilyProperties>
158+
get() = framed {
159+
val pCount = this.mInt()
160+
nGetQueueFamilyProperties(pCount.adr)
161+
val count = pCount[0]
162+
val pQueueFamilyProperties = this.ncalloc(VkQueueFamilyProperties.ALIGNOF, count, VkQueueFamilyProperties.SIZEOF)
163+
nGetQueueFamilyProperties(pCount.adr, pQueueFamilyProperties)
164+
Array(count) {
165+
QueueFamilyProperties(BytePtr(pQueueFamilyProperties + VkQueueFamilyProperties.SIZEOF * it))
166+
}
167+
}
168+
169+
val queueFamilyProperties: Array<QueueFamilyProperties>
170+
get() = stak { it.queueFamilyProperties }
171+
172+
// --- [ vkGetPhysicalDeviceSurfaceCapabilitiesKHR ] ---
173+
174+
infix fun MemoryStack.getSurfaceCapabilitiesKHR(surface: VkSurfaceKHR): SurfaceCapabilitiesKHR =
175+
framed { SurfaceCapabilitiesKHR.read(this) { VK_CHECK_RESULT(callPJPI(adr, surface.L, it, capabilities.vkGetPhysicalDeviceSurfaceCapabilitiesKHR)) } }
176+
177+
infix fun getSurfaceCapabilitiesKHR(surface: VkSurfaceKHR): SurfaceCapabilitiesKHR =
178+
stak { it getSurfaceCapabilitiesKHR surface }
179+
180+
// --- [ vkGetPhysicalDeviceSurfacePresentModesKHR ] ---
181+
182+
infix fun MemoryStack.getSurfacePresentModesKHR(surface: VkSurfaceKHR): VkPresentModeKHR_Array =
183+
framed {
184+
val pPresentModeCount = this.mInt()
185+
var propertyCount: Int
186+
var result: VkResult
187+
var pPresentModes = IntPtr.NULL
188+
do {
189+
result = nGetSurfacePresentModesKHR(surface, pPresentModeCount.adr)
190+
propertyCount = pPresentModeCount[0]
191+
if (result == VkResult.SUCCESS && propertyCount != 0) {
192+
pPresentModes = this.mInt(propertyCount)
193+
nGetSurfacePresentModesKHR(surface, pPresentModeCount.adr, pPresentModes.adr).check()
194+
}
195+
} while (result == VkResult.INCOMPLETE)
196+
VkPresentModeKHR_Array(propertyCount) { VkPresentModeKHR(pPresentModes[it]) }
197+
}
198+
199+
infix fun getSurfacePresentModesKHR(surface: VkSurfaceKHR): VkPresentModeKHR_Array =
200+
stak { it getSurfacePresentModesKHR surface }
97201
}
98202

99-
private inline fun PhysicalDevice_vk10.nEnumerateDeviceExtensionProperties(pLayerName: Ptr, pPropertyCount: IntPtr, pProperties: Ptr = MemoryUtil.NULL): VkResult =
203+
private inline fun PhysicalDevice_vk10.nEnumerateDeviceExtensionProperties(pLayerName: Ptr, pPropertyCount: IntPtr, pProperties: Ptr = NULL): VkResult =
100204
VkResult(callPPPPI(adr, pLayerName, pPropertyCount.adr, pProperties, capabilities.vkEnumerateDeviceExtensionProperties))
101205

102-
private inline fun PhysicalDevice_vk10.nEnumerateDeviceLayerProperties(pPropertyCount: IntPtr, pProperties: Ptr = MemoryUtil.NULL): VkResult =
206+
private inline fun PhysicalDevice_vk10.nEnumerateDeviceLayerProperties(pPropertyCount: IntPtr, pProperties: Ptr = NULL): VkResult =
103207
VkResult(callPPPI(adr, pPropertyCount.adr, pProperties, capabilities.vkEnumerateDeviceLayerProperties))
104208

105-
private inline infix fun PhysicalDevice_vk10.nGetFeatures(pFeatures: Adr) =
106-
callPPV(adr, pFeatures, capabilities.vkGetPhysicalDeviceFeatures)
209+
private inline fun PhysicalDevice_vk10.nGetSparseImageFormatProperties(format: VkFormat, type: VkImageType, samples: VkSampleCount, usage: VkImageUsageFlags, tiling: VkImageTiling, pPropertyCount: IntPtr, pProperties: Ptr = NULL) =
210+
callPPPV(adr, format.i, type.i, samples.i, usage, tiling.i, pPropertyCount.adr, pProperties, capabilities.vkGetPhysicalDeviceSparseImageFormatProperties)
107211

108-
private inline fun PhysicalDevice_vk10.nGetFormatProperties(format: VkFormat, pProperties: Adr) =
109-
callPPV(adr, format.i, pProperties, capabilities.vkGetPhysicalDeviceFormatProperties)
212+
private inline fun PhysicalDevice_vk10.nGetSurfaceFormatsKHR(surface: VkSurfaceKHR, pSurfaceFormatCount: Ptr, pSurfaceFormats: Ptr = NULL): VkResult =
213+
VkResult(callPJPPI(adr, surface.L, pSurfaceFormatCount, pSurfaceFormats, capabilities.vkGetPhysicalDeviceSurfaceFormatsKHR))
110214

111-
private inline fun PhysicalDevice_vk10.nGetImageFormatProperties(format: VkFormat, type: VkImageType, tiling: VkImageTiling, usage: VkImageUsageFlags, flags: VkImageCreateFlags, pProperties: Adr) =
112-
callPPI(adr, format.i, type.i, tiling.i, usage, flags, pProperties, capabilities.vkGetPhysicalDeviceImageFormatProperties)
215+
private inline fun PhysicalDevice_vk10.nGetQueueFamilyProperties(pQueueFamilyPropertyCount: Ptr, pQueueFamilyProperties: Ptr = NULL) =
216+
callPPPV(adr, pQueueFamilyPropertyCount, pQueueFamilyProperties, capabilities.vkGetPhysicalDeviceQueueFamilyProperties)
113217

114-
private inline fun PhysicalDevice_vk10.nGetProperties(pProperties: Adr) =
115-
callPPV(adr, pProperties, capabilities.vkGetPhysicalDeviceProperties)
218+
private inline fun PhysicalDevice_vk10.nGetSurfacePresentModesKHR(surface: VkSurfaceKHR, pPresentModeCount: Ptr, pPresentModes: Ptr = NULL): VkResult =
219+
VkResult(callPJPPI(adr, surface.L, pPresentModeCount, pPresentModes, capabilities.vkGetPhysicalDeviceSurfacePresentModesKHR))

0 commit comments

Comments
 (0)