diff --git a/CHANGELOG.md b/CHANGELOG.md index b9c14c437..de8e9d303 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog -## 0.10.3 (SNAPSHOT) +## 0.11.0 (SNAPSHOT) + +- Update `wgpu` from `0.19.4.1` to `22.1.0.5`. ## 0.10.2 diff --git a/README.md b/README.md index 79a0de4c6..a3ba4c160 100644 --- a/README.md +++ b/README.md @@ -74,12 +74,12 @@ repositories { kotlin { jvm { compilations.all { - kotlinOptions.jvmTarget = "21" // littlekt targets jvm 21 so we must target at least 17 + kotlinOptions.jvmTarget = "22" // littlekt snapshot targets jvm 22 } } } -val littleKtVersion = "0.10.0.a9529eb-SNAPSHOT" // or whichever hash you are using +val littleKtVersion = "0.11.0.a9529eb-SNAPSHOT" // or whichever hash you are using val kotlinCoroutinesVersion = "1.9.1" // or whatever version you are using sourceSets { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 858d1209e..5ab456bc3 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType @@ -15,14 +16,8 @@ kotlin { env = System.getProperty("env") } systemProperty("env", env ?: "dev") - jvmArgs("--enable-preview") - } - jvm { - compilations.all { - kotlinOptions.jvmTarget = "11" - compileJavaTaskProvider?.get()?.options?.compilerArgs?.add("--enable-preview") - } } + jvm { compilerOptions { jvmTarget = JvmTarget.JVM_22 } } js(KotlinJsCompilerType.IR) { browser { binaries.executable() diff --git a/core/src/commonMain/kotlin/com/littlekt/graphics/webgpu/enums.kt b/core/src/commonMain/kotlin/com/littlekt/graphics/webgpu/enums.kt index 4227078b4..5003b310c 100644 --- a/core/src/commonMain/kotlin/com/littlekt/graphics/webgpu/enums.kt +++ b/core/src/commonMain/kotlin/com/littlekt/graphics/webgpu/enums.kt @@ -33,7 +33,7 @@ enum class PrimitiveTopology { * * Vertices `0 1 2 3 4 5` create four triangles `0 1 2`, `2 1 3`, `2 3 4`, and `4 3 5`. */ - TRIANGLE_STRIP + TRIANGLE_STRIP, } /** Vertex winding order which classifies the "front" face of a triangle. */ @@ -50,7 +50,7 @@ enum class FrontFace { * * This is the default with left-handed coordinate spaces. */ - CW + CW, } /** Face of a vertex. */ @@ -62,7 +62,7 @@ enum class CullMode { FRONT, /** Back face. */ - BACK + BACK, } /** @@ -114,7 +114,7 @@ enum class TextureViewDimension { CUBE_ARRAY, /** A three-dimensional texture. */ - D3 + D3, } /** Type of data the texture holds. */ @@ -126,7 +126,7 @@ enum class TextureAspect { STENCIL_ONLY, /** Depth only. */ - DEPTH_ONLY + DEPTH_ONLY, } /** Dimensionality of a texture. */ @@ -138,7 +138,7 @@ enum class TextureDimension { D2, /** 3D texture. */ - D3 + D3, } /** @@ -313,7 +313,7 @@ enum class BlendOperation { MIN, /** max(Src, Dst) */ - MAX + MAX, } /** Operation to perform on the stencil value. */ @@ -341,7 +341,7 @@ enum class StencilOperation { /** Increments stencil value by one, wrapping on overflow. */ INCREMENT_WRAP, /** Decrements stencil value by one, wrapping on underflow. */ - DECREMENT_WRAP + DECREMENT_WRAP, } /** Alpha blend factor. */ @@ -383,7 +383,7 @@ enum class BlendFactor { CONSTANT_COLOR, /** 1.0 - Constant */ - ONE_MINUS_CONSTANT_COLOR + ONE_MINUS_CONSTANT_COLOR, } /** Format of indices used with pipeline. */ @@ -402,7 +402,7 @@ enum class VertexFormat( /** The byte size of the format. */ val bytes: Int, /** If the format uses integer or float. */ - val isInt: Boolean = false + val isInt: Boolean = false, ) { /** Two unsigned bytes. uvec2 in shaders */ UINT8x2(2, 2, true), @@ -492,7 +492,7 @@ enum class VertexFormat( SINT32x3(3, 12, true), /** four signed ints. ivec2 in shaders */ - SINT32x4(4, 16, true) + SINT32x4(4, 16, true), } /** Whether a vertex buffer is indexed by vertex or by instance. */ @@ -501,7 +501,7 @@ enum class VertexStepMode { VERTEX, /** Vertex data is advanced every instance. */ - INSTANCE + INSTANCE, } /** Operation to perform to the output attachment at the start of a render pass. */ @@ -520,7 +520,7 @@ enum class LoadOp { CLEAR, /** Loads the existing value for this attachment into the render pass. */ - LOAD + LOAD, } /** Operation to perform to the output attachment at the end of a render pass. */ @@ -538,7 +538,7 @@ enum class StoreOp { DISCARD, /** Stores the resulting value of the render pass for this attachment. */ - STORE + STORE, } /** Specific type of a buffer binding. */ @@ -575,18 +575,18 @@ enum class BufferBindingType { * var my_element: array>; * ``` */ - READ_ONLY_STORAGE + READ_ONLY_STORAGE, } enum class AddressMode { CLAMP_TO_EDGE, REPEAT, - MIRROR_REPEAT + MIRROR_REPEAT, } enum class FilterMode { NEAREST, - LINEAR + LINEAR, } /** Comparison function used for depth and stencil operations. */ @@ -620,7 +620,7 @@ enum class CompareFunction { GREATER_EQUAL, /** Function always passes. */ - ALWAYS + ALWAYS, } /** Specific type of a sample in a texture binding. */ @@ -664,7 +664,7 @@ enum class TextureSampleType { * var t: texture_2d; * ``` */ - UINT + UINT, } /** Specific type of a sampler binding. */ @@ -683,7 +683,7 @@ enum class SamplerBindingType { * analogous functionality in * [OpenGL](https://www.khronos.org/opengl/wiki/Sampler_Object#Comparison_mode). */ - COMPARISON + COMPARISON, } /** A color write mask. Disabled color channels will not be written to. */ @@ -720,7 +720,7 @@ value class ColorWriteMask(val usageFlag: Int) { /** Specifies how the alpha channel of the texture should be handled during compositing. */ enum class AlphaMode { /** - * Chooses either [Opaque] or [Inherit] automatically,depending on the `alphaMode` that the + * Chooses either [OPAQUE] or [INHERIT] automatically,depending on the `alphaMode` that the * current surface can support. */ AUTO, @@ -821,7 +821,7 @@ enum class PresentMode { * * This is traditionally called “Fast Vsync” */ - MAILBOX + MAILBOX, } /** Status of the received surface texture. */ @@ -1006,5 +1006,5 @@ enum class Feature { * (@blend_src(0) and @blend_src(1)) as inputs to a blending operation with the single color * attachment at location 0. */ - DUAL_SOURCE_BLENDING + DUAL_SOURCE_BLENDING, } diff --git a/core/src/jvmMain/kotlin/com/littlekt/LwjglContext.kt b/core/src/jvmMain/kotlin/com/littlekt/LwjglContext.kt index e7a0045c0..b6110c8a7 100644 --- a/core/src/jvmMain/kotlin/com/littlekt/LwjglContext.kt +++ b/core/src/jvmMain/kotlin/com/littlekt/LwjglContext.kt @@ -95,11 +95,11 @@ class LwjglContext(override val configuration: JvmConfiguration) : Context() { GLFW.glfwDefaultWindowHints() GLFW.glfwWindowHint( GLFW.GLFW_VISIBLE, - GLFW.GLFW_FALSE + GLFW.GLFW_FALSE, ) // the window will stay hidden after creation GLFW.glfwWindowHint( GLFW.GLFW_RESIZABLE, - configuration.resizeable.glfw + configuration.resizeable.glfw, ) // the window will be resizable GLFW.glfwWindowHint(GLFW.GLFW_MAXIMIZED, configuration.maximized.glfw) GLFW.glfwWindowHint(GLFW.GLFW_CLIENT_API, GLFW.GLFW_NO_API) // prevent opengl @@ -113,7 +113,7 @@ class LwjglContext(override val configuration: JvmConfiguration) : Context() { configuration.height, configuration.title, MemoryUtil.NULL, - MemoryUtil.NULL + MemoryUtil.NULL, ) if (windowHandle == MemoryUtil.NULL) throw RuntimeException("Failed to create the GLFW window") @@ -133,7 +133,7 @@ class LwjglContext(override val configuration: JvmConfiguration) : Context() { GLFW.glfwSetWindowPos( windowHandle, configuration.windowPosX ?: ((vidmode.width() - graphics.width) / 2), - configuration.windowPosY ?: ((vidmode.height() - graphics.height) / 2) + configuration.windowPosY ?: ((vidmode.height() - graphics.height) / 2), ) // set window icon @@ -148,7 +148,7 @@ class LwjglContext(override val configuration: JvmConfiguration) : Context() { pixmap.height, ByteBuffer.allocateDirect(pixmap.pixels.capacity) .put(pixmap.pixels.toArray()) - .flip() + .flip(), ) buffer.put(icon) icon.free() @@ -164,7 +164,7 @@ class LwjglContext(override val configuration: JvmConfiguration) : Context() { pixmap.height, ByteBuffer.allocateDirect(pixmap.pixels.capacity) .put(pixmap.pixels.toArray()) - .flip() + .flip(), ) val buffer = GLFWImage.malloc(1) buffer.put(icon) @@ -211,7 +211,7 @@ class LwjglContext(override val configuration: JvmConfiguration) : Context() { private fun initLogging() { val callback = WGPULogCallback.Function { level, message, _ -> - val messageJvm = message.getUtf8String(0) + val messageJvm = message.getString(0) val logLevel = when (level) { WGPULogLevel_Error() -> Logger.Level.ERROR diff --git a/core/src/jvmMain/kotlin/com/littlekt/LwjglGraphics.kt b/core/src/jvmMain/kotlin/com/littlekt/LwjglGraphics.kt index 7d6d5c5f9..6d670c445 100644 --- a/core/src/jvmMain/kotlin/com/littlekt/LwjglGraphics.kt +++ b/core/src/jvmMain/kotlin/com/littlekt/LwjglGraphics.kt @@ -61,7 +61,7 @@ class LwjglGraphics(private val context: LwjglContext) : Graphics, Releasable { usage: TextureUsage, format: TextureFormat, presentMode: PresentMode, - alphaMode: AlphaMode + alphaMode: AlphaMode, ) { surface.configure( SurfaceConfiguration(device, usage, format, presentMode, alphaMode, width, height) @@ -74,17 +74,17 @@ class LwjglGraphics(private val context: LwjglContext) : Graphics, Releasable { Arena.ofConfined().use { scope -> val options = WGPURequestAdapterOptions.allocate(scope) val callback = - WGPURequestAdapterCallback.allocate( + WGPUInstanceRequestAdapterCallback.allocate( { status, adapter, message, _ -> if (status == WGPURequestAdapterStatus_Success()) { output.update { adapter } } else { logger.error { - "requestAdapter status=$status, message=${message.getUtf8String(0)}" + "requestAdapter status=$status, message=${message.getString(0)}" } } }, - scope + scope, ) WGPURequestAdapterOptions.powerPreference(options, powerPreference.nativeVal) WGPURequestAdapterOptions.compatibleSurface(options, surface.segment) @@ -142,7 +142,7 @@ class LwjglGraphics(private val context: LwjglContext) : Graphics, Releasable { } WGPUChainedStruct.sType( WGPUInstanceExtras.chain(extras), - WGPUSType_InstanceExtras() + WGPUSType_InstanceExtras(), ) WGPUInstanceDescriptor.nextInChain(instanceDesc, extras) Instance(wgpuCreateInstance(instanceDesc)) @@ -163,12 +163,12 @@ class LwjglGraphics(private val context: LwjglContext) : Graphics, Releasable { val windowsDesc = WGPUSurfaceDescriptorFromWindowsHWND.allocate(scope) WGPUSurfaceDescriptorFromWindowsHWND.hwnd( windowsDesc, - MemorySegment.ofAddress(osHandle) + MemorySegment.ofAddress(osHandle), ) WGPUSurfaceDescriptorFromWindowsHWND.hinstance(windowsDesc, WGPU_NULL) WGPUChainedStruct.sType( WGPUSurfaceDescriptorFromWindowsHWND.chain(windowsDesc), - WGPUSType_SurfaceDescriptorFromWindowsHWND() + WGPUSType_SurfaceDescriptorFromWindowsHWND(), ) WGPUSurfaceDescriptor.label(desc, WGPU_NULL) WGPUSurfaceDescriptor.nextInChain(desc, windowsDesc) @@ -187,15 +187,15 @@ class LwjglGraphics(private val context: LwjglContext) : Graphics, Releasable { WGPUSurfaceDescriptorFromXlibWindow.allocate(scope) WGPUSurfaceDescriptorFromXlibWindow.display( windowsDesc, - MemorySegment.ofAddress(display) + MemorySegment.ofAddress(display), ) WGPUSurfaceDescriptorFromXlibWindow.window( windowsDesc, - osHandle + osHandle, ) WGPUChainedStruct.sType( WGPUSurfaceDescriptorFromXlibWindow.chain(windowsDesc), - WGPUSType_SurfaceDescriptorFromXlibWindow() + WGPUSType_SurfaceDescriptorFromXlibWindow(), ) WGPUSurfaceDescriptor.label(desc, WGPU_NULL) WGPUSurfaceDescriptor.nextInChain(desc, windowsDesc) @@ -212,15 +212,15 @@ class LwjglGraphics(private val context: LwjglContext) : Graphics, Releasable { WGPUSurfaceDescriptorFromWaylandSurface.allocate(scope) WGPUSurfaceDescriptorFromWaylandSurface.display( windowsDesc, - MemorySegment.ofAddress(display) + MemorySegment.ofAddress(display), ) WGPUSurfaceDescriptorFromWaylandSurface.surface( windowsDesc, - MemorySegment.ofAddress(osHandle) + MemorySegment.ofAddress(osHandle), ) WGPUChainedStruct.sType( WGPUSurfaceDescriptorFromWaylandSurface.chain(windowsDesc), - WGPUSType_SurfaceDescriptorFromWaylandSurface() + WGPUSType_SurfaceDescriptorFromWaylandSurface(), ) WGPUSurfaceDescriptor.label(desc, WGPU_NULL) WGPUSurfaceDescriptor.nextInChain(desc, windowsDesc) @@ -252,18 +252,18 @@ class LwjglGraphics(private val context: LwjglContext) : Graphics, Releasable { contentView, sel_getUid("setLayer:"), metal_layer, - objc_msgSend + objc_msgSend, ) val desc = WGPUSurfaceDescriptor.allocate(scope) val metalDesc = WGPUSurfaceDescriptorFromMetalLayer.allocate(scope) WGPUSurfaceDescriptorFromMetalLayer.layer( metalDesc, - MemorySegment.ofAddress(metal_layer) + MemorySegment.ofAddress(metal_layer), ) WGPUChainedStruct.sType( WGPUSurfaceDescriptorFromMetalLayer.chain(metalDesc), - WGPUSType_SurfaceDescriptorFromMetalLayer() + WGPUSType_SurfaceDescriptorFromMetalLayer(), ) WGPUSurfaceDescriptor.label(desc, WGPU_NULL) WGPUSurfaceDescriptor.nextInChain(desc, metalDesc) diff --git a/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/-utils.kt b/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/-utils.kt index 73c2e1b65..abb208169 100644 --- a/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/-utils.kt +++ b/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/-utils.kt @@ -9,7 +9,7 @@ internal fun Array.mapToNativeEntries( scope: SegmentAllocator, nativeSize: Long, allocator: (Long, SegmentAllocator) -> MemorySegment, - action: (entry: T, nativeEntry: MemorySegment) -> Unit + action: (entry: T, nativeEntry: MemorySegment) -> Unit, ): MemorySegment { val nativeArray = allocator(this.size.toLong(), scope) forEachIndexed { index, jvmEntry -> @@ -25,7 +25,7 @@ internal fun Collection.mapToNativeEntries( scope: SegmentAllocator, nativeSize: Long, allocator: (Long, SegmentAllocator) -> MemorySegment, - action: (entry: T, nativeEntry: MemorySegment) -> Unit + action: (entry: T, nativeEntry: MemorySegment) -> Unit, ): MemorySegment { val nativeArray = allocator(this.size.toLong(), scope) forEachIndexed { index, jvmEntry -> @@ -40,15 +40,15 @@ internal fun Collection.mapToNativeEntries( internal val WGPU_NULL: MemorySegment = WGPU.NULL() internal fun List.toNativeArray(scope: SegmentAllocator) = - scope.allocateArray(ValueLayout.JAVA_LONG, *map { it.address() }.toLongArray()) + scope.allocateFrom(ValueLayout.JAVA_LONG, *map { it.address() }.toLongArray()) -internal fun String.toNativeString(scope: SegmentAllocator) = scope.allocateUtf8String(this) +internal fun String.toNativeString(scope: SegmentAllocator) = scope.allocateFrom(this) internal fun Boolean.toInt() = if (this) 1 else 0 /** * Allocated WGPU [MemorySegment] may have a max size of [Long.MAX_VALUE]. This isn't helpful when - * we are trying to + * we are trying to create arrays or lists of items that may be small. */ internal fun MemorySegment.mapFromIntUntilNull(transform: (Int) -> T): List { val results = mutableListOf() diff --git a/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/command.jvm.kt b/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/command.jvm.kt index 5ec4183e0..c7a80fea5 100644 --- a/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/command.jvm.kt +++ b/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/command.jvm.kt @@ -68,30 +68,30 @@ actual class CommandEncoder(val segment: MemorySegment) : Releasable { WGPURenderPassDescriptor.allocate(scope).let { renderPassDesc -> WGPURenderPassDescriptor.label( renderPassDesc, - desc.label?.toNativeString(scope) ?: WGPU_NULL + desc.label?.toNativeString(scope) ?: WGPU_NULL, ) WGPURenderPassDescriptor.colorAttachmentCount( renderPassDesc, - desc.colorAttachments.size.toLong() + desc.colorAttachments.size.toLong(), ) WGPURenderPassDescriptor.colorAttachments( renderPassDesc, desc.colorAttachments.mapToNativeEntries( scope, WGPURenderPassColorAttachment.sizeof(), - WGPURenderPassColorAttachment::allocateArray + WGPURenderPassColorAttachment::allocateArray, ) { colorAttachment, nativeColorAttachment -> WGPURenderPassColorAttachment.view( nativeColorAttachment, - colorAttachment.view.segment + colorAttachment.view.segment, ) WGPURenderPassColorAttachment.loadOp( nativeColorAttachment, - colorAttachment.loadOp.nativeVal + colorAttachment.loadOp.nativeVal, ) WGPURenderPassColorAttachment.storeOp( nativeColorAttachment, - colorAttachment.storeOp.nativeVal + colorAttachment.storeOp.nativeVal, ) colorAttachment.clearColor?.let { clearColor -> WGPUColor.allocate(scope) @@ -104,11 +104,11 @@ actual class CommandEncoder(val segment: MemorySegment) : Releasable { .let { WGPURenderPassColorAttachment.clearValue( nativeColorAttachment, - it + it, ) } } - } + }, ) desc.depthStencilAttachment?.let { depthStencilAttachment -> @@ -117,60 +117,60 @@ actual class CommandEncoder(val segment: MemorySegment) : Releasable { WGPURenderPassDepthStencilAttachment.view( nativeDepthStencilAttachment, - depthStencilAttachment.view.segment + depthStencilAttachment.view.segment, ) WGPURenderPassDepthStencilAttachment.depthClearValue( nativeDepthStencilAttachment, - depthStencilAttachment.depthClearValue + depthStencilAttachment.depthClearValue, ) depthStencilAttachment.depthLoadOp?.nativeVal?.let { WGPURenderPassDepthStencilAttachment.depthLoadOp( nativeDepthStencilAttachment, - it + it, ) } depthStencilAttachment.depthStoreOp?.nativeVal?.let { WGPURenderPassDepthStencilAttachment.depthStoreOp( nativeDepthStencilAttachment, - it + it, ) } WGPURenderPassDepthStencilAttachment.depthReadOnly( nativeDepthStencilAttachment, - depthStencilAttachment.depthReadOnly.toInt() + depthStencilAttachment.depthReadOnly.toInt(), ) WGPURenderPassDepthStencilAttachment.stencilClearValue( nativeDepthStencilAttachment, - depthStencilAttachment.stencilClearValue + depthStencilAttachment.stencilClearValue, ) depthStencilAttachment.stencilLoadOp?.nativeVal?.let { WGPURenderPassDepthStencilAttachment.stencilLoadOp( nativeDepthStencilAttachment, - it + it, ) } depthStencilAttachment.stencilStoreOp?.nativeVal?.let { WGPURenderPassDepthStencilAttachment.stencilStoreOp( nativeDepthStencilAttachment, - it + it, ) } WGPURenderPassDepthStencilAttachment.depthReadOnly( nativeDepthStencilAttachment, - depthStencilAttachment.stencilReadOnly.toInt() + depthStencilAttachment.stencilReadOnly.toInt(), ) WGPURenderPassDescriptor.depthStencilAttachment( renderPassDesc, - nativeDepthStencilAttachment + nativeDepthStencilAttachment, ) } RenderPassEncoder( wgpuCommandEncoderBeginRenderPass(segment, renderPassDesc), - desc.label + desc.label, ) } } @@ -183,14 +183,14 @@ actual class CommandEncoder(val segment: MemorySegment) : Releasable { actual fun copyBufferToTexture( source: BufferCopyView, destination: TextureCopyView, - copySize: Extent3D + copySize: Extent3D, ) { Arena.ofConfined().use { scope -> wgpuCommandEncoderCopyBufferToTexture( segment, source.toNative(scope), destination.toNative(scope), - copySize.toNative(scope) + copySize.toNative(scope), ) } } @@ -208,7 +208,7 @@ actual class CommandEncoder(val segment: MemorySegment) : Releasable { destination: GPUBuffer, sourceOffset: Int, destinationOffset: Int, - size: Long + size: Long, ) { wgpuCommandEncoderCopyBufferToBuffer( segment, @@ -216,7 +216,7 @@ actual class CommandEncoder(val segment: MemorySegment) : Releasable { sourceOffset.toLong(), destination.segment, destinationOffset.toLong(), - size + size, ) } @@ -255,7 +255,7 @@ actual class RenderPassEncoder(val segment: MemorySegment, actual val label: Str instanceCount: Int, firstIndex: Int, baseVertex: Int, - firstInstance: Int + firstInstance: Int, ) { EngineStats.drawCalls++ EngineStats.triangles += (indexCount / 3) * instanceCount @@ -265,7 +265,7 @@ actual class RenderPassEncoder(val segment: MemorySegment, actual val label: Str instanceCount, firstIndex, baseVertex, - firstInstance + firstInstance, ) } @@ -273,14 +273,14 @@ actual class RenderPassEncoder(val segment: MemorySegment, actual val label: Str buffer: GPUBuffer, indexFormat: IndexFormat, offset: Long, - size: Long + size: Long, ) { wgpuRenderPassEncoderSetIndexBuffer( segment, buffer.segment, indexFormat.nativeVal, offset, - size + size, ) } @@ -288,13 +288,13 @@ actual class RenderPassEncoder(val segment: MemorySegment, actual val label: Str if (dynamicOffsets.isNotEmpty()) { Arena.ofConfined().use { scope -> val offsets = - scope.allocateArray(ValueLayout.JAVA_LONG, *dynamicOffsets.toLongArray()) + scope.allocateFrom(ValueLayout.JAVA_LONG, *dynamicOffsets.toLongArray()) wgpuRenderPassEncoderSetBindGroup( segment, index, bindGroup.segment, dynamicOffsets.size.toLong(), - offsets + offsets, ) } } else { @@ -312,7 +312,7 @@ actual class RenderPassEncoder(val segment: MemorySegment, actual val label: Str width: Int, height: Int, minDepth: Float, - maxDepth: Float + maxDepth: Float, ) { wgpuRenderPassEncoderSetViewport( segment, @@ -321,7 +321,7 @@ actual class RenderPassEncoder(val segment: MemorySegment, actual val label: Str width.toFloat(), height.toFloat(), minDepth, - maxDepth + maxDepth, ) } @@ -356,13 +356,13 @@ actual class ComputePassEncoder(val segment: MemorySegment) : Releasable { actual fun dispatchWorkgroups( workgroupCountX: Int, workgroupCountY: Int, - workgroupCountZ: Int + workgroupCountZ: Int, ) { wgpuComputePassEncoderDispatchWorkgroups( segment, workgroupCountX, workgroupCountY, - workgroupCountZ + workgroupCountZ, ) } diff --git a/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/webgpu.jvm.kt b/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/webgpu.jvm.kt index 71b78d168..e346ed348 100644 --- a/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/webgpu.jvm.kt +++ b/core/src/jvmMain/kotlin/com/littlekt/graphics/webgpu/webgpu.jvm.kt @@ -72,7 +72,7 @@ actual class Device(val segment: MemorySegment) : Releasable { maxComputeWorkgroupSizeX = WGPULimits.maxComputeWorkgroupSizeX(desc), maxComputeWorkgroupSizeY = WGPULimits.maxComputeWorkgroupSizeY(desc), maxComputeWorkgroupSizeZ = WGPULimits.maxComputeWorkgroupSizeZ(desc), - maxComputeWorkgroupsPerDimension = WGPULimits.maxComputeWorkgroupsPerDimension(desc) + maxComputeWorkgroupsPerDimension = WGPULimits.maxComputeWorkgroupsPerDimension(desc), ) } } @@ -85,7 +85,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUChainedStruct.next(wgslChain, WGPU_NULL) WGPUChainedStruct.sType(wgslChain, WGPUSType_ShaderModuleWGSLDescriptor()) - WGPUShaderModuleWGSLDescriptor.code(wgsl, scope.allocateUtf8String(src)) + WGPUShaderModuleWGSLDescriptor.code(wgsl, scope.allocateFrom(src)) WGPUShaderModuleDescriptor.nextInChain(desc, wgslChain) ShaderModule(wgpuDeviceCreateShaderModule(segment, desc)) } @@ -99,13 +99,13 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUFragmentState.module(fragDesc, desc.fragment.module.segment) WGPUFragmentState.entryPoint( fragDesc, - desc.fragment.entryPoint.toNativeString(scope) + desc.fragment.entryPoint.toNativeString(scope), ) val targets = WGPUColorTargetState.allocateArray( desc.fragment.targets.size.toLong(), - scope + scope, ) desc.fragment.targets.forEach { colorTargetState -> if (colorTargetState.blendState == null) { @@ -116,33 +116,33 @@ actual class Device(val segment: MemorySegment) : Releasable { val alphaBlend = WGPUBlendState.alpha(blendState) WGPUBlendComponent.srcFactor( colorBlend, - colorTargetState.blendState.color.srcFactor.nativeVal + colorTargetState.blendState.color.srcFactor.nativeVal, ) WGPUBlendComponent.dstFactor( colorBlend, - colorTargetState.blendState.color.dstFactor.nativeVal + colorTargetState.blendState.color.dstFactor.nativeVal, ) WGPUBlendComponent.operation( colorBlend, - colorTargetState.blendState.color.operation.nativeVal + colorTargetState.blendState.color.operation.nativeVal, ) WGPUBlendComponent.srcFactor( alphaBlend, - colorTargetState.blendState.alpha.srcFactor.nativeVal + colorTargetState.blendState.alpha.srcFactor.nativeVal, ) WGPUBlendComponent.dstFactor( alphaBlend, - colorTargetState.blendState.alpha.dstFactor.nativeVal + colorTargetState.blendState.alpha.dstFactor.nativeVal, ) WGPUBlendComponent.operation( alphaBlend, - colorTargetState.blendState.alpha.operation.nativeVal + colorTargetState.blendState.alpha.operation.nativeVal, ) WGPUColorTargetState.format(targets, colorTargetState.format.nativeVal) WGPUColorTargetState.writeMask( targets, - colorTargetState.writeMask.usageFlag + colorTargetState.writeMask.usageFlag, ) WGPUColorTargetState.blend(targets, blendState) } @@ -157,17 +157,17 @@ actual class Device(val segment: MemorySegment) : Releasable { desc.vertex.buffers.mapToNativeEntries( scope, WGPUVertexBufferLayout.sizeof(), - WGPUVertexBufferLayout::allocateArray + WGPUVertexBufferLayout::allocateArray, ) { bufferLayout, nativeBufferLayout -> val attributes = bufferLayout.attributes.mapToNativeEntries( scope, WGPUVertexAttribute.sizeof(), - WGPUVertexAttribute::allocateArray + WGPUVertexAttribute::allocateArray, ) { attribute, nativeAttribute -> WGPUVertexAttribute.shaderLocation( nativeAttribute, - attribute.shaderLocation + attribute.shaderLocation, ) WGPUVertexAttribute.format(nativeAttribute, attribute.format.nativeVal) WGPUVertexAttribute.offset(nativeAttribute, attribute.offset) @@ -176,11 +176,11 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUVertexBufferLayout.arrayStride(nativeBufferLayout, bufferLayout.arrayStride) WGPUVertexBufferLayout.stepMode( nativeBufferLayout, - bufferLayout.stepMode.nativeVal + bufferLayout.stepMode.nativeVal, ) WGPUVertexBufferLayout.attributeCount( nativeBufferLayout, - bufferLayout.attributes.size.toLong() + bufferLayout.attributes.size.toLong(), ) WGPUVertexBufferLayout.attributes(nativeBufferLayout, attributes) } @@ -192,7 +192,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPURenderPipelineDescriptor.label( descriptor, - desc.label?.toNativeString(scope) ?: WGPU_NULL + desc.label?.toNativeString(scope) ?: WGPU_NULL, ) WGPURenderPipelineDescriptor.layout(descriptor, desc.layout.segment) @@ -204,7 +204,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUPrimitiveState.topology(primitiveState, desc.primitive.topology.nativeVal) WGPUPrimitiveState.stripIndexFormat( primitiveState, - desc.primitive.stripIndexFormat?.nativeVal ?: WGPUIndexFormat_Undefined() + desc.primitive.stripIndexFormat?.nativeVal ?: WGPUIndexFormat_Undefined(), ) WGPUPrimitiveState.frontFace(primitiveState, desc.primitive.frontFace.nativeVal) WGPUPrimitiveState.cullMode(primitiveState, desc.primitive.cullMode.nativeVal) @@ -214,7 +214,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUDepthStencilState.format(depthStencilState, it.format.nativeVal) WGPUDepthStencilState.depthWriteEnabled( depthStencilState, - it.depthWriteEnabled.toInt() + it.depthWriteEnabled.toInt(), ) WGPUDepthStencilState.depthCompare(depthStencilState, it.depthCompare.nativeVal) WGPUDepthStencilState.stencilReadMask(depthStencilState, it.stencil.readMask) @@ -228,7 +228,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUStencilFaceState.failOp(stencilFront, it.stencil.front.failOp.nativeVal) WGPUStencilFaceState.depthFailOp( stencilFront, - it.stencil.front.depthFailOp.nativeVal + it.stencil.front.depthFailOp.nativeVal, ) WGPUStencilFaceState.passOp(stencilFront, it.stencil.front.passOp.nativeVal) @@ -245,7 +245,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUMultisampleState.mask(multisampleState, desc.multisample.mask) WGPUMultisampleState.alphaToCoverageEnabled( multisampleState, - desc.multisample.alphaToCoverageEnabled.toInt() + desc.multisample.alphaToCoverageEnabled.toInt(), ) WGPURenderPipelineDescriptor.fragment(descriptor, fragDesc) @@ -261,7 +261,7 @@ actual class Device(val segment: MemorySegment) : Releasable { val computeDesc = WGPUProgrammableStageDescriptor.allocate(scope) WGPUProgrammableStageDescriptor.entryPoint( computeDesc, - desc.compute.entryPoint.toNativeString(scope) + desc.compute.entryPoint.toNativeString(scope), ) WGPUProgrammableStageDescriptor.module(computeDesc, desc.compute.module.segment) @@ -269,7 +269,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUComputePipelineDescriptor.compute(wgpuDesc, computeDesc) WGPUComputePipelineDescriptor.label( wgpuDesc, - desc.label?.toNativeString(scope) ?: WGPU_NULL + desc.label?.toNativeString(scope) ?: WGPU_NULL, ) ComputePipeline(wgpuDeviceCreateComputePipeline(segment, wgpuDesc)) @@ -281,12 +281,12 @@ actual class Device(val segment: MemorySegment) : Releasable { val wgpuDesc = WGPUPipelineLayoutDescriptor.allocate(scope) WGPUPipelineLayoutDescriptor.bindGroupLayouts( wgpuDesc, - desc.segments.toNativeArray(scope) + desc.segments.toNativeArray(scope), ) WGPUPipelineLayoutDescriptor.bindGroupLayoutCount(wgpuDesc, desc.segments.size.toLong()) WGPUPipelineLayoutDescriptor.label( wgpuDesc, - desc.label?.toNativeString(scope) ?: WGPU_NULL + desc.label?.toNativeString(scope) ?: WGPU_NULL, ) PipelineLayout(wgpuDeviceCreatePipelineLayout(segment, wgpuDesc)) } @@ -297,7 +297,7 @@ actual class Device(val segment: MemorySegment) : Releasable { val descriptor = WGPUCommandEncoderDescriptor.allocate(scope) WGPUCommandEncoderDescriptor.label( descriptor, - label?.toNativeString(scope) ?: WGPU_NULL + label?.toNativeString(scope) ?: WGPU_NULL, ) CommandEncoder(wgpuDeviceCreateCommandEncoder(segment, descriptor)) } @@ -320,13 +320,13 @@ actual class Device(val segment: MemorySegment) : Releasable { val descriptor = WGPUBindGroupLayoutDescriptor.allocate(scope) WGPUBindGroupLayoutDescriptor.label( descriptor, - desc.label?.toNativeString(scope) ?: WGPU_NULL + desc.label?.toNativeString(scope) ?: WGPU_NULL, ) val entries = desc.entries.mapToNativeEntries( scope, WGPUBindGroupLayoutEntry.sizeof(), - WGPUBindGroupLayoutEntry::allocateArray + WGPUBindGroupLayoutEntry::allocateArray, ) { entry, nativeEntry -> WGPUBindGroupLayoutEntry.binding(nativeEntry, entry.binding) WGPUBindGroupLayoutEntry.visibility(nativeEntry, entry.visibility.usageFlag) @@ -339,22 +339,22 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUBufferBindingLayout.type(bufferBinding, WGPUBufferBindingType_Undefined()) WGPUSamplerBindingLayout.type( samplerBinding, - WGPUSamplerBindingType_Undefined() + WGPUSamplerBindingType_Undefined(), ) WGPUTextureBindingLayout.sampleType( textureBinding, - WGPUTextureSampleType_Undefined() + WGPUTextureSampleType_Undefined(), ) WGPUStorageTextureBindingLayout.access( storageTextureBinding, - WGPUStorageTextureAccess_Undefined() + WGPUStorageTextureAccess_Undefined(), ) entry.bindingLayout.intoNative( bufferBinding, samplerBinding, textureBinding, - storageTextureBinding + storageTextureBinding, ) } WGPUBindGroupLayoutDescriptor.entries(descriptor, entries) @@ -370,14 +370,14 @@ actual class Device(val segment: MemorySegment) : Releasable { desc.entries.mapToNativeEntries( scope, WGPUBindGroupEntry.sizeof(), - WGPUBindGroupEntry::allocateArray + WGPUBindGroupEntry::allocateArray, ) { entry, nativeEntry -> WGPUBindGroupEntry.binding(nativeEntry, entry.binding) entry.resource.intoBindingResource(nativeEntry) } WGPUBindGroupDescriptor.label( descriptor, - desc.label?.toNativeString(scope) ?: WGPU_NULL + desc.label?.toNativeString(scope) ?: WGPU_NULL, ) WGPUBindGroupDescriptor.layout(descriptor, desc.layout.segment) WGPUBindGroupDescriptor.entries(descriptor, entries) @@ -401,7 +401,7 @@ actual class Device(val segment: MemorySegment) : Releasable { WGPUSamplerDescriptor.lodMaxClamp(descriptor, desc.lodMaxClamp) WGPUSamplerDescriptor.compare( descriptor, - desc.compare?.nativeVal ?: WGPUCompareFunction_Undefined() + desc.compare?.nativeVal ?: WGPUCompareFunction_Undefined(), ) WGPUSamplerDescriptor.maxAnisotropy(descriptor, desc.maxAnisotropy) @@ -433,7 +433,7 @@ actual class Device(val segment: MemorySegment) : Releasable { actual fun createGPUShortBuffer( label: String, data: ShortArray, - usage: BufferUsage + usage: BufferUsage, ): GPUBuffer { val buffer = createBuffer( @@ -448,7 +448,7 @@ actual class Device(val segment: MemorySegment) : Releasable { actual fun createGPUFloatBuffer( label: String, data: FloatArray, - usage: BufferUsage + usage: BufferUsage, ): GPUBuffer { val buffer = createBuffer( @@ -547,8 +547,7 @@ actual class Adapter(var segment: MemorySegment) : Releasable { maxComputeWorkgroupSizeX = WGPULimits.maxComputeWorkgroupSizeX(desc), maxComputeWorkgroupSizeY = WGPULimits.maxComputeWorkgroupSizeY(desc), maxComputeWorkgroupSizeZ = WGPULimits.maxComputeWorkgroupSizeZ(desc), - maxComputeWorkgroupsPerDimension = - WGPULimits.maxComputeWorkgroupsPerDimension(desc), + maxComputeWorkgroupsPerDimension = WGPULimits.maxComputeWorkgroupsPerDimension(desc), ) } } @@ -560,17 +559,17 @@ actual class Adapter(var segment: MemorySegment) : Releasable { val deviceExtras = WGPUDeviceExtras.allocate(scope) val chainedStruct = WGPUDeviceExtras.chain(deviceExtras) val callback = - WGPURequestDeviceCallback.allocate( + WGPUAdapterRequestDeviceCallback.allocate( { status, device, message, _ -> if (status == WGPURequestAdapterStatus_Success()) { output.update { device } } else { logger.log(Logger.Level.ERROR) { - "requestDevice status=$status, message=${message.getUtf8String(0)}" + "requestDevice status=$status, message=${message.getString(0)}" } } }, - scope + scope, ) WGPUChainedStruct.sType(chainedStruct, WGPUSType_DeviceExtras()) @@ -578,7 +577,7 @@ actual class Adapter(var segment: MemorySegment) : Releasable { if (descriptor != null) { descriptor.label?.let { WGPUDeviceDescriptor.label(desc, it.toNativeString(scope)) } descriptor.requiredFeatures?.let { - val nativeArray = scope.allocateArray(ValueLayout.JAVA_INT, it.size.toLong()) + val nativeArray = scope.allocateFrom(ValueLayout.JAVA_INT, it.size) it.forEachIndexed { index, jvmEntry -> val nativeEntry = nativeArray.asSlice((Int.SIZE_BYTES * index).toLong()) @@ -681,7 +680,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { wgpuQueueSubmit( segment, cmdBuffers.size.toLong(), - cmdBuffers.map { it.segment }.toNativeArray(scope) + cmdBuffers.map { it.segment }.toNativeArray(scope), ) } } @@ -701,7 +700,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { data.segment, size, layout.toNative(scope), - copySize.toNative(scope) + copySize.toNative(scope), ) } } @@ -711,7 +710,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { data: ShortBuffer, offset: Long, dataOffset: Long, - size: Long + size: Long, ) { data as ShortBufferImpl wgpuQueueWriteBuffer( @@ -719,7 +718,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { buffer.segment, offset, if (dataOffset > 0) data.segment.asSlice(dataOffset) else data.segment, - size * Short.SIZE_BYTES + size * Short.SIZE_BYTES, ) } @@ -728,7 +727,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { data: IntBuffer, offset: Long, dataOffset: Long, - size: Long + size: Long, ) { data as IntBufferImpl wgpuQueueWriteBuffer( @@ -736,7 +735,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { buffer.segment, offset, if (dataOffset > 0) data.segment.asSlice(dataOffset) else data.segment, - size * Int.SIZE_BYTES + size * Int.SIZE_BYTES, ) } @@ -745,7 +744,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { data: FloatBuffer, offset: Long, dataOffset: Long, - size: Long + size: Long, ) { data as FloatBufferImpl wgpuQueueWriteBuffer( @@ -753,7 +752,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { buffer.segment, offset, if (dataOffset > 0) data.segment.asSlice(dataOffset) else data.segment, - size * Float.SIZE_BYTES + size * Float.SIZE_BYTES, ) } @@ -762,7 +761,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { data: ByteBuffer, offset: Long, dataOffset: Long, - size: Long + size: Long, ) { data as ByteBufferImpl wgpuQueueWriteBuffer( @@ -770,7 +769,7 @@ actual class Queue(val segment: MemorySegment) : Releasable { buffer.segment, offset, if (dataOffset > 0) data.segment.asSlice(dataOffset) else data.segment, - size + size, ) } @@ -779,16 +778,16 @@ actual class Queue(val segment: MemorySegment) : Releasable { destination: TextureCopyView, layout: TextureDataLayout, copySize: Extent3D, - size: Long + size: Long, ) { Arena.ofConfined().use { scope -> wgpuQueueWriteTexture( segment, destination.toNative(scope), - scope.allocateArray(ValueLayout.JAVA_BYTE, *data), + scope.allocateFrom(ValueLayout.JAVA_BYTE, *data), size, layout.toNative(scope), - copySize.toNative(scope) + copySize.toNative(scope), ) } } @@ -829,17 +828,19 @@ actual class Surface(val segment: MemorySegment) : Releasable { } actual fun getCurrentTexture(): SurfaceTexture { - val surfaceTexture: MemorySegment = WGPUSurfaceTexture.allocate(Arena.ofConfined()) - wgpuSurfaceGetCurrentTexture(segment, surfaceTexture) - val texture = - WGPUSurfaceTexture.texture(surfaceTexture).let { - if (it == WGPU_NULL) null else WebGPUTexture(it, it.byteSize()) - } - val status = - WGPUSurfaceTexture.status(surfaceTexture).let { - TextureStatus.from(it) ?: error("Invalid texture status: $it") - } - return SurfaceTexture(surfaceTexture, texture, status) + return Arena.ofConfined().use { scope -> + val surfaceTexture: MemorySegment = WGPUSurfaceTexture.allocate(scope) + wgpuSurfaceGetCurrentTexture(segment, surfaceTexture) + val texture = + WGPUSurfaceTexture.texture(surfaceTexture).let { + if (it == WGPU_NULL) null else WebGPUTexture(it, it.byteSize()) + } + val status = + WGPUSurfaceTexture.status(surfaceTexture).let { + TextureStatus.from(it) ?: error("Invalid texture status: $it") + } + SurfaceTexture(surfaceTexture, texture, status) + } } actual fun present() { @@ -851,21 +852,19 @@ actual class Surface(val segment: MemorySegment) : Releasable { val surfaceCapabilities = WGPUSurfaceCapabilities.allocate(scope) wgpuSurfaceGetCapabilities(segment, adapter.segment, surfaceCapabilities) val formats = - WGPUSurfaceCapabilities.formats(surfaceCapabilities).mapFromIntUntilNull { - TextureFormat.from(it) - } + WGPUSurfaceCapabilities.formats(surfaceCapabilities) + .mapFromIntUntilNull { TextureFormat.from(it) } + .distinct() val alphaModes = - WGPUSurfaceCapabilities.alphaModes(surfaceCapabilities).mapFromIntUntilNull { - AlphaMode.from(it) - } + WGPUSurfaceCapabilities.alphaModes(surfaceCapabilities) + .mapFromIntUntilNull { AlphaMode.from(it) } + .distinct() SurfaceCapabilities(surfaceCapabilities, formats, alphaModes) } } actual fun getPreferredFormat(adapter: Adapter): TextureFormat { - return wgpuSurfaceGetPreferredFormat(segment, adapter.segment).let { - TextureFormat.from(it) ?: error("Invalid TextureFormat: $") - } + return getCapabilities(adapter).formats[0] } actual override fun release() { @@ -884,7 +883,7 @@ actual class WebGPUTexture(val segment: MemorySegment, val size: Long) : Releasa WGPUTextureViewDescriptor.allocate(scope).also { WGPUTextureViewDescriptor.label( it, - desc.label?.toNativeString(scope) ?: WGPU_NULL + desc.label?.toNativeString(scope) ?: WGPU_NULL, ) WGPUTextureViewDescriptor.format(it, desc.format.nativeVal) WGPUTextureViewDescriptor.dimension(it, desc.dimension.nativeVal) @@ -972,11 +971,11 @@ fun Extent3D.toNative(scope: SegmentAllocator): MemorySegment { actual class SurfaceCapabilities( val segment: MemorySegment, actual val formats: List, - actual val alphaModes: List + actual val alphaModes: List, ) {} actual class SurfaceTexture( val segment: MemorySegment, actual val texture: WebGPUTexture?, - actual val status: TextureStatus + actual val status: TextureStatus, ) diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 2dd2da208..02fa809c7 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -1,4 +1,5 @@ import org.apache.tools.ant.taskdefs.condition.Os +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType plugins { alias(libs.plugins.kotlin.multiplatform) } @@ -6,9 +7,9 @@ plugins { alias(libs.plugins.kotlin.multiplatform) } repositories { maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") } kotlin { - tasks.withType { jvmArgs("--enable-preview", "--enable-native-access=ALL-UNNAMED") } + tasks.withType { jvmArgs("--enable-native-access=ALL-UNNAMED") } jvm { - compilations.all { kotlinOptions.jvmTarget = "21" } + compilerOptions { jvmTarget = JvmTarget.JVM_22 } compilations { val main by getting val mainClassName = "com.littlekt.examples.JvmRunnerKt" @@ -30,7 +31,7 @@ kotlin { destinationDirectory.set(File("${layout.buildDirectory.asFile.get()}/publish/")) from( main.runtimeDependencyFiles.map { if (it.isDirectory) it else zipTree(it) }, - main.output.classesDirs + main.output.classesDirs, ) doLast { logger.lifecycle( @@ -47,7 +48,7 @@ kotlin { dependsOn(mainCompile.compileAllTaskName) classpath( { mainCompile.output.allOutputs.files }, - (configurations["jvmRuntimeClasspath"]) + (configurations["jvmRuntimeClasspath"]), ) } } @@ -65,15 +66,13 @@ kotlin { (devServer ?: org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig .DevServer()) - .copy( - open = mapOf("app" to mapOf("name" to "chrome")), - ) + .copy(open = mapOf("app" to mapOf("name" to "chrome"))) } } this.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.js) - compilations.all { kotlinOptions.sourceMap = true } + compilerOptions { sourceMap = true } } sourceSets { diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/AssetProviderExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/AssetProviderExample.kt index 654ea49ef..21328cd4b 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/AssetProviderExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/AssetProviderExample.kt @@ -110,8 +110,8 @@ class AssetProviderExample(context: Context) : ContextListener(context) { arialFont.draw(it, "Hello\nLittleKt!", -300f, 0f) Fonts.default.draw(it, "Hello\nLittleKt!", 150f, 0f, align = HAlign.RIGHT) } - renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -119,7 +119,6 @@ class AssetProviderExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/FontExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/FontExample.kt index 85a83b846..6e9115ed7 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/FontExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/FontExample.kt @@ -30,7 +30,7 @@ class FontExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat) @@ -43,7 +43,7 @@ class FontExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -83,7 +83,7 @@ class FontExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) @@ -97,6 +97,7 @@ class FontExample(context: Context) : ContextListener(context) { } renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -104,7 +105,6 @@ class FontExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapCacheExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapCacheExample.kt index 38bce87de..6c3a91b4c 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapCacheExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapCacheExample.kt @@ -29,7 +29,7 @@ class LDtkTileMapCacheExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val cache = SpriteCache(device, preferredFormat) @@ -46,7 +46,7 @@ class LDtkTileMapCacheExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -65,7 +65,7 @@ class LDtkTileMapCacheExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) logger.info { "getCurrentTexture status=$status" } return@onUpdate @@ -90,7 +90,7 @@ class LDtkTileMapCacheExample(context: Context) : ContextListener(context) { view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = bgColor + clearColor = bgColor, ) ) ) @@ -100,6 +100,7 @@ class LDtkTileMapCacheExample(context: Context) : ContextListener(context) { cache.render(renderPassEncoder, camera.viewProjection) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -107,7 +108,6 @@ class LDtkTileMapCacheExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapExample.kt index 1b334740e..172319bd9 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/LDtkTileMapExample.kt @@ -33,7 +33,7 @@ class LDtkTileMapExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat, size = 400) @@ -49,7 +49,7 @@ class LDtkTileMapExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -87,7 +87,7 @@ class LDtkTileMapExample(context: Context) : ContextListener(context) { view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = bgColor + clearColor = bgColor, ) ) ) @@ -98,6 +98,7 @@ class LDtkTileMapExample(context: Context) : ContextListener(context) { world.render(it, camera, scale = 1f) } renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -105,7 +106,6 @@ class LDtkTileMapExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/MultipleTexturesExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/MultipleTexturesExample.kt index 200779404..e1a4eeae9 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/MultipleTexturesExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/MultipleTexturesExample.kt @@ -29,7 +29,7 @@ class MultipleTexturesExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat) @@ -44,7 +44,7 @@ class MultipleTexturesExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -84,7 +84,7 @@ class MultipleTexturesExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) @@ -97,6 +97,7 @@ class MultipleTexturesExample(context: Context) : ContextListener(context) { batch.flush(renderPassEncoder, camera.viewProjection) batch.end() renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -104,7 +105,6 @@ class MultipleTexturesExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/RenderSpriteBatchAndMultipleShadersExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/RenderSpriteBatchAndMultipleShadersExample.kt index 02bb3aa94..86c50eb31 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/RenderSpriteBatchAndMultipleShadersExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/RenderSpriteBatchAndMultipleShadersExample.kt @@ -67,20 +67,20 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList BindGroupLayoutDescriptor( listOf( BindGroupLayoutEntry(0, ShaderStage.FRAGMENT, TextureBindingLayout()), - BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()) + BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()), ) - ) - ) + ), + ), ) { override fun MutableList.createBindGroupsWithTexture( texture: Texture, - data: Map + data: Map, ) { add( device.createBindGroup( BindGroupDescriptor( layouts[0], - listOf(BindGroupEntry(0, cameraUniformBufferBinding)) + listOf(BindGroupEntry(0, cameraUniformBufferBinding)), ) ) ) @@ -88,7 +88,7 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList device.createBindGroup( BindGroupDescriptor( layouts[1], - listOf(BindGroupEntry(0, texture.view), BindGroupEntry(1, texture.sampler)) + listOf(BindGroupEntry(0, texture.view), BindGroupEntry(1, texture.sampler)), ) ) ) @@ -97,7 +97,7 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList override fun setBindGroups( encoder: RenderPassEncoder, bindGroups: List, - dynamicOffsets: List + dynamicOffsets: List, ) { encoder.setBindGroup(0, bindGroups[0]) encoder.setBindGroup(1, bindGroups[1]) @@ -120,7 +120,7 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat) @@ -133,13 +133,13 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList bottom = -height * 0.5f, top = height * 0.5f, near = 0f, - far = 1f + far = 1f, ) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -176,7 +176,7 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = Color.DARK_GRAY.toLinear() + clearColor = Color.DARK_GRAY.toLinear(), ) ) ) @@ -190,6 +190,7 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList batch.flush(renderPassEncoder) batch.end() renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -197,7 +198,6 @@ class RenderSpriteBatchAndMultipleShadersExample(context: Context) : ContextList graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/RenderTargetExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/RenderTargetExample.kt index 82087658e..20e967ad0 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/RenderTargetExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/RenderTargetExample.kt @@ -30,7 +30,7 @@ class RenderTargetExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat) @@ -39,7 +39,7 @@ class RenderTargetExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -77,10 +77,10 @@ class RenderTargetExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.YELLOW.toLinear() - else Color.YELLOW + else Color.YELLOW, ) ), - label = "Surface render pass" + label = "Surface render pass", ) ) @@ -88,6 +88,7 @@ class RenderTargetExample(context: Context) : ContextListener(context) { batch.draw(icon, 0f, 0f) batch.flush(renderTargetRenderPass) renderTargetRenderPass.end() + renderTargetRenderPass.release() val surfaceRenderPass = commandEncoder.beginRenderPass( @@ -99,10 +100,10 @@ class RenderTargetExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ), - label = "Surface render pass" + label = "Surface render pass", ) ) batch.draw( @@ -115,14 +116,13 @@ class RenderTargetExample(context: Context) : ContextListener(context) { batch.flush(surfaceRenderPass) batch.end() surfaceRenderPass.end() + surfaceRenderPass.release() val commandBuffer = commandEncoder.finish() device.queue.submit(commandBuffer) graphics.surface.present() - renderTargetRenderPass.release() - surfaceRenderPass.release() commandBuffer.release() commandEncoder.release() frame.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/RotatingCubeExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/RotatingCubeExample.kt index ba8c92cc7..13a8d4f33 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/RotatingCubeExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/RotatingCubeExample.kt @@ -433,7 +433,7 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - AlphaMode.OPAQUE + AlphaMode.OPAQUE, ) val projMatrix = @@ -455,7 +455,7 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { device.createGPUFloatBuffer( "mvp buffer", modelViewProjMatrix.data, - BufferUsage.UNIFORM or BufferUsage.COPY_DST + BufferUsage.UNIFORM or BufferUsage.COPY_DST, ) val shader = device.createShaderModule(shaderSrc) @@ -487,15 +487,15 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { WebGPUVertexAttribute( VertexFormat.FLOAT32x4, cubePositionOffset, - 0 + 0, ), WebGPUVertexAttribute( VertexFormat.FLOAT32x2, cubeUVOffset, - 1 - ) - ) - ) + 1, + ), + ), + ), ), fragment = FragmentState( @@ -505,8 +505,8 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { ColorTargetState( preferredFormat, BlendState.Opaque, - ColorWriteMask.ALL - ) + ColorWriteMask.ALL, + ), ), primitive = PrimitiveState(PrimitiveTopology.TRIANGLE_LIST, cullMode = CullMode.BACK), @@ -514,9 +514,9 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { DepthStencilState( format = TextureFormat.DEPTH24_PLUS, true, - CompareFunction.LESS + CompareFunction.LESS, ), - multisample = MultisampleState(1, 0xFFFFFFF, false) + multisample = MultisampleState(1, 0xFFFFFFF, false), ) ) var depthTexture = @@ -527,7 +527,7 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { 1, TextureDimension.D2, TextureFormat.DEPTH24_PLUS, - TextureUsage.RENDER_ATTACHMENT + TextureUsage.RENDER_ATTACHMENT, ) ) var depthTextureView = depthTexture.createView() @@ -547,7 +547,7 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { 1, TextureDimension.D2, TextureFormat.DEPTH24_PLUS, - TextureUsage.RENDER_ATTACHMENT + TextureUsage.RENDER_ATTACHMENT, ) ) depthTextureView = depthTexture.createView() @@ -558,7 +558,7 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { PresentMode.FIFO, AlphaMode.OPAQUE, graphics.width, - graphics.height + graphics.height, ) } if (!valid) return@onUpdate @@ -577,7 +577,7 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = Color.BLACK + clearColor = Color.BLACK, ) ), depthStencilAttachment = @@ -585,8 +585,8 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { depthTextureView, depthClearValue = 1f, depthLoadOp = LoadOp.CLEAR, - depthStoreOp = StoreOp.STORE - ) + depthStoreOp = StoreOp.STORE, + ), ) ) renderPassEncoder.setPipeline(renderPipeline) @@ -594,6 +594,7 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { renderPassEncoder.setVertexBuffer(0, vertexBuffer) renderPassEncoder.draw(cubeVertexCount, 1) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -601,7 +602,6 @@ class RotatingCubeExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/SimpleCameraExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/SimpleCameraExample.kt index 166952430..e906fd369 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/SimpleCameraExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/SimpleCameraExample.kt @@ -29,7 +29,7 @@ class SimpleCameraExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat) @@ -42,7 +42,7 @@ class SimpleCameraExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -82,7 +82,7 @@ class SimpleCameraExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) @@ -93,6 +93,7 @@ class SimpleCameraExample(context: Context) : ContextListener(context) { batch.flush(renderPassEncoder, camera.viewProjection) batch.end() renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -100,7 +101,6 @@ class SimpleCameraExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteBatchMultiPassExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteBatchMultiPassExample.kt index 712640d37..12366ef5e 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteBatchMultiPassExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteBatchMultiPassExample.kt @@ -112,6 +112,7 @@ class SpriteBatchMultiPassExample(context: Context) : ContextListener(context) { pixelFont.draw(batch, "Hello\nLittleKt!", 0f, 0f, align = HAlign.CENTER) } renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -119,7 +120,6 @@ class SpriteBatchMultiPassExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteCacheQuadsExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteCacheQuadsExample.kt index 8d085fe08..cec7ab848 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteCacheQuadsExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/SpriteCacheQuadsExample.kt @@ -44,7 +44,7 @@ class SpriteCacheQuadsExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) onResize { width, height -> @@ -53,7 +53,7 @@ class SpriteCacheQuadsExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -95,13 +95,14 @@ class SpriteCacheQuadsExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) ) cache.render(renderPassEncoder, camera.viewProjection) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -109,7 +110,6 @@ class SpriteCacheQuadsExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureBlendsExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureBlendsExample.kt index 787c1e680..ec8339ff8 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureBlendsExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureBlendsExample.kt @@ -28,7 +28,7 @@ class TextureBlendsExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat) @@ -41,13 +41,13 @@ class TextureBlendsExample(context: Context) : ContextListener(context) { bottom = -height * 0.5f, top = height * 0.5f, near = 0f, - far = 1f + far = 1f, ) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -84,7 +84,7 @@ class TextureBlendsExample(context: Context) : ContextListener(context) { view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = Color.DARK_GRAY + clearColor = Color.DARK_GRAY, ) ) ) @@ -101,16 +101,17 @@ class TextureBlendsExample(context: Context) : ContextListener(context) { graphics.width * 0.5f - logoTexture.width * 0.5f * 0.1f, 0f, scaleX = 0.1f, - scaleY = 0.1f + scaleY = 0.1f, ) batch.draw( pikaTexture, graphics.width * 0.5f - pikaTexture.width * 0.5f, - -pikaTexture.height - 10f + -pikaTexture.height - 10f, ) batch.flush(renderPassEncoder) batch.end() renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -118,7 +119,6 @@ class TextureBlendsExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureExample.kt index 890c9fa5f..25dcd371a 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureExample.kt @@ -68,7 +68,7 @@ class TextureExample(context: Context) : ContextListener(context) { 0.5f, -0.5f, 1f, - 1f + 1f, ) ) val indices = ShortBuffer(shortArrayOf(0, 1, 2, 0, 2, 3)) @@ -88,7 +88,7 @@ class TextureExample(context: Context) : ContextListener(context) { TextureDimension.D2, if (preferredFormat.srgb) TextureFormat.RGBA8_UNORM_SRGB else TextureFormat.RGBA8_UNORM, - TextureUsage.COPY_DST or TextureUsage.TEXTURE + TextureUsage.COPY_DST or TextureUsage.TEXTURE, ) ) @@ -97,7 +97,7 @@ class TextureExample(context: Context) : ContextListener(context) { data = image.pixels.toArray(), destination = TextureCopyView(texture), layout = TextureDataLayout(image.width * 4, image.height), - copySize = Extent3D(image.width, image.height, 1) + copySize = Extent3D(image.width, image.height, 1), ) val sampler = device.createSampler(SamplerDescriptor()) @@ -107,7 +107,7 @@ class TextureExample(context: Context) : ContextListener(context) { BindGroupLayoutDescriptor( listOf( BindGroupLayoutEntry(0, ShaderStage.FRAGMENT, TextureBindingLayout()), - BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()) + BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()), ) ) ) @@ -116,7 +116,7 @@ class TextureExample(context: Context) : ContextListener(context) { desc = BindGroupDescriptor( bindGroupLayout, - listOf(BindGroupEntry(0, textureView), BindGroupEntry(1, sampler)) + listOf(BindGroupEntry(0, textureView), BindGroupEntry(1, sampler)), ) ) val pipelineLayout = device.createPipelineLayout(PipelineLayoutDescriptor(bindGroupLayout)) @@ -135,10 +135,10 @@ class TextureExample(context: Context) : ContextListener(context) { WebGPUVertexAttribute( VertexFormat.FLOAT32x2, 2L * Float.SIZE_BYTES, - 1 - ) - ) - ) + 1, + ), + ), + ), ), fragment = FragmentState( @@ -148,20 +148,20 @@ class TextureExample(context: Context) : ContextListener(context) { ColorTargetState( format = preferredFormat, blendState = BlendState.NonPreMultiplied, - writeMask = ColorWriteMask.ALL - ) + writeMask = ColorWriteMask.ALL, + ), ), primitive = PrimitiveState(topology = PrimitiveTopology.TRIANGLE_LIST), depthStencil = null, multisample = - MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false) + MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false), ) val renderPipeline = device.createRenderPipeline(renderPipelineDesc) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) onUpdate { @@ -178,7 +178,7 @@ class TextureExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) logger.info { "getCurrentTexture status=$status" } return@onUpdate @@ -205,7 +205,7 @@ class TextureExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) @@ -216,6 +216,7 @@ class TextureExample(context: Context) : ContextListener(context) { renderPassEncoder.setIndexBuffer(ibo, IndexFormat.UINT16) renderPassEncoder.drawIndexed(indices.capacity, 1) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -223,7 +224,6 @@ class TextureExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshAndCameraExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshAndCameraExample.kt index 393ec7801..662d7bd0e 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshAndCameraExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshAndCameraExample.kt @@ -93,7 +93,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { device.createGPUFloatBuffer( "camera uniform buffer", cameraFloatBuffer.toArray(), - BufferUsage.UNIFORM or BufferUsage.COPY_DST + BufferUsage.UNIFORM or BufferUsage.COPY_DST, ) val shader = device.createShaderModule(textureShader) @@ -112,7 +112,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { device.createBindGroup( BindGroupDescriptor( vertexGroupLayout, - listOf(BindGroupEntry(0, BufferBinding(cameraUniformBuffer))) + listOf(BindGroupEntry(0, BufferBinding(cameraUniformBuffer))), ) ) val fragmentGroupLayout = @@ -120,7 +120,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { BindGroupLayoutDescriptor( listOf( BindGroupLayoutEntry(0, ShaderStage.FRAGMENT, TextureBindingLayout()), - BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()) + BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()), ) ) ) @@ -129,7 +129,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { desc = BindGroupDescriptor( fragmentGroupLayout, - listOf(BindGroupEntry(0, texture.view), BindGroupEntry(1, texture.sampler)) + listOf(BindGroupEntry(0, texture.view), BindGroupEntry(1, texture.sampler)), ) ) val pipelineLayout = @@ -143,7 +143,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { VertexState( module = shader, entryPoint = "vs_main", - mesh.geometry.layout.gpuVertexBufferLayout + mesh.geometry.layout.gpuVertexBufferLayout, ), fragment = FragmentState( @@ -153,20 +153,20 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { ColorTargetState( format = preferredFormat, blendState = BlendState.NonPreMultiplied, - writeMask = ColorWriteMask.ALL - ) + writeMask = ColorWriteMask.ALL, + ), ), primitive = PrimitiveState(topology = PrimitiveTopology.TRIANGLE_LIST), depthStencil = null, multisample = - MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false) + MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false), ) val renderPipeline = device.createRenderPipeline(renderPipelineDesc) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) onResize { width, height -> @@ -175,7 +175,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -219,7 +219,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) @@ -231,6 +231,7 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { renderPassEncoder.setIndexBuffer(mesh.ibo, IndexFormat.UINT16) renderPassEncoder.drawIndexed(6, 1) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -238,7 +239,6 @@ class TextureMeshAndCameraExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshExample.kt index 67713dcf0..0029eb36a 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureMeshExample.kt @@ -85,7 +85,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { TextureDimension.D2, if (preferredFormat.srgb) TextureFormat.RGBA8_UNORM_SRGB else TextureFormat.RGBA8_UNORM, - TextureUsage.COPY_DST or TextureUsage.TEXTURE + TextureUsage.COPY_DST or TextureUsage.TEXTURE, ) ) @@ -94,7 +94,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { data = image.pixels.toArray(), destination = TextureCopyView(texture), layout = TextureDataLayout(image.width * 4, image.height), - copySize = Extent3D(image.width, image.height, 1) + copySize = Extent3D(image.width, image.height, 1), ) val sampler = device.createSampler(SamplerDescriptor()) @@ -104,7 +104,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { BindGroupLayoutDescriptor( listOf( BindGroupLayoutEntry(0, ShaderStage.FRAGMENT, TextureBindingLayout()), - BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()) + BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()), ) ) ) @@ -113,7 +113,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { desc = BindGroupDescriptor( bindGroupLayout, - listOf(BindGroupEntry(0, textureView), BindGroupEntry(1, sampler)) + listOf(BindGroupEntry(0, textureView), BindGroupEntry(1, sampler)), ) ) val pipelineLayout = device.createPipelineLayout(PipelineLayoutDescriptor(bindGroupLayout)) @@ -124,7 +124,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { VertexState( module = shader, entryPoint = "vs_main", - mesh.geometry.layout.gpuVertexBufferLayout + mesh.geometry.layout.gpuVertexBufferLayout, ), fragment = FragmentState( @@ -134,20 +134,20 @@ class TextureMeshExample(context: Context) : ContextListener(context) { ColorTargetState( format = preferredFormat, blendState = BlendState.NonPreMultiplied, - writeMask = ColorWriteMask.ALL - ) + writeMask = ColorWriteMask.ALL, + ), ), primitive = PrimitiveState(topology = PrimitiveTopology.TRIANGLE_LIST), depthStencil = null, multisample = - MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false) + MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false), ) val renderPipeline = device.createRenderPipeline(renderPipelineDesc) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) onUpdate { @@ -164,7 +164,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) logger.info { "getCurrentTexture status=$status" } return@onUpdate @@ -191,7 +191,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) @@ -202,6 +202,7 @@ class TextureMeshExample(context: Context) : ContextListener(context) { renderPassEncoder.setIndexBuffer(mesh.ibo, IndexFormat.UINT16) renderPassEncoder.drawIndexed(6, 1) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -209,7 +210,6 @@ class TextureMeshExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureViaCommandEncoderExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureViaCommandEncoderExample.kt index 6a6ba7bbc..4cce7f0cf 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TextureViaCommandEncoderExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TextureViaCommandEncoderExample.kt @@ -66,7 +66,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex 0.5f, -0.5f, 1f, - 1f + 1f, ) val indices = shortArrayOf(0, 1, 2, 0, 2, 3) // @formatter:on @@ -85,7 +85,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex 1, TextureDimension.D2, TextureFormat.RGBA8_UNORM_SRGB, - TextureUsage.COPY_DST or TextureUsage.TEXTURE + TextureUsage.COPY_DST or TextureUsage.TEXTURE, ) ) @@ -97,7 +97,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex commandEncoder.copyBufferToTexture( BufferCopyView(textureBuffer, TextureDataLayout(image.width * 4, image.height)), TextureCopyView(texture), - Extent3D(image.width, image.height, 1) + Extent3D(image.width, image.height, 1), ) queue.submit(commandEncoder.finish()) textureBuffer.destroy() @@ -110,7 +110,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex BindGroupLayoutDescriptor( listOf( BindGroupLayoutEntry(0, ShaderStage.FRAGMENT, TextureBindingLayout()), - BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()) + BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()), ) ) ) @@ -119,7 +119,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex desc = BindGroupDescriptor( bindGroupLayout, - listOf(BindGroupEntry(0, textureView), BindGroupEntry(1, sampler)) + listOf(BindGroupEntry(0, textureView), BindGroupEntry(1, sampler)), ) ) val pipelineLayout = device.createPipelineLayout(PipelineLayoutDescriptor(bindGroupLayout)) @@ -138,10 +138,10 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex WebGPUVertexAttribute( VertexFormat.FLOAT32x2, 2L * Float.SIZE_BYTES, - 1 - ) - ) - ) + 1, + ), + ), + ), ), fragment = FragmentState( @@ -151,20 +151,20 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex ColorTargetState( format = preferredFormat, blendState = BlendState.NonPreMultiplied, - writeMask = ColorWriteMask.ALL - ) + writeMask = ColorWriteMask.ALL, + ), ), primitive = PrimitiveState(topology = PrimitiveTopology.TRIANGLE_LIST), depthStencil = null, multisample = - MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false) + MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false), ) val renderPipeline = device.createRenderPipeline(renderPipelineDesc) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) onUpdate { @@ -181,7 +181,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) logger.info { "getCurrentTexture status=$status" } return@onUpdate @@ -206,7 +206,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = Color.CLEAR + clearColor = Color.CLEAR, ) ) ) @@ -217,6 +217,7 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex renderPassEncoder.setIndexBuffer(ibo, IndexFormat.UINT16) renderPassEncoder.drawIndexed(indices.size, 1) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -224,7 +225,6 @@ class TextureViaCommandEncoderExample(context: Context) : ContextListener(contex graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TiledMeshExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TiledMeshExample.kt index 98ad0728f..968b6415d 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TiledMeshExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TiledMeshExample.kt @@ -111,7 +111,7 @@ class TiledMeshExample(context: Context) : ContextListener(context) { device.createGPUFloatBuffer( "camera uniform buffer", cameraFloatBuffer.toArray(), - BufferUsage.UNIFORM or BufferUsage.COPY_DST + BufferUsage.UNIFORM or BufferUsage.COPY_DST, ) val shader = device.createShaderModule(textureShader) @@ -130,7 +130,7 @@ class TiledMeshExample(context: Context) : ContextListener(context) { device.createBindGroup( BindGroupDescriptor( vertexGroupLayout, - listOf(BindGroupEntry(0, BufferBinding(cameraUniformBuffer))) + listOf(BindGroupEntry(0, BufferBinding(cameraUniformBuffer))), ) ) val fragmentGroupLayout = @@ -138,7 +138,7 @@ class TiledMeshExample(context: Context) : ContextListener(context) { BindGroupLayoutDescriptor( listOf( BindGroupLayoutEntry(0, ShaderStage.FRAGMENT, TextureBindingLayout()), - BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()) + BindGroupLayoutEntry(1, ShaderStage.FRAGMENT, SamplerBindingLayout()), ) ) ) @@ -149,8 +149,8 @@ class TiledMeshExample(context: Context) : ContextListener(context) { fragmentGroupLayout, listOf( BindGroupEntry(0, Textures.white.texture.view), - BindGroupEntry(1, Textures.white.texture.sampler) - ) + BindGroupEntry(1, Textures.white.texture.sampler), + ), ) ) val pipelineLayout = @@ -164,7 +164,7 @@ class TiledMeshExample(context: Context) : ContextListener(context) { VertexState( module = shader, entryPoint = "vs_main", - mesh.geometry.layout.gpuVertexBufferLayout + mesh.geometry.layout.gpuVertexBufferLayout, ), fragment = FragmentState( @@ -174,20 +174,20 @@ class TiledMeshExample(context: Context) : ContextListener(context) { ColorTargetState( format = preferredFormat, blendState = BlendState.NonPreMultiplied, - writeMask = ColorWriteMask.ALL - ) + writeMask = ColorWriteMask.ALL, + ), ), primitive = PrimitiveState(topology = PrimitiveTopology.TRIANGLE_LIST), depthStencil = null, multisample = - MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false) + MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false), ) val renderPipeline = device.createRenderPipeline(renderPipelineDesc) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) onResize { width, height -> @@ -197,7 +197,7 @@ class TiledMeshExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -241,7 +241,7 @@ class TiledMeshExample(context: Context) : ContextListener(context) { storeOp = StoreOp.STORE, clearColor = if (preferredFormat.srgb) Color.DARK_GRAY.toLinear() - else Color.DARK_GRAY + else Color.DARK_GRAY, ) ) ) @@ -254,6 +254,7 @@ class TiledMeshExample(context: Context) : ContextListener(context) { EngineStats.extra("Quads", totalQuads) renderPassEncoder.drawIndexed(totalQuads * 6, 1) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -261,7 +262,6 @@ class TiledMeshExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapCacheExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapCacheExample.kt index 0789b86bd..b46eef4cf 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapCacheExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapCacheExample.kt @@ -29,7 +29,7 @@ class TiledTileMapCacheExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val cache = SpriteCache(device, preferredFormat) @@ -47,7 +47,7 @@ class TiledTileMapCacheExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -85,7 +85,7 @@ class TiledTileMapCacheExample(context: Context) : ContextListener(context) { view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = bgColor + clearColor = bgColor, ) ) ) @@ -94,6 +94,7 @@ class TiledTileMapCacheExample(context: Context) : ContextListener(context) { map.updateCachedAnimationTiles(cache) cache.render(renderPassEncoder, camera.viewProjection) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -101,7 +102,6 @@ class TiledTileMapCacheExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapExample.kt index 1020dfce5..7aada23da 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TiledTileMapExample.kt @@ -31,7 +31,7 @@ class TiledTileMapExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) val batch = SpriteBatch(device, graphics, preferredFormat, 2000) @@ -49,7 +49,7 @@ class TiledTileMapExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) } @@ -87,7 +87,7 @@ class TiledTileMapExample(context: Context) : ContextListener(context) { view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = bgColor + clearColor = bgColor, ) ) ) @@ -101,10 +101,11 @@ class TiledTileMapExample(context: Context) : ContextListener(context) { camera, scale = 1 / 8f, displayObjects = true, - shapeRenderer = shapeRenderer + shapeRenderer = shapeRenderer, ) } renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -112,7 +113,6 @@ class TiledTileMapExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() swapChainTexture.release() diff --git a/examples/src/commonMain/kotlin/com/littlekt/examples/TriangleExample.kt b/examples/src/commonMain/kotlin/com/littlekt/examples/TriangleExample.kt index 18262c7ab..8c9c6472c 100644 --- a/examples/src/commonMain/kotlin/com/littlekt/examples/TriangleExample.kt +++ b/examples/src/commonMain/kotlin/com/littlekt/examples/TriangleExample.kt @@ -49,20 +49,20 @@ class TriangleExample(context: Context) : ContextListener(context) { ColorTargetState( format = preferredFormat, blendState = BlendState.Opaque, - writeMask = ColorWriteMask.ALL - ) + writeMask = ColorWriteMask.ALL, + ), ), primitive = PrimitiveState(topology = PrimitiveTopology.TRIANGLE_LIST), depthStencil = null, multisample = - MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false) + MultisampleState(count = 1, mask = 0xFFFFFFF, alphaToCoverageEnabled = false), ) val renderPipeline = device.createRenderPipeline(renderPipelineDesc) graphics.configureSurface( TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) onUpdate { @@ -79,7 +79,7 @@ class TriangleExample(context: Context) : ContextListener(context) { TextureUsage.RENDER_ATTACHMENT, preferredFormat, PresentMode.FIFO, - surfaceCapabilities.alphaModes[0] + surfaceCapabilities.alphaModes[0], ) logger.info { "getCurrentTexture status=$status" } return@onUpdate @@ -103,7 +103,7 @@ class TriangleExample(context: Context) : ContextListener(context) { view = frame, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, - clearColor = Color.CLEAR + clearColor = Color.CLEAR, ) ) ) @@ -111,6 +111,7 @@ class TriangleExample(context: Context) : ContextListener(context) { renderPassEncoder.setPipeline(renderPipeline) renderPassEncoder.draw(3, 1, 0, 0) renderPassEncoder.end() + renderPassEncoder.release() val commandBuffer = commandEncoder.finish() @@ -118,7 +119,6 @@ class TriangleExample(context: Context) : ContextListener(context) { graphics.surface.present() commandBuffer.release() - renderPassEncoder.release() commandEncoder.release() frame.release() texture.release() diff --git a/extensions/tools/build.gradle.kts b/extensions/tools/build.gradle.kts index 09cda4ae2..55cdbb70d 100644 --- a/extensions/tools/build.gradle.kts +++ b/extensions/tools/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType @@ -11,7 +12,7 @@ repositories { mavenCentral() } kotlin { jvm { - compilations.all { kotlinOptions.jvmTarget = "11" } + compilerOptions { jvmTarget = JvmTarget.JVM_22 } testRuns["test"].executionTask.configure { useJUnit() } } js(KotlinJsCompilerType.IR) { diff --git a/gradle.properties b/gradle.properties index 55a25e958..7bd9fb1d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ kotlin.mpp.enableCInteropCommonization=true android.useAndroidX=true android.nonTransitiveRClass=true #Wgpu-native -webgpuHeadersSHA=d02fec1b96af29695b9f5659a91067a241f40b04 -wgpuNativeVersion=0.19.4.1 +webgpuHeadersSHA=043af6c77e566f707db36759d9c9f161ebb616fd +wgpuNativeVersion=22.1.0.5 #LittleKT -littleKtVersion=0.10.3-SNAPSHOT \ No newline at end of file +littleKtVersion=0.11.0-SNAPSHOT \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 20db9ad5c..4eaec4670 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/scene-graph/build.gradle.kts b/scene-graph/build.gradle.kts index 3d3a557dc..69a83f8e6 100644 --- a/scene-graph/build.gradle.kts +++ b/scene-graph/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType @@ -7,13 +8,8 @@ plugins { } kotlin { - tasks.withType { jvmArgs("--enable-preview", "--enable-native-access=ALL-UNNAMED") } - jvm { - compilations.all { - kotlinOptions.jvmTarget = "11" - compileJavaTaskProvider?.get()?.options?.compilerArgs?.add("--enable-preview") - } - } + tasks.withType { jvmArgs("--enable-native-access=ALL-UNNAMED") } + jvm { compilerOptions { jvmTarget = JvmTarget.JVM_22 } } js(KotlinJsCompilerType.IR) { browser { binaries.executable() @@ -22,7 +18,7 @@ kotlin { this.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.js) - compilations.all { kotlinOptions.sourceMap = true } + compilerOptions { sourceMap = true } } sourceSets { diff --git a/wgpu-ffm/README.md b/wgpu-ffm/README.md index 1ccd242d8..5115c3b38 100644 --- a/wgpu-ffm/README.md +++ b/wgpu-ffm/README.md @@ -4,4 +4,4 @@ **JDK22: cmd.exe** -`jextract -t com.littlekt.wgpu --output ./wgpuj/src/main/java --header-class-name WGPU wgpu-natives/src/main/c/wgpu.h` \ No newline at end of file +`jextract -t com.littlekt.wgpu --output ./wgpu-ffm/src/main/java --header-class-name WGPU wgpu-natives/src/main/c/wgpu.h` \ No newline at end of file diff --git a/wgpu-ffm/build.gradle.kts b/wgpu-ffm/build.gradle.kts index f49afb7b4..4596123db 100644 --- a/wgpu-ffm/build.gradle.kts +++ b/wgpu-ffm/build.gradle.kts @@ -3,13 +3,9 @@ plugins { id("module.publication") } -tasks.withType { jvmArgs("--enable-preview") } - -tasks.withType { options.compilerArgs.add("--enable-preview") } - java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_22 + targetCompatibility = JavaVersion.VERSION_22 withSourcesJar() } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPU.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPU.java index 075bc68c5..d16d3bc98 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPU.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPU.java @@ -1674,19 +1674,19 @@ public static int WGPUCullMode_Back() { public static int WGPUCullMode_Force32() { return WGPUCullMode_Force32; } - private static final int WGPUDeviceLostReason_Undefined = (int)0L; + private static final int WGPUDeviceLostReason_Unknown = (int)1L; /** * {@snippet lang=c : - * enum WGPUDeviceLostReason.WGPUDeviceLostReason_Undefined = 0 + * enum WGPUDeviceLostReason.WGPUDeviceLostReason_Unknown = 1 * } */ - public static int WGPUDeviceLostReason_Undefined() { - return WGPUDeviceLostReason_Undefined; + public static int WGPUDeviceLostReason_Unknown() { + return WGPUDeviceLostReason_Unknown; } - private static final int WGPUDeviceLostReason_Destroyed = (int)1L; + private static final int WGPUDeviceLostReason_Destroyed = (int)2L; /** * {@snippet lang=c : - * enum WGPUDeviceLostReason.WGPUDeviceLostReason_Destroyed = 1 + * enum WGPUDeviceLostReason.WGPUDeviceLostReason_Destroyed = 2 * } */ public static int WGPUDeviceLostReason_Destroyed() { @@ -4149,6 +4149,60 @@ public static int WGPUVertexStepMode_VertexBufferNotUsed() { public static int WGPUVertexStepMode_Force32() { return WGPUVertexStepMode_Force32; } + private static final int WGPUWGSLFeatureName_Undefined = (int)0L; + /** + * {@snippet lang=c : + * enum WGPUWGSLFeatureName.WGPUWGSLFeatureName_Undefined = 0 + * } + */ + public static int WGPUWGSLFeatureName_Undefined() { + return WGPUWGSLFeatureName_Undefined; + } + private static final int WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures = (int)1L; + /** + * {@snippet lang=c : + * enum WGPUWGSLFeatureName.WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures = 1 + * } + */ + public static int WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures() { + return WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures; + } + private static final int WGPUWGSLFeatureName_Packed4x8IntegerDotProduct = (int)2L; + /** + * {@snippet lang=c : + * enum WGPUWGSLFeatureName.WGPUWGSLFeatureName_Packed4x8IntegerDotProduct = 2 + * } + */ + public static int WGPUWGSLFeatureName_Packed4x8IntegerDotProduct() { + return WGPUWGSLFeatureName_Packed4x8IntegerDotProduct; + } + private static final int WGPUWGSLFeatureName_UnrestrictedPointerParameters = (int)3L; + /** + * {@snippet lang=c : + * enum WGPUWGSLFeatureName.WGPUWGSLFeatureName_UnrestrictedPointerParameters = 3 + * } + */ + public static int WGPUWGSLFeatureName_UnrestrictedPointerParameters() { + return WGPUWGSLFeatureName_UnrestrictedPointerParameters; + } + private static final int WGPUWGSLFeatureName_PointerCompositeAccess = (int)4L; + /** + * {@snippet lang=c : + * enum WGPUWGSLFeatureName.WGPUWGSLFeatureName_PointerCompositeAccess = 4 + * } + */ + public static int WGPUWGSLFeatureName_PointerCompositeAccess() { + return WGPUWGSLFeatureName_PointerCompositeAccess; + } + private static final int WGPUWGSLFeatureName_Force32 = (int)2147483647L; + /** + * {@snippet lang=c : + * enum WGPUWGSLFeatureName.WGPUWGSLFeatureName_Force32 = 2147483647 + * } + */ + public static int WGPUWGSLFeatureName_Force32() { + return WGPUWGSLFeatureName_Force32; + } private static final int WGPUBufferUsage_None = (int)0L; /** * {@snippet lang=c : @@ -4671,14 +4725,13 @@ public static long wgpuAdapterEnumerateFeatures(MemorySegment adapter, MemorySeg } } - private static class wgpuAdapterGetLimits { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - WGPU.C_INT, + private static class wgpuAdapterGetInfo { + public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( WGPU.C_POINTER, WGPU.C_POINTER ); - public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuAdapterGetLimits"); + public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuAdapterGetInfo"); public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); } @@ -4686,57 +4739,58 @@ private static class wgpuAdapterGetLimits { /** * Function descriptor for: * {@snippet lang=c : - * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) + * void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo *info) * } */ - public static FunctionDescriptor wgpuAdapterGetLimits$descriptor() { - return wgpuAdapterGetLimits.DESC; + public static FunctionDescriptor wgpuAdapterGetInfo$descriptor() { + return wgpuAdapterGetInfo.DESC; } /** * Downcall method handle for: * {@snippet lang=c : - * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) + * void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo *info) * } */ - public static MethodHandle wgpuAdapterGetLimits$handle() { - return wgpuAdapterGetLimits.HANDLE; + public static MethodHandle wgpuAdapterGetInfo$handle() { + return wgpuAdapterGetInfo.HANDLE; } /** * Address for: * {@snippet lang=c : - * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) + * void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo *info) * } */ - public static MemorySegment wgpuAdapterGetLimits$address() { - return wgpuAdapterGetLimits.ADDR; + public static MemorySegment wgpuAdapterGetInfo$address() { + return wgpuAdapterGetInfo.ADDR; } /** * {@snippet lang=c : - * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) + * void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo *info) * } */ - public static int wgpuAdapterGetLimits(MemorySegment adapter, MemorySegment limits) { - var mh$ = wgpuAdapterGetLimits.HANDLE; + public static void wgpuAdapterGetInfo(MemorySegment adapter, MemorySegment info) { + var mh$ = wgpuAdapterGetInfo.HANDLE; try { if (TRACE_DOWNCALLS) { - traceDowncall("wgpuAdapterGetLimits", adapter, limits); + traceDowncall("wgpuAdapterGetInfo", adapter, info); } - return (int)mh$.invokeExact(adapter, limits); + mh$.invokeExact(adapter, info); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } } - private static class wgpuAdapterGetProperties { - public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( + private static class wgpuAdapterGetLimits { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + WGPU.C_INT, WGPU.C_POINTER, WGPU.C_POINTER ); - public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuAdapterGetProperties"); + public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuAdapterGetLimits"); public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); } @@ -4744,45 +4798,45 @@ private static class wgpuAdapterGetProperties { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties *properties) + * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) * } */ - public static FunctionDescriptor wgpuAdapterGetProperties$descriptor() { - return wgpuAdapterGetProperties.DESC; + public static FunctionDescriptor wgpuAdapterGetLimits$descriptor() { + return wgpuAdapterGetLimits.DESC; } /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties *properties) + * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) * } */ - public static MethodHandle wgpuAdapterGetProperties$handle() { - return wgpuAdapterGetProperties.HANDLE; + public static MethodHandle wgpuAdapterGetLimits$handle() { + return wgpuAdapterGetLimits.HANDLE; } /** * Address for: * {@snippet lang=c : - * void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties *properties) + * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) * } */ - public static MemorySegment wgpuAdapterGetProperties$address() { - return wgpuAdapterGetProperties.ADDR; + public static MemorySegment wgpuAdapterGetLimits$address() { + return wgpuAdapterGetLimits.ADDR; } /** * {@snippet lang=c : - * void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties *properties) + * WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits *limits) * } */ - public static void wgpuAdapterGetProperties(MemorySegment adapter, MemorySegment properties) { - var mh$ = wgpuAdapterGetProperties.HANDLE; + public static int wgpuAdapterGetLimits(MemorySegment adapter, MemorySegment limits) { + var mh$ = wgpuAdapterGetLimits.HANDLE; try { if (TRACE_DOWNCALLS) { - traceDowncall("wgpuAdapterGetProperties", adapter, properties); + traceDowncall("wgpuAdapterGetLimits", adapter, limits); } - mh$.invokeExact(adapter, properties); + return (int)mh$.invokeExact(adapter, limits); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } @@ -4863,7 +4917,7 @@ private static class wgpuAdapterRequestDevice { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPURequestDeviceCallback callback, void *userdata) + * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPUAdapterRequestDeviceCallback callback, void *userdata) * } */ public static FunctionDescriptor wgpuAdapterRequestDevice$descriptor() { @@ -4873,7 +4927,7 @@ private static class wgpuAdapterRequestDevice { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPURequestDeviceCallback callback, void *userdata) + * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPUAdapterRequestDeviceCallback callback, void *userdata) * } */ public static MethodHandle wgpuAdapterRequestDevice$handle() { @@ -4883,7 +4937,7 @@ private static class wgpuAdapterRequestDevice { /** * Address for: * {@snippet lang=c : - * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPURequestDeviceCallback callback, void *userdata) + * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPUAdapterRequestDeviceCallback callback, void *userdata) * } */ public static MemorySegment wgpuAdapterRequestDevice$address() { @@ -4892,7 +4946,7 @@ private static class wgpuAdapterRequestDevice { /** * {@snippet lang=c : - * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPURequestDeviceCallback callback, void *userdata) + * void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor *descriptor, WGPUAdapterRequestDeviceCallback callback, void *userdata) * } */ public static void wgpuAdapterRequestDevice(MemorySegment adapter, MemorySegment descriptor, MemorySegment callback, MemorySegment userdata) { @@ -5021,6 +5075,63 @@ public static void wgpuAdapterRelease(MemorySegment adapter) { } } + private static class wgpuAdapterInfoFreeMembers { + public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( + WGPUAdapterInfo.layout() + ); + + public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuAdapterInfoFreeMembers"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) + * } + */ + public static FunctionDescriptor wgpuAdapterInfoFreeMembers$descriptor() { + return wgpuAdapterInfoFreeMembers.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) + * } + */ + public static MethodHandle wgpuAdapterInfoFreeMembers$handle() { + return wgpuAdapterInfoFreeMembers.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) + * } + */ + public static MemorySegment wgpuAdapterInfoFreeMembers$address() { + return wgpuAdapterInfoFreeMembers.ADDR; + } + + /** + * {@snippet lang=c : + * void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) + * } + */ + public static void wgpuAdapterInfoFreeMembers(MemorySegment adapterInfo) { + var mh$ = wgpuAdapterInfoFreeMembers.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("wgpuAdapterInfoFreeMembers", adapterInfo); + } + mh$.invokeExact(adapterInfo); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static class wgpuBindGroupSetLabel { public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( WGPU.C_POINTER, @@ -5734,7 +5845,7 @@ private static class wgpuBufferMapAsync { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void *userdata) + * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, void *userdata) * } */ public static FunctionDescriptor wgpuBufferMapAsync$descriptor() { @@ -5744,7 +5855,7 @@ private static class wgpuBufferMapAsync { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void *userdata) + * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, void *userdata) * } */ public static MethodHandle wgpuBufferMapAsync$handle() { @@ -5754,7 +5865,7 @@ private static class wgpuBufferMapAsync { /** * Address for: * {@snippet lang=c : - * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void *userdata) + * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, void *userdata) * } */ public static MemorySegment wgpuBufferMapAsync$address() { @@ -5763,7 +5874,7 @@ private static class wgpuBufferMapAsync { /** * {@snippet lang=c : - * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void *userdata) + * void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, void *userdata) * } */ public static void wgpuBufferMapAsync(MemorySegment buffer, int mode, long offset, long size, MemorySegment callback, MemorySegment userdata) { @@ -8306,7 +8417,7 @@ private static class wgpuDeviceCreateComputePipelineAsync { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUCreateComputePipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, void *userdata) * } */ public static FunctionDescriptor wgpuDeviceCreateComputePipelineAsync$descriptor() { @@ -8316,7 +8427,7 @@ private static class wgpuDeviceCreateComputePipelineAsync { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUCreateComputePipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, void *userdata) * } */ public static MethodHandle wgpuDeviceCreateComputePipelineAsync$handle() { @@ -8326,7 +8437,7 @@ private static class wgpuDeviceCreateComputePipelineAsync { /** * Address for: * {@snippet lang=c : - * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUCreateComputePipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, void *userdata) * } */ public static MemorySegment wgpuDeviceCreateComputePipelineAsync$address() { @@ -8335,7 +8446,7 @@ private static class wgpuDeviceCreateComputePipelineAsync { /** * {@snippet lang=c : - * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUCreateComputePipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor *descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, void *userdata) * } */ public static void wgpuDeviceCreateComputePipelineAsync(MemorySegment device, MemorySegment descriptor, MemorySegment callback, MemorySegment userdata) { @@ -8602,7 +8713,7 @@ private static class wgpuDeviceCreateRenderPipelineAsync { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, void *userdata) * } */ public static FunctionDescriptor wgpuDeviceCreateRenderPipelineAsync$descriptor() { @@ -8612,7 +8723,7 @@ private static class wgpuDeviceCreateRenderPipelineAsync { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, void *userdata) * } */ public static MethodHandle wgpuDeviceCreateRenderPipelineAsync$handle() { @@ -8622,7 +8733,7 @@ private static class wgpuDeviceCreateRenderPipelineAsync { /** * Address for: * {@snippet lang=c : - * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, void *userdata) * } */ public static MemorySegment wgpuDeviceCreateRenderPipelineAsync$address() { @@ -8631,7 +8742,7 @@ private static class wgpuDeviceCreateRenderPipelineAsync { /** * {@snippet lang=c : - * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void *userdata) + * void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor *descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, void *userdata) * } */ public static void wgpuDeviceCreateRenderPipelineAsync(MemorySegment device, MemorySegment descriptor, MemorySegment callback, MemorySegment userdata) { @@ -9290,65 +9401,6 @@ public static void wgpuDeviceSetLabel(MemorySegment device, MemorySegment label) } } - private static class wgpuDeviceSetUncapturedErrorCallback { - public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( - WGPU.C_POINTER, - WGPU.C_POINTER, - WGPU.C_POINTER - ); - - public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuDeviceSetUncapturedErrorCallback"); - - public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); - } - - /** - * Function descriptor for: - * {@snippet lang=c : - * void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void *userdata) - * } - */ - public static FunctionDescriptor wgpuDeviceSetUncapturedErrorCallback$descriptor() { - return wgpuDeviceSetUncapturedErrorCallback.DESC; - } - - /** - * Downcall method handle for: - * {@snippet lang=c : - * void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void *userdata) - * } - */ - public static MethodHandle wgpuDeviceSetUncapturedErrorCallback$handle() { - return wgpuDeviceSetUncapturedErrorCallback.HANDLE; - } - - /** - * Address for: - * {@snippet lang=c : - * void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void *userdata) - * } - */ - public static MemorySegment wgpuDeviceSetUncapturedErrorCallback$address() { - return wgpuDeviceSetUncapturedErrorCallback.ADDR; - } - - /** - * {@snippet lang=c : - * void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void *userdata) - * } - */ - public static void wgpuDeviceSetUncapturedErrorCallback(MemorySegment device, MemorySegment callback, MemorySegment userdata) { - var mh$ = wgpuDeviceSetUncapturedErrorCallback.HANDLE; - try { - if (TRACE_DOWNCALLS) { - traceDowncall("wgpuDeviceSetUncapturedErrorCallback", device, callback, userdata); - } - mh$.invokeExact(device, callback, userdata); - } catch (Throwable ex$) { - throw new AssertionError("should not reach here", ex$); - } - } - private static class wgpuDeviceReference { public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( WGPU.C_POINTER @@ -9522,6 +9574,65 @@ public static MemorySegment wgpuInstanceCreateSurface(MemorySegment instance, Me } } + private static class wgpuInstanceHasWGSLLanguageFeature { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + WGPU.C_INT, + WGPU.C_POINTER, + WGPU.C_INT + ); + + public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuInstanceHasWGSLLanguageFeature"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) + * } + */ + public static FunctionDescriptor wgpuInstanceHasWGSLLanguageFeature$descriptor() { + return wgpuInstanceHasWGSLLanguageFeature.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) + * } + */ + public static MethodHandle wgpuInstanceHasWGSLLanguageFeature$handle() { + return wgpuInstanceHasWGSLLanguageFeature.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) + * } + */ + public static MemorySegment wgpuInstanceHasWGSLLanguageFeature$address() { + return wgpuInstanceHasWGSLLanguageFeature.ADDR; + } + + /** + * {@snippet lang=c : + * WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) + * } + */ + public static int wgpuInstanceHasWGSLLanguageFeature(MemorySegment instance, int feature) { + var mh$ = wgpuInstanceHasWGSLLanguageFeature.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("wgpuInstanceHasWGSLLanguageFeature", instance, feature); + } + return (int)mh$.invokeExact(instance, feature); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static class wgpuInstanceProcessEvents { public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( WGPU.C_POINTER @@ -9595,7 +9706,7 @@ private static class wgpuInstanceRequestAdapter { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPURequestAdapterCallback callback, void *userdata) + * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPUInstanceRequestAdapterCallback callback, void *userdata) * } */ public static FunctionDescriptor wgpuInstanceRequestAdapter$descriptor() { @@ -9605,7 +9716,7 @@ private static class wgpuInstanceRequestAdapter { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPURequestAdapterCallback callback, void *userdata) + * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPUInstanceRequestAdapterCallback callback, void *userdata) * } */ public static MethodHandle wgpuInstanceRequestAdapter$handle() { @@ -9615,7 +9726,7 @@ private static class wgpuInstanceRequestAdapter { /** * Address for: * {@snippet lang=c : - * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPURequestAdapterCallback callback, void *userdata) + * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPUInstanceRequestAdapterCallback callback, void *userdata) * } */ public static MemorySegment wgpuInstanceRequestAdapter$address() { @@ -9624,7 +9735,7 @@ private static class wgpuInstanceRequestAdapter { /** * {@snippet lang=c : - * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPURequestAdapterCallback callback, void *userdata) + * void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions *options, WGPUInstanceRequestAdapterCallback callback, void *userdata) * } */ public static void wgpuInstanceRequestAdapter(MemorySegment instance, MemorySegment options, MemorySegment callback, MemorySegment userdata) { @@ -10285,7 +10396,7 @@ private static class wgpuQueueOnSubmittedWorkDone { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void *userdata) + * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, void *userdata) * } */ public static FunctionDescriptor wgpuQueueOnSubmittedWorkDone$descriptor() { @@ -10295,7 +10406,7 @@ private static class wgpuQueueOnSubmittedWorkDone { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void *userdata) + * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, void *userdata) * } */ public static MethodHandle wgpuQueueOnSubmittedWorkDone$handle() { @@ -10305,7 +10416,7 @@ private static class wgpuQueueOnSubmittedWorkDone { /** * Address for: * {@snippet lang=c : - * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void *userdata) + * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, void *userdata) * } */ public static MemorySegment wgpuQueueOnSubmittedWorkDone$address() { @@ -10314,7 +10425,7 @@ private static class wgpuQueueOnSubmittedWorkDone { /** * {@snippet lang=c : - * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void *userdata) + * void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, void *userdata) * } */ public static void wgpuQueueOnSubmittedWorkDone(MemorySegment queue, MemorySegment callback, MemorySegment userdata) { @@ -13457,7 +13568,7 @@ private static class wgpuShaderModuleGetCompilationInfo { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void *userdata) + * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, void *userdata) * } */ public static FunctionDescriptor wgpuShaderModuleGetCompilationInfo$descriptor() { @@ -13467,7 +13578,7 @@ private static class wgpuShaderModuleGetCompilationInfo { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void *userdata) + * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, void *userdata) * } */ public static MethodHandle wgpuShaderModuleGetCompilationInfo$handle() { @@ -13477,7 +13588,7 @@ private static class wgpuShaderModuleGetCompilationInfo { /** * Address for: * {@snippet lang=c : - * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void *userdata) + * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, void *userdata) * } */ public static MemorySegment wgpuShaderModuleGetCompilationInfo$address() { @@ -13486,7 +13597,7 @@ private static class wgpuShaderModuleGetCompilationInfo { /** * {@snippet lang=c : - * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void *userdata) + * void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, void *userdata) * } */ public static void wgpuShaderModuleGetCompilationInfo(MemorySegment shaderModule, MemorySegment callback, MemorySegment userdata) { @@ -13848,14 +13959,12 @@ public static void wgpuSurfaceGetCurrentTexture(MemorySegment surface, MemorySeg } } - private static class wgpuSurfaceGetPreferredFormat { - public static final FunctionDescriptor DESC = FunctionDescriptor.of( - WGPU.C_INT, - WGPU.C_POINTER, + private static class wgpuSurfacePresent { + public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( WGPU.C_POINTER ); - public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuSurfaceGetPreferredFormat"); + public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuSurfacePresent"); public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); } @@ -13863,56 +13972,57 @@ private static class wgpuSurfaceGetPreferredFormat { /** * Function descriptor for: * {@snippet lang=c : - * WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) + * void wgpuSurfacePresent(WGPUSurface surface) * } */ - public static FunctionDescriptor wgpuSurfaceGetPreferredFormat$descriptor() { - return wgpuSurfaceGetPreferredFormat.DESC; + public static FunctionDescriptor wgpuSurfacePresent$descriptor() { + return wgpuSurfacePresent.DESC; } /** * Downcall method handle for: * {@snippet lang=c : - * WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) + * void wgpuSurfacePresent(WGPUSurface surface) * } */ - public static MethodHandle wgpuSurfaceGetPreferredFormat$handle() { - return wgpuSurfaceGetPreferredFormat.HANDLE; + public static MethodHandle wgpuSurfacePresent$handle() { + return wgpuSurfacePresent.HANDLE; } /** * Address for: * {@snippet lang=c : - * WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) + * void wgpuSurfacePresent(WGPUSurface surface) * } */ - public static MemorySegment wgpuSurfaceGetPreferredFormat$address() { - return wgpuSurfaceGetPreferredFormat.ADDR; + public static MemorySegment wgpuSurfacePresent$address() { + return wgpuSurfacePresent.ADDR; } /** * {@snippet lang=c : - * WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) + * void wgpuSurfacePresent(WGPUSurface surface) * } */ - public static int wgpuSurfaceGetPreferredFormat(MemorySegment surface, MemorySegment adapter) { - var mh$ = wgpuSurfaceGetPreferredFormat.HANDLE; + public static void wgpuSurfacePresent(MemorySegment surface) { + var mh$ = wgpuSurfacePresent.HANDLE; try { if (TRACE_DOWNCALLS) { - traceDowncall("wgpuSurfaceGetPreferredFormat", surface, adapter); + traceDowncall("wgpuSurfacePresent", surface); } - return (int)mh$.invokeExact(surface, adapter); + mh$.invokeExact(surface); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } } - private static class wgpuSurfacePresent { + private static class wgpuSurfaceSetLabel { public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( + WGPU.C_POINTER, WGPU.C_POINTER ); - public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuSurfacePresent"); + public static final MemorySegment ADDR = WGPU.findOrThrow("wgpuSurfaceSetLabel"); public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); } @@ -13920,45 +14030,45 @@ private static class wgpuSurfacePresent { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuSurfacePresent(WGPUSurface surface) + * void wgpuSurfaceSetLabel(WGPUSurface surface, const char *label) * } */ - public static FunctionDescriptor wgpuSurfacePresent$descriptor() { - return wgpuSurfacePresent.DESC; + public static FunctionDescriptor wgpuSurfaceSetLabel$descriptor() { + return wgpuSurfaceSetLabel.DESC; } /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuSurfacePresent(WGPUSurface surface) + * void wgpuSurfaceSetLabel(WGPUSurface surface, const char *label) * } */ - public static MethodHandle wgpuSurfacePresent$handle() { - return wgpuSurfacePresent.HANDLE; + public static MethodHandle wgpuSurfaceSetLabel$handle() { + return wgpuSurfaceSetLabel.HANDLE; } /** * Address for: * {@snippet lang=c : - * void wgpuSurfacePresent(WGPUSurface surface) + * void wgpuSurfaceSetLabel(WGPUSurface surface, const char *label) * } */ - public static MemorySegment wgpuSurfacePresent$address() { - return wgpuSurfacePresent.ADDR; + public static MemorySegment wgpuSurfaceSetLabel$address() { + return wgpuSurfaceSetLabel.ADDR; } /** * {@snippet lang=c : - * void wgpuSurfacePresent(WGPUSurface surface) + * void wgpuSurfaceSetLabel(WGPUSurface surface, const char *label) * } */ - public static void wgpuSurfacePresent(MemorySegment surface) { - var mh$ = wgpuSurfacePresent.HANDLE; + public static void wgpuSurfaceSetLabel(MemorySegment surface, MemorySegment label) { + var mh$ = wgpuSurfaceSetLabel.HANDLE; try { if (TRACE_DOWNCALLS) { - traceDowncall("wgpuSurfacePresent", surface); + traceDowncall("wgpuSurfaceSetLabel", surface, label); } - mh$.invokeExact(surface); + mh$.invokeExact(surface, label); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } @@ -14148,7 +14258,7 @@ private static class wgpuSurfaceCapabilitiesFreeMembers { /** * Function descriptor for: * {@snippet lang=c : - * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities capabilities) + * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) * } */ public static FunctionDescriptor wgpuSurfaceCapabilitiesFreeMembers$descriptor() { @@ -14158,7 +14268,7 @@ private static class wgpuSurfaceCapabilitiesFreeMembers { /** * Downcall method handle for: * {@snippet lang=c : - * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities capabilities) + * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) * } */ public static MethodHandle wgpuSurfaceCapabilitiesFreeMembers$handle() { @@ -14168,7 +14278,7 @@ private static class wgpuSurfaceCapabilitiesFreeMembers { /** * Address for: * {@snippet lang=c : - * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities capabilities) + * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) * } */ public static MemorySegment wgpuSurfaceCapabilitiesFreeMembers$address() { @@ -14177,16 +14287,16 @@ private static class wgpuSurfaceCapabilitiesFreeMembers { /** * {@snippet lang=c : - * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities capabilities) + * void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) * } */ - public static void wgpuSurfaceCapabilitiesFreeMembers(MemorySegment capabilities) { + public static void wgpuSurfaceCapabilitiesFreeMembers(MemorySegment surfaceCapabilities) { var mh$ = wgpuSurfaceCapabilitiesFreeMembers.HANDLE; try { if (TRACE_DOWNCALLS) { - traceDowncall("wgpuSurfaceCapabilitiesFreeMembers", capabilities); + traceDowncall("wgpuSurfaceCapabilitiesFreeMembers", surfaceCapabilities); } - mh$.invokeExact(capabilities); + mh$.invokeExact(surfaceCapabilities); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } @@ -15304,6 +15414,123 @@ public static int WGPUNativeFeature_StorageResourceBindingArray() { public static int WGPUNativeFeature_PartiallyBoundBindingArray() { return WGPUNativeFeature_PartiallyBoundBindingArray; } + private static final int WGPUNativeFeature_TextureFormat16bitNorm = (int)196619L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_TextureFormat16bitNorm = 196619 + * } + */ + public static int WGPUNativeFeature_TextureFormat16bitNorm() { + return WGPUNativeFeature_TextureFormat16bitNorm; + } + private static final int WGPUNativeFeature_TextureCompressionAstcHdr = (int)196620L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_TextureCompressionAstcHdr = 196620 + * } + */ + public static int WGPUNativeFeature_TextureCompressionAstcHdr() { + return WGPUNativeFeature_TextureCompressionAstcHdr; + } + private static final int WGPUNativeFeature_MappablePrimaryBuffers = (int)196622L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_MappablePrimaryBuffers = 196622 + * } + */ + public static int WGPUNativeFeature_MappablePrimaryBuffers() { + return WGPUNativeFeature_MappablePrimaryBuffers; + } + private static final int WGPUNativeFeature_BufferBindingArray = (int)196623L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_BufferBindingArray = 196623 + * } + */ + public static int WGPUNativeFeature_BufferBindingArray() { + return WGPUNativeFeature_BufferBindingArray; + } + private static final int WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = (int)196624L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 196624 + * } + */ + public static int WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing() { + return WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing; + } + private static final int WGPUNativeFeature_VertexAttribute64bit = (int)196633L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_VertexAttribute64bit = 196633 + * } + */ + public static int WGPUNativeFeature_VertexAttribute64bit() { + return WGPUNativeFeature_VertexAttribute64bit; + } + private static final int WGPUNativeFeature_TextureFormatNv12 = (int)196634L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_TextureFormatNv12 = 196634 + * } + */ + public static int WGPUNativeFeature_TextureFormatNv12() { + return WGPUNativeFeature_TextureFormatNv12; + } + private static final int WGPUNativeFeature_RayTracingAccelerationStructure = (int)196635L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_RayTracingAccelerationStructure = 196635 + * } + */ + public static int WGPUNativeFeature_RayTracingAccelerationStructure() { + return WGPUNativeFeature_RayTracingAccelerationStructure; + } + private static final int WGPUNativeFeature_RayQuery = (int)196636L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_RayQuery = 196636 + * } + */ + public static int WGPUNativeFeature_RayQuery() { + return WGPUNativeFeature_RayQuery; + } + private static final int WGPUNativeFeature_ShaderF64 = (int)196637L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_ShaderF64 = 196637 + * } + */ + public static int WGPUNativeFeature_ShaderF64() { + return WGPUNativeFeature_ShaderF64; + } + private static final int WGPUNativeFeature_ShaderI16 = (int)196638L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_ShaderI16 = 196638 + * } + */ + public static int WGPUNativeFeature_ShaderI16() { + return WGPUNativeFeature_ShaderI16; + } + private static final int WGPUNativeFeature_ShaderPrimitiveIndex = (int)196639L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_ShaderPrimitiveIndex = 196639 + * } + */ + public static int WGPUNativeFeature_ShaderPrimitiveIndex() { + return WGPUNativeFeature_ShaderPrimitiveIndex; + } + private static final int WGPUNativeFeature_ShaderEarlyDepthTest = (int)196640L; + /** + * {@snippet lang=c : + * enum WGPUNativeFeature.WGPUNativeFeature_ShaderEarlyDepthTest = 196640 + * } + */ + public static int WGPUNativeFeature_ShaderEarlyDepthTest() { + return WGPUNativeFeature_ShaderEarlyDepthTest; + } private static final int WGPUNativeFeature_Force32 = (int)2147483647L; /** * {@snippet lang=c : @@ -15682,6 +15909,69 @@ public static int WGPUNativeQueryType_Force32() { * } */ public static final OfLong WGPUSubmissionIndex = WGPU.C_LONG_LONG; + private static final int WGPUNativeTextureFormat_R16Unorm = (int)196609L; + /** + * {@snippet lang=c : + * enum WGPUNativeTextureFormat.WGPUNativeTextureFormat_R16Unorm = 196609 + * } + */ + public static int WGPUNativeTextureFormat_R16Unorm() { + return WGPUNativeTextureFormat_R16Unorm; + } + private static final int WGPUNativeTextureFormat_R16Snorm = (int)196610L; + /** + * {@snippet lang=c : + * enum WGPUNativeTextureFormat.WGPUNativeTextureFormat_R16Snorm = 196610 + * } + */ + public static int WGPUNativeTextureFormat_R16Snorm() { + return WGPUNativeTextureFormat_R16Snorm; + } + private static final int WGPUNativeTextureFormat_Rg16Unorm = (int)196611L; + /** + * {@snippet lang=c : + * enum WGPUNativeTextureFormat.WGPUNativeTextureFormat_Rg16Unorm = 196611 + * } + */ + public static int WGPUNativeTextureFormat_Rg16Unorm() { + return WGPUNativeTextureFormat_Rg16Unorm; + } + private static final int WGPUNativeTextureFormat_Rg16Snorm = (int)196612L; + /** + * {@snippet lang=c : + * enum WGPUNativeTextureFormat.WGPUNativeTextureFormat_Rg16Snorm = 196612 + * } + */ + public static int WGPUNativeTextureFormat_Rg16Snorm() { + return WGPUNativeTextureFormat_Rg16Snorm; + } + private static final int WGPUNativeTextureFormat_Rgba16Unorm = (int)196613L; + /** + * {@snippet lang=c : + * enum WGPUNativeTextureFormat.WGPUNativeTextureFormat_Rgba16Unorm = 196613 + * } + */ + public static int WGPUNativeTextureFormat_Rgba16Unorm() { + return WGPUNativeTextureFormat_Rgba16Unorm; + } + private static final int WGPUNativeTextureFormat_Rgba16Snorm = (int)196614L; + /** + * {@snippet lang=c : + * enum WGPUNativeTextureFormat.WGPUNativeTextureFormat_Rgba16Snorm = 196614 + * } + */ + public static int WGPUNativeTextureFormat_Rgba16Snorm() { + return WGPUNativeTextureFormat_Rgba16Snorm; + } + private static final int WGPUNativeTextureFormat_NV12 = (int)196615L; + /** + * {@snippet lang=c : + * enum WGPUNativeTextureFormat.WGPUNativeTextureFormat_NV12 = 196615 + * } + */ + public static int WGPUNativeTextureFormat_NV12() { + return WGPUNativeTextureFormat_NV12; + } private static class wgpuGenerateReport { public static final FunctionDescriptor DESC = FunctionDescriptor.ofVoid( @@ -17087,6 +17377,15 @@ public static int WGPU_ARRAY_LAYER_COUNT_UNDEFINED() { public static int WGPU_COPY_STRIDE_UNDEFINED() { return WGPU_COPY_STRIDE_UNDEFINED; } + private static final int WGPU_DEPTH_SLICE_UNDEFINED = (int)4294967295L; + /** + * {@snippet lang=c : + * #define WGPU_DEPTH_SLICE_UNDEFINED 4294967295 + * } + */ + public static int WGPU_DEPTH_SLICE_UNDEFINED() { + return WGPU_DEPTH_SLICE_UNDEFINED; + } private static final int WGPU_LIMIT_U32_UNDEFINED = (int)4294967295L; /** * {@snippet lang=c : diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterProperties.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterInfo.java similarity index 76% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterProperties.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterInfo.java index 1926e21fe..ea8cad862 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterProperties.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterInfo.java @@ -14,38 +14,36 @@ /** * {@snippet lang=c : - * struct WGPUAdapterProperties { + * struct WGPUAdapterInfo { * WGPUChainedStructOut *nextInChain; - * uint32_t vendorID; - * const char *vendorName; + * const char *vendor; * const char *architecture; - * uint32_t deviceID; - * const char *name; - * const char *driverDescription; - * WGPUAdapterType adapterType; + * const char *device; + * const char *description; * WGPUBackendType backendType; + * WGPUAdapterType adapterType; + * uint32_t vendorID; + * uint32_t deviceID; * } * } */ -public class WGPUAdapterProperties { +public class WGPUAdapterInfo { - WGPUAdapterProperties() { + WGPUAdapterInfo() { // Should not be called directly } private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( WGPU.C_POINTER.withName("nextInChain"), - WGPU.C_INT.withName("vendorID"), - MemoryLayout.paddingLayout(4), - WGPU.C_POINTER.withName("vendorName"), + WGPU.C_POINTER.withName("vendor"), WGPU.C_POINTER.withName("architecture"), - WGPU.C_INT.withName("deviceID"), - MemoryLayout.paddingLayout(4), - WGPU.C_POINTER.withName("name"), - WGPU.C_POINTER.withName("driverDescription"), + WGPU.C_POINTER.withName("device"), + WGPU.C_POINTER.withName("description"), + WGPU.C_INT.withName("backendType"), WGPU.C_INT.withName("adapterType"), - WGPU.C_INT.withName("backendType") - ).withName("WGPUAdapterProperties"); + WGPU.C_INT.withName("vendorID"), + WGPU.C_INT.withName("deviceID") + ).withName("WGPUAdapterInfo"); /** * The layout of this struct @@ -98,356 +96,356 @@ public static void nextInChain(MemorySegment struct, MemorySegment fieldValue) { struct.set(nextInChain$LAYOUT, nextInChain$OFFSET, fieldValue); } - private static final OfInt vendorID$LAYOUT = (OfInt)$LAYOUT.select(groupElement("vendorID")); + private static final AddressLayout vendor$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("vendor")); /** * Layout for field: * {@snippet lang=c : - * uint32_t vendorID + * const char *vendor * } */ - public static final OfInt vendorID$layout() { - return vendorID$LAYOUT; + public static final AddressLayout vendor$layout() { + return vendor$LAYOUT; } - private static final long vendorID$OFFSET = 8; + private static final long vendor$OFFSET = 8; /** * Offset for field: * {@snippet lang=c : - * uint32_t vendorID + * const char *vendor * } */ - public static final long vendorID$offset() { - return vendorID$OFFSET; + public static final long vendor$offset() { + return vendor$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * uint32_t vendorID + * const char *vendor * } */ - public static int vendorID(MemorySegment struct) { - return struct.get(vendorID$LAYOUT, vendorID$OFFSET); + public static MemorySegment vendor(MemorySegment struct) { + return struct.get(vendor$LAYOUT, vendor$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * uint32_t vendorID + * const char *vendor * } */ - public static void vendorID(MemorySegment struct, int fieldValue) { - struct.set(vendorID$LAYOUT, vendorID$OFFSET, fieldValue); + public static void vendor(MemorySegment struct, MemorySegment fieldValue) { + struct.set(vendor$LAYOUT, vendor$OFFSET, fieldValue); } - private static final AddressLayout vendorName$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("vendorName")); + private static final AddressLayout architecture$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("architecture")); /** * Layout for field: * {@snippet lang=c : - * const char *vendorName + * const char *architecture * } */ - public static final AddressLayout vendorName$layout() { - return vendorName$LAYOUT; + public static final AddressLayout architecture$layout() { + return architecture$LAYOUT; } - private static final long vendorName$OFFSET = 16; + private static final long architecture$OFFSET = 16; /** * Offset for field: * {@snippet lang=c : - * const char *vendorName + * const char *architecture * } */ - public static final long vendorName$offset() { - return vendorName$OFFSET; + public static final long architecture$offset() { + return architecture$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * const char *vendorName + * const char *architecture * } */ - public static MemorySegment vendorName(MemorySegment struct) { - return struct.get(vendorName$LAYOUT, vendorName$OFFSET); + public static MemorySegment architecture(MemorySegment struct) { + return struct.get(architecture$LAYOUT, architecture$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * const char *vendorName + * const char *architecture * } */ - public static void vendorName(MemorySegment struct, MemorySegment fieldValue) { - struct.set(vendorName$LAYOUT, vendorName$OFFSET, fieldValue); + public static void architecture(MemorySegment struct, MemorySegment fieldValue) { + struct.set(architecture$LAYOUT, architecture$OFFSET, fieldValue); } - private static final AddressLayout architecture$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("architecture")); + private static final AddressLayout device$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("device")); /** * Layout for field: * {@snippet lang=c : - * const char *architecture + * const char *device * } */ - public static final AddressLayout architecture$layout() { - return architecture$LAYOUT; + public static final AddressLayout device$layout() { + return device$LAYOUT; } - private static final long architecture$OFFSET = 24; + private static final long device$OFFSET = 24; /** * Offset for field: * {@snippet lang=c : - * const char *architecture + * const char *device * } */ - public static final long architecture$offset() { - return architecture$OFFSET; + public static final long device$offset() { + return device$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * const char *architecture + * const char *device * } */ - public static MemorySegment architecture(MemorySegment struct) { - return struct.get(architecture$LAYOUT, architecture$OFFSET); + public static MemorySegment device(MemorySegment struct) { + return struct.get(device$LAYOUT, device$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * const char *architecture + * const char *device * } */ - public static void architecture(MemorySegment struct, MemorySegment fieldValue) { - struct.set(architecture$LAYOUT, architecture$OFFSET, fieldValue); + public static void device(MemorySegment struct, MemorySegment fieldValue) { + struct.set(device$LAYOUT, device$OFFSET, fieldValue); } - private static final OfInt deviceID$LAYOUT = (OfInt)$LAYOUT.select(groupElement("deviceID")); + private static final AddressLayout description$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("description")); /** * Layout for field: * {@snippet lang=c : - * uint32_t deviceID + * const char *description * } */ - public static final OfInt deviceID$layout() { - return deviceID$LAYOUT; + public static final AddressLayout description$layout() { + return description$LAYOUT; } - private static final long deviceID$OFFSET = 32; + private static final long description$OFFSET = 32; /** * Offset for field: * {@snippet lang=c : - * uint32_t deviceID + * const char *description * } */ - public static final long deviceID$offset() { - return deviceID$OFFSET; + public static final long description$offset() { + return description$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * uint32_t deviceID + * const char *description * } */ - public static int deviceID(MemorySegment struct) { - return struct.get(deviceID$LAYOUT, deviceID$OFFSET); + public static MemorySegment description(MemorySegment struct) { + return struct.get(description$LAYOUT, description$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * uint32_t deviceID + * const char *description * } */ - public static void deviceID(MemorySegment struct, int fieldValue) { - struct.set(deviceID$LAYOUT, deviceID$OFFSET, fieldValue); + public static void description(MemorySegment struct, MemorySegment fieldValue) { + struct.set(description$LAYOUT, description$OFFSET, fieldValue); } - private static final AddressLayout name$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("name")); + private static final OfInt backendType$LAYOUT = (OfInt)$LAYOUT.select(groupElement("backendType")); /** * Layout for field: * {@snippet lang=c : - * const char *name + * WGPUBackendType backendType * } */ - public static final AddressLayout name$layout() { - return name$LAYOUT; + public static final OfInt backendType$layout() { + return backendType$LAYOUT; } - private static final long name$OFFSET = 40; + private static final long backendType$OFFSET = 40; /** * Offset for field: * {@snippet lang=c : - * const char *name + * WGPUBackendType backendType * } */ - public static final long name$offset() { - return name$OFFSET; + public static final long backendType$offset() { + return backendType$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * const char *name + * WGPUBackendType backendType * } */ - public static MemorySegment name(MemorySegment struct) { - return struct.get(name$LAYOUT, name$OFFSET); + public static int backendType(MemorySegment struct) { + return struct.get(backendType$LAYOUT, backendType$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * const char *name + * WGPUBackendType backendType * } */ - public static void name(MemorySegment struct, MemorySegment fieldValue) { - struct.set(name$LAYOUT, name$OFFSET, fieldValue); + public static void backendType(MemorySegment struct, int fieldValue) { + struct.set(backendType$LAYOUT, backendType$OFFSET, fieldValue); } - private static final AddressLayout driverDescription$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("driverDescription")); + private static final OfInt adapterType$LAYOUT = (OfInt)$LAYOUT.select(groupElement("adapterType")); /** * Layout for field: * {@snippet lang=c : - * const char *driverDescription + * WGPUAdapterType adapterType * } */ - public static final AddressLayout driverDescription$layout() { - return driverDescription$LAYOUT; + public static final OfInt adapterType$layout() { + return adapterType$LAYOUT; } - private static final long driverDescription$OFFSET = 48; + private static final long adapterType$OFFSET = 44; /** * Offset for field: * {@snippet lang=c : - * const char *driverDescription + * WGPUAdapterType adapterType * } */ - public static final long driverDescription$offset() { - return driverDescription$OFFSET; + public static final long adapterType$offset() { + return adapterType$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * const char *driverDescription + * WGPUAdapterType adapterType * } */ - public static MemorySegment driverDescription(MemorySegment struct) { - return struct.get(driverDescription$LAYOUT, driverDescription$OFFSET); + public static int adapterType(MemorySegment struct) { + return struct.get(adapterType$LAYOUT, adapterType$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * const char *driverDescription + * WGPUAdapterType adapterType * } */ - public static void driverDescription(MemorySegment struct, MemorySegment fieldValue) { - struct.set(driverDescription$LAYOUT, driverDescription$OFFSET, fieldValue); + public static void adapterType(MemorySegment struct, int fieldValue) { + struct.set(adapterType$LAYOUT, adapterType$OFFSET, fieldValue); } - private static final OfInt adapterType$LAYOUT = (OfInt)$LAYOUT.select(groupElement("adapterType")); + private static final OfInt vendorID$LAYOUT = (OfInt)$LAYOUT.select(groupElement("vendorID")); /** * Layout for field: * {@snippet lang=c : - * WGPUAdapterType adapterType + * uint32_t vendorID * } */ - public static final OfInt adapterType$layout() { - return adapterType$LAYOUT; + public static final OfInt vendorID$layout() { + return vendorID$LAYOUT; } - private static final long adapterType$OFFSET = 56; + private static final long vendorID$OFFSET = 48; /** * Offset for field: * {@snippet lang=c : - * WGPUAdapterType adapterType + * uint32_t vendorID * } */ - public static final long adapterType$offset() { - return adapterType$OFFSET; + public static final long vendorID$offset() { + return vendorID$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * WGPUAdapterType adapterType + * uint32_t vendorID * } */ - public static int adapterType(MemorySegment struct) { - return struct.get(adapterType$LAYOUT, adapterType$OFFSET); + public static int vendorID(MemorySegment struct) { + return struct.get(vendorID$LAYOUT, vendorID$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * WGPUAdapterType adapterType + * uint32_t vendorID * } */ - public static void adapterType(MemorySegment struct, int fieldValue) { - struct.set(adapterType$LAYOUT, adapterType$OFFSET, fieldValue); + public static void vendorID(MemorySegment struct, int fieldValue) { + struct.set(vendorID$LAYOUT, vendorID$OFFSET, fieldValue); } - private static final OfInt backendType$LAYOUT = (OfInt)$LAYOUT.select(groupElement("backendType")); + private static final OfInt deviceID$LAYOUT = (OfInt)$LAYOUT.select(groupElement("deviceID")); /** * Layout for field: * {@snippet lang=c : - * WGPUBackendType backendType + * uint32_t deviceID * } */ - public static final OfInt backendType$layout() { - return backendType$LAYOUT; + public static final OfInt deviceID$layout() { + return deviceID$LAYOUT; } - private static final long backendType$OFFSET = 60; + private static final long deviceID$OFFSET = 52; /** * Offset for field: * {@snippet lang=c : - * WGPUBackendType backendType + * uint32_t deviceID * } */ - public static final long backendType$offset() { - return backendType$OFFSET; + public static final long deviceID$offset() { + return deviceID$OFFSET; } /** * Getter for field: * {@snippet lang=c : - * WGPUBackendType backendType + * uint32_t deviceID * } */ - public static int backendType(MemorySegment struct) { - return struct.get(backendType$LAYOUT, backendType$OFFSET); + public static int deviceID(MemorySegment struct) { + return struct.get(deviceID$LAYOUT, deviceID$OFFSET); } /** * Setter for field: * {@snippet lang=c : - * WGPUBackendType backendType + * uint32_t deviceID * } */ - public static void backendType(MemorySegment struct, int fieldValue) { - struct.set(backendType$LAYOUT, backendType$OFFSET, fieldValue); + public static void deviceID(MemorySegment struct, int fieldValue) { + struct.set(deviceID$LAYOUT, deviceID$OFFSET, fieldValue); } /** diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURequestDeviceCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterRequestDeviceCallback.java similarity index 83% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURequestDeviceCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterRequestDeviceCallback.java index 4dc812b04..763b9c837 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURequestDeviceCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUAdapterRequestDeviceCallback.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus, WGPUDevice, const char *, void *) + * typedef void (*WGPUAdapterRequestDeviceCallback)(WGPURequestDeviceStatus, WGPUDevice, const char *, void *) * } */ -public class WGPURequestDeviceCallback { +public class WGPUAdapterRequestDeviceCallback { - WGPURequestDeviceCallback() { + WGPUAdapterRequestDeviceCallback() { // Should not be called directly } @@ -44,13 +44,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPURequestDeviceCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUAdapterRequestDeviceCallback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPURequestDeviceCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUAdapterRequestDeviceCallback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUQueueWorkDoneCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUBufferMapAsyncCallback.java similarity index 84% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUQueueWorkDoneCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUBufferMapAsyncCallback.java index ff251ed2d..0247e82c6 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUQueueWorkDoneCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUBufferMapAsyncCallback.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus, void *) + * typedef void (*WGPUBufferMapAsyncCallback)(WGPUBufferMapAsyncStatus, void *) * } */ -public class WGPUQueueWorkDoneCallback { +public class WGPUBufferMapAsyncCallback { - WGPUQueueWorkDoneCallback() { + WGPUBufferMapAsyncCallback() { // Should not be called directly } @@ -42,13 +42,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUQueueWorkDoneCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUBufferMapAsyncCallback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUQueueWorkDoneCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUBufferMapAsyncCallback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCreateComputePipelineAsyncCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceCreateComputePipelineAsyncCallback.java similarity index 80% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCreateComputePipelineAsyncCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceCreateComputePipelineAsyncCallback.java index 7f300d676..59a066049 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCreateComputePipelineAsyncCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceCreateComputePipelineAsyncCallback.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus, WGPUComputePipeline, const char *, void *) + * typedef void (*WGPUDeviceCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus, WGPUComputePipeline, const char *, void *) * } */ -public class WGPUCreateComputePipelineAsyncCallback { +public class WGPUDeviceCreateComputePipelineAsyncCallback { - WGPUCreateComputePipelineAsyncCallback() { + WGPUDeviceCreateComputePipelineAsyncCallback() { // Should not be called directly } @@ -44,13 +44,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUCreateComputePipelineAsyncCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUDeviceCreateComputePipelineAsyncCallback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUCreateComputePipelineAsyncCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUDeviceCreateComputePipelineAsyncCallback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCreateRenderPipelineAsyncCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceCreateRenderPipelineAsyncCallback.java similarity index 80% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCreateRenderPipelineAsyncCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceCreateRenderPipelineAsyncCallback.java index 4788dc5fd..e870900cb 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCreateRenderPipelineAsyncCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceCreateRenderPipelineAsyncCallback.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus, WGPURenderPipeline, const char *, void *) + * typedef void (*WGPUDeviceCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus, WGPURenderPipeline, const char *, void *) * } */ -public class WGPUCreateRenderPipelineAsyncCallback { +public class WGPUDeviceCreateRenderPipelineAsyncCallback { - WGPUCreateRenderPipelineAsyncCallback() { + WGPUDeviceCreateRenderPipelineAsyncCallback() { // Should not be called directly } @@ -44,13 +44,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUCreateRenderPipelineAsyncCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUDeviceCreateRenderPipelineAsyncCallback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUCreateRenderPipelineAsyncCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUDeviceCreateRenderPipelineAsyncCallback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceDescriptor.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceDescriptor.java index e861748d8..d3b6a1a1a 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceDescriptor.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUDeviceDescriptor.java @@ -23,6 +23,7 @@ * WGPUQueueDescriptor defaultQueue; * WGPUDeviceLostCallback deviceLostCallback; * void *deviceLostUserdata; + * WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; * } * } */ @@ -40,7 +41,8 @@ public class WGPUDeviceDescriptor { WGPU.C_POINTER.withName("requiredLimits"), WGPUQueueDescriptor.layout().withName("defaultQueue"), WGPU.C_POINTER.withName("deviceLostCallback"), - WGPU.C_POINTER.withName("deviceLostUserdata") + WGPU.C_POINTER.withName("deviceLostUserdata"), + WGPUUncapturedErrorCallbackInfo.layout().withName("uncapturedErrorCallbackInfo") ).withName("WGPUDeviceDescriptor"); /** @@ -402,6 +404,50 @@ public static void deviceLostUserdata(MemorySegment struct, MemorySegment fieldV struct.set(deviceLostUserdata$LAYOUT, deviceLostUserdata$OFFSET, fieldValue); } + private static final GroupLayout uncapturedErrorCallbackInfo$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("uncapturedErrorCallbackInfo")); + + /** + * Layout for field: + * {@snippet lang=c : + * WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo + * } + */ + public static final GroupLayout uncapturedErrorCallbackInfo$layout() { + return uncapturedErrorCallbackInfo$LAYOUT; + } + + private static final long uncapturedErrorCallbackInfo$OFFSET = 72; + + /** + * Offset for field: + * {@snippet lang=c : + * WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo + * } + */ + public static final long uncapturedErrorCallbackInfo$offset() { + return uncapturedErrorCallbackInfo$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo + * } + */ + public static MemorySegment uncapturedErrorCallbackInfo(MemorySegment struct) { + return struct.asSlice(uncapturedErrorCallbackInfo$OFFSET, uncapturedErrorCallbackInfo$LAYOUT.byteSize()); + } + + /** + * Setter for field: + * {@snippet lang=c : + * WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo + * } + */ + public static void uncapturedErrorCallbackInfo(MemorySegment struct, MemorySegment fieldValue) { + MemorySegment.copy(fieldValue, 0L, struct, uncapturedErrorCallbackInfo$OFFSET, uncapturedErrorCallbackInfo$LAYOUT.byteSize()); + } + /** * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURequestAdapterCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUInstanceRequestAdapterCallback.java similarity index 82% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURequestAdapterCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUInstanceRequestAdapterCallback.java index efe30dcc0..287c649ee 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURequestAdapterCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUInstanceRequestAdapterCallback.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus, WGPUAdapter, const char *, void *) + * typedef void (*WGPUInstanceRequestAdapterCallback)(WGPURequestAdapterStatus, WGPUAdapter, const char *, void *) * } */ -public class WGPURequestAdapterCallback { +public class WGPUInstanceRequestAdapterCallback { - WGPURequestAdapterCallback() { + WGPUInstanceRequestAdapterCallback() { // Should not be called directly } @@ -44,13 +44,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPURequestAdapterCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUInstanceRequestAdapterCallback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPURequestAdapterCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUInstanceRequestAdapterCallback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterGetProperties.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterGetInfo.java similarity index 75% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterGetProperties.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterGetInfo.java index 02cbd265f..56269a656 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterGetProperties.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterGetInfo.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter, WGPUAdapterProperties *) + * typedef void (*WGPUProcAdapterGetInfo)(WGPUAdapter, WGPUAdapterInfo *) * } */ -public class WGPUProcAdapterGetProperties { +public class WGPUProcAdapterGetInfo { - WGPUProcAdapterGetProperties() { + WGPUProcAdapterGetInfo() { // Should not be called directly } @@ -27,7 +27,7 @@ public class WGPUProcAdapterGetProperties { * The function pointer signature, expressed as a functional interface */ public interface Function { - void apply(MemorySegment adapter, MemorySegment properties); + void apply(MemorySegment adapter, MemorySegment info); } private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( @@ -42,13 +42,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUProcAdapterGetProperties.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUProcAdapterGetInfo.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUProcAdapterGetProperties.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUProcAdapterGetInfo.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } @@ -57,9 +57,9 @@ public static MemorySegment allocate(WGPUProcAdapterGetProperties.Function fi, A /** * Invoke the upcall stub {@code funcPtr}, with given parameters */ - public static void invoke(MemorySegment funcPtr,MemorySegment adapter, MemorySegment properties) { + public static void invoke(MemorySegment funcPtr,MemorySegment adapter, MemorySegment info) { try { - DOWN$MH.invokeExact(funcPtr, adapter, properties); + DOWN$MH.invokeExact(funcPtr, adapter, info); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterInfoFreeMembers.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterInfoFreeMembers.java new file mode 100644 index 000000000..fd0a21cd5 --- /dev/null +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterInfoFreeMembers.java @@ -0,0 +1,67 @@ +// Generated by jextract + +package com.littlekt.wgpu; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +/** + * {@snippet lang=c : + * typedef void (*WGPUProcAdapterInfoFreeMembers)(WGPUAdapterInfo) + * } + */ +public class WGPUProcAdapterInfoFreeMembers { + + WGPUProcAdapterInfoFreeMembers() { + // Should not be called directly + } + + /** + * The function pointer signature, expressed as a functional interface + */ + public interface Function { + void apply(MemorySegment adapterInfo); + } + + private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( + WGPUAdapterInfo.layout() + ); + + /** + * The descriptor of this function pointer + */ + public static FunctionDescriptor descriptor() { + return $DESC; + } + + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUProcAdapterInfoFreeMembers.Function.class, "apply", $DESC); + + /** + * Allocates a new upcall stub, whose implementation is defined by {@code fi}. + * The lifetime of the returned segment is managed by {@code arena} + */ + public static MemorySegment allocate(WGPUProcAdapterInfoFreeMembers.Function fi, Arena arena) { + return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); + } + + private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); + + /** + * Invoke the upcall stub {@code funcPtr}, with given parameters + */ + public static void invoke(MemorySegment funcPtr,MemorySegment adapterInfo) { + try { + DOWN$MH.invokeExact(funcPtr, adapterInfo); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } +} + diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterRequestDevice.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterRequestDevice.java index 0f53fc25e..4b0b73dff 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterRequestDevice.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcAdapterRequestDevice.java @@ -14,7 +14,7 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter, const WGPUDeviceDescriptor *, WGPURequestDeviceCallback, void *) + * typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter, const WGPUDeviceDescriptor *, WGPUAdapterRequestDeviceCallback, void *) * } */ public class WGPUProcAdapterRequestDevice { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcBufferMapAsync.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcBufferMapAsync.java index e1e170a48..a6df28126 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcBufferMapAsync.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcBufferMapAsync.java @@ -14,7 +14,7 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer, WGPUMapModeFlags, size_t, size_t, WGPUBufferMapCallback, void *) + * typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer, WGPUMapModeFlags, size_t, size_t, WGPUBufferMapAsyncCallback, void *) * } */ public class WGPUProcBufferMapAsync { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateComputePipelineAsync.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateComputePipelineAsync.java index 9110762bd..f71d9e149 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateComputePipelineAsync.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateComputePipelineAsync.java @@ -14,7 +14,7 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice, const WGPUComputePipelineDescriptor *, WGPUCreateComputePipelineAsyncCallback, void *) + * typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice, const WGPUComputePipelineDescriptor *, WGPUDeviceCreateComputePipelineAsyncCallback, void *) * } */ public class WGPUProcDeviceCreateComputePipelineAsync { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateRenderPipelineAsync.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateRenderPipelineAsync.java index 4e988efed..58f4105a2 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateRenderPipelineAsync.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceCreateRenderPipelineAsync.java @@ -14,7 +14,7 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice, const WGPURenderPipelineDescriptor *, WGPUCreateRenderPipelineAsyncCallback, void *) + * typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice, const WGPURenderPipelineDescriptor *, WGPUDeviceCreateRenderPipelineAsyncCallback, void *) * } */ public class WGPUProcDeviceCreateRenderPipelineAsync { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceGetPreferredFormat.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcInstanceHasWGSLLanguageFeature.java similarity index 73% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceGetPreferredFormat.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcInstanceHasWGSLLanguageFeature.java index 6b138efed..4fccf903a 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceGetPreferredFormat.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcInstanceHasWGSLLanguageFeature.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef WGPUTextureFormat (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface, WGPUAdapter) + * typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance, WGPUWGSLFeatureName) * } */ -public class WGPUProcSurfaceGetPreferredFormat { +public class WGPUProcInstanceHasWGSLLanguageFeature { - WGPUProcSurfaceGetPreferredFormat() { + WGPUProcInstanceHasWGSLLanguageFeature() { // Should not be called directly } @@ -27,13 +27,13 @@ public class WGPUProcSurfaceGetPreferredFormat { * The function pointer signature, expressed as a functional interface */ public interface Function { - int apply(MemorySegment surface, MemorySegment adapter); + int apply(MemorySegment instance, int feature); } private static final FunctionDescriptor $DESC = FunctionDescriptor.of( WGPU.C_INT, WGPU.C_POINTER, - WGPU.C_POINTER + WGPU.C_INT ); /** @@ -43,13 +43,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUProcSurfaceGetPreferredFormat.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUProcInstanceHasWGSLLanguageFeature.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUProcSurfaceGetPreferredFormat.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUProcInstanceHasWGSLLanguageFeature.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } @@ -58,9 +58,9 @@ public static MemorySegment allocate(WGPUProcSurfaceGetPreferredFormat.Function /** * Invoke the upcall stub {@code funcPtr}, with given parameters */ - public static int invoke(MemorySegment funcPtr,MemorySegment surface, MemorySegment adapter) { + public static int invoke(MemorySegment funcPtr,MemorySegment instance, int feature) { try { - return (int) DOWN$MH.invokeExact(funcPtr, surface, adapter); + return (int) DOWN$MH.invokeExact(funcPtr, instance, feature); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcInstanceRequestAdapter.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcInstanceRequestAdapter.java index d1250f2dc..bf0bac1d1 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcInstanceRequestAdapter.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcInstanceRequestAdapter.java @@ -14,7 +14,7 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance, const WGPURequestAdapterOptions *, WGPURequestAdapterCallback, void *) + * typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance, const WGPURequestAdapterOptions *, WGPUInstanceRequestAdapterCallback, void *) * } */ public class WGPUProcInstanceRequestAdapter { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcQueueOnSubmittedWorkDone.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcQueueOnSubmittedWorkDone.java index 259a5514a..254339274 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcQueueOnSubmittedWorkDone.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcQueueOnSubmittedWorkDone.java @@ -14,7 +14,7 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue, WGPUQueueWorkDoneCallback, void *) + * typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue, WGPUQueueOnSubmittedWorkDoneCallback, void *) * } */ public class WGPUProcQueueOnSubmittedWorkDone { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcShaderModuleGetCompilationInfo.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcShaderModuleGetCompilationInfo.java index 923d50a03..38d74e9c7 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcShaderModuleGetCompilationInfo.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcShaderModuleGetCompilationInfo.java @@ -14,7 +14,7 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule, WGPUCompilationInfoCallback, void *) + * typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule, WGPUShaderModuleGetCompilationInfoCallback, void *) * } */ public class WGPUProcShaderModuleGetCompilationInfo { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceCapabilitiesFreeMembers.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceCapabilitiesFreeMembers.java index 7af2d684f..ac23302c2 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceCapabilitiesFreeMembers.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceCapabilitiesFreeMembers.java @@ -27,7 +27,7 @@ public class WGPUProcSurfaceCapabilitiesFreeMembers { * The function pointer signature, expressed as a functional interface */ public interface Function { - void apply(MemorySegment capabilities); + void apply(MemorySegment surfaceCapabilities); } private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( @@ -56,9 +56,9 @@ public static MemorySegment allocate(WGPUProcSurfaceCapabilitiesFreeMembers.Func /** * Invoke the upcall stub {@code funcPtr}, with given parameters */ - public static void invoke(MemorySegment funcPtr,MemorySegment capabilities) { + public static void invoke(MemorySegment funcPtr,MemorySegment surfaceCapabilities) { try { - DOWN$MH.invokeExact(funcPtr, capabilities); + DOWN$MH.invokeExact(funcPtr, surfaceCapabilities); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceSetUncapturedErrorCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceSetLabel.java similarity index 70% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceSetUncapturedErrorCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceSetLabel.java index 273551747..40afdd8c2 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcDeviceSetUncapturedErrorCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUProcSurfaceSetLabel.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPUProcDeviceSetUncapturedErrorCallback)(WGPUDevice, WGPUErrorCallback, void *) + * typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface, const char *) * } */ -public class WGPUProcDeviceSetUncapturedErrorCallback { +public class WGPUProcSurfaceSetLabel { - WGPUProcDeviceSetUncapturedErrorCallback() { + WGPUProcSurfaceSetLabel() { // Should not be called directly } @@ -27,11 +27,10 @@ public class WGPUProcDeviceSetUncapturedErrorCallback { * The function pointer signature, expressed as a functional interface */ public interface Function { - void apply(MemorySegment device, MemorySegment callback, MemorySegment userdata); + void apply(MemorySegment surface, MemorySegment label); } private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid( - WGPU.C_POINTER, WGPU.C_POINTER, WGPU.C_POINTER ); @@ -43,13 +42,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUProcDeviceSetUncapturedErrorCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUProcSurfaceSetLabel.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUProcDeviceSetUncapturedErrorCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUProcSurfaceSetLabel.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } @@ -58,9 +57,9 @@ public static MemorySegment allocate(WGPUProcDeviceSetUncapturedErrorCallback.Fu /** * Invoke the upcall stub {@code funcPtr}, with given parameters */ - public static void invoke(MemorySegment funcPtr,MemorySegment device, MemorySegment callback, MemorySegment userdata) { + public static void invoke(MemorySegment funcPtr,MemorySegment surface, MemorySegment label) { try { - DOWN$MH.invokeExact(funcPtr, device, callback, userdata); + DOWN$MH.invokeExact(funcPtr, surface, label); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUBufferMapCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUQueueOnSubmittedWorkDoneCallback.java similarity index 82% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUBufferMapCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUQueueOnSubmittedWorkDoneCallback.java index 03e2d349e..aa8431d63 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUBufferMapCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUQueueOnSubmittedWorkDoneCallback.java @@ -14,12 +14,12 @@ /** * {@snippet lang=c : - * typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus, void *) + * typedef void (*WGPUQueueOnSubmittedWorkDoneCallback)(WGPUQueueWorkDoneStatus, void *) * } */ -public class WGPUBufferMapCallback { +public class WGPUQueueOnSubmittedWorkDoneCallback { - WGPUBufferMapCallback() { + WGPUQueueOnSubmittedWorkDoneCallback() { // Should not be called directly } @@ -42,13 +42,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUBufferMapCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUQueueOnSubmittedWorkDoneCallback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUBufferMapCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUQueueOnSubmittedWorkDoneCallback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURenderPassColorAttachment.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURenderPassColorAttachment.java index 76a4e69c0..8a757412d 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURenderPassColorAttachment.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPURenderPassColorAttachment.java @@ -17,6 +17,7 @@ * struct WGPURenderPassColorAttachment { * const WGPUChainedStruct *nextInChain; * WGPUTextureView view; + * uint32_t depthSlice; * WGPUTextureView resolveTarget; * WGPULoadOp loadOp; * WGPUStoreOp storeOp; @@ -33,6 +34,8 @@ public class WGPURenderPassColorAttachment { private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( WGPU.C_POINTER.withName("nextInChain"), WGPU.C_POINTER.withName("view"), + WGPU.C_INT.withName("depthSlice"), + MemoryLayout.paddingLayout(4), WGPU.C_POINTER.withName("resolveTarget"), WGPU.C_INT.withName("loadOp"), WGPU.C_INT.withName("storeOp"), @@ -134,6 +137,50 @@ public static void view(MemorySegment struct, MemorySegment fieldValue) { struct.set(view$LAYOUT, view$OFFSET, fieldValue); } + private static final OfInt depthSlice$LAYOUT = (OfInt)$LAYOUT.select(groupElement("depthSlice")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t depthSlice + * } + */ + public static final OfInt depthSlice$layout() { + return depthSlice$LAYOUT; + } + + private static final long depthSlice$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t depthSlice + * } + */ + public static final long depthSlice$offset() { + return depthSlice$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t depthSlice + * } + */ + public static int depthSlice(MemorySegment struct) { + return struct.get(depthSlice$LAYOUT, depthSlice$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t depthSlice + * } + */ + public static void depthSlice(MemorySegment struct, int fieldValue) { + struct.set(depthSlice$LAYOUT, depthSlice$OFFSET, fieldValue); + } + private static final AddressLayout resolveTarget$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("resolveTarget")); /** @@ -146,7 +193,7 @@ public static void view(MemorySegment struct, MemorySegment fieldValue) { return resolveTarget$LAYOUT; } - private static final long resolveTarget$OFFSET = 16; + private static final long resolveTarget$OFFSET = 24; /** * Offset for field: @@ -190,7 +237,7 @@ public static void resolveTarget(MemorySegment struct, MemorySegment fieldValue) return loadOp$LAYOUT; } - private static final long loadOp$OFFSET = 24; + private static final long loadOp$OFFSET = 32; /** * Offset for field: @@ -234,7 +281,7 @@ public static void loadOp(MemorySegment struct, int fieldValue) { return storeOp$LAYOUT; } - private static final long storeOp$OFFSET = 28; + private static final long storeOp$OFFSET = 36; /** * Offset for field: @@ -278,7 +325,7 @@ public static void storeOp(MemorySegment struct, int fieldValue) { return clearValue$LAYOUT; } - private static final long clearValue$OFFSET = 32; + private static final long clearValue$OFFSET = 40; /** * Offset for field: diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCompilationInfoCallback.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUShaderModuleGetCompilationInfoCallback.java similarity index 81% rename from wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCompilationInfoCallback.java rename to wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUShaderModuleGetCompilationInfoCallback.java index 4e611ddbe..8634eda09 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUCompilationInfoCallback.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUShaderModuleGetCompilationInfoCallback.java @@ -14,16 +14,16 @@ /** * {@snippet lang=c : - * typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus, const struct WGPUCompilationInfo { + * typedef void (*WGPUShaderModuleGetCompilationInfoCallback)(WGPUCompilationInfoRequestStatus, const struct WGPUCompilationInfo { * const WGPUChainedStruct *nextInChain; * size_t messageCount; * const WGPUCompilationMessage *messages; * } *, void *) * } */ -public class WGPUCompilationInfoCallback { +public class WGPUShaderModuleGetCompilationInfoCallback { - WGPUCompilationInfoCallback() { + WGPUShaderModuleGetCompilationInfoCallback() { // Should not be called directly } @@ -47,13 +47,13 @@ public static FunctionDescriptor descriptor() { return $DESC; } - private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUCompilationInfoCallback.Function.class, "apply", $DESC); + private static final MethodHandle UP$MH = WGPU.upcallHandle(WGPUShaderModuleGetCompilationInfoCallback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ - public static MemorySegment allocate(WGPUCompilationInfoCallback.Function fi, Arena arena) { + public static MemorySegment allocate(WGPUShaderModuleGetCompilationInfoCallback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceCapabilities.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceCapabilities.java index 8c9ea10a1..7f8d14d43 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceCapabilities.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceCapabilities.java @@ -16,12 +16,13 @@ * {@snippet lang=c : * struct WGPUSurfaceCapabilities { * WGPUChainedStructOut *nextInChain; + * WGPUTextureUsageFlags usages; * size_t formatCount; - * WGPUTextureFormat *formats; + * const WGPUTextureFormat *formats; * size_t presentModeCount; - * WGPUPresentMode *presentModes; + * const WGPUPresentMode *presentModes; * size_t alphaModeCount; - * WGPUCompositeAlphaMode *alphaModes; + * const WGPUCompositeAlphaMode *alphaModes; * } * } */ @@ -33,6 +34,8 @@ public class WGPUSurfaceCapabilities { private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( WGPU.C_POINTER.withName("nextInChain"), + WGPU.C_INT.withName("usages"), + MemoryLayout.paddingLayout(4), WGPU.C_LONG_LONG.withName("formatCount"), WGPU.C_POINTER.withName("formats"), WGPU.C_LONG_LONG.withName("presentModeCount"), @@ -92,6 +95,50 @@ public static void nextInChain(MemorySegment struct, MemorySegment fieldValue) { struct.set(nextInChain$LAYOUT, nextInChain$OFFSET, fieldValue); } + private static final OfInt usages$LAYOUT = (OfInt)$LAYOUT.select(groupElement("usages")); + + /** + * Layout for field: + * {@snippet lang=c : + * WGPUTextureUsageFlags usages + * } + */ + public static final OfInt usages$layout() { + return usages$LAYOUT; + } + + private static final long usages$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * WGPUTextureUsageFlags usages + * } + */ + public static final long usages$offset() { + return usages$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * WGPUTextureUsageFlags usages + * } + */ + public static int usages(MemorySegment struct) { + return struct.get(usages$LAYOUT, usages$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * WGPUTextureUsageFlags usages + * } + */ + public static void usages(MemorySegment struct, int fieldValue) { + struct.set(usages$LAYOUT, usages$OFFSET, fieldValue); + } + private static final OfLong formatCount$LAYOUT = (OfLong)$LAYOUT.select(groupElement("formatCount")); /** @@ -104,7 +151,7 @@ public static void nextInChain(MemorySegment struct, MemorySegment fieldValue) { return formatCount$LAYOUT; } - private static final long formatCount$OFFSET = 8; + private static final long formatCount$OFFSET = 16; /** * Offset for field: @@ -141,19 +188,19 @@ public static void formatCount(MemorySegment struct, long fieldValue) { /** * Layout for field: * {@snippet lang=c : - * WGPUTextureFormat *formats + * const WGPUTextureFormat *formats * } */ public static final AddressLayout formats$layout() { return formats$LAYOUT; } - private static final long formats$OFFSET = 16; + private static final long formats$OFFSET = 24; /** * Offset for field: * {@snippet lang=c : - * WGPUTextureFormat *formats + * const WGPUTextureFormat *formats * } */ public static final long formats$offset() { @@ -163,7 +210,7 @@ public static void formatCount(MemorySegment struct, long fieldValue) { /** * Getter for field: * {@snippet lang=c : - * WGPUTextureFormat *formats + * const WGPUTextureFormat *formats * } */ public static MemorySegment formats(MemorySegment struct) { @@ -173,7 +220,7 @@ public static MemorySegment formats(MemorySegment struct) { /** * Setter for field: * {@snippet lang=c : - * WGPUTextureFormat *formats + * const WGPUTextureFormat *formats * } */ public static void formats(MemorySegment struct, MemorySegment fieldValue) { @@ -192,7 +239,7 @@ public static void formats(MemorySegment struct, MemorySegment fieldValue) { return presentModeCount$LAYOUT; } - private static final long presentModeCount$OFFSET = 24; + private static final long presentModeCount$OFFSET = 32; /** * Offset for field: @@ -229,19 +276,19 @@ public static void presentModeCount(MemorySegment struct, long fieldValue) { /** * Layout for field: * {@snippet lang=c : - * WGPUPresentMode *presentModes + * const WGPUPresentMode *presentModes * } */ public static final AddressLayout presentModes$layout() { return presentModes$LAYOUT; } - private static final long presentModes$OFFSET = 32; + private static final long presentModes$OFFSET = 40; /** * Offset for field: * {@snippet lang=c : - * WGPUPresentMode *presentModes + * const WGPUPresentMode *presentModes * } */ public static final long presentModes$offset() { @@ -251,7 +298,7 @@ public static void presentModeCount(MemorySegment struct, long fieldValue) { /** * Getter for field: * {@snippet lang=c : - * WGPUPresentMode *presentModes + * const WGPUPresentMode *presentModes * } */ public static MemorySegment presentModes(MemorySegment struct) { @@ -261,7 +308,7 @@ public static MemorySegment presentModes(MemorySegment struct) { /** * Setter for field: * {@snippet lang=c : - * WGPUPresentMode *presentModes + * const WGPUPresentMode *presentModes * } */ public static void presentModes(MemorySegment struct, MemorySegment fieldValue) { @@ -280,7 +327,7 @@ public static void presentModes(MemorySegment struct, MemorySegment fieldValue) return alphaModeCount$LAYOUT; } - private static final long alphaModeCount$OFFSET = 40; + private static final long alphaModeCount$OFFSET = 48; /** * Offset for field: @@ -317,19 +364,19 @@ public static void alphaModeCount(MemorySegment struct, long fieldValue) { /** * Layout for field: * {@snippet lang=c : - * WGPUCompositeAlphaMode *alphaModes + * const WGPUCompositeAlphaMode *alphaModes * } */ public static final AddressLayout alphaModes$layout() { return alphaModes$LAYOUT; } - private static final long alphaModes$OFFSET = 48; + private static final long alphaModes$OFFSET = 56; /** * Offset for field: * {@snippet lang=c : - * WGPUCompositeAlphaMode *alphaModes + * const WGPUCompositeAlphaMode *alphaModes * } */ public static final long alphaModes$offset() { @@ -339,7 +386,7 @@ public static void alphaModeCount(MemorySegment struct, long fieldValue) { /** * Getter for field: * {@snippet lang=c : - * WGPUCompositeAlphaMode *alphaModes + * const WGPUCompositeAlphaMode *alphaModes * } */ public static MemorySegment alphaModes(MemorySegment struct) { @@ -349,7 +396,7 @@ public static MemorySegment alphaModes(MemorySegment struct) { /** * Setter for field: * {@snippet lang=c : - * WGPUCompositeAlphaMode *alphaModes + * const WGPUCompositeAlphaMode *alphaModes * } */ public static void alphaModes(MemorySegment struct, MemorySegment fieldValue) { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceConfigurationExtras.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceConfigurationExtras.java index 17a65567f..37f653397 100644 --- a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceConfigurationExtras.java +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUSurfaceConfigurationExtras.java @@ -16,7 +16,7 @@ * {@snippet lang=c : * struct WGPUSurfaceConfigurationExtras { * WGPUChainedStruct chain; - * WGPUBool desiredMaximumFrameLatency; + * uint32_t desiredMaximumFrameLatency; * } * } */ @@ -88,7 +88,7 @@ public static void chain(MemorySegment struct, MemorySegment fieldValue) { /** * Layout for field: * {@snippet lang=c : - * WGPUBool desiredMaximumFrameLatency + * uint32_t desiredMaximumFrameLatency * } */ public static final OfInt desiredMaximumFrameLatency$layout() { @@ -100,7 +100,7 @@ public static void chain(MemorySegment struct, MemorySegment fieldValue) { /** * Offset for field: * {@snippet lang=c : - * WGPUBool desiredMaximumFrameLatency + * uint32_t desiredMaximumFrameLatency * } */ public static final long desiredMaximumFrameLatency$offset() { @@ -110,7 +110,7 @@ public static void chain(MemorySegment struct, MemorySegment fieldValue) { /** * Getter for field: * {@snippet lang=c : - * WGPUBool desiredMaximumFrameLatency + * uint32_t desiredMaximumFrameLatency * } */ public static int desiredMaximumFrameLatency(MemorySegment struct) { @@ -120,7 +120,7 @@ public static int desiredMaximumFrameLatency(MemorySegment struct) { /** * Setter for field: * {@snippet lang=c : - * WGPUBool desiredMaximumFrameLatency + * uint32_t desiredMaximumFrameLatency * } */ public static void desiredMaximumFrameLatency(MemorySegment struct, int fieldValue) { diff --git a/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUUncapturedErrorCallbackInfo.java b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUUncapturedErrorCallbackInfo.java new file mode 100644 index 000000000..e9f0eb4de --- /dev/null +++ b/wgpu-ffm/src/main/java/com/littlekt/wgpu/WGPUUncapturedErrorCallbackInfo.java @@ -0,0 +1,219 @@ +// Generated by jextract + +package com.littlekt.wgpu; + +import java.lang.invoke.*; +import java.lang.foreign.*; +import java.nio.ByteOrder; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.foreign.MemoryLayout.PathElement.*; + +/** + * {@snippet lang=c : + * struct WGPUUncapturedErrorCallbackInfo { + * const WGPUChainedStruct *nextInChain; + * WGPUErrorCallback callback; + * void *userdata; + * } + * } + */ +public class WGPUUncapturedErrorCallbackInfo { + + WGPUUncapturedErrorCallbackInfo() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + WGPU.C_POINTER.withName("nextInChain"), + WGPU.C_POINTER.withName("callback"), + WGPU.C_POINTER.withName("userdata") + ).withName("WGPUUncapturedErrorCallbackInfo"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final AddressLayout nextInChain$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("nextInChain")); + + /** + * Layout for field: + * {@snippet lang=c : + * const WGPUChainedStruct *nextInChain + * } + */ + public static final AddressLayout nextInChain$layout() { + return nextInChain$LAYOUT; + } + + private static final long nextInChain$OFFSET = 0; + + /** + * Offset for field: + * {@snippet lang=c : + * const WGPUChainedStruct *nextInChain + * } + */ + public static final long nextInChain$offset() { + return nextInChain$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * const WGPUChainedStruct *nextInChain + * } + */ + public static MemorySegment nextInChain(MemorySegment struct) { + return struct.get(nextInChain$LAYOUT, nextInChain$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * const WGPUChainedStruct *nextInChain + * } + */ + public static void nextInChain(MemorySegment struct, MemorySegment fieldValue) { + struct.set(nextInChain$LAYOUT, nextInChain$OFFSET, fieldValue); + } + + private static final AddressLayout callback$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("callback")); + + /** + * Layout for field: + * {@snippet lang=c : + * WGPUErrorCallback callback + * } + */ + public static final AddressLayout callback$layout() { + return callback$LAYOUT; + } + + private static final long callback$OFFSET = 8; + + /** + * Offset for field: + * {@snippet lang=c : + * WGPUErrorCallback callback + * } + */ + public static final long callback$offset() { + return callback$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * WGPUErrorCallback callback + * } + */ + public static MemorySegment callback(MemorySegment struct) { + return struct.get(callback$LAYOUT, callback$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * WGPUErrorCallback callback + * } + */ + public static void callback(MemorySegment struct, MemorySegment fieldValue) { + struct.set(callback$LAYOUT, callback$OFFSET, fieldValue); + } + + private static final AddressLayout userdata$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("userdata")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *userdata + * } + */ + public static final AddressLayout userdata$layout() { + return userdata$LAYOUT; + } + + private static final long userdata$OFFSET = 16; + + /** + * Offset for field: + * {@snippet lang=c : + * void *userdata + * } + */ + public static final long userdata$offset() { + return userdata$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *userdata + * } + */ + public static MemorySegment userdata(MemorySegment struct) { + return struct.get(userdata$LAYOUT, userdata$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *userdata + * } + */ + public static void userdata(MemorySegment struct, MemorySegment fieldValue) { + struct.set(userdata$LAYOUT, userdata$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/wgpu-natives/build.gradle.kts b/wgpu-natives/build.gradle.kts index 9962ec5ed..e71675682 100644 --- a/wgpu-natives/build.gradle.kts +++ b/wgpu-natives/build.gradle.kts @@ -34,10 +34,10 @@ tasks { onlyIfModified(true) src( listOf( - "$baseUrl/wgpu-windows-x86_64-release.zip", + "$baseUrl/wgpu-windows-x86_64-msvc-release.zip", "$baseUrl/wgpu-macos-x86_64-release.zip ", "$baseUrl/wgpu-macos-aarch64-release.zip ", - "$baseUrl/wgpu-linux-x86_64-release.zip" + "$baseUrl/wgpu-linux-x86_64-release.zip", ) ) dest(layout.buildDirectory.asFile.get()) @@ -47,7 +47,7 @@ tasks { dependsOn("downloadWgpuNativeBinaries") val buildDir = layout.buildDirectory.asFile.get().path - from(zipTree("$buildDir/wgpu-windows-x86_64-release.zip")) { include("**.dll") } + from(zipTree("$buildDir/wgpu-windows-x86_64-msvc-release.zip")) { include("**.dll") } from(zipTree("$buildDir/wgpu-macos-x86_64-release.zip")) { include("**.dylib") } from(zipTree("$buildDir/wgpu-macos-aarch64-release.zip")) { include("**.dylib") diff --git a/wgpu-natives/src/main/c/webgpu.h b/wgpu-natives/src/main/c/webgpu.h index d25335135..cb423fc07 100644 --- a/wgpu-natives/src/main/c/webgpu.h +++ b/wgpu-natives/src/main/c/webgpu.h @@ -1,32 +1,20 @@ -// BSD 3-Clause License -// -// Copyright (c) 2019, "WebGPU native" developers -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/** + * Copyright 2019-2023 WebGPU-Native developers + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** @file */ + +/** + * \mainpage + * + * **Important:** *This documentation is a Work In Progress.* + * + * This is the home of WebGPU C API specification. We define here the standard + * `webgpu.h` header that all implementations should provide. + */ + #ifndef WEBGPU_H_ #define WEBGPU_H_ @@ -67,18 +55,44 @@ #include #include + +/** + * \defgroup Constants + * \brief Constants. + * + * @{ + */ #define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (0xffffffffUL) #define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL) +#define WGPU_DEPTH_SLICE_UNDEFINED (0xffffffffUL) #define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL) #define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL) #define WGPU_MIP_LEVEL_COUNT_UNDEFINED (0xffffffffUL) #define WGPU_QUERY_SET_INDEX_UNDEFINED (0xffffffffUL) -#define WGPU_WHOLE_MAP_SIZE SIZE_MAX +#define WGPU_WHOLE_MAP_SIZE (SIZE_MAX) #define WGPU_WHOLE_SIZE (0xffffffffffffffffULL) + +/** @} */ + +/** + * \defgroup Typedefs + * \brief Utility typedefs. + * + * @{ + */ typedef uint32_t WGPUFlags; typedef uint32_t WGPUBool; + +/** @} */ + +/** + * \defgroup Objects + * \brief Opaque, non-dispatchable handles to WebGPU objects. + * + * @{ + */ typedef struct WGPUAdapterImpl* WGPUAdapter WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUBindGroupImpl* WGPUBindGroup WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout WGPU_OBJECT_ATTRIBUTE; @@ -102,8 +116,10 @@ typedef struct WGPUSurfaceImpl* WGPUSurface WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureImpl* WGPUTexture WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE; + +/** @} */ // Structure forward declarations -struct WGPUAdapterProperties; +struct WGPUAdapterInfo; struct WGPUBindGroupEntry; struct WGPUBlendComponent; struct WGPUBufferBindingLayout; @@ -151,6 +167,7 @@ struct WGPUSurfaceTexture; struct WGPUTextureBindingLayout; struct WGPUTextureDataLayout; struct WGPUTextureViewDescriptor; +struct WGPUUncapturedErrorCallbackInfo; struct WGPUVertexAttribute; struct WGPUBindGroupDescriptor; struct WGPUBindGroupLayoutEntry; @@ -176,6 +193,13 @@ struct WGPUVertexState; struct WGPUFragmentState; struct WGPURenderPipelineDescriptor; + +/** + * \defgroup Enumerations + * \brief Enums. + * + * @{ + */ typedef enum WGPUAdapterType { WGPUAdapterType_DiscreteGPU = 0x00000000, WGPUAdapterType_IntegratedGPU = 0x00000001, @@ -313,8 +337,8 @@ typedef enum WGPUCullMode { } WGPUCullMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUDeviceLostReason { - WGPUDeviceLostReason_Undefined = 0x00000000, - WGPUDeviceLostReason_Destroyed = 0x00000001, + WGPUDeviceLostReason_Unknown = 0x00000001, + WGPUDeviceLostReason_Destroyed = 0x00000002, WGPUDeviceLostReason_Force32 = 0x7FFFFFFF } WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; @@ -674,6 +698,24 @@ typedef enum WGPUVertexStepMode { WGPUVertexStepMode_Force32 = 0x7FFFFFFF } WGPUVertexStepMode WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUWGSLFeatureName { + WGPUWGSLFeatureName_Undefined = 0x00000000, + WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, + WGPUWGSLFeatureName_Packed4x8IntegerDotProduct = 0x00000002, + WGPUWGSLFeatureName_UnrestrictedPointerParameters = 0x00000003, + WGPUWGSLFeatureName_PointerCompositeAccess = 0x00000004, + WGPUWGSLFeatureName_Force32 = 0x7FFFFFFF +} WGPUWGSLFeatureName WGPU_ENUM_ATTRIBUTE; + + +/** @} */ + +/** + * \defgroup Bitflags + * \brief Enum used as bit flags. + * + * @{ + */ typedef enum WGPUBufferUsage { WGPUBufferUsage_None = 0x00000000, WGPUBufferUsage_MapRead = 0x00000001, @@ -696,7 +738,7 @@ typedef enum WGPUColorWriteMask { WGPUColorWriteMask_Green = 0x00000002, WGPUColorWriteMask_Blue = 0x00000004, WGPUColorWriteMask_Alpha = 0x00000008, - WGPUColorWriteMask_All = 0x0000000F, + WGPUColorWriteMask_All = WGPUColorWriteMask_None | WGPUColorWriteMask_Red | WGPUColorWriteMask_Green | WGPUColorWriteMask_Blue | WGPUColorWriteMask_Alpha, WGPUColorWriteMask_Force32 = 0x7FFFFFFF } WGPUColorWriteMask WGPU_ENUM_ATTRIBUTE; typedef WGPUFlags WGPUColorWriteMaskFlags WGPU_ENUM_ATTRIBUTE; @@ -729,16 +771,36 @@ typedef enum WGPUTextureUsage { } WGPUTextureUsage WGPU_ENUM_ATTRIBUTE; typedef WGPUFlags WGPUTextureUsageFlags WGPU_ENUM_ATTRIBUTE; -typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus status, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; + +/** @} */ +typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; + typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; + +/** + * \defgroup Callbacks + * \brief Callbacks through which asynchronous functions return. + * + * @{ + */ + +typedef void (*WGPUAdapterRequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUBufferMapAsyncCallback)(WGPUBufferMapAsyncStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUDeviceCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUDeviceCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUInstanceRequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUQueueOnSubmittedWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUShaderModuleGetCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; + + +/** @} */ +/** + * \defgroup ChainedStructures Chained Structures + * \brief Structures used to extend descriptors. + * + * @{ + */ typedef struct WGPUChainedStruct { struct WGPUChainedStruct const * next; @@ -750,17 +812,26 @@ typedef struct WGPUChainedStructOut { WGPUSType sType; } WGPUChainedStructOut WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUAdapterProperties { +/** @} */ + + +/** + * \defgroup Structures + * \brief Descriptors and other transparent structures. + * + * @{ + */ +typedef struct WGPUAdapterInfo { WGPUChainedStructOut * nextInChain; - uint32_t vendorID; - char const * vendorName; + char const * vendor; char const * architecture; - uint32_t deviceID; - char const * name; - char const * driverDescription; - WGPUAdapterType adapterType; + char const * device; + char const * description; WGPUBackendType backendType; -} WGPUAdapterProperties WGPU_STRUCTURE_ATTRIBUTE; + WGPUAdapterType adapterType; + uint32_t vendorID; + uint32_t deviceID; +} WGPUAdapterInfo WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupEntry { WGPUChainedStruct const * nextInChain; @@ -900,7 +971,6 @@ typedef struct WGPUPipelineLayoutDescriptor { WGPUBindGroupLayout const * bindGroupLayouts; } WGPUPipelineLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUPrimitiveState typedef struct WGPUPrimitiveDepthClipControl { WGPUChainedStruct chain; WGPUBool unclippedDepth; @@ -954,7 +1024,6 @@ typedef struct WGPURenderPassDepthStencilAttachment { WGPUBool stencilReadOnly; } WGPURenderPassDepthStencilAttachment WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPURenderPassDescriptor typedef struct WGPURenderPassDescriptorMaxDrawCount { WGPUChainedStruct chain; uint64_t maxDrawCount; @@ -1000,14 +1069,12 @@ typedef struct WGPUShaderModuleCompilationHint { WGPUPipelineLayout layout; } WGPUShaderModuleCompilationHint WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUShaderModuleDescriptor typedef struct WGPUShaderModuleSPIRVDescriptor { WGPUChainedStruct chain; uint32_t codeSize; uint32_t const * code; } WGPUShaderModuleSPIRVDescriptor WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUShaderModuleDescriptor typedef struct WGPUShaderModuleWGSLDescriptor { WGPUChainedStruct chain; char const * code; @@ -1029,12 +1096,13 @@ typedef struct WGPUStorageTextureBindingLayout { typedef struct WGPUSurfaceCapabilities { WGPUChainedStructOut * nextInChain; + WGPUTextureUsageFlags usages; size_t formatCount; - WGPUTextureFormat * formats; + WGPUTextureFormat const * formats; size_t presentModeCount; - WGPUPresentMode * presentModes; + WGPUPresentMode const * presentModes; size_t alphaModeCount; - WGPUCompositeAlphaMode * alphaModes; + WGPUCompositeAlphaMode const * alphaModes; } WGPUSurfaceCapabilities WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSurfaceConfiguration { @@ -1055,46 +1123,39 @@ typedef struct WGPUSurfaceDescriptor { WGPU_NULLABLE char const * label; } WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromAndroidNativeWindow { WGPUChainedStruct chain; void * window; } WGPUSurfaceDescriptorFromAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromCanvasHTMLSelector { WGPUChainedStruct chain; char const * selector; } WGPUSurfaceDescriptorFromCanvasHTMLSelector WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromMetalLayer { WGPUChainedStruct chain; void * layer; } WGPUSurfaceDescriptorFromMetalLayer WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromWaylandSurface { WGPUChainedStruct chain; void * display; void * surface; } WGPUSurfaceDescriptorFromWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromWindowsHWND { WGPUChainedStruct chain; void * hinstance; void * hwnd; } WGPUSurfaceDescriptorFromWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromXcbWindow { WGPUChainedStruct chain; void * connection; uint32_t window; } WGPUSurfaceDescriptorFromXcbWindow WGPU_STRUCTURE_ATTRIBUTE; -// Can be chained in WGPUSurfaceDescriptor typedef struct WGPUSurfaceDescriptorFromXlibWindow { WGPUChainedStruct chain; void * display; @@ -1133,6 +1194,12 @@ typedef struct WGPUTextureViewDescriptor { WGPUTextureAspect aspect; } WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUUncapturedErrorCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUErrorCallback callback; + void * userdata; +} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + typedef struct WGPUVertexAttribute { WGPUVertexFormat format; uint64_t offset; @@ -1213,6 +1280,7 @@ typedef struct WGPUProgrammableStageDescriptor { typedef struct WGPURenderPassColorAttachment { WGPUChainedStruct const * nextInChain; WGPU_NULLABLE WGPUTextureView view; + uint32_t depthSlice; WGPU_NULLABLE WGPUTextureView resolveTarget; WGPULoadOp loadOp; WGPUStoreOp storeOp; @@ -1286,6 +1354,7 @@ typedef struct WGPUDeviceDescriptor { WGPUQueueDescriptor defaultQueue; WGPUDeviceLostCallback deviceLostCallback; void * deviceLostUserdata; + WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; } WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassDescriptor { @@ -1329,6 +1398,8 @@ typedef struct WGPURenderPipelineDescriptor { WGPU_NULLABLE WGPUFragmentState const * fragment; } WGPURenderPipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** @} */ + #ifdef __cplusplus extern "C" { #endif @@ -1340,13 +1411,16 @@ typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procN // Procs of Adapter typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter adapter, WGPUAdapterProperties * properties) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcAdapterReference)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcAdapterRelease)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +// Procs of AdapterInfo +typedef void (*WGPUProcAdapterInfoFreeMembers)(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; + // Procs of BindGroup typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; @@ -1364,7 +1438,7 @@ typedef WGPUBufferMapState (*WGPUProcBufferGetMapState)(WGPUBuffer buffer) WGPU_ typedef void * (*WGPUProcBufferGetMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUBufferUsageFlags (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcBufferReference)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; @@ -1418,12 +1492,12 @@ typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice de typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -1435,14 +1509,14 @@ typedef WGPUBool (*WGPUProcDeviceHasFeature)(WGPUDevice device, WGPUFeatureName typedef void (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceSetUncapturedErrorCallback)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcDeviceReference)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcDeviceRelease)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; // Procs of Instance typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcInstanceReference)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; @@ -1460,7 +1534,7 @@ typedef void (*WGPUProcQuerySetReference)(WGPUQuerySet querySet) WGPU_FUNCTION_A typedef void (*WGPUProcQuerySetRelease)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; // Procs of Queue -typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; @@ -1526,7 +1600,7 @@ typedef void (*WGPUProcSamplerReference)(WGPUSampler sampler) WGPU_FUNCTION_ATTR typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; // Procs of ShaderModule -typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; @@ -1535,14 +1609,14 @@ typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_ typedef void (*WGPUProcSurfaceConfigure)(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcSurfaceGetCapabilities)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcSurfaceGetCurrentTexture)(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUTextureFormat (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcSurfacePresent)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface surface, char const * label) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcSurfaceUnconfigure)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; // Procs of SurfaceCapabilities -typedef void (*WGPUProcSurfaceCapabilitiesFreeMembers)(WGPUSurfaceCapabilities capabilities) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUProcSurfaceCapabilitiesFreeMembers)(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; // Procs of Texture typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -1567,48 +1641,119 @@ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUN #endif // !defined(WGPU_SKIP_PROCS) #if !defined(WGPU_SKIP_DECLARATIONS) - +/** + * \defgroup GlobalFunctions Global Functions + * \brief Functions that are not specific to an object. + * + * @{ + */ WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; -// Methods of Adapter + +/** @} */ + +/** + * \defgroup Methods + * \brief Functions that are relative to a specific object. + * + * @{ + */ + +/** + * \defgroup WGPUAdapterMethods WGPUAdapter methods + * \brief Functions whose first argument has type WGPUAdapter. + * + * @{ + */ WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUAdapterInfoMethods WGPUAdapterInfo methods + * \brief Functions whose first argument has type WGPUAdapterInfo. + * + * @{ + */ +WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + -// Methods of BindGroup + +/** + * \defgroup WGPUBindGroupMethods WGPUBindGroup methods + * \brief Functions whose first argument has type WGPUBindGroup. + * + * @{ + */ WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of BindGroupLayout +/** + * \defgroup WGPUBindGroupLayoutMethods WGPUBindGroupLayout methods + * \brief Functions whose first argument has type WGPUBindGroupLayout. + * + * @{ + */ WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of Buffer +/** + * \defgroup WGPUBufferMethods WGPUBuffer methods + * \brief Functions whose first argument has type WGPUBuffer. + * + * @{ + */ WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of CommandBuffer + + +/** + * \defgroup WGPUCommandBufferMethods WGPUCommandBuffer methods + * \brief Functions whose first argument has type WGPUCommandBuffer. + * + * @{ + */ WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + -// Methods of CommandEncoder + +/** + * \defgroup WGPUCommandEncoderMethods WGPUCommandEncoder methods + * \brief Functions whose first argument has type WGPUCommandEncoder. + * + * @{ + */ WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; @@ -1625,8 +1770,16 @@ WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, c WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + -// Methods of ComputePassEncoder + +/** + * \defgroup WGPUComputePassEncoderMethods WGPUComputePassEncoder methods + * \brief Functions whose first argument has type WGPUComputePassEncoder. + * + * @{ + */ WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; @@ -1638,25 +1791,41 @@ WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePa WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of ComputePipeline +/** + * \defgroup WGPUComputePipelineMethods WGPUComputePipeline methods + * \brief Functions whose first argument has type WGPUComputePipeline. + * + * @{ + */ WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of Device +/** + * \defgroup WGPUDeviceMethods WGPUDevice methods + * \brief Functions whose first argument has type WGPUDevice. + * + * @{ + */ WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -1668,45 +1837,93 @@ WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName fea WGPU_EXPORT void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Instance + + +/** + * \defgroup WGPUInstanceMethods WGPUInstance methods + * \brief Functions whose first argument has type WGPUInstance. + * + * @{ + */ WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + -// Methods of PipelineLayout + +/** + * \defgroup WGPUPipelineLayoutMethods WGPUPipelineLayout methods + * \brief Functions whose first argument has type WGPUPipelineLayout. + * + * @{ + */ WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + -// Methods of QuerySet + +/** + * \defgroup WGPUQuerySetMethods WGPUQuerySet methods + * \brief Functions whose first argument has type WGPUQuerySet. + * + * @{ + */ WGPU_EXPORT void wgpuQuerySetDestroy(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of Queue -WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * \defgroup WGPUQueueMethods WGPUQueue methods + * \brief Functions whose first argument has type WGPUQueue. + * + * @{ + */ +WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueReference(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of RenderBundle +/** + * \defgroup WGPURenderBundleMethods WGPURenderBundle methods + * \brief Functions whose first argument has type WGPURenderBundle. + * + * @{ + */ WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleReference(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of RenderBundleEncoder + + +/** + * \defgroup WGPURenderBundleEncoderMethods WGPURenderBundleEncoder methods + * \brief Functions whose first argument has type WGPURenderBundleEncoder. + * + * @{ + */ WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; @@ -1722,8 +1939,16 @@ WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder rend WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + -// Methods of RenderPassEncoder + +/** + * \defgroup WGPURenderPassEncoderMethods WGPURenderPassEncoder methods + * \brief Functions whose first argument has type WGPURenderPassEncoder. + * + * @{ + */ WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; @@ -1746,38 +1971,86 @@ WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder rend WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + -// Methods of RenderPipeline + +/** + * \defgroup WGPURenderPipelineMethods WGPURenderPipeline methods + * \brief Functions whose first argument has type WGPURenderPipeline. + * + * @{ + */ WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of Sampler +/** + * \defgroup WGPUSamplerMethods WGPUSampler methods + * \brief Functions whose first argument has type WGPUSampler. + * + * @{ + */ WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSamplerReference(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of ShaderModule -WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * \defgroup WGPUShaderModuleMethods WGPUShaderModule methods + * \brief Functions whose first argument has type WGPUShaderModule. + * + * @{ + */ +WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleReference(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of Surface + + +/** + * \defgroup WGPUSurfaceMethods WGPUSurface methods + * \brief Functions whose first argument has type WGPUSurface. + * + * @{ + */ WGPU_EXPORT void wgpuSurfaceConfigure(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceGetCurrentTexture(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfacePresent(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSurfaceSetLabel(WGPUSurface surface, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceUnconfigure(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUSurfaceCapabilitiesMethods WGPUSurfaceCapabilities methods + * \brief Functions whose first argument has type WGPUSurfaceCapabilities. + * + * @{ + */ +WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ -// Methods of SurfaceCapabilities -WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities capabilities) WGPU_FUNCTION_ATTRIBUTE; -// Methods of Texture + +/** + * \defgroup WGPUTextureMethods WGPUTexture methods + * \brief Functions whose first argument has type WGPUTexture. + * + * @{ + */ WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureDestroy(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; @@ -1791,11 +2064,23 @@ WGPU_EXPORT uint32_t wgpuTextureGetWidth(WGPUTexture texture) WGPU_FUNCTION_ATTR WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureReference(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + -// Methods of TextureView +/** + * \defgroup WGPUTextureViewMethods WGPUTextureView methods + * \brief Functions whose first argument has type WGPUTextureView. + * + * @{ + */ WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureViewReference(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureViewRelease(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + +/** @} */ #endif // !defined(WGPU_SKIP_DECLARATIONS) diff --git a/wgpu-natives/src/main/c/wgpu.h b/wgpu-natives/src/main/c/wgpu.h index ce9c7589c..28a51f629 100644 --- a/wgpu-natives/src/main/c/wgpu.h +++ b/wgpu-natives/src/main/c/wgpu.h @@ -29,6 +29,30 @@ typedef enum WGPUNativeFeature { WGPUNativeFeature_PipelineStatisticsQuery = 0x00030008, WGPUNativeFeature_StorageResourceBindingArray = 0x00030009, WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A, + WGPUNativeFeature_TextureFormat16bitNorm = 0x0003000B, + WGPUNativeFeature_TextureCompressionAstcHdr = 0x0003000C, + // TODO: requires wgpu.h api change + // WGPUNativeFeature_TimestampQueryInsidePasses = 0x0003000D, + WGPUNativeFeature_MappablePrimaryBuffers = 0x0003000E, + WGPUNativeFeature_BufferBindingArray = 0x0003000F, + WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 0x00030010, + // TODO: requires wgpu.h api change + // WGPUNativeFeature_AddressModeClampToZero = 0x00030011, + // WGPUNativeFeature_AddressModeClampToBorder = 0x00030012, + // WGPUNativeFeature_PolygonModeLine = 0x00030013, + // WGPUNativeFeature_PolygonModePoint = 0x00030014, + // WGPUNativeFeature_ConservativeRasterization = 0x00030015, + // WGPUNativeFeature_ClearTexture = 0x00030016, + // WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, + // WGPUNativeFeature_Multiview = 0x00030018, + WGPUNativeFeature_VertexAttribute64bit = 0x00030019, + WGPUNativeFeature_TextureFormatNv12 = 0x0003001A, + WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001B, + WGPUNativeFeature_RayQuery = 0x0003001C, + WGPUNativeFeature_ShaderF64 = 0x0003001D, + WGPUNativeFeature_ShaderI16 = 0x0003001E, + WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F, + WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020, WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; @@ -222,11 +246,23 @@ typedef struct WGPUQuerySetDescriptorExtras { typedef struct WGPUSurfaceConfigurationExtras { WGPUChainedStruct chain; - WGPUBool desiredMaximumFrameLatency; + uint32_t desiredMaximumFrameLatency; } WGPUSurfaceConfigurationExtras WGPU_STRUCTURE_ATTRIBUTE; typedef void (*WGPULogCallback)(WGPULogLevel level, char const * message, void * userdata); +typedef enum WGPUNativeTextureFormat { + // From Features::TEXTURE_FORMAT_16BIT_NORM + WGPUNativeTextureFormat_R16Unorm = 0x00030001, + WGPUNativeTextureFormat_R16Snorm = 0x00030002, + WGPUNativeTextureFormat_Rg16Unorm = 0x00030003, + WGPUNativeTextureFormat_Rg16Snorm = 0x00030004, + WGPUNativeTextureFormat_Rgba16Unorm = 0x00030005, + WGPUNativeTextureFormat_Rgba16Snorm = 0x00030006, + // From Features::TEXTURE_FORMAT_NV12 + WGPUNativeTextureFormat_NV12 = 0x00030007, +} WGPUNativeTextureFormat; + #ifdef __cplusplus extern "C" { #endif diff --git a/wgpu-natives/src/main/resources/wgpu_native.dll b/wgpu-natives/src/main/resources/wgpu_native.dll index 650260bfc..b8f782a2f 100644 Binary files a/wgpu-natives/src/main/resources/wgpu_native.dll and b/wgpu-natives/src/main/resources/wgpu_native.dll differ