diff --git a/.gitattributes b/.gitattributes index e375d2543..d523ee98a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,3 +10,7 @@ vendor/sdl3/SDL3.dll filter=lfs diff=lfs merge=lfs -text vendor/sdl3/SDL3.lib filter=lfs diff=lfs merge=lfs -text vendor/sdl3/mixer/*.dll filter=lfs diff=lfs merge=lfs -text vendor/sdl3/mixer/*.lib filter=lfs diff=lfs merge=lfs -text +vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll filter=lfs diff=lfs merge=lfs -text +vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll.lib filter=lfs diff=lfs merge=lfs -text +vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.lib filter=lfs diff=lfs merge=lfs -text +vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.pdb filter=lfs diff=lfs merge=lfs -text diff --git a/vendor/wgpu/doc.odin b/vendor/wgpu/doc.odin index 693062788..5f72b9147 100644 --- a/vendor/wgpu/doc.odin +++ b/vendor/wgpu/doc.odin @@ -12,8 +12,8 @@ You can find a number of examples on [[Odin's official examples repository; http **Getting the wgpu-native libraries** For native support (not the browser), some libraries are required. Fortunately this is -extremely easy, just download them from the [[releases on GitHub; https://github.com/gfx-rs/wgpu-native/releases/tag/v27.0.2.0]]. -the bindings are for v27.0.2.0 at the moment. +extremely easy, just download them from the [[releases on GitHub; https://github.com/gfx-rs/wgpu-native/releases/tag/v29.0.0.0]]. +the bindings are for v29.0.0.0 at the moment. These are expected in the `lib` folder under the same name as they are released (just unzipped). By default it will look for a static release version (`wgpu-OS-ARCH-release.a|lib`), diff --git a/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll b/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll index 08518a94e..574cdda82 100644 Binary files a/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll and b/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll differ diff --git a/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll.lib b/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll.lib index 55589fea0..33443a527 100644 Binary files a/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll.lib and b/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.dll.lib differ diff --git a/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.lib b/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.lib index 1948c8fca..7c089da19 100644 Binary files a/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.lib and b/vendor/wgpu/lib/wgpu-windows-x86_64-msvc-release/lib/wgpu_native.lib differ diff --git a/vendor/wgpu/wgpu.js b/vendor/wgpu/wgpu.js index df3be2e2d..d916de26d 100644 --- a/vendor/wgpu/wgpu.js +++ b/vendor/wgpu/wgpu.js @@ -4,7 +4,7 @@ const STATUS_SUCCESS = 1; const STATUS_ERROR = 2; const ENUMS = { - FeatureName: [undefined, "depth-clip-control", "depth32float-stencil8", "timestamp-query", "texture-compression-bc", "texture-compression-bc-sliced-3d", "texture-compression-etc2", "texture-compression-astc", "texture-compression-astc-sliced-3d", "indirect-first-instance", "shader-f16", "rg11b10ufloat-renderable", "bgra8unorm-storage", "float32-filterable", "float32-blendable", "clip-distances", "dual-source-blending" ], + FeatureName: [undefined, "core-features-and-limits", "depth-clip-control", "depth32float-stencil8", "texture-compression-bc", "texture-compression-bc-sliced-3d", "texture-compression-etc2", "texture-compression-astc", "texture-compression-astc-sliced-3d", "timestamp-query", "indirect-first-instance", "shader-f16", "rg11b10ufloat-renderable", "bgra8unorm-storage", "float32-filterable", "float32-blendable", "clip-distances", "dual-source-blending", "subgroups", "texture-formats-tier1", "texture-formats-tier2", "primitive-index", "texture-component-swizzle" ], StoreOp: [undefined, "store", "discard", ], LoadOp: [undefined, "load", "clear", ], BufferBindingType: [null, undefined, "uniform", "storage", "read-only-storage", ], @@ -12,9 +12,9 @@ const ENUMS = { TextureSampleType: [null, undefined, "float", "unfilterable-float", "depth", "sint", "uint", ], TextureViewDimension: [undefined, "1d", "2d", "2d-array", "cube", "cube-array", "3d", ], StorageTextureAccess: [null, undefined, "write-only", "read-only", "read-write", ], - TextureFormat: [undefined, "r8unorm", "r8snorm", "r8uint", "r8sint", "r16uint", "r16sint", "r16float", "rg8unorm", "rg8snorm", "rg8uint", "rg8sint", "r32float", "r32uint", "r32sint", "rg16uint", "rg16sint", "rg16float", "rgba8unorm", "rgba8unorm-srgb", "rgba8snorm", "rgba8uint", "rgba8sint", "bgra8unorm", "bgra8unorm-srgb", "rgb10a2uint", "rgb10a2unorm", "rg11b10ufloat", "rgb9e5ufloat", "rg32float", "rg32uint", "rg32sint", "rgba16uint", "rgba16sint", "rgba16float", "rgba32float", "rgba32uint", "rgba32sint", "stencil8", "depth16unorm", "depth24plus", "depth24plus-stencil8", "depth32float", "depth32float-stencil8", "bc1-rgba-unorm", "bc1-rgba-unorm-srgb", "bc2-rgba-unorm", "bc2-rgba-unorm-srgb", "bc3-rgba-unorm", "bc3-rgba-unorm-srgb", "bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm", "bc6h-rgb-ufloat", "bc6h-rgb-float", "bc7-rgba-unorm", "bc7-rgba-unorm-srgb", "etc2-rgb8unorm", "etc2-rgb8unorm-srgb", "etc2-rgb8a1unorm", "etc2-rgb8a1unorm-srgb", "etc2-rgba8unorm", "etc2-rgba8unorm-srgb", "eac-r11unorm", "eac-r11snorm", "eac-rg11unorm", "eac-rg11snorm", "astc-4x4-unorm", "astc-4x4-unorm-srgb", "astc-5x4-unorm", "astc-5x4-unorm-srgb", "astc-5x5-unorm", "astc-5x5-unorm-srgb", "astc-6x5-unorm", "astc-6x5-unorm-srgb", "astc-6x6-unorm", "astc-6x6-unorm-srgb", "astc-8x5-unorm", "astc-8x5-unorm-srgb", "astc-8x6-unorm", "astc-8x6-unorm-srgb", "astc-8x8-unorm", "astc-8x8-unorm-srgb", "astc-10x5-unorm", "astc-10x5-unorm-srgb", "astc-10x6-unorm", "astc-10x6-unorm-srgb", "astc-10x8-unorm", "astc-10x8-unorm-srgb", "astc-10x10-unorm", "astc-10x10-unorm-srgb", "astc-12x10-unorm", "astc-12x10-unorm-srgb", "astc-12x12-unorm", "astc-12x12-unorm-srgb", ], + TextureFormat: [undefined, "r8unorm", "r8snorm", "r8uint", "r8sint", "r16unorm", "r16snorm", "r16uint", "r16sint", "r16float", "rg8unorm", "rg8snorm", "rg8uint", "rg8sint", "r32float", "r32uint", "r32sint", "rg16unorm", "rg16snorm", "rg16uint", "rg16sint", "rg16float", "rgba8unorm", "rgba8unorm-srgb", "rgba8snorm", "rgba8uint", "rgba8sint", "bgra8unorm", "bgra8unorm-srgb", "rgb10a2uint", "rgb10a2unorm", "rg11b10ufloat", "rgb9e5ufloat", "rg32float", "rg32uint", "rg32sint", "rgba16unorm", "rgba16snorm", "rgba16uint", "rgba16sint", "rgba16float", "rgba32float", "rgba32uint", "rgba32sint", "stencil8", "depth16unorm", "depth24plus", "depth24plus-stencil8", "depth32float", "depth32float-stencil8", "bc1-rgba-unorm", "bc1-rgba-unorm-srgb", "bc2-rgba-unorm", "bc2-rgba-unorm-srgb", "bc3-rgba-unorm", "bc3-rgba-unorm-srgb", "bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm", "bc6h-rgb-ufloat", "bc6h-rgb-float", "bc7-rgba-unorm", "bc7-rgba-unorm-srgb", "etc2-rgb8unorm", "etc2-rgb8unorm-srgb", "etc2-rgb8a1unorm", "etc2-rgb8a1unorm-srgb", "etc2-rgba8unorm", "etc2-rgba8unorm-srgb", "eac-r11unorm", "eac-r11snorm", "eac-rg11unorm", "eac-rg11snorm", "astc-4x4-unorm", "astc-4x4-unorm-srgb", "astc-5x4-unorm", "astc-5x4-unorm-srgb", "astc-5x5-unorm", "astc-5x5-unorm-srgb", "astc-6x5-unorm", "astc-6x5-unorm-srgb", "astc-6x6-unorm", "astc-6x6-unorm-srgb", "astc-8x5-unorm", "astc-8x5-unorm-srgb", "astc-8x6-unorm", "astc-8x6-unorm-srgb", "astc-8x8-unorm", "astc-8x8-unorm-srgb", "astc-10x5-unorm", "astc-10x5-unorm-srgb", "astc-10x6-unorm", "astc-10x6-unorm-srgb", "astc-10x8-unorm", "astc-10x8-unorm-srgb", "astc-10x10-unorm", "astc-10x10-unorm-srgb", "astc-12x10-unorm", "astc-12x10-unorm-srgb", "astc-12x12-unorm", "astc-12x12-unorm-srgb", ], QueryType: [undefined, "occlusion", "timestamp", ], - VertexStepMode: [null, undefined, "vertex", "instance", ], + VertexStepMode: [undefined, "vertex", "instance", ], VertexFormat: [undefined, "uint8", "uint8x2", "uint8x4", "sint8", "sint8x2", "sint8x4", "unorm8", "unorm8x2", "unorm8x4", "snorm8", "snorm8x2", "snorm8x4", "uint16", "uint16x2", "uint16x4", "sint16", "sint16x2", "sint16x4", "unorm16", "unorm16x2", "unorm16x4", "snorm16", "snorm16x2", "snorm16x4", "float16", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10-10-2", "unorm8x4-bgra" ], PrimitiveTopology: [undefined, "point-list", "line-list", "line-strip", "triangle-list", "triangle-strip", ], IndexFormat: [undefined, "uint16", "uint32", ], @@ -26,7 +26,7 @@ const ENUMS = { CompareFunction: [undefined, "never", "less", "equal", "less-equal", "greater", "not-equal", "greater-equal", "always", ], TextureDimension: [undefined, "1d", "2d", "3d", ], ErrorType: [undefined, "no-error", "validation", "out-of-memory", "internal", "unknown", ], - WGSLLanguageFeatureName: [undefined, "readonly_and_readwrite_storage_textures", "packed_4x8_integer_dot_product", "unrestricted_pointer_parameters", "pointer_composite_access", ], + WGSLLanguageFeatureName: [undefined, "readonly_and_readwrite_storage_textures", "packed_4x8_integer_dot_product", "unrestricted_pointer_parameters", "pointer_composite_access", "uniform_buffer_standard_layout", "subgroup_id", "texture_and_sampler_let", "subgroup_uniformity", "texture_formats_tier1" ], PowerPreference: [undefined, "low-power", "high-performance", ], CompositeAlphaMode: ["auto", "opaque", "premultiplied", "unpremultiplied", "inherit", ], StencilOperation: [undefined, "keep", "zero", "replace", "invert", "increment-clamp", "decrement-clamp", "increment-wrap", "decrement-wrap", ], @@ -34,20 +34,25 @@ const ENUMS = { BlendFactor: [undefined, "zero", "one", "src", "one-minus-src", "src-alpha", "one-minus-src-alpha", "dst", "one-minus-dst", "dst-alpha", "one-minus-dst-alpha", "src-alpha-saturated", "constant", "one-minus-constant", "src1", "one-minus-src1", "src1-alpha", "one-minus-src1-alpha" ], PresentMode: [undefined, "fifo", "fifo-relaxed", "immediate", "mailbox", ], TextureAspect: [undefined, "all", "stencil-only", "depth-only"], - DeviceLostReason: [undefined, "unknown", "destroyed", "instance-dropped", "failed-creation"], + DeviceLostReason: [undefined, "unknown", "destroyed", "callback-cancelled", "failed-creation"], BufferMapState: [undefined, "unmapped", "pending", "mapped"], OptionalBool: [false, true, undefined], + ComponentSwizzle: [undefined, "0", "1", "r", "g", "b", "a"], + PredefinedColorSpace: [undefined, "srgb", "display-p3"], + ToneMappingMode: [undefined, "standard", "extended"], + FeatureLevel: [undefined, "compatibility", "core"], + TextureViewDimensions: [undefined, "1d", "2d", "2d-array", "cube", "cube-array", "3d"], // WARN: used with indexOf to pass to WASM, if we would pass to JS, this needs to use official naming convention (not like Odin enums) like the ones above. BackendType: [undefined, null, "WebGPU", "D3D11", "D3D12", "Metal", "Vulkan", "OpenGL", "OpenGLES"], AdapterType: [undefined, "DiscreteGPU", "IntegratedGPU", "CPU", "Unknown"], - RequestDeviceStatus: [undefined, "Success", "InstanceDropped", "Error", "Unknown"], - MapAsyncStatus: [undefined, "Success", "InstanceDropped", "Error", "Aborted", "Unknown"], - CreatePipelineAsyncStatus: [undefined, "Success", "InstanceDropped", "ValidationError", "InternalError", "Unknown"], - PopErrorScopeStatus: [undefined, "Success", "InstanceDropped", "EmptyStack"], - RequestAdapterStatus: [undefined, "Success", "InstanceDropped", "Unavailable", "Error", "Unknown"], - QueueWorkDoneStatus: [undefined, "Success", "InstanceDropped", "Error", "Unknown"], - CompilationInfoRequestStatus: [undefined, "Success", "InstanceDropped", "Error", "Unknown"], + RequestDeviceStatus: [undefined, "Success", "CallbackCancelled", "Error"], + MapAsyncStatus: [undefined, "Success", "CallbackCancelled", "Error", "Aborted"], + CreatePipelineAsyncStatus: [undefined, "Success", "CallbackCancelled", "ValidationError", "InternalError"], + PopErrorScopeStatus: [undefined, "Success", "CallbackCancelled", "Error"], + RequestAdapterStatus: [undefined, "Success", "CallbackCancelled", "Unavailable", "Error"], + QueueWorkDoneStatus: [undefined, "Success", "CallbackCancelled", "Error"], + CompilationInfoRequestStatus: [undefined, "Success", "CallbackCancelled"], }; /** @@ -71,7 +76,7 @@ class WebGPUInterface { StorageTextureBindingLayout: [16, 4], StringView: [2*this.mem.intSize, this.mem.intSize], ConstantEntry: [this.mem.intSize === 8 ? 32 : 24, 8], - ProgrammableStageDescriptor: [8 + this.mem.intSize*4, this.mem.intSize], + ComputeState: [8 + this.mem.intSize*4, this.mem.intSize], VertexBufferLayout: [16 + this.mem.intSize*2, 8], VertexAttribute: [24, 8], VertexState: [8 + this.mem.intSize*6, this.mem.intSize], @@ -87,7 +92,7 @@ class WebGPUInterface { UncapturedErrorCallbackInfo: [16, 4], RenderPassColorAttachment: [56, 8], BindGroupEntry: [40, 8], - BindGroupLayoutEntry: [80, 8], + BindGroupLayoutEntry: [88, 8], Extent3D: [12, 4], CompilationMessage: [this.mem.intSize == 8 ? 64 : 48, 8], }; @@ -158,6 +163,9 @@ class WebGPUInterface { /** @type {WebGPUObjectManager} */ this.textureViews = new WebGPUObjectManager("TextureView", this.mem); + /** @type {WebGPUObjectManager} */ + this.externalTextures = new WebGPUObjectManager("ExternalTexture", this.mem); + this.zeroMessageAddr = 0; } @@ -341,21 +349,38 @@ class WebGPUInterface { return STATUS_SUCCESS; } - genericGetAdapterInfo(infoPtr) { + /** + * @param {number} infoPtr + * @param {GPUAdapterInfo} info + */ + genericGetAdapterInfo(infoPtr, info) { this.assert(infoPtr != 0); const off = this.struct(infoPtr); off(4); // nextInChain - off(this.sizes.StringView); // vendor - off(this.sizes.StringView); // architecture - off(this.sizes.StringView); // device - off(this.sizes.StringView); // description + + const storeString = (start, str) => { + const len = new TextEncoder().encode(str).length; + const strAddr = this.mem.exports.wgpu_alloc(len); + this.mem.storeString(strAddr, str); + + this.mem.storeI32(start, strAddr); + this.mem.storeUint(start + this.mem.intSize, len); + }; + + storeString(off(this.sizes.StringView), info.vendor); + storeString(off(this.sizes.StringView), info.architecture); + storeString(off(this.sizes.StringView), info.device); + storeString(off(this.sizes.StringView), info.description); this.mem.storeI32(off(4), ENUMS.BackendType.indexOf("WebGPU")); this.mem.storeI32(off(4), ENUMS.AdapterType.indexOf("Unknown")); - // NOTE: I don't think getting the other fields in this struct is possible. - // `adapter.requestAdapterInfo` is deprecated. + off(4); // vendorID + off(4); // deviceID + + this.mem.storeI32(off(4), info.subGroupMinSize); + this.mem.storeI32(off(4), info.subGroupMaxSize); return STATUS_SUCCESS; } @@ -461,15 +486,15 @@ class WebGPUInterface { /** * @param {number} ptr - * @returns {GPUComputePassTimestampWrites} */ - ComputePassTimestampWritesPtr(ptr) { + PassTimestampWritesPtr(ptr) { const start = this.mem.loadPtr(ptr); if (start == 0) { return undefined; } const off = this.struct(start); + off(4); // nextInChain return { querySet: this.querySets.get(this.mem.loadPtr(off(4))), beginningOfPassWriteIndex: this.mem.loadU32(off(4)), @@ -529,7 +554,7 @@ class WebGPUInterface { } const off = this.struct(start); - + off(4); // nextInChain return { view: this.textureViews.get(this.mem.loadPtr(off(4))), depthLoadOp: this.enumeration("LoadOp", off(4)), @@ -556,14 +581,6 @@ class WebGPUInterface { return this.querySets.get(ptr); } - /** - * @param {number} ptr - * @returns {GPURenderPassTimestampWrites} - */ - RenderPassTimestampWritesPtr(ptr) { - return this.ComputePassTimestampWritesPtr(ptr); - } - /** * @param {number} start * @returns {GPUOrigin3D} @@ -626,12 +643,13 @@ class WebGPUInterface { off(4); const entry = { - binding: this.mem.loadU32(off(4)), - visibility: this.mem.loadU64(off(8)), - buffer: this.BufferBindingLayout(off(this.sizes.BufferBindingLayout)), - sampler: this.SamplerBindingLayout(off(this.sizes.SamplerBindingLayout)), - texture: this.TextureBindingLayout(off(this.sizes.TextureBindingLayout)), - storageTexture: this.StorageTextureBindingLayout(off(this.sizes.StorageTextureBindingLayout)), + binding: this.mem.loadU32(off(4)), + visibility: this.mem.loadU64(off(8)), + bindingArraySize: this.mem.loadU32(off(4)), + buffer: this.BufferBindingLayout(off(this.sizes.BufferBindingLayout)), + sampler: this.SamplerBindingLayout(off(this.sizes.SamplerBindingLayout)), + texture: this.TextureBindingLayout(off(this.sizes.TextureBindingLayout)), + storageTexture: this.StorageTextureBindingLayout(off(this.sizes.StorageTextureBindingLayout)), }; if (!entry.buffer.type) { entry.buffer = undefined; @@ -696,9 +714,9 @@ class WebGPUInterface { /** * @param {number} start - * @returns {GPUProgrammableStage} + * @returns {GPUComputeState} */ - ProgrammableStageDescriptor(start) { + ComputeState(start) { const off = this.struct(start); off(4); @@ -749,7 +767,7 @@ class WebGPUInterface { return { label: label, layout: layoutIdx > 0 ? this.pipelineLayouts.get(layoutIdx) : "auto", - compute: this.ProgrammableStageDescriptor(off(this.sizes.ProgrammableStageDescriptor)), + compute: this.ComputeState(off(this.sizes.ComputeState)), }; } @@ -793,11 +811,9 @@ class WebGPUInterface { */ VertexBufferLayout(start) { const off = this.struct(start); + off(4); // nextInChain const stepMode = this.enumeration("VertexStepMode", off(4)); - if (stepMode == null) { - return null; - } return { arrayStride: this.mem.loadU64(off(8)), @@ -817,6 +833,7 @@ class WebGPUInterface { */ VertexAttribute(start) { const off = this.struct(start); + off(4); // nextInChain return { format: this.enumeration("VertexFormat", off(4)), offset: this.mem.loadU64(off(8)), @@ -1117,12 +1134,26 @@ class WebGPUInterface { }, /** - * @param {number} capabilitiesPtr - * @returns {number} + * @param {number} featuresPtr */ - wgpuGetInstanceCapabilities: (capabilitiesPtr) => { + wgpuGetInstanceFeatures: (featuresPtr) => { // TODO: implement (futures). - return STATUS_ERROR; + }, + + /** + * @param {number} limitsPtr + */ + wgpuGetInstanceLimits: (limitsPtr) => { + // TODO: implement (futures). + }, + + /** + * @param {number} feature + * @returns {boolean} + */ + wgpuHasInstanceFeature: (feature) => { + // TODO: implement (futures). + return false; }, /** @@ -1389,6 +1420,30 @@ class WebGPUInterface { return BigInt(0); }, + /** + * @param {number} bufferIdx + * @param {number|BigInt} offset + * @param {number} ptr + * @param {number|BigInt} size + * @return {number} + */ + wgpuBufferReadMappedRange: (bufferIdx, offset, ptr, size) => { + const buffer = this.buffers.get(bufferIdx); + offset = this.unwrapBigInt(offset); + size = this.unwrapBigInt(size); + + this.assert(!buffer.mapping, "buffer already mapped"); + + const range = buffer.buffer.getMappedRange(offset, size); + + const mapping = new Uint8Array(this.mem.memory.buffer, ptr, size); + mapping.set(new Uint8Array(range)); + + buffer.mapping = { range: range, ptr: ptr, size: range.byteLength }; + + return STATUS_SUCCESS; + }, + /** * @param {number} bufferIdx * @param {number} labelPtr @@ -1415,6 +1470,30 @@ class WebGPUInterface { buffer.mapping = null; }, + /** + * @param {number} bufferIdx + * @param {number|BigInt} offset + * @param {number} ptr + * @param {number|BigInt} size + * @return {number} + */ + wgpuBufferWriteMappedRange: (bufferIdx, offset, ptr, size) => { + const buffer = this.buffers.get(bufferIdx); + offset = this.unwrapBigInt(offset); + size = this.unwrapBigInt(size); + + this.assert(!buffer.mapping, "buffer already mapped"); + + const range = buffer.buffer.getMappedRange(offset, size); + + const mapping = new Uint8Array(this.mem.memory.buffer, ptr, size); + (new Uint8Array(range)).set(mapping); + + buffer.mapping = { range: range, ptr: ptr, size: range.byteLength }; + + return STATUS_SUCCESS; + }, + ...this.buffers.interface(), /* ---------------------- CommandBuffer ---------------------- */ @@ -1438,7 +1517,7 @@ class WebGPUInterface { off(4); descriptor = { label: this.StringView(off(this.sizes.StringView)), - timestampWrites: this.ComputePassTimestampWritesPtr(off(4)), + timestampWrites: this.PassTimestampWritesPtr(off(4)), }; } @@ -1478,7 +1557,7 @@ class WebGPUInterface { ), depthStencilAttachment: this.RenderPassDepthStencilAttachmentPtr(off(4)), occlusionQuerySet: this.QuerySet(off(4)), - timestampWrites: this.RenderPassTimestampWritesPtr(off(4)), + timestampWrites: this.PassTimestampWritesPtr(off(4)), maxDrawCount: maxDrawCount, }; @@ -1881,7 +1960,7 @@ class WebGPUInterface { device.createComputePipelineAsync(this.ComputePipelineDescriptor(descriptorPtr)) .catch((e) => { const messageAddr = this.makeMessageArg(e.message); - this.callCallback(callbackInfo, [ENUMS.CreatePipelineAsyncStatus.indexOf("Unknown"), 0, messageAddr]); + this.callCallback(callbackInfo, [ENUMS.CreatePipelineAsyncStatus.indexOf("ValidationError"), 0, messageAddr]); this.mem.exports.wgpu_free(messageAddr); }) .then((computePipeline) => { @@ -2185,6 +2264,11 @@ class WebGPUInterface { const callbackInfo = this.CallbackInfo(callbackInfoPtr); device.popErrorScope() + .catch((e) => { + const messageAddr = this.makeMessageArg(e.message); + this.callCallback(callbackInfo, [ENUMS.PopErrorScopeStatus.indexOf("Error"), ENUMS.ErrorType.indexOf("unknown"), messageAddr]); + this.mem.exports.wgpu_free(messageAddr); + }) .then((error) => { if (!error) { this.callCallback(callbackInfo, [ENUMS.PopErrorScopeStatus.indexOf("Success"), ENUMS.ErrorType.indexOf("no-error"), this.zeroMessageArg()]); @@ -2222,6 +2306,10 @@ class WebGPUInterface { ...this.devices.interface(true), + /* ---------------------- ExternalTexture ---------------------- */ + + ...this.externalTextures.interface(true), + /* ---------------------- Instance ---------------------- */ /** @@ -2261,7 +2349,6 @@ class WebGPUInterface { /** * @param {number} instanceIdx * @param {number} featurePtr - * @returns {number} */ wgpuInstanceGetWGSLLanguageFeatures: (instanceIdx, featuresPtr) => { this.assert(featuresPtr != 0); @@ -2292,8 +2379,6 @@ class WebGPUInterface { for (let i = 0; i < availableFeatures.length; i += 1) { this.mem.storeI32(off(4), availableFeatures[i]); } - - return STATUS_SUCCESS; }, /** @@ -2325,11 +2410,22 @@ class WebGPUInterface { let options; if (optionsPtr != 0) { const off = this.struct(optionsPtr); - off(4); // nextInChain - off(4); // featureLevel + + let xrCompatible = undefined; + const nextInChain = this.mem.loadPtr(off(4)); + if (nextInChain != 0) { + const nextInChainType = this.mem.loadI32(nextInChain + 4); + // RequestAdapterWebXROptions = 0x0000000B, + if (nextInChainType == 0x0000000B) { + xrCompatible = this.mem.loadB32(nextInChain + 8); + } + } + options = { + featureLevel: this.enumeration("FeatureLevel", off(4)), powerPreference: this.enumeration("PowerPreference", off(4)), forceFallbackAdapter: this.mem.loadB32(off(4)), + xrCompatible: xrCompatible, }; } @@ -2405,10 +2501,12 @@ class WebGPUInterface { queue.onSubmittedWorkDone() .catch((e) => { console.warn(e); - this.callCallback(callbackInfo, [ENUMS.QueueWorkDoneStatus.indexOf("Error")]); + const messageAddr = this.makeMessageArg(e.message); + this.callCallback(callbackInfo, [ENUMS.QueueWorkDoneStatus.indexOf("Error"), messageAddr]); + this.mem.exports.wgpu_free(messageAddr); }) .then(() => { - this.callCallback(callbackInfo, [ENUMS.QueueWorkDoneStatus.indexOf("Success")]); + this.callCallback(callbackInfo, [ENUMS.QueueWorkDoneStatus.indexOf("Success"), this.zeroMessageArg()]); }); // TODO: futures? @@ -2920,7 +3018,7 @@ class WebGPUInterface { shaderModule.getCompilationInfo() .catch((e) => { console.warn(e); - this.callCallback(callbackInfo, [ENUMS.CompilationInfoRequestStatus.indexOf("Error"), null]); + this.callCallback(callbackInfo, [ENUMS.CompilationInfoRequestStatus.indexOf("CallbackCancelled"), null]); }) .then((compilationInfo) => { const ptrsToFree = []; @@ -2975,6 +3073,11 @@ class WebGPUInterface { this.mem.exports.wgpu_free(supportedFeaturesPtr); }, + /* ---------------------- SupportedInstanceFeatures ---------------------- */ + + wgpuSupportedInstanceFeaturesFreeMembers: (supportedFeaturesCount, supportedFeaturesPtr) => { + }, + /* ---------------------- SupportedWGSLLanguageFeatures ---------------------- */ wgpuSupportedWGSLLanguageFeaturesFreeMembers: (supportedFeaturesCount, supportedFeaturesPtr) => { @@ -2992,7 +3095,23 @@ class WebGPUInterface { const context = surface.getContext("webgpu"); const off = this.struct(configPtr); - off(4); + + let colorSpace = undefined; + let toneMapping = undefined; + const nextInChain = this.mem.loadPtr(off(4)); + if (nextInChain != 0) { + const colorManagementOff = this.struct(nextInChain); + colorManagementOff(4); // next + const nextInChainType = this.mem.loadI32(colorManagementOff(4)); + // SurfaceColorManagement = 0x0000000A, + if (nextInChainType == 0x0000000A) { + colorSpace = this.enumeration("PredefinedColorSpace", colorManagementOff(4)) ?? "srgb"; + toneMapping = { + mode: this.enumeration("ToneMappingMode", colorManagementOff(4)) ?? "standard", + }; + } + } + const device = this.devices.get(this.mem.loadPtr(off(4))); const format = this.enumeration("TextureFormat", off(4)); const usage = this.mem.loadU64(off(8)); @@ -3019,6 +3138,8 @@ class WebGPUInterface { viewFormats: viewFormats, alphaMode: alphaMode, presentMode: presentMode, + colorSpace: colorSpace, + toneMapping: toneMapping, }; context.configure(config); @@ -3071,7 +3192,7 @@ class WebGPUInterface { const textureIdx = this.textures.create(texture); this.mem.storeI32(texturePtr + 4, textureIdx); - // TODO: determine suboptimal and/or status. + // TODO: determine status somehow? }, /** @@ -3130,7 +3251,27 @@ class WebGPUInterface { let descriptor; if (descriptorPtr != 0) { const off = this.struct(descriptorPtr); - off(4); + + let swizzle = undefined; + const nextInChain = this.mem.loadPtr(off(4)); + if (nextInChain != 0) { + const swizzleOff = this.struct(nextInChain); + swizzleOff(4); // next + const nextInChainType = this.mem.loadI32(swizzleOff(4)); + // TextureComponentSwizzle = 0x00000016, + if (nextInChainType == 0x00000016) { + const r = this.enumeration("ComponentSwizzle", swizzleOff(4)); + this.assert(r !== undefined); + const g = this.enumeration("ComponentSwizzle", swizzleOff(4)); + this.assert(g !== undefined); + const b = this.enumeration("ComponentSwizzle", swizzleOff(4)); + this.assert(b !== undefined); + const a = this.enumeration("ComponentSwizzle", swizzleOff(4)); + this.assert(a !== undefined); + swizzle = r + g + b + a; + } + } + descriptor = { label: this.StringView(off(this.sizes.StringView)), format: this.enumeration("TextureFormat", off(4)), @@ -3141,6 +3282,7 @@ class WebGPUInterface { arrayLayerCount: this.mem.loadU32(off(4)), aspect: this.enumeration("TextureAspect", off(4)), usage: this.mem.loadU64(off(8)), + swizzle: swizzle, }; if (descriptor.arrayLayerCount == 0xFFFFFFFF) { descriptor.arrayLayerCount = undefined; @@ -3216,6 +3358,15 @@ class WebGPUInterface { return texture.sampleCount; }, + /** + * @param {number} textureIdx + * @returns {number} + */ + wgpuTextureGetTextureBindingViewDimension: (textureIdx) => { + const texture = this.textures.get(textureIdx); + return ENUMS.TextureViewDimension.indexOf(texture.textureBindingViewDimension); + }, + /** * @param {number} textureIdx * @returns {number} diff --git a/vendor/wgpu/wgpu.odin b/vendor/wgpu/wgpu.odin index 6da164ae0..796cebec7 100644 --- a/vendor/wgpu/wgpu.odin +++ b/vendor/wgpu/wgpu.odin @@ -13,7 +13,7 @@ when ODIN_OS == .Windows { @(private) LIB :: "lib/wgpu-windows-" + ARCH + "-msvc-" + TYPE + "/lib/wgpu_native" + EXT when !#exists(LIB) { - #panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v27.0.2.0, make sure to read the docs at '" + #directory + "doc.odin'") + #panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v29.0.0.0, make sure to read the docs at '" + #directory + "doc.odin'") } @(export) @@ -39,7 +39,7 @@ when ODIN_OS == .Windows { @(private) LIB :: "lib/wgpu-macos-" + ARCH + "-" + TYPE + "/lib/libwgpu_native" + EXT when !#exists(LIB) { - #panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v27.0.2.0, make sure to read the docs at '" + #directory + "doc.odin'") + #panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v29.0.0.0, make sure to read the docs at '" + #directory + "doc.odin'") } @(export) @@ -56,7 +56,7 @@ when ODIN_OS == .Windows { @(private) LIB :: "lib/wgpu-linux-" + ARCH + "-" + TYPE + "/lib/libwgpu_native" + EXT when !#exists(LIB) { - #panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v27.0.2.0, make sure to read the docs at '" + #directory + "doc.odin'") + #panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v29.0.0.0, make sure to read the docs at '" + #directory + "doc.odin'") } @(export) @@ -81,6 +81,7 @@ WHOLE_MAP_SIZE :: max(uint) WHOLE_SIZE :: max(u64) Flags :: u64 +Bool :: b32 StringView :: string @@ -108,6 +109,7 @@ ShaderModule :: distinct rawptr Surface :: distinct rawptr Texture :: distinct rawptr TextureView :: distinct rawptr +ExternalTexture :: distinct rawptr AdapterType :: enum i32 { DiscreteGPU = 0x00000001, @@ -198,9 +200,7 @@ CompareFunction :: enum i32 { CompilationInfoRequestStatus :: enum i32 { Success = 0x00000001, - InstanceDropped = 0x00000002, - Error = 0x00000003, - Unknown = 0x00000004, + CallbackCancelled = 0x00000002, } CompilationMessageType :: enum i32 { @@ -209,6 +209,16 @@ CompilationMessageType :: enum i32 { Info = 0x00000003, } +ComponentSwizzle :: enum i32 { + Undefined, + Zero, + One, + R, + G, + B, + A, +} + CompositeAlphaMode :: enum i32 { Auto = 0x00000000, Opaque = 0x00000001, @@ -219,10 +229,9 @@ CompositeAlphaMode :: enum i32 { CreatePipelineAsyncStatus :: enum i32 { Success = 0x00000001, - InstanceDropped = 0x00000002, + CallbackCancelled = 0x00000002, ValidationError = 0x00000003, InternalError = 0x00000004, - Unknown = 0x00000005, } CullMode :: enum i32 { @@ -236,7 +245,7 @@ DeviceLostReason :: enum i32 { Undefined = 0x00000000, Unknown = 0x00000001, Destroyed = 0x00000002, - InstanceDropped = 0x00000003, + CallbackCancelled = 0x00000003, FailedCreation = 0x00000004, } @@ -255,6 +264,7 @@ ErrorType :: enum i32 { } FeatureLevel :: enum i32 { + Undefined, Compatibility = 0x00000001, Core = 0x00000002, } @@ -262,25 +272,31 @@ FeatureLevel :: enum i32 { FeatureName :: enum i32 { // WebGPU. Undefined = 0x00000000, - DepthClipControl = 0x00000001, - Depth32FloatStencil8 = 0x00000002, - TimestampQuery = 0x00000003, + CoreFeaturesAndLimits = 0x00000001, + DepthClipControl = 0x00000002, + Depth32FloatStencil8 = 0x00000003, TextureCompressionBC = 0x00000004, TextureCompressionBCSliced3D = 0x00000005, TextureCompressionETC2 = 0x00000006, TextureCompressionASTC = 0x00000007, TextureCompressionASTCSliced3D = 0x00000008, - IndirectFirstInstance = 0x00000009, - ShaderF16 = 0x0000000A, - RG11B10UfloatRenderable = 0x0000000B, - BGRA8UnormStorage = 0x0000000C, - Float32Filterable = 0x0000000D, - Float32Blendable = 0x0000000E, - ClipDistances = 0x0000000F, - DualSourceBlending = 0x00000010, + TimestampQuery = 0x00000009, + IndirectFirstInstance = 0x0000000A, + ShaderF16 = 0x0000000B, + RG11B10UfloatRenderable = 0x0000000C, + BGRA8UnormStorage = 0x0000000D, + Float32Filterable = 0x0000000E, + Float32Blendable = 0x0000000F, + ClipDistances = 0x00000010, + DualSourceBlending = 0x00000011, + Subgroups = 0x00000012, + TextureFormatsTier1 = 0x00000013, + TextureFormatsTier2 = 0x00000014, + PrimitiveIndex = 0x00000015, + TextureComponentSwizzle = 0x00000016, // Native. - PushConstants = 0x00030001, + Immediates = 0x00030001, TextureAdapterSpecificFormatFeatures, MultiDrawIndirectCount = 0x00030004, VertexWritableStorage, @@ -308,8 +324,7 @@ FeatureName :: enum i32 { RayQuery = 0x0003001C, ShaderF64, ShaderI16, - ShaderPrimitiveIndex, - ShaderEarlyDepthTest, + ShaderEarlyDepthTest = 0x00030020, Subgroup, SubgroupVertex, SubgroupBarrier, @@ -336,6 +351,12 @@ IndexFormat :: enum i32 { Uint32 = 0x00000002, } +InstanceFeatureName :: enum i32 { + TimedWaitAny = 1, + ShaderSourceSPIRV = 2, + MultipleDevicesPerAdapter = 3, +} + LoadOp :: enum i32 { Undefined = 0x00000000, Load = 0x00000001, @@ -344,10 +365,9 @@ LoadOp :: enum i32 { MapAsyncStatus :: enum i32 { Success = 0x00000001, - InstanceDropped = 0x00000002, + CallbackCancelled = 0x00000002, Error = 0x00000003, Aborted = 0x00000004, - Unknown = 0x00000005, } MipmapFilterMode :: enum i32 { @@ -364,8 +384,8 @@ OptionalBool :: enum i32 { PopErrorScopeStatus :: enum i32 { Success = 0x00000001, - InstanceDropped = 0x00000002, - EmptyStack = 0x00000003, + CallbackCancelled = 0x00000002, + Error = 0x00000003, } PowerPreference :: enum i32 { @@ -374,6 +394,11 @@ PowerPreference :: enum i32 { HighPerformance = 0x00000002, } +PredefinedColorSpace :: enum i32 { + SRGB = 1, + DisplayP3, +} + PresentMode :: enum i32 { Undefined = 0x00000000, Fifo = 0x00000001, @@ -402,54 +427,21 @@ QueryType :: enum i32 { QueueWorkDoneStatus :: enum i32 { Success = 0x00000001, - InstanceDropped = 0x00000002, + CallbackCancelled = 0x00000002, Error = 0x00000003, - Unknown = 0x00000004, } RequestAdapterStatus :: enum i32 { Success = 0x00000001, - InstanceDropped = 0x00000002, + CallbackCancelled = 0x00000002, Unavailable = 0x00000003, Error = 0x00000004, - Unknown = 0x00000005, } RequestDeviceStatus :: enum i32 { Success = 0x00000001, - InstanceDropped = 0x00000002, + CallbackCancelled = 0x00000002, Error = 0x00000003, - Unknown = 0x00000004, -} - -SType :: enum i32 { - // WebGPU. - ShaderSourceSPIRV = 0x00000001, - ShaderSourceWGSL = 0x00000002, - RenderPassMaxDrawCount = 0x00000003, - SurfaceSourceMetalLayer = 0x00000004, - SurfaceSourceWindowsHWND = 0x00000005, - SurfaceSourceXlibWindow = 0x00000006, - SurfaceSourceWaylandSurface = 0x00000007, - SurfaceSourceAndroidNativeWindow = 0x00000008, - SurfaceSourceXCBWindow = 0x00000009, - - // Native. - DeviceExtras = 0x00030001, - NativeLimits, - PipelineLayoutExtras, - ShaderSourceGLSL, - SupportedLimitsExtras, - InstanceExtras, - BindGroupEntryExtras, - BindGroupLayoutEntryExtras, - QuerySetDescriptorExtras, - SurfaceConfigurationExtras, - SurfaceSourceSwapChainPanel, - PrimitiveStateExtras, - - // Odin. - SurfaceSourceCanvasHTMLSelector = 0x00040001, } SamplerBindingType :: enum i32 { @@ -491,15 +483,53 @@ StoreOp :: enum i32 { Discard = 0x00000002, } +SType :: enum i32 { + // WebGPU. + ShaderSourceSPIRV = 0x00000001, + ShaderSourceWGSL = 0x00000002, + RenderPassMaxDrawCount = 0x00000003, + SurfaceSourceMetalLayer = 0x00000004, + SurfaceSourceWindowsHWND = 0x00000005, + SurfaceSourceXlibWindow = 0x00000006, + SurfaceSourceWaylandSurface = 0x00000007, + SurfaceSourceAndroidNativeWindow = 0x00000008, + SurfaceSourceXCBWindow = 0x00000009, + SurfaceColorManagement = 0x0000000A, + RequestAdapterWebXROptions = 0x0000000B, + TextureComponentSwizzleDescriptor = 0x0000000C, + ExternalTextureBindingLayout = 0x0000000D, + ExternalTextureBindingEntry = 0x0000000E, + CompatibilityModeLimits = 0x0000000F, + TextureBindingViewDimension = 0x00000010, + + // Native. + DeviceExtras = 0x00030001, + NativeLimits, + PipelineLayoutExtras, + ShaderSourceGLSL, + SupportedLimitsExtras, + InstanceExtras, + BindGroupEntryExtras, + BindGroupLayoutEntryExtras, + QuerySetDescriptorExtras, + SurfaceConfigurationExtras, + SurfaceSourceSwapChainPanel, + PrimitiveStateExtras, + + // Odin. + SurfaceSourceCanvasHTMLSelector = 0x00040001, +} + SurfaceGetCurrentTextureStatus :: enum i32 { SuccessOptimal = 0x00000001, SuccessSuboptimal = 0x00000002, Timeout = 0x00000003, Outdated = 0x00000004, Lost = 0x00000005, - OutOfMemory = 0x00000006, - DeviceLost = 0x00000007, - Error = 0x00000008, + Error = 0x00000006, + + // Native. + Occluded = 0x00030001, } TextureAspect :: enum i32 { @@ -522,108 +552,113 @@ TextureFormat :: enum i32 { R8Snorm = 0x00000002, R8Uint = 0x00000003, R8Sint = 0x00000004, - R16Uint = 0x00000005, - R16Sint = 0x00000006, - R16Float = 0x00000007, - RG8Unorm = 0x00000008, - RG8Snorm = 0x00000009, - RG8Uint = 0x0000000A, - RG8Sint = 0x0000000B, - R32Float = 0x0000000C, - R32Uint = 0x0000000D, - R32Sint = 0x0000000E, - RG16Uint = 0x0000000F, - RG16Sint = 0x00000010, - RG16Float = 0x00000011, - RGBA8Unorm = 0x00000012, - RGBA8UnormSrgb = 0x00000013, - RGBA8Snorm = 0x00000014, - RGBA8Uint = 0x00000015, - RGBA8Sint = 0x00000016, - BGRA8Unorm = 0x00000017, - BGRA8UnormSrgb = 0x00000018, - RGB10A2Uint = 0x00000019, - RGB10A2Unorm = 0x0000001A, - RG11B10Ufloat = 0x0000001B, - RGB9E5Ufloat = 0x0000001C, - RG32Float = 0x0000001D, - RG32Uint = 0x0000001E, - RG32Sint = 0x0000001F, - RGBA16Uint = 0x00000020, - RGBA16Sint = 0x00000021, - RGBA16Float = 0x00000022, - RGBA32Float = 0x00000023, - RGBA32Uint = 0x00000024, - RGBA32Sint = 0x00000025, - Stencil8 = 0x00000026, - Depth16Unorm = 0x00000027, - Depth24Plus = 0x00000028, - Depth24PlusStencil8 = 0x00000029, - Depth32Float = 0x0000002A, - Depth32FloatStencil8 = 0x0000002B, - BC1RGBAUnorm = 0x0000002C, - BC1RGBAUnormSrgb = 0x0000002D, - BC2RGBAUnorm = 0x0000002E, - BC2RGBAUnormSrgb = 0x0000002F, - BC3RGBAUnorm = 0x00000030, - BC3RGBAUnormSrgb = 0x00000031, - BC4RUnorm = 0x00000032, - BC4RSnorm = 0x00000033, - BC5RGUnorm = 0x00000034, - BC5RGSnorm = 0x00000035, - BC6HRGBUfloat = 0x00000036, - BC6HRGBFloat = 0x00000037, - BC7RGBAUnorm = 0x00000038, - BC7RGBAUnormSrgb = 0x00000039, - ETC2RGB8Unorm = 0x0000003A, - ETC2RGB8UnormSrgb = 0x0000003B, - ETC2RGB8A1Unorm = 0x0000003C, - ETC2RGB8A1UnormSrgb = 0x0000003D, - ETC2RGBA8Unorm = 0x0000003E, - ETC2RGBA8UnormSrgb = 0x0000003F, - EACR11Unorm = 0x00000040, - EACR11Snorm = 0x00000041, - EACRG11Unorm = 0x00000042, - EACRG11Snorm = 0x00000043, - ASTC4x4Unorm = 0x00000044, - ASTC4x4UnormSrgb = 0x00000045, - ASTC5x4Unorm = 0x00000046, - ASTC5x4UnormSrgb = 0x00000047, - ASTC5x5Unorm = 0x00000048, - ASTC5x5UnormSrgb = 0x00000049, - ASTC6x5Unorm = 0x0000004A, - ASTC6x5UnormSrgb = 0x0000004B, - ASTC6x6Unorm = 0x0000004C, - ASTC6x6UnormSrgb = 0x0000004D, - ASTC8x5Unorm = 0x0000004E, - ASTC8x5UnormSrgb = 0x0000004F, - ASTC8x6Unorm = 0x00000050, - ASTC8x6UnormSrgb = 0x00000051, - ASTC8x8Unorm = 0x00000052, - ASTC8x8UnormSrgb = 0x00000053, - ASTC10x5Unorm = 0x00000054, - ASTC10x5UnormSrgb = 0x00000055, - ASTC10x6Unorm = 0x00000056, - ASTC10x6UnormSrgb = 0x00000057, - ASTC10x8Unorm = 0x00000058, - ASTC10x8UnormSrgb = 0x00000059, - ASTC10x10Unorm = 0x0000005A, - ASTC10x10UnormSrgb = 0x0000005B, - ASTC12x10Unorm = 0x0000005C, - ASTC12x10UnormSrgb = 0x0000005D, - ASTC12x12Unorm = 0x0000005E, - ASTC12x12UnormSrgb = 0x0000005F, + R16Unorm = 0x00000005, + R16Snorm = 0x00000006, + R16Uint = 0x00000007, + R16Sint = 0x00000008, + R16Float = 0x00000009, + RG8Unorm = 0x0000000A, + RG8Snorm = 0x0000000B, + RG8Uint = 0x0000000C, + RG8Sint = 0x0000000D, + R32Float = 0x0000000E, + R32Uint = 0x0000000F, + R32Sint = 0x00000010, + RG16Unorm = 0x00000011, + RG16Snorm = 0x00000012, + RG16Uint = 0x00000013, + RG16Sint = 0x00000014, + RG16Float = 0x00000015, + RGBA8Unorm = 0x00000016, + RGBA8UnormSrgb = 0x00000017, + RGBA8Snorm = 0x00000018, + RGBA8Uint = 0x00000019, + RGBA8Sint = 0x0000001A, + BGRA8Unorm = 0x0000001B, + BGRA8UnormSrgb = 0x0000001C, + RGB10A2Uint = 0x0000001D, + RGB10A2Unorm = 0x0000001E, + RG11B10Ufloat = 0x0000001F, + RGB9E5Ufloat = 0x00000020, + RG32Float = 0x00000021, + RG32Uint = 0x00000022, + RG32Sint = 0x00000023, + RGBA16Unorm = 0x00000024, + RGBA16Snorm = 0x00000025, + RGBA16Uint = 0x00000026, + RGBA16Sint = 0x00000027, + RGBA16Float = 0x00000028, + RGBA32Float = 0x00000029, + RGBA32Uint = 0x0000002A, + RGBA32Sint = 0x0000002B, + Stencil8 = 0x0000002C, + Depth16Unorm = 0x0000002D, + Depth24Plus = 0x0000002E, + Depth24PlusStencil8 = 0x0000002F, + Depth32Float = 0x00000030, + Depth32FloatStencil8 = 0x00000031, + BC1RGBAUnorm = 0x00000032, + BC1RGBAUnormSrgb = 0x00000033, + BC2RGBAUnorm = 0x00000034, + BC2RGBAUnormSrgb = 0x00000035, + BC3RGBAUnorm = 0x00000036, + BC3RGBAUnormSrgb = 0x00000037, + BC4RUnorm = 0x00000038, + BC4RSnorm = 0x00000039, + BC5RGUnorm = 0x0000003A, + BC5RGSnorm = 0x0000003B, + BC6HRGBUfloat = 0x0000003C, + BC6HRGBFloat = 0x0000003D, + BC7RGBAUnorm = 0x0000003E, + BC7RGBAUnormSrgb = 0x0000003F, + ETC2RGB8Unorm = 0x00000040, + ETC2RGB8UnormSrgb = 0x00000041, + ETC2RGB8A1Unorm = 0x00000042, + ETC2RGB8A1UnormSrgb = 0x00000043, + ETC2RGBA8Unorm = 0x00000044, + ETC2RGBA8UnormSrgb = 0x00000045, + EACR11Unorm = 0x00000046, + EACR11Snorm = 0x00000047, + EACRG11Unorm = 0x00000048, + EACRG11Snorm = 0x00000049, + ASTC4x4Unorm = 0x0000004A, + ASTC4x4UnormSrgb = 0x0000004B, + ASTC5x4Unorm = 0x0000004C, + ASTC5x4UnormSrgb = 0x0000004D, + ASTC5x5Unorm = 0x0000004E, + ASTC5x5UnormSrgb = 0x0000004F, + ASTC6x5Unorm = 0x00000050, + ASTC6x5UnormSrgb = 0x00000051, + ASTC6x6Unorm = 0x00000052, + ASTC6x6UnormSrgb = 0x00000053, + ASTC8x5Unorm = 0x00000054, + ASTC8x5UnormSrgb = 0x00000055, + ASTC8x6Unorm = 0x00000056, + ASTC8x6UnormSrgb = 0x00000057, + ASTC8x8Unorm = 0x00000058, + ASTC8x8UnormSrgb = 0x00000059, + ASTC10x5Unorm = 0x0000005A, + ASTC10x5UnormSrgb = 0x0000005B, + ASTC10x6Unorm = 0x0000005C, + ASTC10x6UnormSrgb = 0x0000005D, + ASTC10x8Unorm = 0x0000005E, + ASTC10x8UnormSrgb = 0x0000005F, + ASTC10x10Unorm = 0x00000060, + ASTC10x10UnormSrgb = 0x00000061, + ASTC12x10Unorm = 0x00000062, + ASTC12x10UnormSrgb = 0x00000063, + ASTC12x12Unorm = 0x00000064, + ASTC12x12UnormSrgb = 0x00000065, // Native. // From FeatureName.TextureFormat16bitNorm - R16Unorm = 0x00030001, - R16Snorm, + NativeR16Unorm = 0x00030001, + NativeR16Snorm, Rg16Unorm, Rg16Snorm, Rgba16Unorm, Rgba16Snorm, - // From FeatureName.TextureFormatNv12 NV12, P010, } @@ -648,6 +683,11 @@ TextureViewDimension :: enum i32 { _3D = 0x00000006, } +ToneMappingMode :: enum i32 { + Standard = 1, + Extended, +} + VertexFormat :: enum i32 { Uint8 = 0x00000001, Uint8x2 = 0x00000002, @@ -693,10 +733,15 @@ VertexFormat :: enum i32 { } VertexStepMode :: enum i32 { - VertexBufferNotUsed = 0x00000000, - Undefined = 0x00000001, - Vertex = 0x00000002, - Instance = 0x00000003, + Undefined = 0x00000000, + Vertex = 0x00000001, + Instance = 0x00000002, +} + +WaitStatus :: enum i32 { + Success = 0x00000001, + TimedOut = 0x00000002, + Error = 0x00000003, } WGSLLanguageFeatureName :: enum i32 { @@ -704,14 +749,11 @@ WGSLLanguageFeatureName :: enum i32 { Packed4x8IntegerDotProduct = 0x00000002, UnrestrictedPointerParameters = 0x00000003, PointerCompositeAccess = 0x00000004, -} - -WaitStatus :: enum i32 { - Success = 0x00000001, - TimedOut = 0x00000002, - UnsupportedTimeout = 0x00000003, - UnsupportedCount = 0x00000004, - UnsupportedMixedSource = 0x00000005, + UniformBufferStandardLayout = 0x00000005, + SubgroupId = 0x00000006, + TextureAndSamplerLet = 0x00000007, + SubgroupUniformity = 0x00000008, + TextureFormatsTier1 = 0x00000009, } BufferUsage :: enum i32 { @@ -751,11 +793,12 @@ ShaderStage :: enum i32 { ShaderStageFlags :: bit_set[ShaderStage; Flags] TextureUsage :: enum i32 { - CopySrc = 0x00000000, - CopyDst = 0x00000001, - TextureBinding = 0x00000002, - StorageBinding = 0x00000003, - RenderAttachment = 0x00000004, + CopySrc, + CopyDst, + TextureBinding, + StorageBinding, + RenderAttachment, + TransientAttachment, } TextureUsageFlags :: bit_set[TextureUsage; Flags] @@ -767,7 +810,7 @@ CreateComputePipelineAsyncCallback :: #type proc "c" (status: CreatePipelineAsyn CreateRenderPipelineAsyncCallback :: #type proc "c" (status: CreatePipelineAsyncStatus, pipeline: RenderPipeline, message: StringView, userdata1: rawptr, userdata2: rawptr) DeviceLostCallback :: #type proc "c" (device: ^Device, reason: DeviceLostReason, message: StringView, userdata1: rawptr, userdata2: rawptr) PopErrorScopeCallback :: #type proc "c" (status: PopErrorScopeStatus, type: ErrorType, message: StringView, userdata1: rawptr, userdata2: rawptr) -QueueWorkDoneCallback :: #type proc "c" (status: QueueWorkDoneStatus, userdata1: rawptr, userdata2: rawptr) +QueueWorkDoneCallback :: #type proc "c" (status: QueueWorkDoneStatus, message: StringView, userdata1: rawptr, userdata2: rawptr) RequestAdapterCallback :: #type proc "c" (status: RequestAdapterStatus, adapter: Adapter, message: StringView, userdata1: rawptr, userdata2: rawptr) RequestDeviceCallback :: #type proc "c" (status: RequestDeviceStatus, adapter: Device, message: StringView, userdata1: rawptr, userdata2: rawptr) UncapturedErrorCallback :: #type proc "c" (device: ^Device, type: ErrorType, message: StringView, userdata1: rawptr, userdata2: rawptr) @@ -777,11 +820,6 @@ ChainedStruct :: struct { sType: SType, } -ChainedStructOut :: struct { - next: ^ChainedStructOut, - sType: SType, -} - BufferMapCallbackInfo :: struct { nextInChain: /* const */ ^ChainedStruct, mode: CallbackMode, @@ -862,7 +900,7 @@ UncapturedErrorCallbackInfo :: struct { } AdapterInfo :: struct { - nextInChain: ^ChainedStructOut, + nextInChain: ^ChainedStruct, vendor: StringView, architecture: StringView, device: StringView, @@ -871,16 +909,8 @@ AdapterInfo :: struct { adapterType: AdapterType, vendorID: u32, deviceID: u32, -} - -BindGroupEntry :: struct { - nextInChain: ^ChainedStruct, - binding: u32, - /* NULLABLE */ buffer: Buffer, - offset: u64, - size: u64, - /* NULLABLE */ sampler: Sampler, - /* NULLABLE */ textureView: TextureView, + subgroupMinSize: u32, + subgroupMaxSize: u32, } BlendComponent :: struct { @@ -916,6 +946,14 @@ CommandEncoderDescriptor :: struct { label: StringView, } +CompatibilityModeLimits :: struct { + using chain: ChainedStruct, + maxStorageBuffersInVertexStage: u32, + maxStorageTexturesInVertexStage: u32, + maxStorageBuffersInFragmentStage: u32, + maxStorageTexturesInFragmentStage: u32, +} + CompilationMessage :: struct { nextInChain: ^ChainedStruct, message: StringView, @@ -926,12 +964,6 @@ CompilationMessage :: struct { length: u64, } -ComputePassTimestampWrites :: struct { - querySet: QuerySet, - beginningOfPassWriteIndex: u32, - endOfPassWriteIndex: u32, -} - ConstantEntry :: struct { nextInChain: /* const */ ^ChainedStruct, key: StringView, @@ -944,18 +976,383 @@ Extent3D :: struct { depthOrArrayLayers: u32, } +/* +Chained in a `BindGroupEntry`. +*/ +ExternalTextureBindingEntry :: struct { + using chain: ChainedStruct, + externalTexture: ExternalTexture, +} + +/* +Chained in a `BindGroupLayoutEntry`. +*/ +ExternalTextureBindingLayout :: struct { + using chain: ChainedStruct, +} + Future :: struct { id: u64, } -InstanceCapabilities :: struct { - nextInChain: ^ChainedStructOut, - timedWaitAnyEnable: b32, +InstanceLimits :: struct { + nextInChain: ^ChainedStruct, timedWaitAnyMaxCount: uint, } +MultisampleState :: struct { + nextInChain: ^ChainedStruct, + count: u32, + mask: u32, + alphaToCoverageEnabled: b32, +} + +Origin3D :: struct { + x: u32, + y: u32, + z: u32, +} + +PassTimestampWrites :: struct { + nextInChain: ^ChainedStruct, + querySet: QuerySet, + beginningOfPassWriteIndex: u32, + endOfPassWriteIndex: u32, +} + +PipelineLayoutDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + bindGroupLayoutCount: uint, + bindGroupLayouts: [^]BindGroupLayout `fmt:"v,bindGroupLayoutCount"`, + immediateSize: u32, +} + +PrimitiveState :: struct { + nextInChain: ^ChainedStruct, + topology: PrimitiveTopology, + stripIndexFormat: IndexFormat, + frontFace: FrontFace, + cullMode: CullMode, + unclippedDepth: b32, +} + +QuerySetDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + type: QueryType, + count: u32, +} + +QueueDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, +} + +RenderBundleDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, +} + +RenderBundleEncoderDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + colorFormatCount: uint, + colorFormats: /* const */ [^]TextureFormat `fmt:"v,colorFormatCount"`, + depthStencilFormat: TextureFormat, + sampleCount: u32, + depthReadOnly: b32, + stencilReadOnly: b32, +} + +RenderPassDepthStencilAttachment :: struct { + nextInChain: ^ChainedStruct, + view: TextureView, + depthLoadOp: LoadOp, + depthStoreOp: StoreOp, + depthClearValue: f32, + depthReadOnly: b32, + stencilLoadOp: LoadOp, + stencilStoreOp: StoreOp, + stencilClearValue: u32, + stencilReadOnly: b32, +} + +RenderPassMaxDrawCount :: struct { + using chain: ChainedStruct, + maxDrawCount: u64, +} + +/* +Chained in a `RequestAdapterOptions`. +*/ +RequestAdapterWebXROptions :: struct { + using chain: ChainedStruct, + xrCompatible: b32, +} + +SamplerBindingLayout :: struct { + nextInChain: ^ChainedStruct, + type: SamplerBindingType, +} + +SamplerDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + addressModeU: AddressMode, + addressModeV: AddressMode, + addressModeW: AddressMode, + magFilter: FilterMode, + minFilter: FilterMode, + mipmapFilter: MipmapFilterMode, + lodMinClamp: f32, + lodMaxClamp: f32, + compare: CompareFunction, + maxAnisotropy: u16, +} + +ShaderSourceSPIRV :: struct { + using chain: ChainedStruct, + codeSize: u32, + code: /* const */ [^]u32 `fmt:"v,codeSize"`, +} + +ShaderSourceWGSL :: struct { + using chain: ChainedStruct, + code: StringView, +} + +StencilFaceState :: struct { + compare: CompareFunction, + failOp: StencilOperation, + depthFailOp: StencilOperation, + passOp: StencilOperation, +} + +StorageTextureBindingLayout :: struct { + nextInChain: ^ChainedStruct, + access: StorageTextureAccess, + format: TextureFormat, + viewDimension: TextureViewDimension, +} + +SupportedFeatures :: struct { + featureCount: uint, + features: /* const */ [^]FeatureName `fmt:"v,featureCount"`, +} + +SupportedInstanceFeatures :: struct { + featureCount: uint, + features: /* const */ [^]InstanceFeatureName `fmt:"v,featureCount"`, +} + +SupportedWGSLLanguageFeatures :: struct { + featureCount: uint, + features: /* const */ [^]WGSLLanguageFeatureName `fmt:"v,featureCount"`, +} + +SurfaceCapabilities :: struct { + nextInChain: ^ChainedStruct, + usages: TextureUsageFlags, + formatCount: uint, + formats: /* const */ [^]TextureFormat `fmt:"v,formatCount"`, + presentModeCount: uint, + presentModes: /* const */ [^]PresentMode `fmt:"v,presentModeCount"`, + alphaModeCount: uint, + alphaModes: /* const */ [^]CompositeAlphaMode `fmt:"v,alphaModeCount"`, +} + +/* +Chained in a `SurfaceConfiguration`. +*/ +SurfaceColorManagement :: struct { + using chain: ChainedStruct, + colorSpace: PredefinedColorSpace, + toneMappingMode: ToneMappingMode, +} + +SurfaceConfiguration :: struct { + nextInChain: ^ChainedStruct, + device: Device, + format: TextureFormat, + usage: TextureUsageFlags, + width: u32, + height: u32, + viewFormatCount: uint, + viewFormats: /* const */ [^]TextureFormat `fmt:"v,viewFormatCount"`, + alphaMode: CompositeAlphaMode, + presentMode: PresentMode, +} + +/* +Chained in a `SurfaceDescriptor`. +*/ +SurfaceSourceAndroidNativeWindow :: struct { + using chain: ChainedStruct, + window: rawptr, +} + +/* +Chained in a `SurfaceDescriptor`. +*/ +SurfaceSourceCanvasHTMLSelector :: struct { + using chain: ChainedStruct, + selector: StringView, +} + +/* +Chained in a `SurfaceDescriptor`. +*/ +SurfaceSourceMetalLayer :: struct { + using chain: ChainedStruct, + layer: rawptr, +} + +/* +Chained in a `SurfaceDescriptor`. +*/ +SurfaceSourceWaylandSurface :: struct { + using chain: ChainedStruct, + display: rawptr, + surface: rawptr, +} + +/* +Chained in a `SurfaceDescriptor`. +*/ +SurfaceSourceWindowsHWND :: struct { + using chain: ChainedStruct, + hinstance: rawptr, + hwnd: rawptr, +} + +/* +Chained in a `SurfaceDescriptor`. +*/ +SurfaceSourceXcbWindow :: struct { + using chain: ChainedStruct, + connection: rawptr, + window: u32, +} + +/* +Chained in a `SurfaceDescriptor`. +*/ +SurfaceSourceXlibWindow :: struct { + using chain: ChainedStruct, + display: rawptr, + window: u64, +} + +SurfaceTexture :: struct { + nextInChain: ^ChainedStruct, + texture: Texture, + status: SurfaceGetCurrentTextureStatus, +} + +TexelCopyBufferLayout :: struct { + offset: u64, + bytesPerRow: u32, + rowsPerImage: u32, +} + +TextureBindingLayout :: struct { + nextInChain: ^ChainedStruct, + sampleType: TextureSampleType, + viewDimension: TextureViewDimension, + multisampled: b32, +} + +TextureBindingViewDimension :: struct { + using chain: ChainedStruct, + textureBindingViewDimension: TextureViewDimension, +} + +TextureComponentSwizzle :: struct { + r, g, b, a: ComponentSwizzle, +} + +VertexAttribute :: struct { + nextInChain: ^ChainedStruct, + format: VertexFormat, + offset: u64, + shaderLocation: u32, +} + +BindGroupEntry :: struct { + nextInChain: ^ChainedStruct, + binding: u32, + /* NULLABLE */ buffer: Buffer, + offset: u64, + size: u64, + /* NULLABLE */ sampler: Sampler, + /* NULLABLE */ textureView: TextureView, +} + +BindGroupLayoutEntry :: struct { + nextInChain: ^ChainedStruct, + binding: u32, + visibility: ShaderStageFlags, + bindingArraySize: u32, + buffer: BufferBindingLayout, + sampler: SamplerBindingLayout, + texture: TextureBindingLayout, + storageTexture: StorageTextureBindingLayout, +} + +BlendState :: struct { + color: BlendComponent, + alpha: BlendComponent, +} + +CompilationInfo :: struct { + nextInChain: ^ChainedStruct, + messageCount: uint, + messages: /* const */ [^]CompilationMessage `fmt:"v,messageCount"`, +} + +ComputePassDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + /* NULLABLE */ timestampWrites: /* const */ ^PassTimestampWrites, +} + +ComputeState :: struct { + nextInChain: ^ChainedStruct, + module: ShaderModule, + entryPoint: StringView, + constantCount: uint, + constants: [^]ConstantEntry `fmt:"v,constantCount"`, +} + +DepthStencilState :: struct { + nextInChain: ^ChainedStruct, + format: TextureFormat, + depthWriteEnabled: OptionalBool, + depthCompare: CompareFunction, + stencilFront: StencilFaceState, + stencilBack: StencilFaceState, + stencilReadMask: u32, + stencilWriteMask: u32, + depthBias: i32, + depthBiasSlopeScale: f32, + depthBiasClamp: f32, +} + +FutureWaitInfo :: struct { + future: Future, + completed: b32, +} + +InstanceDescriptor :: struct { + nextInChain: ^ChainedStruct, + requiredFeatureCount: uint, + requiredFeatures: [^]InstanceFeatureName `fmt:"v,requiredFeatureCount"`, + /* NULLABLE */ requiredLimits: ^InstanceLimits, +} + Limits :: struct { - nextInChain: ^ChainedStructOut, + nextInChain: ^ChainedStruct, maxTextureDimension1D: u32, maxTextureDimension2D: u32, maxTextureDimension3D: u32, @@ -987,90 +1384,21 @@ Limits :: struct { maxComputeWorkgroupSizeY: u32, maxComputeWorkgroupSizeZ: u32, maxComputeWorkgroupsPerDimension: u32, + maxImmediateSize: u32, } -MultisampleState :: struct { - nextInChain: /* const */ ^ChainedStruct, - count: u32, - mask: u32, - alphaToCoverageEnabled: b32, -} - -Origin3D :: struct { - x: u32, - y: u32, - z: u32, -} - -PipelineLayoutDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - bindGroupLayoutCount: uint, - bindGroupLayouts: [^]BindGroupLayout `fmt:"v,bindGroupLayoutCount"`, -} - -PrimitiveState :: struct { - nextInChain: /* const */ ^ChainedStruct, - topology: PrimitiveTopology, - stripIndexFormat: IndexFormat, - frontFace: FrontFace, - cullMode: CullMode, - unclippedDepth: b32, -} - -QuerySetDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - type: QueryType, - count: u32, -} - -QueueDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, -} - -RenderBundleDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, -} - -RenderBundleEncoderDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - colorFormatCount: uint, - colorFormats: /* const */ [^]TextureFormat `fmt:"v,colorFormatCount"`, - depthStencilFormat: TextureFormat, - sampleCount: u32, - depthReadOnly: b32, - stencilReadOnly: b32, -} - -RenderPassDepthStencilAttachment :: struct { - view: TextureView, - depthLoadOp: LoadOp, - depthStoreOp: StoreOp, - depthClearValue: f32, - depthReadOnly: b32, - stencilLoadOp: LoadOp, - stencilStoreOp: StoreOp, - stencilClearValue: u32, - stencilReadOnly: b32, -} - -RenderPassMaxDrawCount :: struct { - using chain: ChainedStruct, - maxDrawCount: u64, -} - -RenderPassTimestampWrites :: struct { - querySet: QuerySet, - beginningOfPassWriteIndex: u32, - endOfPassWriteIndex: u32, +RenderPassColorAttachment :: struct { + nextInChain: ^ChainedStruct, + /* NULLABLE */ view: TextureView, + depthSlice: u32, + /* NULLABLE */ resolveTarget: TextureView, + loadOp: LoadOp, + storeOp: StoreOp, + clearValue: Color, } RequestAdapterOptions :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, featureLevel: FeatureLevel, powerPreference: PowerPreference, forceFallbackAdapter: b32, @@ -1078,260 +1406,16 @@ RequestAdapterOptions :: struct { /* NULLABLE */ compatibleSurface: Surface, } -SamplerBindingLayout :: struct { - nextInChain: /* const */ ^ChainedStruct, - type: SamplerBindingType, -} - -SamplerDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - addressModeU: AddressMode, - addressModeV: AddressMode, - addressModeW: AddressMode, - magFilter: FilterMode, - minFilter: FilterMode, - mipmapFilter: MipmapFilterMode, - lodMinClamp: f32, - lodMaxClamp: f32, - compare: CompareFunction, - maxAnisotropy: u16, -} - ShaderModuleDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, label: StringView, } -ShaderSourceSPIRV :: struct { - using chain: ChainedStruct, - codeSize: u32, - code: /* const */ [^]u32 `fmt:"v,codeSize"`, -} - -ShaderSourceWGSL :: struct { - using chain: ChainedStruct, - code: StringView, -} - -StencilFaceState :: struct { - compare: CompareFunction, - failOp: StencilOperation, - depthFailOp: StencilOperation, - passOp: StencilOperation, -} - -StorageTextureBindingLayout :: struct { - nextInChain: /* const */ ^ChainedStruct, - access: StorageTextureAccess, - format: TextureFormat, - viewDimension: TextureViewDimension, -} - -SupportedFeatures :: struct { - featureCount: uint, - features: /* const */ [^]FeatureName `fmt:"v,featureCount"`, -} - -SupportedWGSLLanguageFeatures :: struct { - featureCount: uint, - features: /* const */ [^]WGSLLanguageFeatureName `fmt:"v,featureCount"`, -} - -SurfaceCapabilities :: struct { - nextInChain: ^ChainedStructOut, - usages: TextureUsageFlags, - formatCount: uint, - formats: /* const */ [^]TextureFormat `fmt:"v,formatCount"`, - presentModeCount: uint, - presentModes: /* const */ [^]PresentMode `fmt:"v,presentModeCount"`, - alphaModeCount: uint, - alphaModes: /* const */ [^]CompositeAlphaMode `fmt:"v,alphaModeCount"`, -} - -SurfaceConfiguration :: struct { - nextInChain: /* const */ ^ChainedStruct, - device: Device, - format: TextureFormat, - usage: TextureUsageFlags, - width: u32, - height: u32, - viewFormatCount: uint, - viewFormats: /* const */ [^]TextureFormat `fmt:"v,viewFormatCount"`, - alphaMode: CompositeAlphaMode, - presentMode: PresentMode, -} - SurfaceDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, label: StringView, } -SurfaceSourceAndroidNativeWindow :: struct { - using chain: ChainedStruct, - window: rawptr, -} - -SurfaceSourceCanvasHTMLSelector :: struct { - using chain: ChainedStruct, - selector: StringView, -} - -SurfaceSourceMetalLayer :: struct { - using chain: ChainedStruct, - layer: rawptr, -} - -SurfaceSourceWaylandSurface :: struct { - using chain: ChainedStruct, - display: rawptr, - surface: rawptr, -} - -SurfaceSourceWindowsHWND :: struct { - using chain: ChainedStruct, - hinstance: rawptr, - hwnd: rawptr, -} - -SurfaceSourceXcbWindow :: struct { - using chain: ChainedStruct, - connection: rawptr, - window: u32, -} - -SurfaceSourceXlibWindow :: struct { - using chain: ChainedStruct, - display: rawptr, - window: u64, -} - -SurfaceTexture :: struct { - nextInChain: ^ChainedStructOut, - texture: Texture, - status: SurfaceGetCurrentTextureStatus, -} - -TexelCopyBufferLayout :: struct { - offset: u64, - bytesPerRow: u32, - rowsPerImage: u32, -} - -TextureBindingLayout :: struct { - nextInChain: /* const */ ^ChainedStruct, - sampleType: TextureSampleType, - viewDimension: TextureViewDimension, - multisampled: b32, -} - -TextureViewDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - format: TextureFormat, - dimension: TextureViewDimension, - baseMipLevel: u32, - mipLevelCount: u32, - baseArrayLayer: u32, - arrayLayerCount: u32, - aspect: TextureAspect, - usage: TextureUsageFlags, -} - -VertexAttribute :: struct { - format: VertexFormat, - offset: u64, - shaderLocation: u32, -} - -BindGroupDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - layout: BindGroupLayout, - entryCount: uint, - entries: /* const */ [^]BindGroupEntry `fmt:"v,entryCount"`, -} - -BindGroupLayoutEntry :: struct { - nextInChain: /* const */ ^ChainedStruct, - binding: u32, - visibility: ShaderStageFlags, - buffer: BufferBindingLayout, - sampler: SamplerBindingLayout, - texture: TextureBindingLayout, - storageTexture: StorageTextureBindingLayout, -} - -BlendState :: struct { - color: BlendComponent, - alpha: BlendComponent, -} - -CompilationInfo :: struct { - nextInChain: /* const */ ^ChainedStruct, - messageCount: uint, - messages: /* const */ [^]CompilationMessage `fmt:"v,messageCount"`, -} - -ComputePassDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - /* NULLABLE */ timestampWrites: /* const */ ^ComputePassTimestampWrites, -} - -DepthStencilState :: struct { - nextInChain: /* const */ ^ChainedStruct, - format: TextureFormat, - depthWriteEnabled: OptionalBool, - depthCompare: CompareFunction, - stencilFront: StencilFaceState, - stencilBack: StencilFaceState, - stencilReadMask: u32, - stencilWriteMask: u32, - depthBias: i32, - depthBiasSlopeScale: f32, - depthBiasClamp: f32, -} - -DeviceDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - label: StringView, - requiredFeatureCount: uint, - requiredFeatures: /* const */ [^]FeatureName `fmt:"v,requiredFeatureCount"`, - /* NULLABLE */ requiredLimits: /* const */ ^Limits, - defaultQueue: QueueDescriptor, - deviceLostCallbackInfo: DeviceLostCallbackInfo, - uncapturedErrorCallbackInfo: UncapturedErrorCallbackInfo, -} - -FutureWaitInfo :: struct { - future: Future, - completed: b32, -} - -InstanceDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - features: InstanceCapabilities, -} - -ProgrammableStageDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, - module: ShaderModule, - entryPoint: StringView, - constantCount: uint, - constants: [^]ConstantEntry `fmt:"v,constantCount"`, -} - -RenderPassColorAttachment :: struct { - nextInChain: /* const */ ^ChainedStruct, - /* NULLABLE */ view: TextureView, - depthSlice: u32, - /* NULLABLE */ resolveTarget: TextureView, - loadOp: LoadOp, - storeOp: StoreOp, - clearValue: Color, -} - TexelCopyBufferInfo :: struct { layout: TexelCopyBufferLayout, buffer: Buffer, @@ -1344,8 +1428,16 @@ TexelCopyTextureInfo :: struct { aspect: TextureAspect, } +/* +Chained in a `TextureViewDescriptor`. +*/ +TextureComponentSwizzleDescriptor :: struct { + using chain: ChainedStruct, + swizzle: TextureComponentSwizzle, +} + TextureDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, label: StringView, usage: TextureUsageFlags, dimension: TextureDimension, @@ -1358,14 +1450,23 @@ TextureDescriptor :: struct { } VertexBufferLayout :: struct { + nextInChain: ^ChainedStruct, stepMode: VertexStepMode, arrayStride: u64, attributeCount: uint, attributes: /* const */ [^]VertexAttribute `fmt:"v,attributeCount"`, } +BindGroupDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + layout: BindGroupLayout, + entryCount: uint, + entries: /* const */ [^]BindGroupEntry `fmt:"v,entryCount"`, +} + BindGroupLayoutDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, label: StringView, entryCount: uint, entries: /* const */ [^]BindGroupLayoutEntry `fmt:"v,entryCount"`, @@ -1379,24 +1480,48 @@ ColorTargetState :: struct { } ComputePipelineDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, label: StringView, /* NULLABLE */ layout: PipelineLayout, - compute: ProgrammableStageDescriptor, + compute: ComputeState, +} + +DeviceDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + requiredFeatureCount: uint, + requiredFeatures: /* const */ [^]FeatureName `fmt:"v,requiredFeatureCount"`, + /* NULLABLE */ requiredLimits: /* const */ ^Limits, + defaultQueue: QueueDescriptor, + deviceLostCallbackInfo: DeviceLostCallbackInfo, + uncapturedErrorCallbackInfo: UncapturedErrorCallbackInfo, } RenderPassDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, label: StringView, colorAttachmentCount: uint, colorAttachments: /* const */ [^]RenderPassColorAttachment `fmt:"v,colorAttachmentCount"`, /* NULLABLE */ depthStencilAttachment: /* const */ ^RenderPassDepthStencilAttachment, /* NULLABLE */ occlusionQuerySet: QuerySet, - /* NULLABLE */ timestampWrites: /* const */ ^RenderPassTimestampWrites, + /* NULLABLE */ timestampWrites: /* const */ ^PassTimestampWrites, +} + +TextureViewDescriptor :: struct { + nextInChain: ^ChainedStruct, + label: StringView, + format: TextureFormat, + dimension: TextureViewDimension, + baseMipLevel: u32, + mipLevelCount: u32, + baseArrayLayer: u32, + arrayLayerCount: u32, + aspect: TextureAspect, + usage: TextureUsageFlags, } VertexState :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, module: ShaderModule, entryPoint: StringView, constantCount: uint, @@ -1406,7 +1531,7 @@ VertexState :: struct { } FragmentState :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, module: ShaderModule, entryPoint: StringView, constantCount: uint, @@ -1416,7 +1541,7 @@ FragmentState :: struct { } RenderPipelineDescriptor :: struct { - nextInChain: /* const */ ^ChainedStruct, + nextInChain: ^ChainedStruct, label: StringView, /* NULLABLE */ layout: PipelineLayout, vertex: VertexState, @@ -1430,8 +1555,10 @@ RenderPipelineDescriptor :: struct { foreign libwgpu { @(link_name="wgpuCreateInstance") RawCreateInstance :: proc(/* NULLABLE */ descriptor: /* const */ ^InstanceDescriptor = nil) -> Instance --- - @(link_name="wgpuGetInstanceCapabilities") - RawGetInstanceCapabilities :: proc(capabilities: ^InstanceCapabilities) -> Status --- + GetInstanceFeatures :: proc(features: ^SupportedInstanceFeatures) --- + @(link_name="wgpuGetInstanceLimits") + RawGetInstanceLimits :: proc(limits: ^InstanceLimits) -> Status --- + HasInstanceFeature :: proc(feature: InstanceFeatureName) -> b32 --- GetProcAddress :: proc(procName: StringView) -> Proc --- // Methods of Adapter @@ -1463,14 +1590,16 @@ foreign libwgpu { BufferDestroy :: proc(buffer: Buffer) --- @(link_name="wgpuBufferGetConstMappedRange") RawBufferGetConstMappedRange :: proc(buffer: Buffer, offset: uint, size: uint) -> /* const */ rawptr --- - BufferGetMapState :: proc(buffer: Buffer) -> BufferMapState --- @(link_name="wgpuBufferGetMappedRange") RawBufferGetMappedRange :: proc(buffer: Buffer, offset: uint, size: uint) -> rawptr --- + BufferGetMapState :: proc(buffer: Buffer) -> BufferMapState --- BufferGetSize :: proc(buffer: Buffer) -> u64 --- BufferGetUsage :: proc(buffer: Buffer) -> BufferUsageFlags --- BufferMapAsync :: proc(buffer: Buffer, mode: MapModeFlags, offset: uint, size: uint, callbackInfo: BufferMapCallbackInfo) -> Future --- + BufferReadMappedRange :: proc(buffer: Buffer, offset: uint, data: rawptr, size: uint) -> Status --- BufferSetLabel :: proc(buffer: Buffer, label: StringView) --- BufferUnmap :: proc(buffer: Buffer) --- + BufferWriteMappedRange :: proc(buffer: Buffer, offset: uint, data: rawptr, size: uint) -> Status --- BufferAddRef :: proc(buffer: Buffer) --- BufferRelease :: proc(buffer: Buffer) --- @@ -1548,10 +1677,14 @@ foreign libwgpu { DeviceAddRef :: proc(device: Device) --- DeviceRelease :: proc(device: Device) --- + // Methods of ExternalTexture + ExternalTextureSetLabel :: proc(externalTexture: ExternalTexture, label: StringView) --- + ExternalTextureAddRef :: proc(externalTexture: ExternalTexture) --- + ExternalTextureRelease :: proc(externalTexture: ExternalTexture) --- + // Methods of Instance InstanceCreateSurface :: proc(instance: Instance, descriptor: /* const */ ^SurfaceDescriptor) -> Surface --- - @(link_name="wgpuInstanceGetWGSLLanguageFeatures") - RawInstanceGetWGSLLanguageFeatures :: proc(instance: Instance, features: ^SupportedWGSLLanguageFeatures) -> Status --- + InstanceGetWGSLLanguageFeatures :: proc(instance: Instance, features: ^SupportedWGSLLanguageFeatures) --- InstanceHasWGSLLanguageFeature :: proc(instance: Instance, feature: WGSLLanguageFeatureName) -> b32 --- InstanceProcessEvents :: proc(instance: Instance) --- InstanceRequestAdapter :: proc(instance: Instance, /* NULLABLE */ options: /* const */ ^RequestAdapterOptions, callbackInfo: RequestAdapterCallbackInfo) -> Future --- @@ -1651,6 +1784,9 @@ foreign libwgpu { // Methods of SupportedFeatures SupportedFeaturesFreeMembers :: proc(supportedFeatures: SupportedFeatures) --- + // Methods of SupportedInstanceFeatures + SupportedInstanceFeaturesFreeMembers :: proc(SupportedInstanceFeatures: SupportedInstanceFeatures) --- + // Methods of SupportedWGSLLanguageFeatures SupportedWGSLLanguageFeaturesFreeMembers :: proc(supportedWGSLLanguageFeatures: SupportedWGSLLanguageFeatures) --- @@ -1678,6 +1814,7 @@ foreign libwgpu { TextureGetHeight :: proc(texture: Texture) -> u32 --- TextureGetMipLevelCount :: proc(texture: Texture) -> u32 --- TextureGetSampleCount :: proc(texture: Texture) -> u32 --- + TextureGetTextureBindingViewDimension :: proc(texture: Texture) -> TextureViewDimension --- TextureGetUsage :: proc(texture: Texture) -> TextureUsageFlags --- TextureGetWidth :: proc(texture: Texture) -> u32 --- TextureSetLabel :: proc(texture: Texture, label: StringView) --- @@ -1709,13 +1846,8 @@ CreateInstance :: proc "c" (/* NULLABLE */ descriptor: /* const */ ^InstanceDesc return RawCreateInstance(descriptor) } -GetInstanceCapabilities :: proc "c" () -> (capabilities: InstanceCapabilities, status: Status) { - status = RawGetInstanceCapabilities(&capabilities) - return -} - -InstanceGetWGSLLanguageFeatures :: proc "c" (instance: Instance) -> (features: SupportedWGSLLanguageFeatures, status: Status) { - status = RawInstanceGetWGSLLanguageFeatures(instance, &features) +GetInstanceLimits :: proc "c" () -> (limits: InstanceLimits, status: Status) { + status = RawGetInstanceLimits(&limits) return } diff --git a/vendor/wgpu/wgpu_native.odin b/vendor/wgpu/wgpu_native.odin index c58a8c90e..b1658d714 100644 --- a/vendor/wgpu/wgpu_native.odin +++ b/vendor/wgpu/wgpu_native.odin @@ -11,6 +11,8 @@ foreign libwgpu { @(link_name="wgpuQueueSubmitForIndex") RawQueueSubmitForIndex :: proc(queue: Queue, commandCount: uint, commands: [^]CommandBuffer) -> SubmissionIndex --- + QueueGetTimestampPeriod :: proc(queue: Queue) -> f32 --- + // Returns true if the queue is empty, or false if there are more queue submissions still in flight. DevicePoll :: proc(device: Device, wait: b32, /* NULLABLE */ submissionIndex: /* const */ ^SubmissionIndex = nil) -> b32 --- DeviceCreateShaderModuleSpirV :: proc(device: Device, descriptor: ^ShaderModuleDescriptorSpirV) -> ShaderModule --- @@ -21,9 +23,13 @@ foreign libwgpu { GetVersion :: proc() -> u32 --- - RenderPassEncoderSetPushConstants :: proc(encoder: RenderPassEncoder, stages: ShaderStageFlags, offset: u32, sizeBytes: u32, data: rawptr) --- - ComputePassEncoderSetPushConstants :: proc(encoder: ComputePassEncoder, offset: u32, sizeBytes: u32, data: rawptr) --- - RenderBundleEncoderSetPushConstants :: proc(encoder: RenderBundleEncoder, stages: ShaderStageFlags, offset: u32, sizeBytes: u32, data: rawptr) --- + DeviceGetNativeMetalDevice :: proc(device: Device) -> rawptr --- + DeviceGetNativeMetalCommandQueue :: proc(device: Device) -> rawptr --- + DeviceGetNativeMetalTexture :: proc(device: Device) -> rawptr --- + + RenderPassEncoderSetImmediates :: proc(encoder: RenderPassEncoder, stages: ShaderStageFlags, offset: u32, sizeBytes: u32, data: rawptr) --- + ComputePassEncoderSetImmediates :: proc(encoder: ComputePassEncoder, offset: u32, sizeBytes: u32, data: rawptr) --- + RenderBundleEncoderSetImmediates :: proc(encoder: RenderBundleEncoder, stages: ShaderStageFlags, offset: u32, sizeBytes: u32, data: rawptr) --- RenderPassEncoderMultiDrawIndirect :: proc(encoder: RenderPassEncoder, buffer: Buffer, offset: u64, count: u32) --- RenderPassEncoderMultiDrawIndexedIndirect :: proc(encoder: RenderPassEncoder, buffer: Buffer, offset: u64, count: u32) --- @@ -38,6 +44,9 @@ foreign libwgpu { ComputePassEncoderWriteTimestamp :: proc(computePassEncoder: ComputePassEncoder, querySet: QuerySet, queryIndex: u32) --- RenderPassEncoderWriteTimestamp :: proc(renderPassEncoder: RenderPassEncoder, querySet: QuerySet, queryIndex: u32) --- + + DeviceStartGraphicsDebuggerCapture :: proc(device: Device) -> b32 --- + DeviceStopGraphicsDebuggerCapture :: proc(device: Device) --- } GenerateReport :: proc "c" (instance: Instance) -> (report: GlobalReport) { diff --git a/vendor/wgpu/wgpu_native_types.odin b/vendor/wgpu/wgpu_native_types.odin index ad6ce704e..931aa96db 100644 --- a/vendor/wgpu/wgpu_native_types.odin +++ b/vendor/wgpu/wgpu_native_types.odin @@ -2,8 +2,8 @@ package wgpu import "base:runtime" -BINDINGS_VERSION :: [4]u8{27, 0, 2, 0} -BINDINGS_VERSION_STRING :: "27.0.2.0" +BINDINGS_VERSION :: [4]u8{29, 0, 0, 0} +BINDINGS_VERSION_STRING :: "29.0.0.0" LogLevel :: enum i32 { Off, @@ -19,21 +19,29 @@ InstanceBackend :: enum i32 { GL, Metal, DX12, - DX11, - BrowserWebGPU, + // DX11, + BrowserWebGPU = 5, } InstanceBackendFlags :: bit_set[InstanceBackend; Flags] InstanceBackendFlags_All :: InstanceBackendFlags{} InstanceBackendFlags_Primary :: InstanceBackendFlags{ .Vulkan, .Metal, .DX12, .BrowserWebGPU } -InstanceBackendFlags_Secondary :: InstanceBackendFlags{ .GL, .DX11 } +InstanceBackendFlags_Secondary :: InstanceBackendFlags{ .GL } InstanceFlag :: enum i32 { Debug, Validation, DiscardHalLabels, + AllowUnderlyingNoncompliantAdapter, + GPUBasedValidation, + ValidationIndirectCall, + AutomaticTimestampNormalization, + Default = 24, + Debugging, + AdvancedDebugging, + WithEnv, } InstanceFlags :: bit_set[InstanceFlag; Flags] -InstanceFlags_Default :: InstanceFlags{} +InstanceFlags_Empty :: InstanceFlags{} Dx12Compiler :: enum i32 { Undefined, @@ -72,6 +80,42 @@ GLFenceBehaviour :: enum i32 { AutoFinish, } +Dx12SwapchainKind :: enum i32 { + Undefined, + DxgiFromHwnd, + DxgiFromVisual, +} + +NativeDisplayHandleType :: enum i32 { + None, + Xlib, + Xcb, + Wayland, +} + +XlibDisplayHandle :: struct { + display: rawptr, + screen: i32, +} + +XcbDisplayHandle :: struct { + connection: rawptr, + screen: i32, +} + +WaylandDisplayHandle :: struct { + display: rawptr, +} + +NativeDisplayHandle :: struct { + type: NativeDisplayHandleType, + using data: struct #raw_union { + xlib: XlibDisplayHandle, + xcb: XcbDisplayHandle, + wayland: WaylandDisplayHandle, + }, +} + InstanceExtras :: struct { using chain: ChainedStruct, backends: InstanceBackendFlags, @@ -81,8 +125,10 @@ InstanceExtras :: struct { glFenceBehaviour: GLFenceBehaviour, dxcPath: StringView, dcxMaxShaderModel: DxcMaxShaderModel, + dx12PresentationSystem: Dx12SwapchainKind, budgetForDeviceCreation: ^u8, budgetForDeviceLoss: ^u8, + displayHandle: NativeDisplayHandle, } DeviceExtras :: struct { @@ -91,21 +137,15 @@ DeviceExtras :: struct { } NativeLimits :: struct { - using chain: ChainedStructOut, - maxPushConstantSize: u32, + using chain: ChainedStruct, + maxImmediateSize: u32, maxNonSamplerBindings: u32, -} - -PushConstantRange :: struct { - stages: ShaderStageFlags, - start: u32, - end: u32, + maxBindingArrayElementsPerShaderStage: u32, } PipelineLayoutExtras :: struct { using chain: ChainedStruct, - pushConstantRangeCount: uint, - pushConstantRanges: [^]PushConstantRange `fmt:"v,pushConstantRangeCount"`, + immediateDataSize: u32, } SubmissionIndex :: distinct u64