From dc853f084bc52ed18d9e5e2d37d1b333040f6386 Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Sat, 2 May 2020 20:31:32 +0200 Subject: [PATCH 01/12] Updated WebGPU --- src/library_webgpu.js | 198 ++++++++++++++++++++------------- src/struct_info.json | 72 ++++++++---- system/include/webgpu/webgpu.h | 160 ++++++++++++++++++-------- 3 files changed, 287 insertions(+), 143 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 135eff8b06088..858986aced42c 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -67,11 +67,11 @@ // Assert descriptor is non-null, then that its nextInChain is 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, @@ -147,6 +147,7 @@ var LibraryWebGPU = { {{{ gpu.makeInitManager('RenderBundleEncoder') }}} {{{ gpu.makeInitManager('RenderBundle') }}} + {{{ gpu.makeInitManager('QuerySet') }}} }, trackMapWrite: function(obj, mapped) { @@ -206,8 +207,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) }}}, }; }, @@ -234,8 +235,10 @@ var LibraryWebGPU = { 'storage-buffer', 'readonly-storage-buffer', 'sampler', + 'comparison-sampler', 'sampled-texture', - 'storage-texture', + 'readonly-storage-texture', + 'writeonly-storage-texture', ], BlendFactor: [ 'zero', @@ -266,6 +269,7 @@ var LibraryWebGPU = { 'device-lost', ], CompareFunction: [ + undefined, 'never', 'less', 'less-equal', @@ -319,8 +323,9 @@ var LibraryWebGPU = { 'load', ], PresentMode: [ - 'no-v-sync', - 'v-sync', + 'immediate', + 'mailbox', + 'fifo', ], PrimitiveTopology: [ 'point-list', @@ -329,6 +334,9 @@ var LibraryWebGPU = { 'triangle-list', 'triangle-strip', ], + QueryType: [ + 'occlusion', + ], StencilOperation: [ 'keep', 'zero', @@ -484,6 +492,7 @@ var LibraryWebGPU = { {{{ gpu.makeReferenceRelease('RenderBundleEncoder') }}} {{{ gpu.makeReferenceRelease('RenderBundle') }}} + {{{ gpu.makeReferenceRelease('QuerySet') }}} // *Destroy @@ -492,14 +501,14 @@ var LibraryWebGPU = { // wgpuDevice - // wgpuDeviceCreate* - - wgpuDeviceCreateQueue: function(deviceId) { + wgpuDeviceGetDefaultQueue: 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"]); }, + // wgpuDeviceCreate* + wgpuDeviceCreateCommandEncoder: function(deviceId, descriptor) { var desc; if (descriptor) { @@ -544,12 +553,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', '*') }}} }, @@ -559,7 +568,6 @@ var LibraryWebGPU = { var desc = { "label": undefined, "size": WebGPU.makeExtent3D(descriptor + {{{ C_STRUCTS.WGPUTextureDescriptor.size }}}), - "arrayLayerCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.arrayLayerCount) }}}, "mipLevelCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.mipLevelCount) }}}, "sampleCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.sampleCount) }}}, "dimension": WebGPU.TextureDimension[ @@ -607,40 +615,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 +663,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 +706,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, '*') }}}; @@ -933,6 +943,22 @@ var LibraryWebGPU = { var device = WebGPU["mgrDevice"].get(deviceId); return WebGPU.mgrShaderModule.create(device["createShaderModule"](desc)); }, + + + wgpuDeviceCreateQuerySet: function(deviceId, descriptor) { + {{{ gpu.makeCheckDescriptor('descriptor') }}} + var desc = { + "label": undefined, + "type": WebGPU.QueryType[ + {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.type) }}}], + "count": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.count) }}} + }; + var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.label, '*') }}}; + if (labelPtr) desc["label"] = UTF8ToString(labelPtr); + + var device = WebGPU["mgrDevice"].get(deviceId); + return WebGPU.mgrQuerySet.create(device["createQuerySet"](desc)); + }, #if MINIMAL_RUNTIME wgpuDeviceSetUncapturedErrorCallback__deps: ['$allocateUTF8'], @@ -961,7 +987,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 +1021,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); }, @@ -1125,6 +1151,7 @@ var LibraryWebGPU = { {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.colorAttachments, '*') }}}), "depthStencilAttachment": makeDepthStencilAttachment( {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.depthStencilAttachment, '*') }}}), + "occlusionQuerySet": {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.occlusionQuerySet, '*') }}} }; var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.label, '*') }}}; if (labelPtr) desc["label"] = UTF8ToString(labelPtr); @@ -1145,9 +1172,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) { @@ -1171,14 +1198,25 @@ var LibraryWebGPU = { WebGPU.makeTextureCopyView(srcPtr), WebGPU.makeTextureCopyView(dstPtr), copySize); }, + wgpuCommandEncoderResolveQuerySet: function(encoderId, querySetId, firstQuery, queryCount, dstId, {{{ defineI64Param('dstOffset') }}}) { + {{{ receiveI64ParamAsI32s('dstOffset') }}} + var commandEncoder = WebGPU.mgrCommandEncoder.get(encoderId); + var querySet = WebGPU.mgrQuerySet.get(querySetId); + var buffer = WebGPU.mgrBuffer.get(dstId); + commandEncoder["resolveQuerySet"]( + querySet, firstQuery, queryCount, + buffer, {{{ gpu.makeU64ToNumber('dstOffset_low', 'dstOffset_high') }}} + ); + }, + // wgpuBuffer wgpuBufferSetSubData: function(bufferId, {{{ defineI64Param('start') }}}, {{{ defineI64Param('count') }}}, data) { {{{ 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 +1229,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 +1250,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 +1319,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); }, @@ -1292,6 +1330,16 @@ var LibraryWebGPU = { // wgpuRenderPass + wgpuRenderPassEncoderBeginOcclusionQuery: function(passId, queryIndex) { + var pass = WebGPU.mgrRenderPassEncoder.get(passId); + pass["beginOcclusionQuery"](queryIndex); + }, + + wgpuRenderPassEncoderEndOcclusionQuery: function(passId, queryIndex) { + var pass = WebGPU.mgrRenderPassEncoder.get(passId); + pass["endOcclusionQuery"](queryIndex); + }, + wgpuRenderPassEncoderSetBindGroup: function(passId, groupIndex, groupId, dynamicOffsetCount, dynamicOffsetsPtr) { var pass = WebGPU.mgrRenderPassEncoder.get(passId); var group = WebGPU.mgrBindGroup.get(groupId); @@ -1310,10 +1358,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 +1380,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 +1395,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 +1439,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 +1451,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); }, @@ -1449,7 +1497,7 @@ var LibraryWebGPU = { assert({{{ gpu.SType.SurfaceDescriptorFromHTMLCanvasId }}} === {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}}); #endif - var descriptorFromHTMLCanvasId = nextInChainPtr; + var descriptorFromHTMLCanvasId = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.next) }}}; {{{ gpu.makeCheckDescriptor('descriptorFromHTMLCanvasId') }}} var idPtr = {{{ makeGetValue('descriptorFromHTMLCanvasId', C_STRUCTS.WGPUSurfaceDescriptorFromHTMLCanvasId.id, '*') }}}; @@ -1475,7 +1523,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..56f78c5cf2127 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,8 +1733,8 @@ "dataLength", "data" ], - "WGPUDeviceProperties": [ - "textureCompressionBC" + "WGPUDeviceDescriptor": [ + "nextInChain" ], "WGPUExtent3D": [ "width", @@ -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", @@ -1812,6 +1823,15 @@ "codeSize", "code" ], + "WGPUShaderModuleSPIRVDescriptor": [ + "nextInChain", + "codeSize", + "code" + ], + "WGPUShaderModuleWGSLDescriptor": [ + "nextInChain", + "source" + ], "WGPUStencilStateFaceDescriptor": [ "compare", "failOp", @@ -1824,9 +1844,22 @@ ], "WGPUSurfaceDescriptorFromHTMLCanvasId": [ "nextInChain", - "sType", "id" ], + "WGPUSurfaceDescriptorFromMetalLayer": [ + "nextInChain", + "layer" + ], + "WGPUSurfaceDescriptorFromWindowsHWND": [ + "nextInChain", + "hinstance", + "hwnd" + ], + "WGPUSurfaceDescriptorFromXlib": [ + "nextInChain", + "display", + "window" + ], "WGPUSwapChainDescriptor": [ "nextInChain", "label", @@ -1834,8 +1867,7 @@ "format", "width", "height", - "presentMode", - "implementation" + "presentMode" ], "WGPUTextureViewDescriptor": [ "nextInChain", @@ -1857,14 +1889,14 @@ "nextInChain", "label", "layout", - "bindingCount", - "bindings" + "entryCount", + "entries" ], "WGPUBindGroupLayoutDescriptor": [ "nextInChain", "label", - "bindingCount", - "bindings" + "entryCount", + "entries" ], "WGPUColorStateDescriptor": [ "nextInChain", @@ -1909,7 +1941,6 @@ "usage", "dimension", "size", - "arrayLayerCount", "format", "mipLevelCount", "sampleCount" @@ -1925,7 +1956,8 @@ "label", "colorAttachmentCount", "colorAttachments", - "depthStencilAttachment" + "depthStencilAttachment", + "occlusionQuerySet" ], "WGPUVertexStateDescriptor": [ "nextInChain", diff --git a/system/include/webgpu/webgpu.h b/system/include/webgpu/webgpu.h index aea7a6bb96146..a854f113980e7 100644 --- a/system/include/webgpu/webgpu.h +++ b/system/include/webgpu/webgpu.h @@ -56,6 +56,7 @@ const uint64_t WGPU_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX typedef uint32_t WGPUFlags; +//typedef struct WGPUAdapterImpl* WGPUAdapter; typedef struct WGPUBindGroupImpl* WGPUBindGroup; typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout; typedef struct WGPUBufferImpl* WGPUBuffer; @@ -67,6 +68,7 @@ typedef struct WGPUDeviceImpl* WGPUDevice; typedef struct WGPUFenceImpl* WGPUFence; typedef struct WGPUInstanceImpl* WGPUInstance; typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout; +typedef struct WGPUQuerySetImpl* WGPUQuerySet; typedef struct WGPUQueueImpl* WGPUQueue; typedef struct WGPURenderBundleImpl* WGPURenderBundle; typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder; @@ -110,8 +112,10 @@ 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_ReadonlyStorageTexture = 0x00000006, + WGPUBindingType_WriteonlyStorageTexture = 0x00000007, WGPUBindingType_Force32 = 0x7FFFFFFF } WGPUBindingType; @@ -150,14 +154,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 +228,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; @@ -237,12 +243,19 @@ typedef enum WGPUPrimitiveTopology { WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF } WGPUPrimitiveTopology; +typedef enum WGPUQueryType { + WGPUQueryType_Occlusion = 0x00000000, + WGPUQueryType_Force32 = 0x7FFFFFFF +} WGPUQueryType; + typedef enum WGPUSType { WGPUSType_Invalid = 0x00000000, WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, WGPUSType_SurfaceDescriptorFromXlib = 0x00000003, WGPUSType_SurfaceDescriptorFromHTMLCanvasId = 0x00000004, + WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, + WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType; @@ -398,6 +411,7 @@ typedef enum WGPUBufferUsage { WGPUBufferUsage_Uniform = 0x00000040, WGPUBufferUsage_Storage = 0x00000080, WGPUBufferUsage_Indirect = 0x00000100, + WGPUBufferUsage_QueryResolve = 0x00000200, WGPUBufferUsage_Force32 = 0x7FFFFFFF } WGPUBufferUsage; typedef WGPUFlags WGPUBufferUsageFlags; @@ -429,14 +443,13 @@ typedef enum WGPUTextureUsage { WGPUTextureUsage_Sampled = 0x00000004, WGPUTextureUsage_Storage = 0x00000008, WGPUTextureUsage_OutputAttachment = 0x00000010, - WGPUTextureUsage_Present = 0x00000020, WGPUTextureUsage_Force32 = 0x7FFFFFFF } WGPUTextureUsage; typedef WGPUFlags WGPUTextureUsageFlags; typedef struct WGPUChainedStruct { - struct WGPUChainedStruct const * nextInChain; + struct WGPUChainedStruct const * next; WGPUSType sType; } WGPUChainedStruct; @@ -449,24 +462,25 @@ 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; @@ -478,8 +492,8 @@ typedef struct WGPUBufferCopyView { WGPUChainedStruct const * nextInChain; WGPUBuffer buffer; uint64_t offset; - uint32_t rowPitch; - uint32_t imageHeight; + uint32_t bytesPerRow; + uint32_t rowsPerImage; } WGPUBufferCopyView; typedef struct WGPUBufferDescriptor { @@ -517,9 +531,9 @@ typedef struct WGPUCreateBufferMappedResult { void * data; } WGPUCreateBufferMappedResult; -typedef struct WGPUDeviceProperties { - bool textureCompressionBC; -} WGPUDeviceProperties; +typedef struct WGPUDeviceDescriptor { + WGPUChainedStruct const * nextInChain; +} WGPUDeviceDescriptor; typedef struct WGPUExtent3D { uint32_t width; @@ -556,6 +570,13 @@ typedef struct WGPUProgrammableStageDescriptor { char const * entryPoint; } WGPUProgrammableStageDescriptor; +typedef struct WGPUQuerySetDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUQueryType type; + uint32_t count; +} WGPUQuerySetDescriptor; + typedef struct WGPURasterizationStateDescriptor { WGPUChainedStruct const * nextInChain; WGPUFrontFace frontFace; @@ -589,6 +610,11 @@ typedef struct WGPURenderPassDepthStencilAttachmentDescriptor { uint32_t clearStencil; } WGPURenderPassDepthStencilAttachmentDescriptor; +typedef struct WGPURequestAdapterOptions { + WGPUChainedStruct const * nextInChain; + WGPUSurface compatibleSurface; +} WGPURequestAdapterOptions; + typedef struct WGPUSamplerDescriptor { WGPUChainedStruct const * nextInChain; char const * label; @@ -610,6 +636,17 @@ typedef struct WGPUShaderModuleDescriptor { uint32_t const * code; } WGPUShaderModuleDescriptor; +typedef struct WGPUShaderModuleSPIRVDescriptor { + WGPUChainedStruct const * nextInChain; + uint32_t codeSize; + uint32_t const * code; +} WGPUShaderModuleSPIRVDescriptor; + +typedef struct WGPUShaderModuleWGSLDescriptor { + WGPUChainedStruct const * nextInChain; + char const * source; +} WGPUShaderModuleWGSLDescriptor; + typedef struct WGPUStencilStateFaceDescriptor { WGPUCompareFunction compare; WGPUStencilOperation failOp; @@ -624,26 +661,22 @@ typedef struct WGPUSurfaceDescriptor { typedef struct WGPUSurfaceDescriptorFromHTMLCanvasId { WGPUChainedStruct const * nextInChain; - WGPUSType sType; char const * id; } WGPUSurfaceDescriptorFromHTMLCanvasId; typedef struct WGPUSurfaceDescriptorFromMetalLayer { WGPUChainedStruct const * nextInChain; - WGPUSType sType; void * layer; } WGPUSurfaceDescriptorFromMetalLayer; typedef struct WGPUSurfaceDescriptorFromWindowsHWND { WGPUChainedStruct const * nextInChain; - WGPUSType sType; void * hinstance; void * hwnd; } WGPUSurfaceDescriptorFromWindowsHWND; typedef struct WGPUSurfaceDescriptorFromXlib { WGPUChainedStruct const * nextInChain; - WGPUSType sType; void * display; uint32_t window; } WGPUSurfaceDescriptorFromXlib; @@ -656,7 +689,6 @@ typedef struct WGPUSwapChainDescriptor { uint32_t width; uint32_t height; WGPUPresentMode presentMode; - uint64_t implementation; } WGPUSwapChainDescriptor; typedef struct WGPUTextureViewDescriptor { @@ -681,15 +713,15 @@ typedef struct WGPUBindGroupDescriptor { WGPUChainedStruct const * nextInChain; char const * label; WGPUBindGroupLayout layout; - uint32_t bindingCount; - WGPUBindGroupBinding const * bindings; + uint32_t entryCount; + WGPUBindGroupEntry const * entries; } WGPUBindGroupDescriptor; typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; char const * label; - uint32_t bindingCount; - WGPUBindGroupLayoutBinding const * bindings; + uint32_t entryCount; + WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor; typedef struct WGPUColorStateDescriptor { @@ -740,7 +772,6 @@ typedef struct WGPUTextureDescriptor { WGPUTextureUsageFlags usage; WGPUTextureDimension dimension; WGPUExtent3D size; - uint32_t arrayLayerCount; WGPUTextureFormat format; uint32_t mipLevelCount; uint32_t sampleCount; @@ -759,6 +790,7 @@ typedef struct WGPURenderPassDescriptor { uint32_t colorAttachmentCount; WGPURenderPassColorAttachmentDescriptor const * colorAttachments; WGPURenderPassDepthStencilAttachmentDescriptor const * depthStencilAttachment; + WGPUQuerySet occlusionQuerySet; } WGPURenderPassDescriptor; typedef struct WGPUVertexStateDescriptor { @@ -796,8 +828,11 @@ typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, void 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 (*WGPURequestAdapterCallback)(WGPUAdapter result, void * userdata); +//typedef void (*WGPURequestDeviceCallback)(WGPUDevice result, void * userdata); +//typedef void (*WGPUSurfaceGetPreferredFormatCallback)(WGPUTextureFormat format, void * userdata); -typedef void (*WGPUProc)(); +typedef void (*WGPUProc)(void); #if !defined(WGPU_SKIP_PROCS) @@ -808,6 +843,9 @@ typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procN typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup); typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup); +// Procs of Adapter +//typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter adapter, WGPUAdapterProperties * properties); +//typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata); // Procs of BindGroupLayout typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout); typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout); @@ -836,6 +874,7 @@ typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder com typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * groupLabel); typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder); typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel); +typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder); typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder); @@ -865,13 +904,14 @@ typedef void (*WGPUProcDeviceCreateBufferMappedAsync)(WGPUDevice device, WGPUBuf 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 WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor); 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); @@ -890,9 +930,14 @@ typedef void (*WGPUProcFenceRelease)(WGPUFence fence); // Procs of Instance typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); +//typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance); +//typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata); typedef void (*WGPUProcInstanceReference)(WGPUInstance instance); typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance); +// Procs of QuerySet +typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet); + // Procs of PipelineLayout typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout); typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout); @@ -918,17 +963,19 @@ 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); // Procs of RenderPassEncoder +typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); typedef void (*WGPUProcRenderPassEncoderEndPass)(WGPURenderPassEncoder renderPassEncoder); typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); @@ -936,17 +983,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); @@ -959,6 +1006,7 @@ typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule); typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule); // Procs of Surface +//typedef void (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceGetPreferredFormatCallback callback, void * userdata); typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface); typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface); @@ -985,6 +1033,10 @@ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView); WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor); WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName); +// Methods of Adapter +//WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties); +//WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata); + // Methods of BindGroup WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup); WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup); @@ -1017,6 +1069,7 @@ WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder comman WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * groupLabel); WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder); WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder); WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder); @@ -1033,7 +1086,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); @@ -1046,13 +1099,14 @@ WGPU_EXPORT void wgpuDeviceCreateBufferMappedAsync(WGPUDevice device, WGPUBuffer 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 WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor); 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); @@ -1071,9 +1125,15 @@ WGPU_EXPORT void wgpuFenceRelease(WGPUFence fence); // Methods of Instance WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); +//WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance); +//WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata); WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance); WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance); +// Methods of QuerySet +WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet); +WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet); + // Methods of PipelineLayout WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout); WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout); @@ -1099,17 +1159,19 @@ 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); // Methods of RenderPassEncoder +WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); WGPU_EXPORT void wgpuRenderPassEncoderEndPass(WGPURenderPassEncoder renderPassEncoder); WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); @@ -1117,17 +1179,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); @@ -1142,6 +1204,8 @@ WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule); // Methods of Surface WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface); WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface); +// Methods of Surface +//WGPU_EXPORT void wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceGetPreferredFormatCallback callback, void * userdata); // Methods of SwapChain WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain); From ab22d595750d0f65072e11f97f09eff8af4b58b9 Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Sat, 2 May 2020 21:06:25 +0200 Subject: [PATCH 02/12] Updated AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 5c2b3e0a4375a..f5d17bd3a3134 100644 --- a/AUTHORS +++ b/AUTHORS @@ -469,3 +469,4 @@ a license to everyone to use it as detailed in LICENSE.) * Jānis Rūcis * rssqian * Shachar Langbeheim +* Laurin Agostini From 4aec543a373aa9bbfcf8a9b4fb75bc84d3df7e5f Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Sat, 2 May 2020 20:31:32 +0200 Subject: [PATCH 03/12] Updated WebGPU --- src/library_webgpu.js | 198 ++++++++++++++++++++------------- src/struct_info.json | 72 ++++++++---- system/include/webgpu/webgpu.h | 160 ++++++++++++++++++-------- 3 files changed, 287 insertions(+), 143 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 135eff8b06088..858986aced42c 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -67,11 +67,11 @@ // Assert descriptor is non-null, then that its nextInChain is 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, @@ -147,6 +147,7 @@ var LibraryWebGPU = { {{{ gpu.makeInitManager('RenderBundleEncoder') }}} {{{ gpu.makeInitManager('RenderBundle') }}} + {{{ gpu.makeInitManager('QuerySet') }}} }, trackMapWrite: function(obj, mapped) { @@ -206,8 +207,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) }}}, }; }, @@ -234,8 +235,10 @@ var LibraryWebGPU = { 'storage-buffer', 'readonly-storage-buffer', 'sampler', + 'comparison-sampler', 'sampled-texture', - 'storage-texture', + 'readonly-storage-texture', + 'writeonly-storage-texture', ], BlendFactor: [ 'zero', @@ -266,6 +269,7 @@ var LibraryWebGPU = { 'device-lost', ], CompareFunction: [ + undefined, 'never', 'less', 'less-equal', @@ -319,8 +323,9 @@ var LibraryWebGPU = { 'load', ], PresentMode: [ - 'no-v-sync', - 'v-sync', + 'immediate', + 'mailbox', + 'fifo', ], PrimitiveTopology: [ 'point-list', @@ -329,6 +334,9 @@ var LibraryWebGPU = { 'triangle-list', 'triangle-strip', ], + QueryType: [ + 'occlusion', + ], StencilOperation: [ 'keep', 'zero', @@ -484,6 +492,7 @@ var LibraryWebGPU = { {{{ gpu.makeReferenceRelease('RenderBundleEncoder') }}} {{{ gpu.makeReferenceRelease('RenderBundle') }}} + {{{ gpu.makeReferenceRelease('QuerySet') }}} // *Destroy @@ -492,14 +501,14 @@ var LibraryWebGPU = { // wgpuDevice - // wgpuDeviceCreate* - - wgpuDeviceCreateQueue: function(deviceId) { + wgpuDeviceGetDefaultQueue: 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"]); }, + // wgpuDeviceCreate* + wgpuDeviceCreateCommandEncoder: function(deviceId, descriptor) { var desc; if (descriptor) { @@ -544,12 +553,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', '*') }}} }, @@ -559,7 +568,6 @@ var LibraryWebGPU = { var desc = { "label": undefined, "size": WebGPU.makeExtent3D(descriptor + {{{ C_STRUCTS.WGPUTextureDescriptor.size }}}), - "arrayLayerCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.arrayLayerCount) }}}, "mipLevelCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.mipLevelCount) }}}, "sampleCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.sampleCount) }}}, "dimension": WebGPU.TextureDimension[ @@ -607,40 +615,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 +663,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 +706,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, '*') }}}; @@ -933,6 +943,22 @@ var LibraryWebGPU = { var device = WebGPU["mgrDevice"].get(deviceId); return WebGPU.mgrShaderModule.create(device["createShaderModule"](desc)); }, + + + wgpuDeviceCreateQuerySet: function(deviceId, descriptor) { + {{{ gpu.makeCheckDescriptor('descriptor') }}} + var desc = { + "label": undefined, + "type": WebGPU.QueryType[ + {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.type) }}}], + "count": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.count) }}} + }; + var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.label, '*') }}}; + if (labelPtr) desc["label"] = UTF8ToString(labelPtr); + + var device = WebGPU["mgrDevice"].get(deviceId); + return WebGPU.mgrQuerySet.create(device["createQuerySet"](desc)); + }, #if MINIMAL_RUNTIME wgpuDeviceSetUncapturedErrorCallback__deps: ['$allocateUTF8'], @@ -961,7 +987,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 +1021,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); }, @@ -1125,6 +1151,7 @@ var LibraryWebGPU = { {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.colorAttachments, '*') }}}), "depthStencilAttachment": makeDepthStencilAttachment( {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.depthStencilAttachment, '*') }}}), + "occlusionQuerySet": {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.occlusionQuerySet, '*') }}} }; var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.label, '*') }}}; if (labelPtr) desc["label"] = UTF8ToString(labelPtr); @@ -1145,9 +1172,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) { @@ -1171,14 +1198,25 @@ var LibraryWebGPU = { WebGPU.makeTextureCopyView(srcPtr), WebGPU.makeTextureCopyView(dstPtr), copySize); }, + wgpuCommandEncoderResolveQuerySet: function(encoderId, querySetId, firstQuery, queryCount, dstId, {{{ defineI64Param('dstOffset') }}}) { + {{{ receiveI64ParamAsI32s('dstOffset') }}} + var commandEncoder = WebGPU.mgrCommandEncoder.get(encoderId); + var querySet = WebGPU.mgrQuerySet.get(querySetId); + var buffer = WebGPU.mgrBuffer.get(dstId); + commandEncoder["resolveQuerySet"]( + querySet, firstQuery, queryCount, + buffer, {{{ gpu.makeU64ToNumber('dstOffset_low', 'dstOffset_high') }}} + ); + }, + // wgpuBuffer wgpuBufferSetSubData: function(bufferId, {{{ defineI64Param('start') }}}, {{{ defineI64Param('count') }}}, data) { {{{ 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 +1229,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 +1250,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 +1319,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); }, @@ -1292,6 +1330,16 @@ var LibraryWebGPU = { // wgpuRenderPass + wgpuRenderPassEncoderBeginOcclusionQuery: function(passId, queryIndex) { + var pass = WebGPU.mgrRenderPassEncoder.get(passId); + pass["beginOcclusionQuery"](queryIndex); + }, + + wgpuRenderPassEncoderEndOcclusionQuery: function(passId, queryIndex) { + var pass = WebGPU.mgrRenderPassEncoder.get(passId); + pass["endOcclusionQuery"](queryIndex); + }, + wgpuRenderPassEncoderSetBindGroup: function(passId, groupIndex, groupId, dynamicOffsetCount, dynamicOffsetsPtr) { var pass = WebGPU.mgrRenderPassEncoder.get(passId); var group = WebGPU.mgrBindGroup.get(groupId); @@ -1310,10 +1358,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 +1380,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 +1395,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 +1439,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 +1451,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); }, @@ -1449,7 +1497,7 @@ var LibraryWebGPU = { assert({{{ gpu.SType.SurfaceDescriptorFromHTMLCanvasId }}} === {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}}); #endif - var descriptorFromHTMLCanvasId = nextInChainPtr; + var descriptorFromHTMLCanvasId = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.next) }}}; {{{ gpu.makeCheckDescriptor('descriptorFromHTMLCanvasId') }}} var idPtr = {{{ makeGetValue('descriptorFromHTMLCanvasId', C_STRUCTS.WGPUSurfaceDescriptorFromHTMLCanvasId.id, '*') }}}; @@ -1475,7 +1523,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..56f78c5cf2127 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,8 +1733,8 @@ "dataLength", "data" ], - "WGPUDeviceProperties": [ - "textureCompressionBC" + "WGPUDeviceDescriptor": [ + "nextInChain" ], "WGPUExtent3D": [ "width", @@ -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", @@ -1812,6 +1823,15 @@ "codeSize", "code" ], + "WGPUShaderModuleSPIRVDescriptor": [ + "nextInChain", + "codeSize", + "code" + ], + "WGPUShaderModuleWGSLDescriptor": [ + "nextInChain", + "source" + ], "WGPUStencilStateFaceDescriptor": [ "compare", "failOp", @@ -1824,9 +1844,22 @@ ], "WGPUSurfaceDescriptorFromHTMLCanvasId": [ "nextInChain", - "sType", "id" ], + "WGPUSurfaceDescriptorFromMetalLayer": [ + "nextInChain", + "layer" + ], + "WGPUSurfaceDescriptorFromWindowsHWND": [ + "nextInChain", + "hinstance", + "hwnd" + ], + "WGPUSurfaceDescriptorFromXlib": [ + "nextInChain", + "display", + "window" + ], "WGPUSwapChainDescriptor": [ "nextInChain", "label", @@ -1834,8 +1867,7 @@ "format", "width", "height", - "presentMode", - "implementation" + "presentMode" ], "WGPUTextureViewDescriptor": [ "nextInChain", @@ -1857,14 +1889,14 @@ "nextInChain", "label", "layout", - "bindingCount", - "bindings" + "entryCount", + "entries" ], "WGPUBindGroupLayoutDescriptor": [ "nextInChain", "label", - "bindingCount", - "bindings" + "entryCount", + "entries" ], "WGPUColorStateDescriptor": [ "nextInChain", @@ -1909,7 +1941,6 @@ "usage", "dimension", "size", - "arrayLayerCount", "format", "mipLevelCount", "sampleCount" @@ -1925,7 +1956,8 @@ "label", "colorAttachmentCount", "colorAttachments", - "depthStencilAttachment" + "depthStencilAttachment", + "occlusionQuerySet" ], "WGPUVertexStateDescriptor": [ "nextInChain", diff --git a/system/include/webgpu/webgpu.h b/system/include/webgpu/webgpu.h index aea7a6bb96146..a854f113980e7 100644 --- a/system/include/webgpu/webgpu.h +++ b/system/include/webgpu/webgpu.h @@ -56,6 +56,7 @@ const uint64_t WGPU_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX typedef uint32_t WGPUFlags; +//typedef struct WGPUAdapterImpl* WGPUAdapter; typedef struct WGPUBindGroupImpl* WGPUBindGroup; typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout; typedef struct WGPUBufferImpl* WGPUBuffer; @@ -67,6 +68,7 @@ typedef struct WGPUDeviceImpl* WGPUDevice; typedef struct WGPUFenceImpl* WGPUFence; typedef struct WGPUInstanceImpl* WGPUInstance; typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout; +typedef struct WGPUQuerySetImpl* WGPUQuerySet; typedef struct WGPUQueueImpl* WGPUQueue; typedef struct WGPURenderBundleImpl* WGPURenderBundle; typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder; @@ -110,8 +112,10 @@ 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_ReadonlyStorageTexture = 0x00000006, + WGPUBindingType_WriteonlyStorageTexture = 0x00000007, WGPUBindingType_Force32 = 0x7FFFFFFF } WGPUBindingType; @@ -150,14 +154,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 +228,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; @@ -237,12 +243,19 @@ typedef enum WGPUPrimitiveTopology { WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF } WGPUPrimitiveTopology; +typedef enum WGPUQueryType { + WGPUQueryType_Occlusion = 0x00000000, + WGPUQueryType_Force32 = 0x7FFFFFFF +} WGPUQueryType; + typedef enum WGPUSType { WGPUSType_Invalid = 0x00000000, WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, WGPUSType_SurfaceDescriptorFromXlib = 0x00000003, WGPUSType_SurfaceDescriptorFromHTMLCanvasId = 0x00000004, + WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, + WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType; @@ -398,6 +411,7 @@ typedef enum WGPUBufferUsage { WGPUBufferUsage_Uniform = 0x00000040, WGPUBufferUsage_Storage = 0x00000080, WGPUBufferUsage_Indirect = 0x00000100, + WGPUBufferUsage_QueryResolve = 0x00000200, WGPUBufferUsage_Force32 = 0x7FFFFFFF } WGPUBufferUsage; typedef WGPUFlags WGPUBufferUsageFlags; @@ -429,14 +443,13 @@ typedef enum WGPUTextureUsage { WGPUTextureUsage_Sampled = 0x00000004, WGPUTextureUsage_Storage = 0x00000008, WGPUTextureUsage_OutputAttachment = 0x00000010, - WGPUTextureUsage_Present = 0x00000020, WGPUTextureUsage_Force32 = 0x7FFFFFFF } WGPUTextureUsage; typedef WGPUFlags WGPUTextureUsageFlags; typedef struct WGPUChainedStruct { - struct WGPUChainedStruct const * nextInChain; + struct WGPUChainedStruct const * next; WGPUSType sType; } WGPUChainedStruct; @@ -449,24 +462,25 @@ 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; @@ -478,8 +492,8 @@ typedef struct WGPUBufferCopyView { WGPUChainedStruct const * nextInChain; WGPUBuffer buffer; uint64_t offset; - uint32_t rowPitch; - uint32_t imageHeight; + uint32_t bytesPerRow; + uint32_t rowsPerImage; } WGPUBufferCopyView; typedef struct WGPUBufferDescriptor { @@ -517,9 +531,9 @@ typedef struct WGPUCreateBufferMappedResult { void * data; } WGPUCreateBufferMappedResult; -typedef struct WGPUDeviceProperties { - bool textureCompressionBC; -} WGPUDeviceProperties; +typedef struct WGPUDeviceDescriptor { + WGPUChainedStruct const * nextInChain; +} WGPUDeviceDescriptor; typedef struct WGPUExtent3D { uint32_t width; @@ -556,6 +570,13 @@ typedef struct WGPUProgrammableStageDescriptor { char const * entryPoint; } WGPUProgrammableStageDescriptor; +typedef struct WGPUQuerySetDescriptor { + WGPUChainedStruct const * nextInChain; + char const * label; + WGPUQueryType type; + uint32_t count; +} WGPUQuerySetDescriptor; + typedef struct WGPURasterizationStateDescriptor { WGPUChainedStruct const * nextInChain; WGPUFrontFace frontFace; @@ -589,6 +610,11 @@ typedef struct WGPURenderPassDepthStencilAttachmentDescriptor { uint32_t clearStencil; } WGPURenderPassDepthStencilAttachmentDescriptor; +typedef struct WGPURequestAdapterOptions { + WGPUChainedStruct const * nextInChain; + WGPUSurface compatibleSurface; +} WGPURequestAdapterOptions; + typedef struct WGPUSamplerDescriptor { WGPUChainedStruct const * nextInChain; char const * label; @@ -610,6 +636,17 @@ typedef struct WGPUShaderModuleDescriptor { uint32_t const * code; } WGPUShaderModuleDescriptor; +typedef struct WGPUShaderModuleSPIRVDescriptor { + WGPUChainedStruct const * nextInChain; + uint32_t codeSize; + uint32_t const * code; +} WGPUShaderModuleSPIRVDescriptor; + +typedef struct WGPUShaderModuleWGSLDescriptor { + WGPUChainedStruct const * nextInChain; + char const * source; +} WGPUShaderModuleWGSLDescriptor; + typedef struct WGPUStencilStateFaceDescriptor { WGPUCompareFunction compare; WGPUStencilOperation failOp; @@ -624,26 +661,22 @@ typedef struct WGPUSurfaceDescriptor { typedef struct WGPUSurfaceDescriptorFromHTMLCanvasId { WGPUChainedStruct const * nextInChain; - WGPUSType sType; char const * id; } WGPUSurfaceDescriptorFromHTMLCanvasId; typedef struct WGPUSurfaceDescriptorFromMetalLayer { WGPUChainedStruct const * nextInChain; - WGPUSType sType; void * layer; } WGPUSurfaceDescriptorFromMetalLayer; typedef struct WGPUSurfaceDescriptorFromWindowsHWND { WGPUChainedStruct const * nextInChain; - WGPUSType sType; void * hinstance; void * hwnd; } WGPUSurfaceDescriptorFromWindowsHWND; typedef struct WGPUSurfaceDescriptorFromXlib { WGPUChainedStruct const * nextInChain; - WGPUSType sType; void * display; uint32_t window; } WGPUSurfaceDescriptorFromXlib; @@ -656,7 +689,6 @@ typedef struct WGPUSwapChainDescriptor { uint32_t width; uint32_t height; WGPUPresentMode presentMode; - uint64_t implementation; } WGPUSwapChainDescriptor; typedef struct WGPUTextureViewDescriptor { @@ -681,15 +713,15 @@ typedef struct WGPUBindGroupDescriptor { WGPUChainedStruct const * nextInChain; char const * label; WGPUBindGroupLayout layout; - uint32_t bindingCount; - WGPUBindGroupBinding const * bindings; + uint32_t entryCount; + WGPUBindGroupEntry const * entries; } WGPUBindGroupDescriptor; typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; char const * label; - uint32_t bindingCount; - WGPUBindGroupLayoutBinding const * bindings; + uint32_t entryCount; + WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor; typedef struct WGPUColorStateDescriptor { @@ -740,7 +772,6 @@ typedef struct WGPUTextureDescriptor { WGPUTextureUsageFlags usage; WGPUTextureDimension dimension; WGPUExtent3D size; - uint32_t arrayLayerCount; WGPUTextureFormat format; uint32_t mipLevelCount; uint32_t sampleCount; @@ -759,6 +790,7 @@ typedef struct WGPURenderPassDescriptor { uint32_t colorAttachmentCount; WGPURenderPassColorAttachmentDescriptor const * colorAttachments; WGPURenderPassDepthStencilAttachmentDescriptor const * depthStencilAttachment; + WGPUQuerySet occlusionQuerySet; } WGPURenderPassDescriptor; typedef struct WGPUVertexStateDescriptor { @@ -796,8 +828,11 @@ typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, void 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 (*WGPURequestAdapterCallback)(WGPUAdapter result, void * userdata); +//typedef void (*WGPURequestDeviceCallback)(WGPUDevice result, void * userdata); +//typedef void (*WGPUSurfaceGetPreferredFormatCallback)(WGPUTextureFormat format, void * userdata); -typedef void (*WGPUProc)(); +typedef void (*WGPUProc)(void); #if !defined(WGPU_SKIP_PROCS) @@ -808,6 +843,9 @@ typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procN typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup); typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup); +// Procs of Adapter +//typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter adapter, WGPUAdapterProperties * properties); +//typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata); // Procs of BindGroupLayout typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout); typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout); @@ -836,6 +874,7 @@ typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder com typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * groupLabel); typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder); typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel); +typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder); typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder); @@ -865,13 +904,14 @@ typedef void (*WGPUProcDeviceCreateBufferMappedAsync)(WGPUDevice device, WGPUBuf 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 WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor); 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); @@ -890,9 +930,14 @@ typedef void (*WGPUProcFenceRelease)(WGPUFence fence); // Procs of Instance typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); +//typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance); +//typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata); typedef void (*WGPUProcInstanceReference)(WGPUInstance instance); typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance); +// Procs of QuerySet +typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet); + // Procs of PipelineLayout typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout); typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout); @@ -918,17 +963,19 @@ 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); // Procs of RenderPassEncoder +typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); typedef void (*WGPUProcRenderPassEncoderEndPass)(WGPURenderPassEncoder renderPassEncoder); typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); @@ -936,17 +983,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); @@ -959,6 +1006,7 @@ typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule); typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule); // Procs of Surface +//typedef void (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceGetPreferredFormatCallback callback, void * userdata); typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface); typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface); @@ -985,6 +1033,10 @@ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView); WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor); WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName); +// Methods of Adapter +//WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties); +//WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata); + // Methods of BindGroup WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup); WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup); @@ -1017,6 +1069,7 @@ WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder comman WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * groupLabel); WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder); WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel); +WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder); WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder); @@ -1033,7 +1086,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); @@ -1046,13 +1099,14 @@ WGPU_EXPORT void wgpuDeviceCreateBufferMappedAsync(WGPUDevice device, WGPUBuffer 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 WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor); 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); @@ -1071,9 +1125,15 @@ WGPU_EXPORT void wgpuFenceRelease(WGPUFence fence); // Methods of Instance WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); +//WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance); +//WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata); WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance); WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance); +// Methods of QuerySet +WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet); +WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet); + // Methods of PipelineLayout WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout); WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout); @@ -1099,17 +1159,19 @@ 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); // Methods of RenderPassEncoder +WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); +WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); WGPU_EXPORT void wgpuRenderPassEncoderEndPass(WGPURenderPassEncoder renderPassEncoder); WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); @@ -1117,17 +1179,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); @@ -1142,6 +1204,8 @@ WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule); // Methods of Surface WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface); WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface); +// Methods of Surface +//WGPU_EXPORT void wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceGetPreferredFormatCallback callback, void * userdata); // Methods of SwapChain WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain); From b20b76e54355f30064f3ed5add5a0c2e7ce7a84d Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Sat, 2 May 2020 21:06:25 +0200 Subject: [PATCH 04/12] Updated AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 5c2b3e0a4375a..f5d17bd3a3134 100644 --- a/AUTHORS +++ b/AUTHORS @@ -469,3 +469,4 @@ a license to everyone to use it as detailed in LICENSE.) * Jānis Rūcis * rssqian * Shachar Langbeheim +* Laurin Agostini From 282b4e0e34d81c45008fc03078b7f12490a10472 Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Tue, 5 May 2020 13:24:06 +0200 Subject: [PATCH 05/12] Fixed review issues - Changed 'const * nextInChain' to 'chain' for chained descriptors - Removed unnecessary structs/enums for web - Changed wgpuDeviceGetDefaultQueue so it returns the same queue when called multiple times with the same device - Changed makeCheckDescriptor to also work with 'chain' member (hacky) --- src/library_webgpu.js | 32 ++++++++++++++++++++------------ src/struct_info.json | 20 +++----------------- system/include/webgpu/webgpu.h | 12 ++++++------ 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 858986aced42c..6b0cf41400122 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -65,9 +65,14 @@ }, 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 as a general u32 value. Don't know of a better solution at the moment. var OffsetOfNextInChainMember = 0; - return this.makeCheck(descriptor) + this.makeCheck(makeGetValue(descriptor, OffsetOfNextInChainMember, '*') + ' === 0'); - }, + return this.makeCheck(descriptor) + this.makeCheck(this.makeGetU32(descriptor, OffsetOfNextInChainMember) + ' === 0'); + }, // Must be in sync with webgpu.h. PresentMode: { @@ -75,6 +80,8 @@ }, SType: { SurfaceDescriptorFromHTMLCanvasId: 4, + ShaderModuleSPIRVDescriptor: 5, + ShaderModuleWGSLDescriptor: 6, }, }; return null; @@ -223,6 +230,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: [ @@ -322,11 +334,6 @@ var LibraryWebGPU = { 'clear', 'load', ], - PresentMode: [ - 'immediate', - 'mailbox', - 'fifo', - ], PrimitiveTopology: [ 'point-list', 'line-list', @@ -502,9 +509,11 @@ var LibraryWebGPU = { // wgpuDevice wgpuDeviceGetDefaultQueue: 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"]); + if(WebGPU.mgrQueue.objects.length === 1) { + var device = WebGPU["mgrDevice"].get(deviceId); + WebGPU.defaultQueues[deviceId] = WebGPU.mgrQueue.create(device["defaultQueue"]); + } + return WebGPU.defaultQueues[deviceId]; }, // wgpuDeviceCreate* @@ -943,7 +952,6 @@ var LibraryWebGPU = { var device = WebGPU["mgrDevice"].get(deviceId); return WebGPU.mgrShaderModule.create(device["createShaderModule"](desc)); }, - wgpuDeviceCreateQuerySet: function(deviceId, descriptor) { {{{ gpu.makeCheckDescriptor('descriptor') }}} @@ -953,7 +961,7 @@ var LibraryWebGPU = { {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.type) }}}], "count": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.count) }}} }; - var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.label, '*') }}}; + var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.label, '*') }}}; if (labelPtr) desc["label"] = UTF8ToString(labelPtr); var device = WebGPU["mgrDevice"].get(deviceId); diff --git a/src/struct_info.json b/src/struct_info.json index 56f78c5cf2127..516b7eacf0547 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1824,12 +1824,12 @@ "code" ], "WGPUShaderModuleSPIRVDescriptor": [ - "nextInChain", + "chain", "codeSize", "code" ], "WGPUShaderModuleWGSLDescriptor": [ - "nextInChain", + "chain", "source" ], "WGPUStencilStateFaceDescriptor": [ @@ -1843,23 +1843,9 @@ "label" ], "WGPUSurfaceDescriptorFromHTMLCanvasId": [ - "nextInChain", + "chain", "id" ], - "WGPUSurfaceDescriptorFromMetalLayer": [ - "nextInChain", - "layer" - ], - "WGPUSurfaceDescriptorFromWindowsHWND": [ - "nextInChain", - "hinstance", - "hwnd" - ], - "WGPUSurfaceDescriptorFromXlib": [ - "nextInChain", - "display", - "window" - ], "WGPUSwapChainDescriptor": [ "nextInChain", "label", diff --git a/system/include/webgpu/webgpu.h b/system/include/webgpu/webgpu.h index a854f113980e7..a31d8bbbb3747 100644 --- a/system/include/webgpu/webgpu.h +++ b/system/include/webgpu/webgpu.h @@ -637,13 +637,13 @@ typedef struct WGPUShaderModuleDescriptor { } WGPUShaderModuleDescriptor; typedef struct WGPUShaderModuleSPIRVDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct chain; uint32_t codeSize; uint32_t const * code; } WGPUShaderModuleSPIRVDescriptor; typedef struct WGPUShaderModuleWGSLDescriptor { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct chain; char const * source; } WGPUShaderModuleWGSLDescriptor; @@ -660,23 +660,23 @@ typedef struct WGPUSurfaceDescriptor { } WGPUSurfaceDescriptor; typedef struct WGPUSurfaceDescriptorFromHTMLCanvasId { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct chain; char const * id; } WGPUSurfaceDescriptorFromHTMLCanvasId; typedef struct WGPUSurfaceDescriptorFromMetalLayer { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct chain; void * layer; } WGPUSurfaceDescriptorFromMetalLayer; typedef struct WGPUSurfaceDescriptorFromWindowsHWND { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct chain; void * hinstance; void * hwnd; } WGPUSurfaceDescriptorFromWindowsHWND; typedef struct WGPUSurfaceDescriptorFromXlib { - WGPUChainedStruct const * nextInChain; + WGPUChainedStruct chain; void * display; uint32_t window; } WGPUSurfaceDescriptorFromXlib; From c86cf0eb97d5da217662d218df488d56929ff967 Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Tue, 5 May 2020 18:19:52 +0200 Subject: [PATCH 06/12] Fixed review #2 issues --- src/library_webgpu.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 6b0cf41400122..c24ba296b2b8b 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -69,9 +69,9 @@ // 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 as a general u32 value. Don't know of a better solution at the moment. + // to the descriptor pointer and we can check it to be null. var OffsetOfNextInChainMember = 0; - return this.makeCheck(descriptor) + this.makeCheck(this.makeGetU32(descriptor, OffsetOfNextInChainMember) + ' === 0'); + return this.makeCheck(descriptor) + this.makeCheck(makeGetValue(descriptor, OffsetOfNextInChainMember, '*') + ' === 0'); }, // Must be in sync with webgpu.h. @@ -509,11 +509,19 @@ var LibraryWebGPU = { // wgpuDevice wgpuDeviceGetDefaultQueue: function(deviceId) { - if(WebGPU.mgrQueue.objects.length === 1) { + 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 WebGPU.defaultQueues[deviceId]; + return queueId; }, // wgpuDeviceCreate* From 3f83c6f30bda5ad878f0191355f6c150fefc2fc8 Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Tue, 5 May 2020 19:13:00 +0200 Subject: [PATCH 07/12] Updated shader module creation --- src/library_webgpu.js | 28 ++++++++++++++++++++++++---- system/include/webgpu/webgpu.h | 2 -- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index c24ba296b2b8b..4a2f7ae9caebc 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -947,16 +947,36 @@ 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.WGPUSurfaceDescriptor.nextInChain, '*') }}}; +#if ASSERTIONS + assert(nextInChainPtr !== 0); +#endif + var next = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.next) }}}; + 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('next', C_STRUCTS.WGPUShaderModuleSPIRVDescriptor.codeSize) }}}; + var start = {{{ makeGetValue('next', C_STRUCTS.WGPUShaderModuleSPIRVDescriptor.code, '*') }}}; + desc["code"] = HEAPU32.subarray(start >> 2, (start >> 2) + count); + } + else if(sType === {{{ gpu.SType.ShaderModuleWGSLDescriptor }}}) { + var sourcePtr = {{{ makeGetValue('next', C_STRUCTS.WGPUShaderModuleWGSLDescriptor.source, '*') }}}; + if (sourcePtr) { + desc["code"] = UTF8ToString(sourcePtr); + } + } + var device = WebGPU["mgrDevice"].get(deviceId); return WebGPU.mgrShaderModule.create(device["createShaderModule"](desc)); }, diff --git a/system/include/webgpu/webgpu.h b/system/include/webgpu/webgpu.h index a31d8bbbb3747..be1fb4e62fbe9 100644 --- a/system/include/webgpu/webgpu.h +++ b/system/include/webgpu/webgpu.h @@ -632,8 +632,6 @@ typedef struct WGPUSamplerDescriptor { typedef struct WGPUShaderModuleDescriptor { WGPUChainedStruct const * nextInChain; char const * label; - uint32_t codeSize; - uint32_t const * code; } WGPUShaderModuleDescriptor; typedef struct WGPUShaderModuleSPIRVDescriptor { From 964fa9094926579c0e4a566355c6da0f53c6ebac Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Tue, 5 May 2020 19:20:32 +0200 Subject: [PATCH 08/12] Fixed struct_info.json --- src/struct_info.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/struct_info.json b/src/struct_info.json index 516b7eacf0547..cff2d0a9707ba 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1819,9 +1819,7 @@ ], "WGPUShaderModuleDescriptor": [ "nextInChain", - "label", - "codeSize", - "code" + "label" ], "WGPUShaderModuleSPIRVDescriptor": [ "chain", From 4f975f0c7310ac88e0e3d288bc1ca02c33081503 Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Tue, 5 May 2020 20:37:06 +0200 Subject: [PATCH 09/12] Shader module descriptor chaining --- src/library_webgpu.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 4a2f7ae9caebc..71659c0936004 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -952,7 +952,6 @@ var LibraryWebGPU = { #if ASSERTIONS assert(nextInChainPtr !== 0); #endif - var next = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.next) }}}; var sType = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}}; #if ASSERTIONS assert(sType === {{{ gpu.SType.ShaderModuleSPIRVDescriptor }}} @@ -966,12 +965,12 @@ var LibraryWebGPU = { if (labelPtr) desc["label"] = UTF8ToString(labelPtr); if(sType === {{{ gpu.SType.ShaderModuleSPIRVDescriptor }}}) { - var count = {{{ gpu.makeGetU32('next', C_STRUCTS.WGPUShaderModuleSPIRVDescriptor.codeSize) }}}; - var start = {{{ makeGetValue('next', C_STRUCTS.WGPUShaderModuleSPIRVDescriptor.code, '*') }}}; + 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('next', C_STRUCTS.WGPUShaderModuleWGSLDescriptor.source, '*') }}}; + var sourcePtr = {{{ makeGetValue('nextInChainPtr', C_STRUCTS.WGPUShaderModuleWGSLDescriptor.source, '*') }}}; if (sourcePtr) { desc["code"] = UTF8ToString(sourcePtr); } @@ -1533,7 +1532,7 @@ var LibraryWebGPU = { assert({{{ gpu.SType.SurfaceDescriptorFromHTMLCanvasId }}} === {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}}); #endif - var descriptorFromHTMLCanvasId = {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.next) }}}; + var descriptorFromHTMLCanvasId = nextInChainPtr; {{{ gpu.makeCheckDescriptor('descriptorFromHTMLCanvasId') }}} var idPtr = {{{ makeGetValue('descriptorFromHTMLCanvasId', C_STRUCTS.WGPUSurfaceDescriptorFromHTMLCanvasId.id, '*') }}}; From f041146ded069f2a01a086fc602d67b46b2a811e Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Tue, 5 May 2020 16:30:16 -0700 Subject: [PATCH 10/12] Apply suggestions from code review --- src/library_webgpu.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 71659c0936004..8a229dc8e9341 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -513,12 +513,11 @@ var LibraryWebGPU = { #if ASSERTIONS assert(queueId != 0, 'got invalid queue'); #endif - if(queueId === undefined) { + if (queueId === undefined) { var device = WebGPU["mgrDevice"].get(deviceId); WebGPU.defaultQueues[deviceId] = WebGPU.mgrQueue.create(device["defaultQueue"]); queueId = WebGPU.defaultQueues[deviceId]; - } - else { + } else { WebGPU.mgrQueue.reference(queueId); } return queueId; @@ -964,12 +963,11 @@ var LibraryWebGPU = { var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.label, '*') }}}; if (labelPtr) desc["label"] = UTF8ToString(labelPtr); - if(sType === {{{ gpu.SType.ShaderModuleSPIRVDescriptor }}}) { + 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 }}}) { + } else if (sType === {{{ gpu.SType.ShaderModuleWGSLDescriptor }}}) { var sourcePtr = {{{ makeGetValue('nextInChainPtr', C_STRUCTS.WGPUShaderModuleWGSLDescriptor.source, '*') }}}; if (sourcePtr) { desc["code"] = UTF8ToString(sourcePtr); From d549969c678690a47828396f579a8a7061e09d98 Mon Sep 17 00:00:00 2001 From: Hugo Amiard Date: Sun, 10 May 2020 16:25:12 +0200 Subject: [PATCH 11/12] Adapt to Dawn webgpu.h --- src/library_webgpu.js | 53 ++++------------- src/struct_info.json | 42 +++++++++----- system/include/webgpu/webgpu.h | 103 +++++++++++++-------------------- 3 files changed, 76 insertions(+), 122 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 8a229dc8e9341..d161f23e57c85 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -76,6 +76,8 @@ // Must be in sync with webgpu.h. PresentMode: { + Immediate: 0, + Mailbox: 1, Fifo: 2, }, SType: { @@ -154,7 +156,6 @@ var LibraryWebGPU = { {{{ gpu.makeInitManager('RenderBundleEncoder') }}} {{{ gpu.makeInitManager('RenderBundle') }}} - {{{ gpu.makeInitManager('QuerySet') }}} }, trackMapWrite: function(obj, mapped) { @@ -249,6 +250,7 @@ var LibraryWebGPU = { 'sampler', 'comparison-sampler', 'sampled-texture', + 'storage-texture', 'readonly-storage-texture', 'writeonly-storage-texture', ], @@ -334,6 +336,11 @@ var LibraryWebGPU = { 'clear', 'load', ], + PresentMode: [ + 'immediate', + 'mailbox', + 'fifo', + ], PrimitiveTopology: [ 'point-list', 'line-list', @@ -341,9 +348,6 @@ var LibraryWebGPU = { 'triangle-list', 'triangle-strip', ], - QueryType: [ - 'occlusion', - ], StencilOperation: [ 'keep', 'zero', @@ -499,7 +503,6 @@ var LibraryWebGPU = { {{{ gpu.makeReferenceRelease('RenderBundleEncoder') }}} {{{ gpu.makeReferenceRelease('RenderBundle') }}} - {{{ gpu.makeReferenceRelease('QuerySet') }}} // *Destroy @@ -584,6 +587,7 @@ var LibraryWebGPU = { var desc = { "label": undefined, "size": WebGPU.makeExtent3D(descriptor + {{{ C_STRUCTS.WGPUTextureDescriptor.size }}}), + "arrayLayerCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.arrayLayerCount) }}}, "mipLevelCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.mipLevelCount) }}}, "sampleCount": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUTextureDescriptor.sampleCount) }}}, "dimension": WebGPU.TextureDimension[ @@ -947,7 +951,7 @@ var LibraryWebGPU = { wgpuDeviceCreateShaderModule: function(deviceId, descriptor) { {{{ gpu.makeCheck('descriptor') }}} - var nextInChainPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUSurfaceDescriptor.nextInChain, '*') }}}; + var nextInChainPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.nextInChain, '*') }}}; #if ASSERTIONS assert(nextInChainPtr !== 0); #endif @@ -978,21 +982,6 @@ var LibraryWebGPU = { return WebGPU.mgrShaderModule.create(device["createShaderModule"](desc)); }, - wgpuDeviceCreateQuerySet: function(deviceId, descriptor) { - {{{ gpu.makeCheckDescriptor('descriptor') }}} - var desc = { - "label": undefined, - "type": WebGPU.QueryType[ - {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.type) }}}], - "count": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.count) }}} - }; - var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUQuerySetDescriptor.label, '*') }}}; - if (labelPtr) desc["label"] = UTF8ToString(labelPtr); - - var device = WebGPU["mgrDevice"].get(deviceId); - return WebGPU.mgrQuerySet.create(device["createQuerySet"](desc)); - }, - #if MINIMAL_RUNTIME wgpuDeviceSetUncapturedErrorCallback__deps: ['$allocateUTF8'], #endif @@ -1184,7 +1173,6 @@ var LibraryWebGPU = { {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.colorAttachments, '*') }}}), "depthStencilAttachment": makeDepthStencilAttachment( {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.depthStencilAttachment, '*') }}}), - "occlusionQuerySet": {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.occlusionQuerySet, '*') }}} }; var labelPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPURenderPassDescriptor.label, '*') }}}; if (labelPtr) desc["label"] = UTF8ToString(labelPtr); @@ -1231,17 +1219,6 @@ var LibraryWebGPU = { WebGPU.makeTextureCopyView(srcPtr), WebGPU.makeTextureCopyView(dstPtr), copySize); }, - wgpuCommandEncoderResolveQuerySet: function(encoderId, querySetId, firstQuery, queryCount, dstId, {{{ defineI64Param('dstOffset') }}}) { - {{{ receiveI64ParamAsI32s('dstOffset') }}} - var commandEncoder = WebGPU.mgrCommandEncoder.get(encoderId); - var querySet = WebGPU.mgrQuerySet.get(querySetId); - var buffer = WebGPU.mgrBuffer.get(dstId); - commandEncoder["resolveQuerySet"]( - querySet, firstQuery, queryCount, - buffer, {{{ gpu.makeU64ToNumber('dstOffset_low', 'dstOffset_high') }}} - ); - }, - // wgpuBuffer wgpuBufferSetSubData: function(bufferId, {{{ defineI64Param('start') }}}, {{{ defineI64Param('count') }}}, data) { @@ -1363,16 +1340,6 @@ var LibraryWebGPU = { // wgpuRenderPass - wgpuRenderPassEncoderBeginOcclusionQuery: function(passId, queryIndex) { - var pass = WebGPU.mgrRenderPassEncoder.get(passId); - pass["beginOcclusionQuery"](queryIndex); - }, - - wgpuRenderPassEncoderEndOcclusionQuery: function(passId, queryIndex) { - var pass = WebGPU.mgrRenderPassEncoder.get(passId); - pass["endOcclusionQuery"](queryIndex); - }, - wgpuRenderPassEncoderSetBindGroup: function(passId, groupIndex, groupId, dynamicOffsetCount, dynamicOffsetsPtr) { var pass = WebGPU.mgrRenderPassEncoder.get(passId); var group = WebGPU.mgrBindGroup.get(groupId); diff --git a/src/struct_info.json b/src/struct_info.json index cff2d0a9707ba..15597a2e2a5c3 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1688,6 +1688,7 @@ "type", "hasDynamicOffset", "multisampled", + "textureDimension", "viewDimension", "textureComponentType", "storageTextureFormat" @@ -1701,6 +1702,8 @@ "nextInChain", "buffer", "offset", + "rowPitch", + "imageHeight", "bytesPerRow", "rowsPerImage" ], @@ -1733,9 +1736,9 @@ "dataLength", "data" ], - "WGPUDeviceDescriptor": [ - "nextInChain" - ], + // "WGPUDeviceDescriptor": [ + // "nextInChain" + // ], "WGPUExtent3D": [ "width", "height", @@ -1765,12 +1768,12 @@ "module", "entryPoint" ], - "WGPUQuerySetDescriptor": [ - "nextInChain", - "label", - "type", - "count" - ], + // "WGPUQuerySetDescriptor": [ + // "nextInChain", + // "label", + // "type", + // "count" + // ], "WGPURasterizationStateDescriptor": [ "nextInChain", "frontFace", @@ -1800,10 +1803,10 @@ "stencilStoreOp", "clearStencil" ], - "WGPURequestAdapterOptions": [ - "nextInChain", - "compatibleSurface" - ], + // "WGPURequestAdapterOptions": [ + // "nextInChain", + // "compatibleSurface" + // ], "WGPUSamplerDescriptor": [ "nextInChain", "label", @@ -1819,7 +1822,9 @@ ], "WGPUShaderModuleDescriptor": [ "nextInChain", - "label" + "label", + "codeSize", + "code" ], "WGPUShaderModuleSPIRVDescriptor": [ "chain", @@ -1873,12 +1878,16 @@ "nextInChain", "label", "layout", + "bindingCount", + "bindings", "entryCount", "entries" ], "WGPUBindGroupLayoutDescriptor": [ "nextInChain", "label", + "bindingCount", + "bindings", "entryCount", "entries" ], @@ -1925,6 +1934,7 @@ "usage", "dimension", "size", + "arrayLayerCount", "format", "mipLevelCount", "sampleCount" @@ -1940,8 +1950,8 @@ "label", "colorAttachmentCount", "colorAttachments", - "depthStencilAttachment", - "occlusionQuerySet" + "depthStencilAttachment" + // "occlusionQuerySet" ], "WGPUVertexStateDescriptor": [ "nextInChain", diff --git a/system/include/webgpu/webgpu.h b/system/include/webgpu/webgpu.h index be1fb4e62fbe9..4de662088666d 100644 --- a/system/include/webgpu/webgpu.h +++ b/system/include/webgpu/webgpu.h @@ -52,11 +52,10 @@ #include #include -const uint64_t WGPU_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX +#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL) typedef uint32_t WGPUFlags; -//typedef struct WGPUAdapterImpl* WGPUAdapter; typedef struct WGPUBindGroupImpl* WGPUBindGroup; typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout; typedef struct WGPUBufferImpl* WGPUBuffer; @@ -68,7 +67,6 @@ typedef struct WGPUDeviceImpl* WGPUDevice; typedef struct WGPUFenceImpl* WGPUFence; typedef struct WGPUInstanceImpl* WGPUInstance; typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout; -typedef struct WGPUQuerySetImpl* WGPUQuerySet; typedef struct WGPUQueueImpl* WGPUQueue; typedef struct WGPURenderBundleImpl* WGPURenderBundle; typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder; @@ -114,8 +112,9 @@ typedef enum WGPUBindingType { WGPUBindingType_Sampler = 0x00000003, WGPUBindingType_ComparisonSampler = 0x00000004, WGPUBindingType_SampledTexture = 0x00000005, - WGPUBindingType_ReadonlyStorageTexture = 0x00000006, - WGPUBindingType_WriteonlyStorageTexture = 0x00000007, + WGPUBindingType_StorageTexture = 0x00000006, + WGPUBindingType_ReadonlyStorageTexture = 0x00000007, + WGPUBindingType_WriteonlyStorageTexture = 0x00000008, WGPUBindingType_Force32 = 0x7FFFFFFF } WGPUBindingType; @@ -243,11 +242,6 @@ typedef enum WGPUPrimitiveTopology { WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF } WGPUPrimitiveTopology; -typedef enum WGPUQueryType { - WGPUQueryType_Occlusion = 0x00000000, - WGPUQueryType_Force32 = 0x7FFFFFFF -} WGPUQueryType; - typedef enum WGPUSType { WGPUSType_Invalid = 0x00000000, WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, @@ -256,6 +250,8 @@ typedef enum WGPUSType { WGPUSType_SurfaceDescriptorFromHTMLCanvasId = 0x00000004, WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, + WGPUSType_SamplerDescriptorDummyAnisotropicFiltering = 0x00000007, + WGPUSType_RenderPipelineDescriptorDummyExtension = 0x00000008, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType; @@ -411,7 +407,6 @@ typedef enum WGPUBufferUsage { WGPUBufferUsage_Uniform = 0x00000040, WGPUBufferUsage_Storage = 0x00000080, WGPUBufferUsage_Indirect = 0x00000100, - WGPUBufferUsage_QueryResolve = 0x00000200, WGPUBufferUsage_Force32 = 0x7FFFFFFF } WGPUBufferUsage; typedef WGPUFlags WGPUBufferUsageFlags; @@ -443,6 +438,7 @@ typedef enum WGPUTextureUsage { WGPUTextureUsage_Sampled = 0x00000004, WGPUTextureUsage_Storage = 0x00000008, WGPUTextureUsage_OutputAttachment = 0x00000010, + WGPUTextureUsage_Present = 0x00000020, WGPUTextureUsage_Force32 = 0x7FFFFFFF } WGPUTextureUsage; typedef WGPUFlags WGPUTextureUsageFlags; @@ -477,6 +473,7 @@ typedef struct WGPUBindGroupLayoutEntry { WGPUBindingType type; bool hasDynamicOffset; bool multisampled; + WGPUTextureViewDimension textureDimension; WGPUTextureViewDimension viewDimension; WGPUTextureComponentType textureComponentType; WGPUTextureFormat storageTextureFormat; @@ -492,6 +489,8 @@ typedef struct WGPUBufferCopyView { WGPUChainedStruct const * nextInChain; WGPUBuffer buffer; uint64_t offset; + uint32_t rowPitch; + uint32_t imageHeight; uint32_t bytesPerRow; uint32_t rowsPerImage; } WGPUBufferCopyView; @@ -531,9 +530,9 @@ typedef struct WGPUCreateBufferMappedResult { void * data; } WGPUCreateBufferMappedResult; -typedef struct WGPUDeviceDescriptor { - WGPUChainedStruct const * nextInChain; -} WGPUDeviceDescriptor; +typedef struct WGPUDeviceProperties { + bool textureCompressionBC; +} WGPUDeviceProperties; typedef struct WGPUExtent3D { uint32_t width; @@ -570,13 +569,6 @@ typedef struct WGPUProgrammableStageDescriptor { char const * entryPoint; } WGPUProgrammableStageDescriptor; -typedef struct WGPUQuerySetDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUQueryType type; - uint32_t count; -} WGPUQuerySetDescriptor; - typedef struct WGPURasterizationStateDescriptor { WGPUChainedStruct const * nextInChain; WGPUFrontFace frontFace; @@ -610,11 +602,6 @@ typedef struct WGPURenderPassDepthStencilAttachmentDescriptor { uint32_t clearStencil; } WGPURenderPassDepthStencilAttachmentDescriptor; -typedef struct WGPURequestAdapterOptions { - WGPUChainedStruct const * nextInChain; - WGPUSurface compatibleSurface; -} WGPURequestAdapterOptions; - typedef struct WGPUSamplerDescriptor { WGPUChainedStruct const * nextInChain; char const * label; @@ -629,9 +616,16 @@ typedef struct WGPUSamplerDescriptor { WGPUCompareFunction compare; } WGPUSamplerDescriptor; +typedef struct WGPUSamplerDescriptorDummyAnisotropicFiltering { + WGPUChainedStruct chain; + float maxAnisotropy; +} WGPUSamplerDescriptorDummyAnisotropicFiltering; + typedef struct WGPUShaderModuleDescriptor { WGPUChainedStruct const * nextInChain; char const * label; + uint32_t codeSize; + uint32_t const * code; } WGPUShaderModuleDescriptor; typedef struct WGPUShaderModuleSPIRVDescriptor { @@ -687,6 +681,7 @@ typedef struct WGPUSwapChainDescriptor { uint32_t width; uint32_t height; WGPUPresentMode presentMode; + uint64_t implementation; } WGPUSwapChainDescriptor; typedef struct WGPUTextureViewDescriptor { @@ -711,6 +706,8 @@ typedef struct WGPUBindGroupDescriptor { WGPUChainedStruct const * nextInChain; char const * label; WGPUBindGroupLayout layout; + uint32_t bindingCount; + WGPUBindGroupEntry const * bindings; uint32_t entryCount; WGPUBindGroupEntry const * entries; } WGPUBindGroupDescriptor; @@ -718,6 +715,8 @@ typedef struct WGPUBindGroupDescriptor { typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; char const * label; + uint32_t bindingCount; + WGPUBindGroupLayoutEntry const * bindings; uint32_t entryCount; WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor; @@ -756,6 +755,11 @@ typedef struct WGPURenderPassColorAttachmentDescriptor { WGPUColor clearColor; } WGPURenderPassColorAttachmentDescriptor; +typedef struct WGPURenderPipelineDescriptorDummyExtension { + WGPUChainedStruct chain; + WGPUProgrammableStageDescriptor dummyStage; +} WGPURenderPipelineDescriptorDummyExtension; + typedef struct WGPUTextureCopyView { WGPUChainedStruct const * nextInChain; WGPUTexture texture; @@ -770,6 +774,7 @@ typedef struct WGPUTextureDescriptor { WGPUTextureUsageFlags usage; WGPUTextureDimension dimension; WGPUExtent3D size; + uint32_t arrayLayerCount; WGPUTextureFormat format; uint32_t mipLevelCount; uint32_t sampleCount; @@ -788,7 +793,6 @@ typedef struct WGPURenderPassDescriptor { uint32_t colorAttachmentCount; WGPURenderPassColorAttachmentDescriptor const * colorAttachments; WGPURenderPassDepthStencilAttachmentDescriptor const * depthStencilAttachment; - WGPUQuerySet occlusionQuerySet; } WGPURenderPassDescriptor; typedef struct WGPUVertexStateDescriptor { @@ -816,19 +820,19 @@ 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 (*WGPURequestAdapterCallback)(WGPUAdapter result, void * userdata); -//typedef void (*WGPURequestDeviceCallback)(WGPUDevice result, void * userdata); -//typedef void (*WGPUSurfaceGetPreferredFormatCallback)(WGPUTextureFormat format, void * userdata); typedef void (*WGPUProc)(void); @@ -841,9 +845,6 @@ typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procN typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup); typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup); -// Procs of Adapter -//typedef void (*WGPUProcAdapterGetProperties)(WGPUAdapter adapter, WGPUAdapterProperties * properties); -//typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata); // Procs of BindGroupLayout typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout); typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout); @@ -872,7 +873,6 @@ typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder com typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * groupLabel); typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder); typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel); -typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder); typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder); @@ -889,7 +889,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); @@ -898,11 +898,10 @@ 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 WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor 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); @@ -928,14 +927,9 @@ typedef void (*WGPUProcFenceRelease)(WGPUFence fence); // Procs of Instance typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); -//typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance); -//typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata); typedef void (*WGPUProcInstanceReference)(WGPUInstance instance); typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance); -// Procs of QuerySet -typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet); - // Procs of PipelineLayout typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout); typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout); @@ -968,12 +962,10 @@ typedef void (*WGPUProcRenderBundleEncoderReference)(WGPURenderBundleEncoder ren typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder); // Procs of RenderPassEncoder -typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); typedef void (*WGPUProcRenderPassEncoderEndPass)(WGPURenderPassEncoder renderPassEncoder); typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); @@ -1004,11 +996,11 @@ typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule); typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule); // Procs of Surface -//typedef void (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceGetPreferredFormatCallback callback, void * userdata); 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); @@ -1031,10 +1023,6 @@ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView); WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor); WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName); -// Methods of Adapter -//WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties); -//WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata); - // Methods of BindGroup WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup); WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup); @@ -1067,7 +1055,6 @@ WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder comman WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * groupLabel); WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder); WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel); -WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder); WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder); @@ -1093,11 +1080,10 @@ 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 WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor 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); @@ -1123,15 +1109,9 @@ WGPU_EXPORT void wgpuFenceRelease(WGPUFence fence); // Methods of Instance WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor); -//WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance); -//WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata); WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance); WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance); -// Methods of QuerySet -WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet); -WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet); - // Methods of PipelineLayout WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout); WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout); @@ -1164,12 +1144,10 @@ WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder render WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder); // Methods of RenderPassEncoder -WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); WGPU_EXPORT void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset); -WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex); WGPU_EXPORT void wgpuRenderPassEncoderEndPass(WGPURenderPassEncoder renderPassEncoder); WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, uint32_t bundlesCount, WGPURenderBundle const * bundles); WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel); @@ -1202,10 +1180,9 @@ WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule); // Methods of Surface WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface); WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface); -// Methods of Surface -//WGPU_EXPORT void wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceGetPreferredFormatCallback callback, void * userdata); // 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); From f494f63fe93784f8dce213e2bf53ab55f2490f66 Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Mon, 11 May 2020 14:32:32 -0700 Subject: [PATCH 12/12] Remove some unused and deprecated bits --- src/library_webgpu.js | 9 +-------- src/struct_info.json | 11 +---------- system/include/webgpu/webgpu.h | 9 --------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index d161f23e57c85..153f3eed783d7 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -76,8 +76,6 @@ // Must be in sync with webgpu.h. PresentMode: { - Immediate: 0, - Mailbox: 1, Fifo: 2, }, SType: { @@ -250,7 +248,7 @@ var LibraryWebGPU = { 'sampler', 'comparison-sampler', 'sampled-texture', - 'storage-texture', + undefined, // WGPUBindingType_StorageTexture (deprecated) 'readonly-storage-texture', 'writeonly-storage-texture', ], @@ -336,11 +334,6 @@ var LibraryWebGPU = { 'clear', 'load', ], - PresentMode: [ - 'immediate', - 'mailbox', - 'fifo', - ], PrimitiveTopology: [ 'point-list', 'line-list', diff --git a/src/struct_info.json b/src/struct_info.json index 15597a2e2a5c3..d27a74ae2722d 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1688,7 +1688,6 @@ "type", "hasDynamicOffset", "multisampled", - "textureDimension", "viewDimension", "textureComponentType", "storageTextureFormat" @@ -1702,8 +1701,6 @@ "nextInChain", "buffer", "offset", - "rowPitch", - "imageHeight", "bytesPerRow", "rowsPerImage" ], @@ -1822,9 +1819,7 @@ ], "WGPUShaderModuleDescriptor": [ "nextInChain", - "label", - "codeSize", - "code" + "label" ], "WGPUShaderModuleSPIRVDescriptor": [ "chain", @@ -1878,16 +1873,12 @@ "nextInChain", "label", "layout", - "bindingCount", - "bindings", "entryCount", "entries" ], "WGPUBindGroupLayoutDescriptor": [ "nextInChain", "label", - "bindingCount", - "bindings", "entryCount", "entries" ], diff --git a/system/include/webgpu/webgpu.h b/system/include/webgpu/webgpu.h index 4de662088666d..bd6d6e4a0219d 100644 --- a/system/include/webgpu/webgpu.h +++ b/system/include/webgpu/webgpu.h @@ -250,8 +250,6 @@ typedef enum WGPUSType { WGPUSType_SurfaceDescriptorFromHTMLCanvasId = 0x00000004, WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, - WGPUSType_SamplerDescriptorDummyAnisotropicFiltering = 0x00000007, - WGPUSType_RenderPipelineDescriptorDummyExtension = 0x00000008, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType; @@ -755,11 +753,6 @@ typedef struct WGPURenderPassColorAttachmentDescriptor { WGPUColor clearColor; } WGPURenderPassColorAttachmentDescriptor; -typedef struct WGPURenderPipelineDescriptorDummyExtension { - WGPUChainedStruct chain; - WGPUProgrammableStageDescriptor dummyStage; -} WGPURenderPipelineDescriptorDummyExtension; - typedef struct WGPUTextureCopyView { WGPUChainedStruct const * nextInChain; WGPUTexture texture; @@ -901,7 +894,6 @@ typedef WGPUCreateBufferMappedResult (*WGPUProcDeviceCreateBufferMapped)(WGPUDev 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); @@ -1083,7 +1075,6 @@ WGPU_EXPORT WGPUCreateBufferMappedResult wgpuDeviceCreateBufferMapped(WGPUDevice 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);