diff --git a/AUTHORS b/AUTHORS index 8f75808e6e747..e3c8e14d41264 100644 --- a/AUTHORS +++ b/AUTHORS @@ -469,4 +469,5 @@ a license to everyone to use it as detailed in LICENSE.) * Jānis Rūcis * rssqian * Shachar Langbeheim +* Laurin Agostini * David Carlier diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 135eff8b06088..153f3eed783d7 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -65,16 +65,23 @@ }, makeCheckDescriptor: function(descriptor) { // Assert descriptor is non-null, then that its nextInChain is null. + // For descriptors that aren't the first in the chain (e.g ShaderModuleSPIRVDescriptor), + // there is no nextInChain pointer but a ChainedStruct object named chain. + // So we need to check if chain.nextInChain is null. As long as nextInChain and chain are both the + // first member in the struct, descriptor.nextInChain and descriptor.chain.nextInChain should have the same offset (0) + // to the descriptor pointer and we can check it to be null. var OffsetOfNextInChainMember = 0; return this.makeCheck(descriptor) + this.makeCheck(makeGetValue(descriptor, OffsetOfNextInChainMember, '*') + ' === 0'); }, // Must be in sync with webgpu.h. PresentMode: { - VSync: 1, + Fifo: 2, }, SType: { SurfaceDescriptorFromHTMLCanvasId: 4, + ShaderModuleSPIRVDescriptor: 5, + ShaderModuleWGSLDescriptor: 6, }, }; return null; @@ -206,8 +213,8 @@ var LibraryWebGPU = { "buffer": this.mgrBuffer.get( {{{ makeGetValue('ptr', C_STRUCTS.WGPUBufferCopyView.buffer, '*') }}}), "offset": {{{ gpu.makeGetU64('ptr', C_STRUCTS.WGPUBufferCopyView.offset) }}}, - "rowPitch": {{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUBufferCopyView.rowPitch) }}}, - "imageHeight": {{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUBufferCopyView.imageHeight) }}}, + "bytesPerRow": {{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUBufferCopyView.bytesPerRow) }}}, + "rowsPerImage": {{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUBufferCopyView.rowsPerImage) }}}, }; }, @@ -222,6 +229,11 @@ var LibraryWebGPU = { }; }, + // maps deviceId to the queueId of the device's defaultQueue + defaultQueues: { + 0: 0 + }, + // This section is auto-generated: // https://dawn.googlesource.com/dawn/+/refs/heads/master/generator/templates/library_webgpu_enum_tables.json AddressMode: [ @@ -234,8 +246,11 @@ var LibraryWebGPU = { 'storage-buffer', 'readonly-storage-buffer', 'sampler', + 'comparison-sampler', 'sampled-texture', - 'storage-texture', + undefined, // WGPUBindingType_StorageTexture (deprecated) + 'readonly-storage-texture', + 'writeonly-storage-texture', ], BlendFactor: [ 'zero', @@ -266,6 +281,7 @@ var LibraryWebGPU = { 'device-lost', ], CompareFunction: [ + undefined, 'never', 'less', 'less-equal', @@ -318,10 +334,6 @@ var LibraryWebGPU = { 'clear', 'load', ], - PresentMode: [ - 'no-v-sync', - 'v-sync', - ], PrimitiveTopology: [ 'point-list', 'line-list', @@ -492,14 +504,23 @@ var LibraryWebGPU = { // wgpuDevice - // wgpuDeviceCreate* - - wgpuDeviceCreateQueue: function(deviceId) { - assert(WebGPU.mgrQueue.objects.length === 1, 'there is only one queue'); - var device = WebGPU["mgrDevice"].get(deviceId); - return WebGPU.mgrQueue.create(device["defaultQueue"]); + wgpuDeviceGetDefaultQueue: function(deviceId) { + var queueId = WebGPU.defaultQueues[deviceId]; +#if ASSERTIONS + assert(queueId != 0, 'got invalid queue'); +#endif + if (queueId === undefined) { + var device = WebGPU["mgrDevice"].get(deviceId); + WebGPU.defaultQueues[deviceId] = WebGPU.mgrQueue.create(device["defaultQueue"]); + queueId = WebGPU.defaultQueues[deviceId]; + } else { + WebGPU.mgrQueue.reference(queueId); + } + return queueId; }, + // wgpuDeviceCreate* + wgpuDeviceCreateCommandEncoder: function(deviceId, descriptor) { var desc; if (descriptor) { @@ -544,12 +565,12 @@ var LibraryWebGPU = { var bufferId = WebGPU.mgrBuffer.create(buffer, bufferWrapper); WebGPU.trackMapWrite(bufferWrapper, mapped); - var dataLength_h = (mapped.byteLength / 0x100000000) | 0; - var dataLength_l = mapped.byteLength | 0; + var dataLength_high = (mapped.byteLength / 0x100000000) | 0; + var dataLength_low = mapped.byteLength | 0; {{{ makeSetValue('returnPtr', C_STRUCTS.WGPUCreateBufferMappedResult.buffer, 'bufferId', '*') }}} - {{{ makeSetValue('returnPtr', C_STRUCTS.WGPUCreateBufferMappedResult.dataLength + 0, 'dataLength_l', 'i32') }}} - {{{ makeSetValue('returnPtr', C_STRUCTS.WGPUCreateBufferMappedResult.dataLength + 4, 'dataLength_h', 'i32') }}} + {{{ makeSetValue('returnPtr', C_STRUCTS.WGPUCreateBufferMappedResult.dataLength + 0, 'dataLength_low', 'i32') }}} + {{{ makeSetValue('returnPtr', C_STRUCTS.WGPUCreateBufferMappedResult.dataLength + 4, 'dataLength_high', 'i32') }}} {{{ makeSetValue('returnPtr', C_STRUCTS.WGPUCreateBufferMappedResult.data, 'bufferWrapper.mapWriteSrc', '*') }}} }, @@ -607,40 +628,42 @@ var LibraryWebGPU = { wgpuDeviceCreateBindGroupLayout: function(deviceId, descriptor) { {{{ gpu.makeCheckDescriptor('descriptor') }}} - function makeBinding(bindingPtr) { - {{{ gpu.makeCheck('bindingPtr') }}} + function makeEntry(entryPtr) { + {{{ gpu.makeCheck('entryPtr') }}} return { "binding": - {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.binding) }}}, + {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.binding) }}}, "visibility": - {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.visibility) }}}, + {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.visibility) }}}, "type": WebGPU.BindingType[ - {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.type) }}}], - "textureDimension": WebGPU.TextureViewDimension[ - {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.textureDimension) }}}], + {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.type) }}}], + "viewDimension": WebGPU.TextureViewDimension[ + {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.viewDimension) }}}], "textureComponentType": WebGPU.TextureComponentType[ - {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.textureComponentType) }}}], + {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.textureComponentType) }}}], + "storageTextureFormat": WebGPU.TextureFormat[ + {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.storageTextureFormat) }}}], "multisampled": - {{{ gpu.makeGetBool('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.multisampled) }}}, + {{{ gpu.makeGetBool('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.multisampled) }}}, "hasDynamicOffset": - {{{ gpu.makeGetBool('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.hasDynamicOffset) }}}, + {{{ gpu.makeGetBool('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.hasDynamicOffset) }}}, }; } - function makeBindings(count, bindingsPtrs) { - var bindings = []; + function makeEntries(count, entriesPtrs) { + var entries = []; for (var i = 0; i < count; ++i) { - bindings.push(makeBinding(bindingsPtrs + - {{{ C_STRUCTS.WGPUBindGroupLayoutBinding.__size__ }}} * i)); + entries.push(makeEntry(entriesPtrs + + {{{ C_STRUCTS.WGPUBindGroupLayoutEntry.__size__ }}} * i)); } - return bindings; + return entries; } var desc = { - "bindings": makeBindings( - {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUBindGroupLayoutDescriptor.bindingCount) }}}, - {{{ makeGetValue('descriptor', C_STRUCTS.WGPUBindGroupLayoutDescriptor.bindings, '*') }}} + "entries": makeEntries( + {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUBindGroupLayoutDescriptor.entryCount) }}}, + {{{ makeGetValue('descriptor', C_STRUCTS.WGPUBindGroupLayoutDescriptor.entries, '*') }}} ), }; var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUBindGroupLayoutDescriptor.label, '*') }}}; @@ -653,33 +676,33 @@ var LibraryWebGPU = { wgpuDeviceCreateBindGroup: function(deviceId, descriptor) { {{{ gpu.makeCheckDescriptor('descriptor') }}} - function makeBinding(bindingPtr) { - {{{ gpu.makeCheck('bindingPtr') }}} + function makeEntry(entryPtr) { + {{{ gpu.makeCheck('entryPtr') }}} - var bufferId = {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupBinding.buffer) }}}; - var samplerId = {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupBinding.sampler) }}}; - var textureViewId = {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupBinding.textureView) }}}; + var bufferId = {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupEntry.buffer) }}}; + var samplerId = {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupEntry.sampler) }}}; + var textureViewId = {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupEntry.textureView) }}}; #if ASSERTIONS assert((bufferId != 0) + (samplerId != 0) + (textureViewId != 0) == 1); #endif - var binding = {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupLayoutBinding.binding) }}}; + var binding = {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupLayoutEntry.binding) }}}; if (bufferId != 0) { var size = undefined; // Handle WGPU_WHOLE_SIZE. - var sizePart1 = {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupBinding.size) }}}; - var sizePart2 = {{{ gpu.makeGetU32('bindingPtr', C_STRUCTS.WGPUBindGroupBinding.size + 4) }}}; + var sizePart1 = {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupEntry.size) }}}; + var sizePart2 = {{{ gpu.makeGetU32('entryPtr', C_STRUCTS.WGPUBindGroupEntry.size + 4) }}}; if (sizePart1 != 0xFFFFFFFF || sizePart2 != 0xFFFFFFFF) { - size = {{{ gpu.makeGetU64('bindingPtr', C_STRUCTS.WGPUBindGroupBinding.size) }}}; + size = {{{ gpu.makeGetU64('entryPtr', C_STRUCTS.WGPUBindGroupEntry.size) }}}; } return { "binding": binding, "resource": { "buffer": WebGPU.mgrBuffer.get(bufferId), - "offset": {{{ gpu.makeGetU64('bindingPtr', C_STRUCTS.WGPUBindGroupBinding.offset) }}}, + "offset": {{{ gpu.makeGetU64('entryPtr', C_STRUCTS.WGPUBindGroupEntry.offset) }}}, "size": size, }, }; @@ -696,22 +719,22 @@ var LibraryWebGPU = { } } - function makeBindings(count, bindingsPtrs) { - var bindings = []; + function makeEntries(count, entriesPtrs) { + var entries = []; for (var i = 0; i < count; ++i) { - bindings.push(makeBinding(bindingsPtrs + - {{{C_STRUCTS.WGPUBindGroupBinding.__size__}}} * i)); + entries.push(makeEntry(entriesPtrs + + {{{C_STRUCTS.WGPUBindGroupEntry.__size__}}} * i)); } - return bindings; + return entries; } var desc = { "label": undefined, "layout": WebGPU.mgrBindGroupLayout.get( {{{ makeGetValue('descriptor', C_STRUCTS.WGPUBindGroupDescriptor.layout, '*') }}}), - "bindings": makeBindings( - {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUBindGroupDescriptor.bindingCount) }}}, - {{{ makeGetValue('descriptor', C_STRUCTS.WGPUBindGroupDescriptor.bindings, '*') }}} + "entries": makeEntries( + {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUBindGroupDescriptor.entryCount) }}}, + {{{ makeGetValue('descriptor', C_STRUCTS.WGPUBindGroupDescriptor.entries, '*') }}} ), }; var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUBindGroupDescriptor.label, '*') }}}; @@ -920,16 +943,34 @@ var LibraryWebGPU = { }, wgpuDeviceCreateShaderModule: function(deviceId, descriptor) { - {{{ gpu.makeCheckDescriptor('descriptor') }}} - var count = {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.codeSize) }}}; - var start = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.code, '*') }}}; + {{{ gpu.makeCheck('descriptor') }}} + var nextInChainPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.nextInChain, '*') }}}; +#if ASSERTIONS + assert(nextInChainPtr !== 0); +#endif + var sType = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}}; +#if ASSERTIONS + assert(sType === {{{ gpu.SType.ShaderModuleSPIRVDescriptor }}} + || sType === {{{ gpu.SType.ShaderModuleWGSLDescriptor }}}); +#endif var desc = { "label": undefined, - "code": HEAPU32.subarray(start >> 2, (start >> 2) + count), + "code": "", }; var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.label, '*') }}}; if (labelPtr) desc["label"] = UTF8ToString(labelPtr); + if (sType === {{{ gpu.SType.ShaderModuleSPIRVDescriptor }}}) { + var count = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUShaderModuleSPIRVDescriptor.codeSize) }}}; + var start = {{{ makeGetValue('nextInChainPtr', C_STRUCTS.WGPUShaderModuleSPIRVDescriptor.code, '*') }}}; + desc["code"] = HEAPU32.subarray(start >> 2, (start >> 2) + count); + } else if (sType === {{{ gpu.SType.ShaderModuleWGSLDescriptor }}}) { + var sourcePtr = {{{ makeGetValue('nextInChainPtr', C_STRUCTS.WGPUShaderModuleWGSLDescriptor.source, '*') }}}; + if (sourcePtr) { + desc["code"] = UTF8ToString(sourcePtr); + } + } + var device = WebGPU["mgrDevice"].get(deviceId); return WebGPU.mgrShaderModule.create(device["createShaderModule"](desc)); }, @@ -961,7 +1002,7 @@ var LibraryWebGPU = { wgpuFenceOnCompletion: function(fenceId, {{{ defineI64Param('completionValue') }}}, callback, userdata) { {{{ receiveI64ParamAsI32s('completionValue') }}} var fence = WebGPU.mgrFence.get(fenceId); - var completionValue = {{{ gpu.makeU64ToNumber('completionValue_l', 'completionValue_h') }}}; + var completionValue = {{{ gpu.makeU64ToNumber('completionValue_low', 'completionValue_high') }}}; var WEBGPU_FENCE_COMPLETION_STATUS_SUCCESS = 0; var WEBGPU_FENCE_COMPLETION_STATUS_ERROR = 1; @@ -995,7 +1036,7 @@ var LibraryWebGPU = { {{{ receiveI64ParamAsI32s('signalValue') }}} var queue = WebGPU.mgrQueue.get(queueId); var fence = WebGPU.mgrFence.get(fenceId); - var signalValue = {{{ gpu.makeU64ToNumber('signalValue_l', 'signalValue_h') }}}; + var signalValue = {{{ gpu.makeU64ToNumber('signalValue_low', 'signalValue_high') }}}; queue.signal(fence, signalValue); }, @@ -1145,9 +1186,9 @@ var LibraryWebGPU = { var src = WebGPU.mgrBuffer.get(srcId); var dst = WebGPU.mgrBuffer.get(dstId); commandEncoder["copyBufferToBuffer"]( - src, {{{ gpu.makeU64ToNumber('srcOffset_l', 'srcOffset_h') }}}, - dst, {{{ gpu.makeU64ToNumber('dstOffset_l', 'dstOffset_h') }}}, - {{{ gpu.makeU64ToNumber('size_l', 'size_h') }}}); + src, {{{ gpu.makeU64ToNumber('srcOffset_low', 'srcOffset_high') }}}, + dst, {{{ gpu.makeU64ToNumber('dstOffset_low', 'dstOffset_high') }}}, + {{{ gpu.makeU64ToNumber('size_low', 'size_high') }}}); }, wgpuCommandEncoderCopyBufferToTexture: function(encoderId, srcPtr, dstPtr, copySizePtr) { @@ -1177,8 +1218,8 @@ var LibraryWebGPU = { {{{ receiveI64ParamAsI32s('start') }}} {{{ receiveI64ParamAsI32s('count') }}} var buffer = WebGPU.mgrBuffer.get(bufferId); - var start = {{{ gpu.makeU64ToNumber('start_l', 'start_h') }}}; - var count = {{{ gpu.makeU64ToNumber('count_l', 'count_h') }}}; + var start = {{{ gpu.makeU64ToNumber('start_low', 'start_high') }}}; + var count = {{{ gpu.makeU64ToNumber('count_low', 'count_high') }}}; buffer["setSubData"](start, HEAPU8, data, count); }, @@ -1191,10 +1232,10 @@ var LibraryWebGPU = { var WEBGPU_BUFFER_MAP_ASYNC_STATUS_SUCCESS = 0; var data = _malloc(mapped.byteLength); HEAPU8.set(new Uint8Array(mapped), data); - var dataLength_h = (mapped.byteLength / 0x100000000) | 0; - var dataLength_l = mapped.byteLength | 0; + var dataLength_high = (mapped.byteLength / 0x100000000) | 0; + var dataLength_low = mapped.byteLength | 0; // WGPUBufferMapAsyncStatus status, const void* data, uint64_t dataLength, void* userdata - dynCall('viiji', callback, [WEBGPU_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, {{{ sendI64Argument('dataLength_l', 'dataLength_h') }}}, userdata]); + dynCall('viiji', callback, [WEBGPU_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, {{{ sendI64Argument('dataLength_low', 'dataLength_high') }}}, userdata]); }, function() { // TODO(kainino0x): Figure out how to pick other error status values. var WEBGPU_BUFFER_MAP_ASYNC_STATUS_ERROR = 1; @@ -1212,10 +1253,10 @@ var LibraryWebGPU = { WebGPU.trackMapWrite(bufferWrapper, mapped); var data = bufferWrapper.mapWriteSrc; - var dataLength_h = (mapped.byteLength / 0x100000000) | 0; - var dataLength_l = mapped.byteLength | 0; + var dataLength_high = (mapped.byteLength / 0x100000000) | 0; + var dataLength_low = mapped.byteLength | 0; // WGPUBufferMapAsyncStatus status, void* data, uint64_t dataLength, void* userdata - dynCall('viiji', callback, [WEBGPU_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, {{{ sendI64Argument('dataLength_l', 'dataLength_h') }}}, userdata]); + dynCall('viiji', callback, [WEBGPU_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, {{{ sendI64Argument('dataLength_low', 'dataLength_high') }}}, userdata]); }, function() { // TODO(kainino0x): Figure out how to pick other error status values. dynCall('viiji', callback, [WEBGPU_BUFFER_MAP_ASYNC_STATUS_ERROR, 0, 0, 0, userdata]); @@ -1281,7 +1322,7 @@ var LibraryWebGPU = { wgpuComputePassEncoderDispatchIndirect: function(passId, indirectBufferId, {{{ defineI64Param('indirectOffset') }}}) { {{{ receiveI64ParamAsI32s('indirectOffset') }}} var indirectBuffer = WebGPU.mgrBuffer.get(indirectBufferId); - var indirectOffset = {{{ gpu.makeU64ToNumber('indirectOffset_l', 'indirectOffset_h') }}}; + var indirectOffset = {{{ gpu.makeU64ToNumber('indirectOffset_low', 'indirectOffset_high') }}}; var pass = WebGPU.mgrComputePassEncoder.get(passId); pass["dispatchIndirect"](indirectBuffer, indirectOffset); }, @@ -1310,10 +1351,10 @@ var LibraryWebGPU = { var color = WebGPU.makeColor(colorPtr); pass["setBlendColor"](color); }, - wgpuRenderPassEncoderSetIndexBuffer: function(passId, bufferId, offset) { + wgpuRenderPassEncoderSetIndexBuffer: function(passId, bufferId, offset, size) { var pass = WebGPU.mgrRenderPassEncoder.get(passId); var buffer = WebGPU.mgrBuffer.get(bufferId); - pass["setIndexBuffer"](buffer, offset); + pass["setIndexBuffer"](buffer, offset, size); }, wgpuRenderPassEncoderSetPipeline: function(passId, pipelineId) { var pass = WebGPU.mgrRenderPassEncoder.get(passId); @@ -1332,9 +1373,9 @@ var LibraryWebGPU = { var pass = WebGPU.mgrRenderPassEncoder.get(passId); pass["setStencilReference"](reference); }, - wgpuRenderPassEncoderSetVertexBuffer: function(passId, slot, bufferId, offset) { + wgpuRenderPassEncoderSetVertexBuffer: function(passId, slot, bufferId, offset, size) { var pass = WebGPU.mgrRenderPassEncoder.get(passId); - pass["setVertexBuffer"](slot, WebGPU.mgrBuffer.get(bufferId), offset); + pass["setVertexBuffer"](slot, WebGPU.mgrBuffer.get(bufferId), offset, size); }, wgpuRenderPassEncoderDraw: function(passId, vertexCount, instanceCount, firstVertex, firstInstance) { var pass = WebGPU.mgrRenderPassEncoder.get(passId); @@ -1347,14 +1388,14 @@ var LibraryWebGPU = { wgpuRenderPassEncoderDrawIndirect: function(passId, indirectBufferId, {{{ defineI64Param('indirectOffset') }}}) { {{{ receiveI64ParamAsI32s('indirectOffset') }}} var indirectBuffer = WebGPU.mgrBuffer.get(indirectBufferId); - var indirectOffset = {{{ gpu.makeU64ToNumber('indirectOffset_l', 'indirectOffset_h') }}}; + var indirectOffset = {{{ gpu.makeU64ToNumber('indirectOffset_low', 'indirectOffset_high') }}}; var pass = WebGPU.mgrRenderPassEncoder.get(passId); pass["drawIndirect"](indirectBuffer, indirectOffset); }, wgpuRenderPassEncoderDrawIndexedIndirect: function(passId, indirectBufferId, {{{ defineI64Param('indirectOffset') }}}) { {{{ receiveI64ParamAsI32s('indirectOffset') }}} var indirectBuffer = WebGPU.mgrBuffer.get(indirectBufferId); - var indirectOffset = {{{ gpu.makeU64ToNumber('indirectOffset_l', 'indirectOffset_h') }}}; + var indirectOffset = {{{ gpu.makeU64ToNumber('indirectOffset_low', 'indirectOffset_high') }}}; var pass = WebGPU.mgrRenderPassEncoder.get(passId); pass["drawIndexedIndirect"](indirectBuffer, indirectOffset); }, @@ -1391,7 +1432,7 @@ var LibraryWebGPU = { }, wgpuRenderBundleEncoderSetIndexBuffer: function(bundleId, bufferId, {{{ defineI64Param('offset') }}}) { {{{ receiveI64ParamAsI32s('offset') }}} - var offset = {{{ gpu.makeU64ToNumber('offset_l', 'offset_h') }}}; + var offset = {{{ gpu.makeU64ToNumber('offset_low', 'offset_high') }}}; var pass = WebGPU.mgrRenderBundleEncoder.get(bundleId); var buffer = WebGPU.mgrBuffer.get(bufferId); pass["setIndexBuffer"](buffer, offset); @@ -1403,7 +1444,7 @@ var LibraryWebGPU = { }, wgpuRenderBundleEncoderSetVertexBuffer: function(bundleId, slot, bufferId, {{{ defineI64Param('offset') }}}) { {{{ receiveI64ParamAsI32s('offset') }}} - var offset = {{{ gpu.makeU64ToNumber('offset_l', 'offset_h') }}}; + var offset = {{{ gpu.makeU64ToNumber('offset_low', 'offset_high') }}}; var pass = WebGPU.mgrRenderBundleEncoder.get(bundleId); pass["setVertexBuffer"](slot, WebGPU.mgrBuffer.get(bufferId), offset); }, @@ -1475,7 +1516,7 @@ var LibraryWebGPU = { canvas.height = {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.height) }}}; var ctx = canvas.getContext('gpupresent'); - assert({{{ gpu.PresentMode.VSync }}} === + assert({{{ gpu.PresentMode.Fifo }}} === {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.presentMode) }}}); var desc = { diff --git a/src/struct_info.json b/src/struct_info.json index b21c6345c3f8b..d27a74ae2722d 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1655,15 +1655,15 @@ }, // =========================================== // WebGPU - // This is auto-generated: - // https://dawn.googlesource.com/dawn/+/refs/heads/master/generator/templates/api_struct_info.json + // This COULD BE auto-generated: + // https://dawn.googlesource.com/dawn/+/refs/heads/master/generator/templates/webgpu_struct_info.json // =========================================== { "file": "webgpu/webgpu.h", "defines": [], "structs": { "WGPUChainedStruct": [ - "nextInChain", + "next", "sType" ], "WGPUAdapterProperties": [ @@ -1674,7 +1674,7 @@ "adapterType", "backendType" ], - "WGPUBindGroupBinding": [ + "WGPUBindGroupEntry": [ "binding", "buffer", "offset", @@ -1682,14 +1682,15 @@ "sampler", "textureView" ], - "WGPUBindGroupLayoutBinding": [ + "WGPUBindGroupLayoutEntry": [ "binding", "visibility", "type", "hasDynamicOffset", "multisampled", - "textureDimension", - "textureComponentType" + "viewDimension", + "textureComponentType", + "storageTextureFormat" ], "WGPUBlendDescriptor": [ "operation", @@ -1700,8 +1701,8 @@ "nextInChain", "buffer", "offset", - "rowPitch", - "imageHeight" + "bytesPerRow", + "rowsPerImage" ], "WGPUBufferDescriptor": [ "nextInChain", @@ -1732,9 +1733,9 @@ "dataLength", "data" ], - "WGPUDeviceProperties": [ - "textureCompressionBC" - ], + // "WGPUDeviceDescriptor": [ + // "nextInChain" + // ], "WGPUExtent3D": [ "width", "height", @@ -1764,6 +1765,12 @@ "module", "entryPoint" ], + // "WGPUQuerySetDescriptor": [ + // "nextInChain", + // "label", + // "type", + // "count" + // ], "WGPURasterizationStateDescriptor": [ "nextInChain", "frontFace", @@ -1793,6 +1800,10 @@ "stencilStoreOp", "clearStencil" ], + // "WGPURequestAdapterOptions": [ + // "nextInChain", + // "compatibleSurface" + // ], "WGPUSamplerDescriptor": [ "nextInChain", "label", @@ -1808,10 +1819,17 @@ ], "WGPUShaderModuleDescriptor": [ "nextInChain", - "label", + "label" + ], + "WGPUShaderModuleSPIRVDescriptor": [ + "chain", "codeSize", "code" ], + "WGPUShaderModuleWGSLDescriptor": [ + "chain", + "source" + ], "WGPUStencilStateFaceDescriptor": [ "compare", "failOp", @@ -1823,8 +1841,7 @@ "label" ], "WGPUSurfaceDescriptorFromHTMLCanvasId": [ - "nextInChain", - "sType", + "chain", "id" ], "WGPUSwapChainDescriptor": [ @@ -1834,8 +1851,7 @@ "format", "width", "height", - "presentMode", - "implementation" + "presentMode" ], "WGPUTextureViewDescriptor": [ "nextInChain", @@ -1857,14 +1873,14 @@ "nextInChain", "label", "layout", - "bindingCount", - "bindings" + "entryCount", + "entries" ], "WGPUBindGroupLayoutDescriptor": [ "nextInChain", "label", - "bindingCount", - "bindings" + "entryCount", + "entries" ], "WGPUColorStateDescriptor": [ "nextInChain", @@ -1926,6 +1942,7 @@ "colorAttachmentCount", "colorAttachments", "depthStencilAttachment" + // "occlusionQuerySet" ], "WGPUVertexStateDescriptor": [ "nextInChain", diff --git a/system/include/webgpu/webgpu.h b/system/include/webgpu/webgpu.h index aea7a6bb96146..bd6d6e4a0219d 100644 --- a/system/include/webgpu/webgpu.h +++ b/system/include/webgpu/webgpu.h @@ -52,7 +52,7 @@ #include #include -const uint64_t WGPU_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX +#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL) typedef uint32_t WGPUFlags; @@ -110,8 +110,11 @@ typedef enum WGPUBindingType { WGPUBindingType_StorageBuffer = 0x00000001, WGPUBindingType_ReadonlyStorageBuffer = 0x00000002, WGPUBindingType_Sampler = 0x00000003, - WGPUBindingType_SampledTexture = 0x00000004, - WGPUBindingType_StorageTexture = 0x00000005, + WGPUBindingType_ComparisonSampler = 0x00000004, + WGPUBindingType_SampledTexture = 0x00000005, + WGPUBindingType_StorageTexture = 0x00000006, + WGPUBindingType_ReadonlyStorageTexture = 0x00000007, + WGPUBindingType_WriteonlyStorageTexture = 0x00000008, WGPUBindingType_Force32 = 0x7FFFFFFF } WGPUBindingType; @@ -150,14 +153,15 @@ typedef enum WGPUBufferMapAsyncStatus { } WGPUBufferMapAsyncStatus; typedef enum WGPUCompareFunction { - WGPUCompareFunction_Never = 0x00000000, - WGPUCompareFunction_Less = 0x00000001, - WGPUCompareFunction_LessEqual = 0x00000002, - WGPUCompareFunction_Greater = 0x00000003, - WGPUCompareFunction_GreaterEqual = 0x00000004, - WGPUCompareFunction_Equal = 0x00000005, - WGPUCompareFunction_NotEqual = 0x00000006, - WGPUCompareFunction_Always = 0x00000007, + WGPUCompareFunction_Undefined = 0x00000000, + WGPUCompareFunction_Never = 0x00000001, + WGPUCompareFunction_Less = 0x00000002, + WGPUCompareFunction_LessEqual = 0x00000003, + WGPUCompareFunction_Greater = 0x00000004, + WGPUCompareFunction_GreaterEqual = 0x00000005, + WGPUCompareFunction_Equal = 0x00000006, + WGPUCompareFunction_NotEqual = 0x00000007, + WGPUCompareFunction_Always = 0x00000008, WGPUCompareFunction_Force32 = 0x7FFFFFFF } WGPUCompareFunction; @@ -223,8 +227,9 @@ typedef enum WGPULoadOp { } WGPULoadOp; typedef enum WGPUPresentMode { - WGPUPresentMode_NoVSync = 0x00000000, - WGPUPresentMode_VSync = 0x00000001, + WGPUPresentMode_Immediate = 0x00000000, + WGPUPresentMode_Mailbox = 0x00000001, + WGPUPresentMode_Fifo = 0x00000002, WGPUPresentMode_Force32 = 0x7FFFFFFF } WGPUPresentMode; @@ -243,6 +248,8 @@ typedef enum WGPUSType { WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, WGPUSType_SurfaceDescriptorFromXlib = 0x00000003, WGPUSType_SurfaceDescriptorFromHTMLCanvasId = 0x00000004, + WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, + WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType; @@ -436,7 +443,7 @@ typedef WGPUFlags WGPUTextureUsageFlags; typedef struct WGPUChainedStruct { - struct WGPUChainedStruct const * nextInChain; + struct WGPUChainedStruct const * next; WGPUSType sType; } WGPUChainedStruct; @@ -449,24 +456,26 @@ typedef struct WGPUAdapterProperties { WGPUBackendType backendType; } WGPUAdapterProperties; -typedef struct WGPUBindGroupBinding { +typedef struct WGPUBindGroupEntry { uint32_t binding; WGPUBuffer buffer; uint64_t offset; uint64_t size; WGPUSampler sampler; WGPUTextureView textureView; -} WGPUBindGroupBinding; +} WGPUBindGroupEntry; -typedef struct WGPUBindGroupLayoutBinding { +typedef struct WGPUBindGroupLayoutEntry { uint32_t binding; WGPUShaderStageFlags visibility; WGPUBindingType type; bool hasDynamicOffset; bool multisampled; WGPUTextureViewDimension textureDimension; + WGPUTextureViewDimension viewDimension; WGPUTextureComponentType textureComponentType; -} WGPUBindGroupLayoutBinding; + WGPUTextureFormat storageTextureFormat; +} WGPUBindGroupLayoutEntry; typedef struct WGPUBlendDescriptor { WGPUBlendOperation operation; @@ -480,6 +489,8 @@ typedef struct WGPUBufferCopyView { uint64_t offset; uint32_t rowPitch; uint32_t imageHeight; + uint32_t bytesPerRow; + uint32_t rowsPerImage; } WGPUBufferCopyView; typedef struct WGPUBufferDescriptor { @@ -603,6 +614,11 @@ typedef struct WGPUSamplerDescriptor { WGPUCompareFunction compare; } WGPUSamplerDescriptor; +typedef struct WGPUSamplerDescriptorDummyAnisotropicFiltering { + WGPUChainedStruct chain; + float maxAnisotropy; +} WGPUSamplerDescriptorDummyAnisotropicFiltering; + typedef struct WGPUShaderModuleDescriptor { WGPUChainedStruct const * nextInChain; char const * label; @@ -610,6 +626,17 @@ typedef struct WGPUShaderModuleDescriptor { uint32_t const * code; } WGPUShaderModuleDescriptor; +typedef struct WGPUShaderModuleSPIRVDescriptor { + WGPUChainedStruct chain; + uint32_t codeSize; + uint32_t const * code; +} WGPUShaderModuleSPIRVDescriptor; + +typedef struct WGPUShaderModuleWGSLDescriptor { + WGPUChainedStruct chain; + char const * source; +} WGPUShaderModuleWGSLDescriptor; + typedef struct WGPUStencilStateFaceDescriptor { WGPUCompareFunction compare; WGPUStencilOperation failOp; @@ -623,27 +650,23 @@ typedef struct WGPUSurfaceDescriptor { } WGPUSurfaceDescriptor; typedef struct WGPUSurfaceDescriptorFromHTMLCanvasId { - WGPUChainedStruct const * nextInChain; - WGPUSType sType; + WGPUChainedStruct chain; char const * id; } WGPUSurfaceDescriptorFromHTMLCanvasId; typedef struct WGPUSurfaceDescriptorFromMetalLayer { - WGPUChainedStruct const * nextInChain; - WGPUSType sType; + WGPUChainedStruct chain; void * layer; } WGPUSurfaceDescriptorFromMetalLayer; typedef struct WGPUSurfaceDescriptorFromWindowsHWND { - WGPUChainedStruct const * nextInChain; - WGPUSType sType; + WGPUChainedStruct chain; void * hinstance; void * hwnd; } WGPUSurfaceDescriptorFromWindowsHWND; typedef struct WGPUSurfaceDescriptorFromXlib { - WGPUChainedStruct const * nextInChain; - WGPUSType sType; + WGPUChainedStruct chain; void * display; uint32_t window; } WGPUSurfaceDescriptorFromXlib; @@ -682,14 +705,18 @@ typedef struct WGPUBindGroupDescriptor { char const * label; WGPUBindGroupLayout layout; uint32_t bindingCount; - WGPUBindGroupBinding const * bindings; + WGPUBindGroupEntry const * bindings; + uint32_t entryCount; + WGPUBindGroupEntry const * entries; } WGPUBindGroupDescriptor; typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; char const * label; uint32_t bindingCount; - WGPUBindGroupLayoutBinding const * bindings; + WGPUBindGroupLayoutEntry const * bindings; + uint32_t entryCount; + WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor; typedef struct WGPUColorStateDescriptor { @@ -786,18 +813,21 @@ typedef struct WGPURenderPipelineDescriptor { } WGPURenderPipelineDescriptor; +// TODO(dawn:22): Remove this once users use the "Entry" version. +typedef WGPUBindGroupEntry WGPUBindGroupBinding; +typedef WGPUBindGroupLayoutEntry WGPUBindGroupLayoutBinding; + #ifdef __cplusplus extern "C" { #endif -typedef void (*WGPUBufferCreateMappedCallback)(WGPUBufferMapAsyncStatus status, WGPUCreateBufferMappedResult result, void * userdata); typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, void const * data, uint64_t dataLength, void * userdata); typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, void * data, uint64_t dataLength, void * userdata); typedef void (*WGPUDeviceLostCallback)(char const * message, void * userdata); typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata); typedef void (*WGPUFenceOnCompletionCallback)(WGPUFenceCompletionStatus status, void * userdata); -typedef void (*WGPUProc)(); +typedef void (*WGPUProc)(void); #if !defined(WGPU_SKIP_PROCS) @@ -852,7 +882,7 @@ typedef void (*WGPUProcComputePassEncoderReference)(WGPUComputePassEncoder compu typedef void (*WGPUProcComputePassEncoderRelease)(WGPUComputePassEncoder computePassEncoder); // Procs of ComputePipeline -typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t group); +typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t groupIndex); typedef void (*WGPUProcComputePipelineReference)(WGPUComputePipeline computePipeline); typedef void (*WGPUProcComputePipelineRelease)(WGPUComputePipeline computePipeline); @@ -861,17 +891,16 @@ typedef WGPUBindGroup (*WGPUProcDeviceCreateBindGroup)(WGPUDevice device, WGPUBi typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor); typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor); typedef WGPUCreateBufferMappedResult (*WGPUProcDeviceCreateBufferMapped)(WGPUDevice device, WGPUBufferDescriptor const * descriptor); -typedef void (*WGPUProcDeviceCreateBufferMappedAsync)(WGPUDevice device, WGPUBufferDescriptor const * descriptor, WGPUBufferCreateMappedCallback callback, void * userdata); typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor); typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor); typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor); -typedef WGPUQueue (*WGPUProcDeviceCreateQueue)(WGPUDevice device); typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor); typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor); typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPUSamplerDescriptor const * descriptor); typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor); typedef WGPUSwapChain (*WGPUProcDeviceCreateSwapChain)(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor); typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor); +typedef WGPUQueue (*WGPUProcDeviceGetDefaultQueue)(WGPUDevice device); typedef void (*WGPUProcDeviceInjectError)(WGPUDevice device, WGPUErrorType type, char const * message); typedef void (*WGPUProcDeviceLoseForTesting)(WGPUDevice device); typedef bool (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata); @@ -918,9 +947,9 @@ typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEnc typedef void (*WGPUProcRenderBundleEncoderPopDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder); typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); typedef void (*WGPUProcRenderBundleEncoderSetBindGroup)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, uint64_t offset); +typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline); -typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset); +typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); typedef void (*WGPUProcRenderBundleEncoderReference)(WGPURenderBundleEncoder renderBundleEncoder); typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder); @@ -936,17 +965,17 @@ typedef void (*WGPUProcRenderPassEncoderPopDebugGroup)(WGPURenderPassEncoder ren typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); typedef void (*WGPUProcRenderPassEncoderSetBindGroup)(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); typedef void (*WGPUProcRenderPassEncoderSetBlendColor)(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color); -typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, uint64_t offset); +typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); typedef void (*WGPUProcRenderPassEncoderSetPipeline)(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline); typedef void (*WGPUProcRenderPassEncoderSetScissorRect)(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height); typedef void (*WGPUProcRenderPassEncoderSetStencilReference)(WGPURenderPassEncoder renderPassEncoder, uint32_t reference); -typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset); +typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth); typedef void (*WGPUProcRenderPassEncoderReference)(WGPURenderPassEncoder renderPassEncoder); typedef void (*WGPUProcRenderPassEncoderRelease)(WGPURenderPassEncoder renderPassEncoder); // Procs of RenderPipeline -typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t group); +typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t groupIndex); typedef void (*WGPUProcRenderPipelineReference)(WGPURenderPipeline renderPipeline); typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline); @@ -963,6 +992,7 @@ typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface); typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface); // Procs of SwapChain +typedef void (*WGPUProcSwapChainConfigure)(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height); typedef WGPUTextureView (*WGPUProcSwapChainGetCurrentTextureView)(WGPUSwapChain swapChain); typedef void (*WGPUProcSwapChainPresent)(WGPUSwapChain swapChain); typedef void (*WGPUProcSwapChainReference)(WGPUSwapChain swapChain); @@ -1033,7 +1063,7 @@ WGPU_EXPORT void wgpuComputePassEncoderReference(WGPUComputePassEncoder computeP WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder); // Methods of ComputePipeline -WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t group); +WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex); WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline); WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline); @@ -1042,17 +1072,16 @@ WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindG WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor); WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor); WGPU_EXPORT WGPUCreateBufferMappedResult wgpuDeviceCreateBufferMapped(WGPUDevice device, WGPUBufferDescriptor const * descriptor); -WGPU_EXPORT void wgpuDeviceCreateBufferMappedAsync(WGPUDevice device, WGPUBufferDescriptor const * descriptor, WGPUBufferCreateMappedCallback callback, void * userdata); WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor); WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor); WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor); -WGPU_EXPORT WGPUQueue wgpuDeviceCreateQueue(WGPUDevice device); WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor); WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor); WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor); WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor); WGPU_EXPORT WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor); WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor); +WGPU_EXPORT WGPUQueue wgpuDeviceGetDefaultQueue(WGPUDevice device); WGPU_EXPORT void wgpuDeviceInjectError(WGPUDevice device, WGPUErrorType type, char const * message); WGPU_EXPORT void wgpuDeviceLoseForTesting(WGPUDevice device); WGPU_EXPORT bool wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata); @@ -1099,9 +1128,9 @@ WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncode WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder); WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel); WGPU_EXPORT void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); -WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, uint64_t offset); +WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline); -WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset); +WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder); WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder); @@ -1117,17 +1146,17 @@ WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder render WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, uint32_t dynamicOffsetCount, uint32_t const * dynamicOffsets); WGPU_EXPORT void wgpuRenderPassEncoderSetBlendColor(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color); -WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, uint64_t offset); +WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size); WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline); WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height); WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference); -WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset); +WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size); WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth); WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder); WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder); // Methods of RenderPipeline -WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t group); +WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex); WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline); WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline); @@ -1144,6 +1173,7 @@ WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface); WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface); // Methods of SwapChain +WGPU_EXPORT void wgpuSwapChainConfigure(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height); WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain); WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain); WGPU_EXPORT void wgpuSwapChainReference(WGPUSwapChain swapChain);