Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vulkan] Module: Vulkan #51

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ jobs:
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Execute Gradle build
run: ./gradlew build
- name: Build core module
run: ./gradlew :core:build
- name: Build other modules
run: ./gradlew build --parallel
# - name: Upload build reports
# uses: actions/upload-artifact@v4
# with:
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ artifactNameMap.forEach { (subprojectName, artifactName) ->
allprojects {
tasks.withType<Javadoc> {
options {
verbose()
if (this is CoreJavadocOptions) {
if (jdkEnablePreview.toBoolean()) {
addBooleanOption("-enable-preview", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import kotlin.io.path.Path
val UPPERCASE = Regex("([A-Z])")

fun indent(indent: Int) = " ".repeat(indent)
fun removeConstPrefix(string: String) = string.removePrefix("VK_")
fun String.removeConstPrefix(): String {
val s = this.removePrefix("VK_")
return if (!s.first().isJavaIdentifierStart()) "_$s" else s
}

fun formatNumber(string: String) = string
.removeSurrounding("(", ")")
.removeSuffix("LL")
Expand Down Expand Up @@ -161,13 +165,13 @@ class VKFile(
* @since 0.1.0
*/
fun main() {
val VK10 = VKFile(
"VK10", document = """
val Vk10 = VKFile(
"Vk10", document = """
The Vulkan binding.
@since 0.1.0
""".trimIndent()
)
VK10.superclasses.add("overrun.marshal.DirectAccess")
Vk10.superclasses.add("overrun.marshal.DirectAccess")

val builder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
ClassLoader.getSystemResourceAsStream("vk.xml")!!.use { stream ->
Expand All @@ -183,8 +187,11 @@ fun main() {
}
}

fun endsWithVendor(string: String) =
vendors.firstOrNull(string::endsWith)

fun removeVendorSuffix(string: String) =
vendors.firstOrNull { string.endsWith(it) }
endsWithVendor(string)
?.let { string.removeSuffix(it) }
?: string

Expand All @@ -196,8 +203,8 @@ fun main() {
enumsNode.childNodes.forEach { node ->
if (node.nodeName == "enum") {
val attrib = node.attributes
val name = removeConstPrefix(attrib["name"].nodeValue)
val alias = attrib["alias"]?.nodeValue?.let { removeConstPrefix(it) }
val name = attrib["name"].nodeValue.removeConstPrefix()
val alias = attrib["alias"]?.nodeValue?.removeConstPrefix()
if (alias != null) {
list.add(Constant(list.find { it.name == alias }!!.type, name, alias))
} else {
Expand All @@ -206,14 +213,15 @@ fun main() {
}
}
}
list.forEach(VK10::addComponent)
list.forEach(Vk10::addComponent)
}

else -> {
when (attributes["type"].nodeValue) {
"enum" -> {
val clazz = VKFile(enumName, classType = "enum")
clazz.superinterfaces.add("overrun.marshal.CEnum")
val clazzVendor = endsWithVendor(enumName)
val prefix = "${
removeVendorSuffix(enumName)
.replace(UPPERCASE) { "_${it.groupValues[1]}" }
Expand All @@ -224,14 +232,15 @@ fun main() {
if (node.nodeName == "enum") {
val attrib = node.attributes
val name =
removeVendorSuffix(attrib["name"].nodeValue.removePrefix(prefix))
attrib["name"].nodeValue.removePrefix(prefix)
.let { if (clazzVendor == endsWithVendor(it)) removeVendorSuffix(it) else it }
.removeSuffix("_")
.removePrefix("VK_")
.removeConstPrefix()
val alias = attrib["alias"]?.nodeValue
?.removePrefix(prefix)
?.let { removeVendorSuffix(it) }
?.let { if (clazzVendor == endsWithVendor(it)) removeVendorSuffix(it) else it }
?.removeSuffix("_")
?.removePrefix("VK_")
?.removeConstPrefix()
if (alias != null) {
clazz.addComponent(
EnumValue(
Expand All @@ -246,6 +255,9 @@ fun main() {
name = name,
args = listOf(attrib["value"].nodeValue),
document = attrib["comment"]?.nodeValue
?.replace("&", "&amp;")
?.replace("<", "&lt;")
?.replace(">", "&gt;")
)
)
}
Expand All @@ -268,7 +280,7 @@ fun main() {
}
}
}
VK10.generate()
Vk10.generate()
}

private inline fun NodeList.forEach(action: (Node) -> Unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* The Vulkan binding.
* @since 0.1.0
*/
public interface VK10 extends overrun.marshal.DirectAccess {
public interface Vk10 extends overrun.marshal.DirectAccess {
int MAX_PHYSICAL_DEVICE_NAME_SIZE = 256;
int UUID_SIZE = 16;
int LUID_SIZE = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package overrungl.vulkan;

public enum VkDisplacementMicromapFormatNV implements overrun.marshal.CEnum {
64_TRIANGLES_64_BYTES(1),
256_TRIANGLES_128_BYTES(2),
1024_TRIANGLES_128_BYTES(3),
_64_TRIANGLES_64_BYTES(1),
_256_TRIANGLES_128_BYTES(2),
_1024_TRIANGLES_128_BYTES(3),
;
private final int value;
VkDisplacementMicromapFormatNV(int value) { this.value = value; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public enum VkDriverId implements overrun.marshal.CEnum {
/**
* Intel Corporation
*/
INTEL_OPEN_SOURCE(6),
INTEL_OPEN_SOURCE_MESA(6),
/**
* Imagination Technologies
*/
Expand Down Expand Up @@ -75,7 +75,7 @@ public enum VkDriverId implements overrun.marshal.CEnum {
*/
MOLTENVK(14),
/**
* Core Avionics & Industrial Inc.
* Core Avionics &amp; Industrial Inc.
*/
COREAVI_PROPRIETARY(15),
/**
Expand Down Expand Up @@ -117,7 +117,7 @@ public enum VkDriverId implements overrun.marshal.CEnum {
/**
* Imagination Technologies
*/
IMAGINATION_OPEN_SOURCE(25),
IMAGINATION_OPEN_SOURCE_MESA(25),
/**
* Mesa open source project
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
package overrungl.vulkan;

public enum VkFragmentShadingRateNV implements overrun.marshal.CEnum {
1_INVOCATION_PER_PIXEL(0),
1_INVOCATION_PER_1X2_PIXELS(1),
1_INVOCATION_PER_2X1_PIXELS(4),
1_INVOCATION_PER_2X2_PIXELS(5),
1_INVOCATION_PER_2X4_PIXELS(6),
1_INVOCATION_PER_4X2_PIXELS(9),
1_INVOCATION_PER_4X4_PIXELS(10),
2_INVOCATIONS_PER_PIXEL(11),
4_INVOCATIONS_PER_PIXEL(12),
8_INVOCATIONS_PER_PIXEL(13),
16_INVOCATIONS_PER_PIXEL(14),
_1_INVOCATION_PER_PIXEL(0),
_1_INVOCATION_PER_1X2_PIXELS(1),
_1_INVOCATION_PER_2X1_PIXELS(4),
_1_INVOCATION_PER_2X2_PIXELS(5),
_1_INVOCATION_PER_2X4_PIXELS(6),
_1_INVOCATION_PER_4X2_PIXELS(9),
_1_INVOCATION_PER_4X4_PIXELS(10),
_2_INVOCATIONS_PER_PIXEL(11),
_4_INVOCATIONS_PER_PIXEL(12),
_8_INVOCATIONS_PER_PIXEL(13),
_16_INVOCATIONS_PER_PIXEL(14),
NO_INVOCATIONS(15),
;
private final int value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package overrungl.vulkan;

public enum VkImageType implements overrun.marshal.CEnum {
1D(0),
2D(1),
3D(2),
_1D(0),
_2D(1),
_3D(2),
;
private final int value;
VkImageType(int value) { this.value = value; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
package overrungl.vulkan;

public enum VkImageViewType implements overrun.marshal.CEnum {
1D(0),
2D(1),
3D(2),
_1D(0),
_2D(1),
_3D(2),
CUBE(3),
1D_ARRAY(4),
2D_ARRAY(5),
_1D_ARRAY(4),
_2D_ARRAY(5),
CUBE_ARRAY(6),
;
private final int value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

public enum VkLineRasterizationModeKHR implements overrun.marshal.CEnum {
DEFAULT(0),
DEFAULT(DEFAULT.value),
DEFAULT_EXT(DEFAULT.value),
RECTANGULAR(1),
RECTANGULAR(RECTANGULAR.value),
RECTANGULAR_EXT(RECTANGULAR.value),
BRESENHAM(2),
BRESENHAM(BRESENHAM.value),
BRESENHAM_EXT(BRESENHAM.value),
RECTANGULAR_SMOOTH(3),
RECTANGULAR_SMOOTH(RECTANGULAR_SMOOTH.value),
RECTANGULAR_SMOOTH_EXT(RECTANGULAR_SMOOTH.value),
;
private final int value;
VkLineRasterizationModeKHR(int value) { this.value = value; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package overrungl.vulkan;

public enum VkOpacityMicromapFormatEXT implements overrun.marshal.CEnum {
2_STATE(1),
4_STATE(2),
_2_STATE(1),
_4_STATE(2),
;
private final int value;
VkOpacityMicromapFormatEXT(int value) { this.value = value; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public enum VkQueueGlobalPriorityKHR implements overrun.marshal.CEnum {
MEDIUM(256),
HIGH(512),
REALTIME(1024),
LOW(LOW.value),
MEDIUM(MEDIUM.value),
HIGH(HIGH.value),
REALTIME(REALTIME.value),
LOW_EXT(LOW.value),
MEDIUM_EXT(MEDIUM.value),
HIGH_EXT(HIGH.value),
REALTIME_EXT(REALTIME.value),
;
private final int value;
VkQueueGlobalPriorityKHR(int value) { this.value = value; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public enum VkResult implements overrun.marshal.CEnum {
*/
ERROR_INITIALIZATION_FAILED(-3),
/**
* The logical device has been lost. See <<devsandqueues-lost-device>>
* The logical device has been lost. See &lt;&lt;devsandqueues-lost-device&gt;&gt;
*/
ERROR_DEVICE_LOST(-4),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package overrungl.vulkan;

public enum VkShaderFloatControlsIndependence implements overrun.marshal.CEnum {
32_BIT_ONLY(0),
_32_BIT_ONLY(0),
ALL(1),
NONE(2),
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@

public enum VkShadingRatePaletteEntryNV implements overrun.marshal.CEnum {
NO_INVOCATIONS(0),
16_INVOCATIONS_PER_PIXEL(1),
8_INVOCATIONS_PER_PIXEL(2),
4_INVOCATIONS_PER_PIXEL(3),
2_INVOCATIONS_PER_PIXEL(4),
1_INVOCATION_PER_PIXEL(5),
1_INVOCATION_PER_2X1_PIXELS(6),
1_INVOCATION_PER_1X2_PIXELS(7),
1_INVOCATION_PER_2X2_PIXELS(8),
1_INVOCATION_PER_4X2_PIXELS(9),
1_INVOCATION_PER_2X4_PIXELS(10),
1_INVOCATION_PER_4X4_PIXELS(11),
_16_INVOCATIONS_PER_PIXEL(1),
_8_INVOCATIONS_PER_PIXEL(2),
_4_INVOCATIONS_PER_PIXEL(3),
_2_INVOCATIONS_PER_PIXEL(4),
_1_INVOCATION_PER_PIXEL(5),
_1_INVOCATION_PER_2X1_PIXELS(6),
_1_INVOCATION_PER_1X2_PIXELS(7),
_1_INVOCATION_PER_2X2_PIXELS(8),
_1_INVOCATION_PER_4X2_PIXELS(9),
_1_INVOCATION_PER_2X4_PIXELS(10),
_1_INVOCATION_PER_4X4_PIXELS(11),
;
private final int value;
VkShadingRatePaletteEntryNV(int value) { this.value = value; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public enum VkVendorId implements overrun.marshal.CEnum {
/**
* Vivante vendor ID
*/
(0x10001),
VIV(0x10001),
/**
* VeriSilicon vendor ID
*/
(0x10002),
VSI(0x10002),
/**
* Kazan Software Renderer
*/
Expand All @@ -37,7 +37,7 @@ public enum VkVendorId implements overrun.marshal.CEnum {
/**
* Mesa vendor ID
*/
(0x10005),
MESA(0x10005),
/**
* PoCL vendor ID
*/
Expand Down