@luma.gl/webgpu 9.0.0-alpha.14 → 9.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/helpers/accessor-to-format.js +100 -1
- package/dist/adapter/helpers/convert-texture-format.js +5 -6
- package/dist/adapter/helpers/generate-mipmaps.js +88 -92
- package/dist/adapter/helpers/get-bind-group.js +54 -48
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +97 -84
- package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +181 -129
- package/dist/adapter/resources/webgpu-buffer.js +57 -73
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +47 -63
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +51 -55
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +22 -24
- package/dist/adapter/resources/webgpu-external-texture.js +26 -27
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +89 -103
- package/dist/adapter/resources/webgpu-query.js +42 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +64 -89
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +158 -154
- package/dist/adapter/resources/webgpu-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +16 -22
- package/dist/adapter/resources/webgpu-shader.d.ts +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +47 -58
- package/dist/adapter/resources/webgpu-texture.d.ts +0 -1
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +100 -103
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +77 -90
- package/dist/adapter/webgpu-device.js +215 -242
- package/dist/adapter/webgpu-types.js +0 -2
- package/dist/bundle.js +1 -2
- package/dist/dist.js +8051 -0
- package/dist/dist.min.js +1 -0
- package/dist/es5/adapter/helpers/accessor-to-format.js +2 -0
- package/dist/es5/adapter/helpers/accessor-to-format.js.map +1 -0
- package/dist/es5/adapter/helpers/convert-texture-format.js +13 -0
- package/dist/es5/adapter/helpers/convert-texture-format.js.map +1 -0
- package/dist/es5/adapter/helpers/generate-mipmaps.js +103 -0
- package/dist/es5/adapter/helpers/generate-mipmaps.js.map +1 -0
- package/dist/es5/adapter/helpers/get-bind-group.js +66 -0
- package/dist/es5/adapter/helpers/get-bind-group.js.map +1 -0
- package/dist/es5/adapter/helpers/get-vertex-buffer-layout.js +149 -0
- package/dist/es5/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
- package/dist/es5/adapter/helpers/webgpu-parameters.js +150 -0
- package/dist/es5/adapter/helpers/webgpu-parameters.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-buffer.js +131 -0
- package/dist/es5/adapter/resources/webgpu-buffer.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-command-encoder.js +90 -0
- package/dist/es5/adapter/resources/webgpu-command-encoder.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-compute-pass.js +85 -0
- package/dist/es5/adapter/resources/webgpu-compute-pass.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-compute-pipeline.js +48 -0
- package/dist/es5/adapter/resources/webgpu-compute-pipeline.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-external-texture.js +50 -0
- package/dist/es5/adapter/resources/webgpu-external-texture.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-framebuffer.js +126 -0
- package/dist/es5/adapter/resources/webgpu-framebuffer.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-query.js +2 -0
- package/dist/es5/adapter/resources/webgpu-query.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-render-pass.js +124 -0
- package/dist/es5/adapter/resources/webgpu-render-pass.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-render-pipeline.js +185 -0
- package/dist/es5/adapter/resources/webgpu-render-pipeline.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-sampler.js +45 -0
- package/dist/es5/adapter/resources/webgpu-sampler.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-shader.js +125 -0
- package/dist/es5/adapter/resources/webgpu-shader.js.map +1 -0
- package/dist/es5/adapter/resources/webgpu-texture.js +138 -0
- package/dist/es5/adapter/resources/webgpu-texture.js.map +1 -0
- package/dist/es5/adapter/webgpu-canvas-context.js +111 -0
- package/dist/es5/adapter/webgpu-canvas-context.js.map +1 -0
- package/dist/es5/adapter/webgpu-device.js +317 -0
- package/dist/es5/adapter/webgpu-device.js.map +1 -0
- package/dist/es5/adapter/webgpu-types.js +2 -0
- package/dist/es5/adapter/webgpu-types.js.map +1 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/glsl/glsllang.js +47 -0
- package/dist/es5/glsl/glsllang.js.map +1 -0
- package/dist/es5/index.js +44 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/init.js +7 -0
- package/dist/es5/init.js.map +1 -0
- package/dist/esm/adapter/helpers/accessor-to-format.js +2 -0
- package/dist/esm/adapter/helpers/accessor-to-format.js.map +1 -0
- package/dist/esm/adapter/helpers/convert-texture-format.js +7 -0
- package/dist/esm/adapter/helpers/convert-texture-format.js.map +1 -0
- package/dist/esm/adapter/helpers/generate-mipmaps.js +88 -0
- package/dist/esm/adapter/helpers/generate-mipmaps.js.map +1 -0
- package/dist/esm/adapter/helpers/get-bind-group.js +51 -0
- package/dist/esm/adapter/helpers/get-bind-group.js.map +1 -0
- package/dist/esm/adapter/helpers/get-vertex-buffer-layout.js +83 -0
- package/dist/esm/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
- package/dist/esm/adapter/helpers/webgpu-parameters.js +137 -0
- package/dist/esm/adapter/helpers/webgpu-parameters.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-buffer.js +70 -0
- package/dist/esm/adapter/resources/webgpu-buffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-command-encoder.js +49 -0
- package/dist/esm/adapter/resources/webgpu-command-encoder.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-compute-pass.js +44 -0
- package/dist/esm/adapter/resources/webgpu-compute-pass.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-compute-pipeline.js +23 -0
- package/dist/esm/adapter/resources/webgpu-compute-pipeline.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-external-texture.js +23 -0
- package/dist/esm/adapter/resources/webgpu-external-texture.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-framebuffer.js +93 -0
- package/dist/esm/adapter/resources/webgpu-framebuffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-query.js +2 -0
- package/dist/esm/adapter/resources/webgpu-query.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-render-pass.js +79 -0
- package/dist/esm/adapter/resources/webgpu-render-pass.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-render-pipeline.js +130 -0
- package/dist/esm/adapter/resources/webgpu-render-pipeline.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-sampler.js +20 -0
- package/dist/esm/adapter/resources/webgpu-sampler.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-shader.js +50 -0
- package/dist/esm/adapter/resources/webgpu-shader.js.map +1 -0
- package/dist/esm/adapter/resources/webgpu-texture.js +95 -0
- package/dist/esm/adapter/resources/webgpu-texture.js.map +1 -0
- package/dist/esm/adapter/webgpu-canvas-context.js +74 -0
- package/dist/esm/adapter/webgpu-canvas-context.js.map +1 -0
- package/dist/esm/adapter/webgpu-device.js +196 -0
- package/dist/esm/adapter/webgpu-device.js.map +1 -0
- package/dist/esm/adapter/webgpu-types.js +2 -0
- package/dist/esm/adapter/webgpu-types.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/glsl/glsllang.js +9 -0
- package/dist/esm/glsl/glsllang.js.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/init.js +4 -0
- package/dist/esm/init.js.map +1 -0
- package/dist/glsl/glsllang.js +9 -7
- package/dist/index.js +8 -6
- package/dist/init.js +1 -2
- package/package.json +8 -8
- package/src/adapter/helpers/webgpu-parameters.ts +7 -2
- package/src/adapter/resources/webgpu-command-encoder.ts +2 -1
- package/src/adapter/resources/webgpu-compute-pass.ts +4 -4
- package/src/adapter/resources/webgpu-compute-pipeline.ts +2 -1
- package/src/adapter/resources/webgpu-framebuffer.ts +3 -2
- package/src/adapter/resources/webgpu-render-pass.ts +2 -2
- package/src/adapter/resources/webgpu-render-pipeline.ts +2 -1
- package/src/adapter/resources/webgpu-shader.ts +1 -1
- package/src/adapter/webgpu-canvas-context.ts +3 -2
- package/src/adapter/webgpu-device.ts +2 -2
- package/dist/adapter/helpers/accessor-to-format.js.map +0 -1
- package/dist/adapter/helpers/convert-texture-format.js.map +0 -1
- package/dist/adapter/helpers/generate-mipmaps.js.map +0 -1
- package/dist/adapter/helpers/get-bind-group.js.map +0 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +0 -1
- package/dist/adapter/helpers/webgpu-parameters.js.map +0 -1
- package/dist/adapter/resources/webgpu-buffer.js.map +0 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgpu-compute-pass.js.map +0 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgpu-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgpu-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgpu-query.js.map +0 -1
- package/dist/adapter/resources/webgpu-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgpu-sampler.js.map +0 -1
- package/dist/adapter/resources/webgpu-shader.js.map +0 -1
- package/dist/adapter/resources/webgpu-texture.js.map +0 -1
- package/dist/adapter/webgpu-canvas-context.js.map +0 -1
- package/dist/adapter/webgpu-device.js.map +0 -1
- package/dist/adapter/webgpu-types.js.map +0 -1
- package/dist/bundle.js.map +0 -1
- package/dist/glsl/glsllang.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/init.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-parameters.js","names":["addDepthStencil","descriptor","depthStencil","format","stencilFront","stencilBack","depthWriteEnabled","undefined","depthCompare","PARAMETER_TABLE","cullMode","parameter","value","primitive","frontFace","depthFormat","depthBias","depthBiasSlopeScale","depthBiasClamp","stencilReadMask","stencilWriteMask","stencilCompare","compare","stencilPassOperation","passOp","stencilFailOperation","failOp","stencilDepthFailOperation","depthFailOp","sampleCount","multisample","count","sampleMask","mask","sampleAlphaToCoverageEnabled","alphaToCoverageEnabled","colorMask","targets","addColorState","writeMask","blendColorOperation","DEFAULT_PIPELINE_DESCRIPTOR","topology","vertex","module","entryPoint","fragment","layout","applyParametersToRenderPipelineDescriptor","pipelineDescriptor","parameters","arguments","length","Object","assign","setParameters","key","entries","setterFunction","Error","concat","_descriptor$fragment","_descriptor$fragment2","_descriptor$fragment3","_descriptor$fragment4","_descriptor$fragment5","Array","isArray","_descriptor$fragment$","push"],"sources":["../../../../src/adapter/helpers/webgpu-parameters.ts"],"sourcesContent":["import {Parameters} from '@luma.gl/api';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: undefined!,\n depthCompare: undefined!\n };\n return descriptor.depthStencil;\n}\n\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE: Record<keyof Parameters, Function> = {\n // RASTERIZATION PARAMETERS\n\n cullMode: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n\n frontFace: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n\n // DEPTH\n\n depthWriteEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n\n depthCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n\n depthFormat: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n\n depthBias: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n\n depthBiasSlopeScale: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n\n depthBiasClamp: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n\n // STENCIL\n\n stencilReadMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n\n stencilWriteMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n\n stencilCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.compare = value;\n depthStencil.stencilBack!.compare = value;\n },\n\n stencilPassOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.passOp = value;\n depthStencil.stencilBack!.passOp = value;\n },\n\n stencilFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.failOp = value;\n depthStencil.stencilBack!.failOp = value;\n },\n\n stencilDepthFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.depthFailOp = value;\n depthStencil.stencilBack!.depthFailOp = value;\n },\n\n // MULTISAMPLE\n\n sampleCount: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n\n sampleMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n\n sampleAlphaToCoverageEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n\n // COLOR\n\n colorMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n\n blendColorOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n // const targets = addColorState(descriptor);\n // const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n\n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n\n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n\n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n\n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\n\nconst DEFAULT_PIPELINE_DESCRIPTOR: GPURenderPipelineDescriptor = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n\n vertex: {\n module: undefined!,\n entryPoint: 'main'\n },\n\n fragment: {\n module: undefined!,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n },\n\n layout: 'auto'\n};\n\nexport function applyParametersToRenderPipelineDescriptor(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters = {}\n): void {\n // Apply defaults\n Object.assign(pipelineDescriptor, {...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor});\n setParameters(pipelineDescriptor, parameters);\n}\n\n// Apply any supplied parameters\nfunction setParameters(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters\n): void {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key as keyof Parameters];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\n\nfunction addColorState(descriptor: GPURenderPipelineDescriptor): GPUColorTargetState[] {\n descriptor.fragment!.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets as GPUColorTargetState[];\n}\n"],"mappings":"AAEA,SAASA,eAAeA,CAACC,UAAuC,EAAwB;EACtFA,UAAU,CAACC,YAAY,GAAGD,UAAU,CAACC,YAAY,IAAI;IAEnDC,MAAM,EAAE,aAAa;IACrBC,YAAY,EAAE,CAAC,CAAC;IAChBC,WAAW,EAAE,CAAC,CAAC;IAEfC,iBAAiB,EAAEC,SAAU;IAC7BC,YAAY,EAAED;EAChB,CAAC;EACD,OAAON,UAAU,CAACC,YAAY;AAChC;AAOA,OAAO,MAAMO,eAAmD,GAAG;EAGjEC,QAAQ,EAAEA,CAACC,SAA2B,EAAEC,KAAU,EAAEX,UAAuC,KAAK;IAC9FA,UAAU,CAACY,SAAS,GAAGZ,UAAU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O,EAAAL,qBAAA,GAAC7D,UAAU,CAAC6C,QAAQ,cAAAgB,qBAAA,uBAAnBA,qBAAA,CAAqBzB,OAAO,CAAC,EAAE;IAChD,MAAM,IAAIsB,KAAK,CAAC,YAAY,CAAC;EAC/B;EACA,IAAI,EAAAI,qBAAA,GAAA9D,UAAU,CAAC6C,QAAQ,cAAAiB,qBAAA,wBAAAC,qBAAA,GAAnBD,qBAAA,CAAqB1B,OAAO,cAAA2B,qBAAA,uBAA5BA,qBAAA,CAA8BZ,MAAM,MAAK,CAAC,EAAE;IAAA,IAAAgB,qBAAA;IAC9C,CAAAA,qBAAA,GAAAnE,UAAU,CAAC6C,QAAQ,CAACT,OAAO,cAAA+B,qBAAA,uBAA3BA,qBAAA,CAA6BC,IAAI,CAAC,CAAC,CAAC,CAAC;EACvC;EACA,QAAAJ,qBAAA,GAAOhE,UAAU,CAAC6C,QAAQ,cAAAmB,qBAAA,uBAAnBA,qBAAA,CAAqB5B,OAAO;AACrC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Buffer } from '@luma.gl/api';
|
|
3
|
+
function getByteLength(props) {
|
|
4
|
+
var _props$data;
|
|
5
|
+
return props.byteLength || ((_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.byteLength) || 0;
|
|
6
|
+
}
|
|
7
|
+
export default class WebGPUBuffer extends Buffer {
|
|
8
|
+
constructor(device, props) {
|
|
9
|
+
super(device, props);
|
|
10
|
+
_defineProperty(this, "device", void 0);
|
|
11
|
+
_defineProperty(this, "handle", void 0);
|
|
12
|
+
_defineProperty(this, "byteLength", void 0);
|
|
13
|
+
this.device = device;
|
|
14
|
+
this.byteLength = getByteLength(props);
|
|
15
|
+
const mapBuffer = Boolean(props.data);
|
|
16
|
+
this.handle = this.props.handle || this.device.handle.createBuffer({
|
|
17
|
+
size: this.byteLength,
|
|
18
|
+
usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
19
|
+
mappedAtCreation: this.props.mappedAtCreation || mapBuffer,
|
|
20
|
+
label: this.props.id
|
|
21
|
+
});
|
|
22
|
+
if (props.data) {
|
|
23
|
+
this._writeMapped(props.data);
|
|
24
|
+
}
|
|
25
|
+
if (mapBuffer && !props.mappedAtCreation) {
|
|
26
|
+
this.handle.unmap();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
destroy() {
|
|
30
|
+
this.handle.destroy();
|
|
31
|
+
}
|
|
32
|
+
write(data) {
|
|
33
|
+
let byteOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
34
|
+
this.device.handle.queue.writeBuffer(this.handle, byteOffset, data.buffer, data.byteOffset, data.byteLength);
|
|
35
|
+
}
|
|
36
|
+
async readAsync() {
|
|
37
|
+
let byteOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
38
|
+
let byteLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.byteLength;
|
|
39
|
+
const tempBuffer = new WebGPUBuffer(this.device, {
|
|
40
|
+
usage: Buffer.MAP_READ | Buffer.COPY_DST,
|
|
41
|
+
byteLength
|
|
42
|
+
});
|
|
43
|
+
const commandEncoder = this.device.handle.createCommandEncoder();
|
|
44
|
+
commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);
|
|
45
|
+
this.device.handle.queue.submit([commandEncoder.finish()]);
|
|
46
|
+
await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);
|
|
47
|
+
const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);
|
|
48
|
+
tempBuffer.handle.unmap();
|
|
49
|
+
tempBuffer.destroy();
|
|
50
|
+
return arrayBuffer;
|
|
51
|
+
}
|
|
52
|
+
_writeMapped(typedArray) {
|
|
53
|
+
const arrayBuffer = this.handle.getMappedRange();
|
|
54
|
+
new typedArray.constructor(arrayBuffer).set(typedArray);
|
|
55
|
+
}
|
|
56
|
+
mapAsync(mode) {
|
|
57
|
+
let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
58
|
+
let size = arguments.length > 2 ? arguments[2] : undefined;
|
|
59
|
+
return this.handle.mapAsync(mode, offset, size);
|
|
60
|
+
}
|
|
61
|
+
getMappedRange() {
|
|
62
|
+
let offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
63
|
+
let size = arguments.length > 1 ? arguments[1] : undefined;
|
|
64
|
+
return this.handle.getMappedRange(offset, size);
|
|
65
|
+
}
|
|
66
|
+
unmap() {
|
|
67
|
+
this.handle.unmap();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=webgpu-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-buffer.js","names":["Buffer","getByteLength","props","_props$data","byteLength","data","WebGPUBuffer","constructor","device","_defineProperty","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","arguments","length","undefined","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"sources":["../../../../src/adapter/resources/webgpu-buffer.ts"],"sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport default class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n this.handle = this.props.handle || this.device.handle.createBuffer({\n size: this.byteLength,\n // usage defaults to vertex\n usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n override write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n override async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<ArrayBuffer> {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});\n\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n\n return arrayBuffer;\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"mappings":";AACA,SAAQA,MAAM,QAAoB,cAAc;AAGhD,SAASC,aAAaA,CAACC,KAAkB,EAAU;EAAA,IAAAC,WAAA;EACjD,OAAOD,KAAK,CAACE,UAAU,MAAAD,WAAA,GAAID,KAAK,CAACG,IAAI,cAAAF,WAAA,uBAAVA,WAAA,CAAYC,UAAU,KAAI,CAAC;AACxD;AAEA,eAAe,MAAME,YAAY,SAASN,MAAM,CAAC;EAK/CO,WAAWA,CAACC,MAAoB,EAAEN,KAAkB,EAAE;IACpD,KAAK,CAACM,MAAM,EAAEN,KAAK,CAAC;IAACO,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACD,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACJ,UAAU,GAAGH,aAAa,CAACC,KAAK,CAAC;IACtC,MAAMQ,SAAS,GAAGC,OAAO,CAACT,KAAK,CAACG,IAAI,CAAC;IAErC,IAAI,CAACO,MAAM,GAAG,IAAI,CAACV,KAAK,CAACU,MAAM,IAAI,IAAI,CAACJ,MAAM,CAACI,MAAM,CAACC,YAAY,CAAC;MACjEC,IAAI,EAAE,IAAI,CAACV,UAAU;MAErBW,KAAK,EAAE,IAAI,CAACb,KAAK,CAACa,KAAK,IAAKC,cAAc,CAACC,MAAM,GAAGD,cAAc,CAACE,QAAS;MAC5EC,gBAAgB,EAAE,IAAI,CAACjB,KAAK,CAACiB,gBAAgB,IAAIT,SAAS;MAC1DU,KAAK,EAAE,IAAI,CAAClB,KAAK,CAACmB;IACpB,CAAC,CAAC;IAEF,IAAInB,KAAK,CAACG,IAAI,EAAE;MACd,IAAI,CAACiB,YAAY,CAACpB,KAAK,CAACG,IAAI,CAAC;IAE/B;IAEA,IAAIK,SAAS,IAAI,CAACR,KAAK,CAACiB,gBAAgB,EAAE;MACxC,IAAI,CAACP,MAAM,CAACW,KAAK,EAAE;IACrB;EACF;EAESC,OAA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E,MAAMwC,WAAW,GAAGV,UAAU,CAACtB,MAAM,CAACiC,cAAc,EAAE,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/DZ,UAAU,CAACtB,MAAM,CAACW,KAAK,EAAE;IACzBW,UAAU,CAACV,OAAO,EAAE;IAEpB,OAAOoB,WAAW;EACpB;EAEAtB,YAAYA,CAAayB,UAAsB,EAAQ;IACrD,MAAMH,WAAW,GAAG,IAAI,CAAChC,MAAM,CAACiC,cAAc,EAAE;IAEhD,IAAIE,UAAU,CAACxC,WAAW,CAACqC,WAAW,CAAC,CAACI,GAAG,CAACD,UAAU,CAAC;EACzD;EAIAN,QAAQA,CAACQ,IAAY,EAAoD;IAAA,IAAlDC,MAAc,GAAAvB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEb,IAAa,GAAAa,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IACtD,OAAO,IAAI,CAACjB,MAAM,CAAC6B,QAAQ,CAACQ,IAAI,EAAEC,MAAM,EAAEpC,IAAI,CAAC;EACjD;EAEA+B,cAAcA,CAAA,EAAiD;IAAA,IAAhDK,MAAc,GAAAvB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEb,IAAa,GAAAa,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAC9C,OAAO,IAAI,CAACjB,MAAM,CAACiC,cAAc,CAACK,MAAM,EAAEpC,IAAI,CAAC;EACjD;EAEAS,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACX,MAAM,CAACW,KAAK,EAAE;EACrB;AACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { CommandEncoder, cast } from '@luma.gl/api';
|
|
3
|
+
export default class WebGPUCommandEncoder extends CommandEncoder {
|
|
4
|
+
constructor(device, props) {
|
|
5
|
+
super(props);
|
|
6
|
+
_defineProperty(this, "device", void 0);
|
|
7
|
+
_defineProperty(this, "handle", void 0);
|
|
8
|
+
this.device = device;
|
|
9
|
+
this.handle = props.handle || this.device.handle.createCommandEncoder({});
|
|
10
|
+
this.handle.label = this.props.id;
|
|
11
|
+
}
|
|
12
|
+
destroy() {}
|
|
13
|
+
finish(options) {
|
|
14
|
+
return this.finish(options);
|
|
15
|
+
}
|
|
16
|
+
copyBufferToBuffer(options) {
|
|
17
|
+
var _options$sourceOffset, _options$destinationO, _options$size;
|
|
18
|
+
this.handle.copyBufferToBuffer(cast(options.source).handle, (_options$sourceOffset = options.sourceOffset) !== null && _options$sourceOffset !== void 0 ? _options$sourceOffset : 0, cast(options.destination).handle, (_options$destinationO = options.destinationOffset) !== null && _options$destinationO !== void 0 ? _options$destinationO : 0, (_options$size = options.size) !== null && _options$size !== void 0 ? _options$size : 0);
|
|
19
|
+
}
|
|
20
|
+
copyBufferToTexture(options) {
|
|
21
|
+
var _options$offset, _options$mipLevel, _options$origin;
|
|
22
|
+
this.handle.copyBufferToTexture({
|
|
23
|
+
buffer: cast(options.source).handle,
|
|
24
|
+
offset: (_options$offset = options.offset) !== null && _options$offset !== void 0 ? _options$offset : 0,
|
|
25
|
+
bytesPerRow: options.bytesPerRow,
|
|
26
|
+
rowsPerImage: options.rowsPerImage
|
|
27
|
+
}, {
|
|
28
|
+
texture: cast(options.destination).handle,
|
|
29
|
+
mipLevel: (_options$mipLevel = options.mipLevel) !== null && _options$mipLevel !== void 0 ? _options$mipLevel : 0,
|
|
30
|
+
origin: (_options$origin = options.origin) !== null && _options$origin !== void 0 ? _options$origin : {}
|
|
31
|
+
}, {
|
|
32
|
+
width: options.extent[0],
|
|
33
|
+
height: options.extent[1],
|
|
34
|
+
depthOrArrayLayers: options.extent[2]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
copyTextureToBuffer(options) {}
|
|
38
|
+
copyTextureToTexture(options) {}
|
|
39
|
+
pushDebugGroup(groupLabel) {
|
|
40
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
41
|
+
}
|
|
42
|
+
popDebugGroup() {
|
|
43
|
+
this.handle.popDebugGroup();
|
|
44
|
+
}
|
|
45
|
+
insertDebugMarker(markerLabel) {
|
|
46
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=webgpu-command-encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","_defineProperty","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../../src/adapter/resources/webgpu-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WEBGPUBuffer from './webgpu-buffer';\nimport WebGPUTexture from './webgpu-texture';\n\nexport default class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = props.handle || this.device.handle.createCommandEncoder({\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }): void {\n this.handle.copyBufferToBuffer(\n cast<WEBGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WEBGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WEBGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n {\n // TODO exclamation mark hack\n width: options.extent![0],\n height: options.extent![1],\n depthOrArrayLayers: options.extent![2]\n }\n );\n }\n\n copyTextureToBuffer(options: {\n source: GPUImageCopyTexture,\n destination: GPUImageCopyBuffer,\n copySize: GPUExtent3D\n }): void {}\n\n copyTextureToTexture(options: {\n source: GPUImageCopyTexture ,\n destination: GPUImageCopyTexture,\n copySize: GPUExtent3D\n }): void {}\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"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O,CAACK,MAAM,CAAC,CAACX,MAAM;MACjDqB,MAAM,GAAAJ,eAAA,GAAEX,OAAO,CAACe,MAAM,cAAAJ,eAAA,cAAAA,eAAA,GAAI,CAAC;MAC3BK,WAAW,EAAEhB,OAAO,CAACgB,WAAW;MAChCC,YAAY,EAAEjB,OAAO,CAACiB;IACxB,CAAC,EACD;MACEC,OAAO,EAAE9B,IAAI,CAAgBY,OAAO,CAACO,WAAW,CAAC,CAACb,MAAM;MACxDyB,QAAQ,GAAAP,iBAAA,GAAEZ,OAAO,CAACmB,QAAQ,cAAAP,iBAAA,cAAAA,iBAAA,GAAI,CAAC;MAC/BQ,MAAM,GAAAP,eAAA,GAAEb,OAAO,CAACoB,MAAM,cAAAP,eAAA,cAAAA,eAAA,GAAI,CAAC;IAE7B,CAAC,EACD;MAEEQ,KAAK,EAAErB,OAAO,CAACsB,MAAM,CAAE,CAAC,CAAC;MACzBC,MAAM,EAAEvB,OAAO,CAACsB,MAAM,CAAE,CAAC,CAAC;MAC1BE,kBAAkB,EAAExB,OAAO,CAACsB,MAAM,CAAE,CAAC;IACvC,CAAC,CACF;EACH;EAEAG,mBAAmBA,CAACzB,OAInB,EAAQ,CAAC;EAEV0B,oBAAoBA,CAAC1B,OAIpB,EAAQ,CAAC;EAED2B,cAAcA,CAACC,UAAkB,EAAQ;IAChD,IAAI,CAAClC,MAAM,CAACiC,cAAc,CAACC,UAAU,CAAC;EACxC;EAESC,aAAaA,CAAA,EAAS;IAC7B,IAAI,CAACnC,MAAM,CAACmC,aAAa,EAAE;EAC7B;EAESC,iBAAiBA,CAACC,WAAmB,EAAQ;IACpD,IAAI,CAACrC,MAAM,CAACoC,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AAWF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { ComputePass, cast } from '@luma.gl/api';
|
|
3
|
+
export default class WebGPUComputePass extends ComputePass {
|
|
4
|
+
constructor(device, props) {
|
|
5
|
+
var _device$commandEncode;
|
|
6
|
+
super(device, props);
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
_defineProperty(this, "handle", void 0);
|
|
9
|
+
_defineProperty(this, "_bindGroupLayout", null);
|
|
10
|
+
this.device = device;
|
|
11
|
+
this.handle = this.props.handle || ((_device$commandEncode = device.commandEncoder) === null || _device$commandEncode === void 0 ? void 0 : _device$commandEncode.beginComputePass({
|
|
12
|
+
label: this.props.id
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
destroy() {}
|
|
16
|
+
end() {
|
|
17
|
+
this.handle.end();
|
|
18
|
+
}
|
|
19
|
+
setPipeline(pipeline) {
|
|
20
|
+
const wgpuPipeline = cast(pipeline);
|
|
21
|
+
this.handle.setPipeline(wgpuPipeline.handle);
|
|
22
|
+
this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
|
|
23
|
+
}
|
|
24
|
+
setBindings(bindings) {
|
|
25
|
+
throw new Error('fix me');
|
|
26
|
+
}
|
|
27
|
+
dispatch(x, y, z) {
|
|
28
|
+
this.handle.dispatchWorkgroups(x, y, z);
|
|
29
|
+
}
|
|
30
|
+
dispatchIndirect(indirectBuffer) {
|
|
31
|
+
let indirectOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
32
|
+
this.handle.dispatchWorkgroupsIndirect(cast(indirectBuffer).handle, indirectOffset);
|
|
33
|
+
}
|
|
34
|
+
pushDebugGroup(groupLabel) {
|
|
35
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
36
|
+
}
|
|
37
|
+
popDebugGroup() {
|
|
38
|
+
this.handle.popDebugGroup();
|
|
39
|
+
}
|
|
40
|
+
insertDebugMarker(markerLabel) {
|
|
41
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=webgpu-compute-pass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pass.js","names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","_device$commandEncode","_defineProperty","handle","commandEncoder","beginComputePass","label","id","destroy","end","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchWorkgroups","dispatchIndirect","indirectBuffer","indirectOffset","arguments","length","undefined","dispatchWorkgroupsIndirect","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../../src/adapter/resources/webgpu-compute-pass.ts"],"sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPUComputePipeline from './webgpu-compute-pipeline';\n\nexport default class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout | null = null;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n this.handle = this.props.handle || device.commandEncoder?.beginComputePass({\n label: this.props.id,\n // timestampWrites?: GPUComputePassTimestampWrites;\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);\n this.handle.setPipeline(wgpuPipeline.handle);\n this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Binding[]): void {\n throw new Error('fix me');\n // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);\n // this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of workgroups to dispatch.\n * @param y Y dimension of the grid of workgroups to dispatch.\n * @param z Z dimension of the grid of workgroups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatchWorkgroups(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectOffset\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {\n this.handle.dispatchWorkgroupsIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n}\n"],"mappings":";AAAA,SAAQA,WAAW,EAAsDC,IAAI,QAAO,cAAc;AAMlG,eAAe,MAAMC,iBAAiB,SAASF,WAAW,CAAC;EAKzDG,WAAWA,CAACC,MAAoB,EAAEC,KAAuB,EAAE;IAAA,IAAAC,qBAAA;IACzD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACE,eAAA;IAAAA,eAAA;IAAAA,eAAA,2BAHuB,IAAI;IAIhD,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACI,MAAM,GAAG,IAAI,CAACH,KAAK,CAACG,MAAM,MAAAF,qBAAA,GAAIF,MAAM,CAACK,cAAc,cAAAH,qBAAA,uBAArBA,qBAAA,CAAuBI,gBAAgB,CAAC;MACzEC,KAAK,EAAE,IAAI,CAACN,KAAK,CAACO;IAEpB,CAAC,CAAC;EACJ;EAGSC,OAAOA,CAAA,EAAS,CAAC;EAE1BC,GAAGA,CAAA,EAAS;IACV,IAAI,CAACN,MAAM,CAACM,GAAG,EAAE;EACnB;EAEAC,WAAWA,CAACC,QAAyB,EAAQ;IAC3C,MAAMC,YAAY,GAAGhB,IAAI,CAAwBe,QAAQ,CAAC;IAC1D,IAAI,CAACR,MAAM,CAACO,WAAW,CAACE,YAAY,CAACT,MAAM,CAAC;IAC5C,IAAI,CAACU,gBAAgB,GAAGD,YAAY,CAACE,mBAAmB,EAAE;EAC5D;EAGAC,WAAWA,CAACC,QAAmB,EAAQ;IACrC,MAAM,IAAIC,KAAK,CAAC,QAAQ,CAAC;EAG3B;EAQAC,QAAQA,CAACC,CAAS,EAAEC,CAAU,EAAEC,CAAU,EAAQ;IAChD,IAAI,CAAClB,MAAM,CAACmB,kBAAkB,CAACH,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC;EACzC;EAOAE,gBAAgBA,CAACC,cAAsB,EAAoC;IAAA,IAAlCC,cAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IACjE,IAAI,CAACvB,MAAM,CAAC0B,0BAA0B,CAACjC,IAAI,CAAe4B,cAAc,CAAC,CAACrB,MAAM,EAAEsB,cAAc,CAAC;EACnG;EAEAK,cAAcA,CAACC,UAAkB,EAAQ;IACvC,IAAI,CAAC5B,MAAM,CAAC2B,cAAc,CAACC,UAAU,CAAC;EACxC;EACAC,aAAaA,CAAA,EAAS;IACpB,IAAI,CAAC7B,MAAM,CAAC6B,aAAa,EAAE;EAC7B;EACAC,iBAAiBA,CAACC,WAAmB,EAAQ;IAC3C,IAAI,CAAC/B,MAAM,CAAC8B,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AAKF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { ComputePipeline, cast } from '@luma.gl/api';
|
|
3
|
+
export default class WebGPUComputePipeline extends ComputePipeline {
|
|
4
|
+
constructor(device, props) {
|
|
5
|
+
super(device, props);
|
|
6
|
+
_defineProperty(this, "device", void 0);
|
|
7
|
+
_defineProperty(this, "handle", void 0);
|
|
8
|
+
this.device = device;
|
|
9
|
+
const module = cast(this.props.cs).handle;
|
|
10
|
+
this.handle = this.props.handle || this.device.handle.createComputePipeline({
|
|
11
|
+
label: this.props.id,
|
|
12
|
+
compute: {
|
|
13
|
+
module,
|
|
14
|
+
entryPoint: this.props.csEntryPoint
|
|
15
|
+
},
|
|
16
|
+
layout: 'auto'
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
_getBindGroupLayout() {
|
|
20
|
+
return this.handle.getBindGroupLayout(0);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=webgpu-compute-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pipeline.js","names":["ComputePipeline","cast","WebGPUComputePipeline","constructor","device","props","_defineProperty","module","cs","handle","createComputePipeline","label","id","compute","entryPoint","csEntryPoint","layout","_getBindGroupLayout","getBindGroupLayout"],"sources":["../../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"sourcesContent":["// prettier-ignore\nimport {ComputePipeline, ComputePipelineProps, cast} from '@luma.gl/api';\n\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUShader from './webgpu-shader';\n\n// COMPUTE PIPELINE\n\n/** Creates a new compute pipeline when parameters change */\nexport default class WebGPUComputePipeline extends ComputePipeline {\n device: WebGPUDevice;\n handle: GPUComputePipeline;\n\n constructor(device: WebGPUDevice, props: ComputePipelineProps) {\n super(device, props);\n this.device = device;\n\n const module = cast<WebGPUShader>(this.props.cs).handle;\n this.handle = this.props.handle || this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module,\n entryPoint: this.props.csEntryPoint,\n // constants: this.props.csConstants\n },\n layout: 'auto'\n });\n }\n\n /** For internal use in render passes */\n _getBindGroupLayout() {\n // TODO: Cache?\n return this.handle.getBindGroupLayout(0);\n }\n}\n"],"mappings":";AACA,SAAQA,eAAe,EAAwBC,IAAI,QAAO,cAAc;AAQxE,eAAe,MAAMC,qBAAqB,SAASF,eAAe,CAAC;EAIjEG,WAAWA,CAACC,MAAoB,EAAEC,KAA2B,EAAE;IAC7D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,MAAMG,MAAM,GAAGN,IAAI,CAAe,IAAI,CAACI,KAAK,CAACG,EAAE,CAAC,CAACC,MAAM;IACvD,IAAI,CAACA,MAAM,GAAG,IAAI,CAACJ,KAAK,CAACI,MAAM,IAAI,IAAI,CAACL,MAAM,CAACK,MAAM,CAACC,qBAAqB,CAAC;MAC1EC,KAAK,EAAE,IAAI,CAACN,KAAK,CAACO,EAAE;MACpBC,OAAO,EAAE;QACPN,MAAM;QACNO,UAAU,EAAE,IAAI,CAACT,KAAK,CAACU;MAEzB,CAAC;MACDC,MAAM,EAAE;IACV,CAAC,CAAC;EACJ;EAGAC,mBAAmBA,CAAA,EAAG;IAEpB,OAAO,IAAI,CAACR,MAAM,CAACS,kBAAkB,CAAC,CAAC,CAAC;EAC1C;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { ExternalTexture } from '@luma.gl/api';
|
|
3
|
+
import WebGPUSampler from './webgpu-sampler';
|
|
4
|
+
export default class WebGPUExternalTexture extends ExternalTexture {
|
|
5
|
+
constructor(device, props) {
|
|
6
|
+
super(device, props);
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
_defineProperty(this, "handle", void 0);
|
|
9
|
+
_defineProperty(this, "sampler", void 0);
|
|
10
|
+
this.device = device;
|
|
11
|
+
this.handle = this.props.handle || this.device.handle.importExternalTexture({
|
|
12
|
+
source: props.source,
|
|
13
|
+
colorSpace: props.colorSpace
|
|
14
|
+
});
|
|
15
|
+
this.sampler = null;
|
|
16
|
+
}
|
|
17
|
+
destroy() {}
|
|
18
|
+
setSampler(sampler) {
|
|
19
|
+
this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=webgpu-external-texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-external-texture.js","names":["ExternalTexture","WebGPUSampler","WebGPUExternalTexture","constructor","device","props","_defineProperty","handle","importExternalTexture","source","colorSpace","sampler","destroy","setSampler"],"sources":["../../../../src/adapter/resources/webgpu-external-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {ExternalTexture, ExternalTextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\nimport WebGPUSampler from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport default class WebGPUExternalTexture extends ExternalTexture {\n readonly device: WebGPUDevice;\n readonly handle: GPUExternalTexture;\n sampler: WebGPUSampler;\n\n constructor(device: WebGPUDevice, props: ExternalTextureProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n this.sampler = null;\n }\n\n override destroy(): void {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n }\n\n /** Set default sampler */\n setSampler(sampler: Sampler | SamplerProps): this {\n // We can accept a sampler instance or set of props;\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n"],"mappings":";AACA,SAAQA,eAAe,QAAoD,cAAc;AAEzF,OAAOC,aAAa,MAAM,kBAAkB;AAM5C,eAAe,MAAMC,qBAAqB,SAASF,eAAe,CAAC;EAKjEG,WAAWA,CAACC,MAAoB,EAAEC,KAA2B,EAAE;IAC7D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,MAAM,GAAG,IAAI,CAACF,KAAK,CAACE,MAAM,IAAI,IAAI,CAACH,MAAM,CAACG,MAAM,CAACC,qBAAqB,CAAC;MAC1EC,MAAM,EAAEJ,KAAK,CAACI,MAAM;MACpBC,UAAU,EAAEL,KAAK,CAACK;IACpB,CAAC,CAAC;IACF,IAAI,CAACC,OAAO,GAAG,IAAI;EACrB;EAESC,OAAOA,CAAA,EAAS,CAIzB;EAGAC,UAAUA,CAACF,OAA+B,EAAQ;IAEhD,IAAI,CAACA,OAAO,GAAGA,OAAO,YAAYV,aAAa,GAAGU,OAAO,GAAG,IAAIV,aAAa,CAAC,IAAI,CAACG,MAAM,EAAEO,OAAO,CAAC;IACnG,OAAO,IAAI;EACb;AACF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Framebuffer, Texture } from '@luma.gl/api';
|
|
3
|
+
import WEBGPUTexture from './webgpu-texture';
|
|
4
|
+
export default class WebGPUFramebuffer extends Framebuffer {
|
|
5
|
+
constructor(device, props) {
|
|
6
|
+
super(device, props);
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
_defineProperty(this, "colorAttachments", []);
|
|
9
|
+
_defineProperty(this, "depthStencilAttachment", null);
|
|
10
|
+
_defineProperty(this, "renderPassDescriptor", {
|
|
11
|
+
colorAttachments: []
|
|
12
|
+
});
|
|
13
|
+
this.device = device;
|
|
14
|
+
if (props.depthStencilAttachment) {
|
|
15
|
+
this.depthStencilAttachment = this.createDepthStencilTexture(props);
|
|
16
|
+
}
|
|
17
|
+
if (props.colorAttachments) {
|
|
18
|
+
this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));
|
|
19
|
+
}
|
|
20
|
+
if (this.depthStencilAttachment) {
|
|
21
|
+
this.renderPassDescriptor.depthStencilAttachment = {
|
|
22
|
+
view: this.depthStencilAttachment.handle.createView(),
|
|
23
|
+
depthClearValue: 1.0,
|
|
24
|
+
depthStoreOp: 'store',
|
|
25
|
+
stencilClearValue: 0,
|
|
26
|
+
stencilStoreOp: 'store'
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (this.colorAttachments.length > 0) {
|
|
30
|
+
this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({
|
|
31
|
+
view: colorAttachment.handle.createView(),
|
|
32
|
+
loadOp: 'clear',
|
|
33
|
+
loadValue: [0.0, 0.0, 0.0, 0.0],
|
|
34
|
+
storeOp: 'store'
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
createDepthStencilTexture(props) {
|
|
39
|
+
if (props.depthStencilAttachment instanceof WEBGPUTexture) {
|
|
40
|
+
return props.depthStencilAttachment;
|
|
41
|
+
}
|
|
42
|
+
if (typeof props.depthStencilAttachment === 'string') {
|
|
43
|
+
return this.device._createTexture({
|
|
44
|
+
id: 'depth-stencil-attachment',
|
|
45
|
+
format: props.depthStencilAttachment,
|
|
46
|
+
width: props.width,
|
|
47
|
+
height: props.height,
|
|
48
|
+
usage: Texture.RENDER_ATTACHMENT
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
throw new Error('type');
|
|
52
|
+
}
|
|
53
|
+
createColorTexture(props, texture) {
|
|
54
|
+
if (texture instanceof WEBGPUTexture) {
|
|
55
|
+
return texture;
|
|
56
|
+
}
|
|
57
|
+
if (typeof texture === 'string') {
|
|
58
|
+
return this.device._createTexture({
|
|
59
|
+
id: 'color-attachment',
|
|
60
|
+
format: texture,
|
|
61
|
+
width: props.width,
|
|
62
|
+
height: props.height,
|
|
63
|
+
usage: Texture.RENDER_ATTACHMENT
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
throw new Error('type');
|
|
67
|
+
}
|
|
68
|
+
_resizeAttachments(width, height) {
|
|
69
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
70
|
+
if (this.colorAttachments[i]) {
|
|
71
|
+
const resizedTexture = this.device._createTexture({
|
|
72
|
+
...this.colorAttachments[i].props,
|
|
73
|
+
width,
|
|
74
|
+
height
|
|
75
|
+
});
|
|
76
|
+
this.colorAttachments[i].destroy();
|
|
77
|
+
this.colorAttachments[i] = resizedTexture;
|
|
78
|
+
this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (this.depthStencilAttachment) {
|
|
82
|
+
const resizedTexture = this.device._createTexture({
|
|
83
|
+
...this.depthStencilAttachment.props,
|
|
84
|
+
width,
|
|
85
|
+
height
|
|
86
|
+
});
|
|
87
|
+
this.depthStencilAttachment.destroy();
|
|
88
|
+
this.depthStencilAttachment = resizedTexture;
|
|
89
|
+
this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=webgpu-framebuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-framebuffer.js","names":["Framebuffer","Texture","WEBGPUTexture","WebGPUFramebuffer","constructor","device","props","_defineProperty","colorAttachments","depthStencilAttachment","createDepthStencilTexture","map","colorAttachment","createColorTexture","renderPassDescriptor","view","handle","createView","depthClearValue","depthStoreOp","stencilClearValue","stencilStoreOp","length","loadOp","loadValue","storeOp","_createTexture","id","format","width","height","usage","RENDER_ATTACHMENT","Error","texture","_resizeAttachments","i","resizedTexture","destroy"],"sources":["../../../../src/adapter/resources/webgpu-framebuffer.ts"],"sourcesContent":["import type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\n// import WebGPUCanvasContext from '../webgpu-canvas-context';\nimport WEBGPUTexture from './webgpu-texture';\nimport WebGPUTexture from './webgpu-texture';\n\n// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';\n\n// const MAX_COLOR_ATTACHMENTS = 8;\n\n/**\n * Create new textures with correct size for all attachments. \n * @note resize() destroys existing textures (if size has changed). \n */\nexport default class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n colorAttachments: WebGPUTexture[] = [];\n depthStencilAttachment: WebGPUTexture | null = null;\n\n /** Partial render pass descriptor. Used by WebGPURenderPass */\n renderPassDescriptor: {\n colorAttachments: GPURenderPassColorAttachment[];\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n } = {\n colorAttachments: []\n };\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n if (props.depthStencilAttachment) {\n this.depthStencilAttachment = this.createDepthStencilTexture(props);\n }\n\n if (props.colorAttachments) {\n this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));\n }\n\n if (this.depthStencilAttachment) {\n this.renderPassDescriptor.depthStencilAttachment = {\n view: this.depthStencilAttachment.handle.createView(),\n // Add default clear values\n depthClearValue: 1.0,\n depthStoreOp: 'store',\n stencilClearValue: 0,\n stencilStoreOp: 'store',\n }\n }\n\n if (this.colorAttachments.length > 0) {\n this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({\n view: colorAttachment.handle.createView(),\n loadOp: 'clear',\n loadValue: [0.0, 0.0, 0.0, 0.0],\n storeOp: 'store'\n }));\n }\n }\n\n /** Create depth stencil texture */\n private createDepthStencilTexture(props: FramebufferProps): WEBGPUTexture {\n if (props.depthStencilAttachment instanceof WEBGPUTexture) {\n return props.depthStencilAttachment;\n }\n\n if (typeof props.depthStencilAttachment === 'string') {\n return this.device._createTexture({\n id: 'depth-stencil-attachment',\n format: props.depthStencilAttachment,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n private createColorTexture(props: FramebufferProps, texture: Texture | ColorTextureFormat): WEBGPUTexture {\n if (texture instanceof WEBGPUTexture) {\n return texture;\n }\n\n if (typeof texture === 'string') {\n return this.device._createTexture({\n id: 'color-attachment',\n format: texture,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n /**\n * Create new textures with correct size for all attachments.\n * @note destroys existing textures.\n */\n protected _resizeAttachments(width: number, height: number): void {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.device._createTexture({...this.colorAttachments[i].props, width, height})\n this.colorAttachments[i].destroy();\n this.colorAttachments[i] = resizedTexture;\n this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();\n }\n }\n\n if (this.depthStencilAttachment) {\n const resizedTexture = this.device._createTexture({...this.depthStencilAttachment.props, width, height})\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = resizedTexture;\n this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();\n }\n }\n}\n"],"mappings":";AACA,SAAQA,WAAW,EAAEC,OAAO,QAAO,cAAc;AAGjD,OAAOC,aAAa,MAAM,kBAAkB;AAW5C,eAAe,MAAMC,iBAAiB,SAASH,WAAW,CAAC;EAczDI,WAAWA,CAACC,MAAoB,EAAEC,KAAuB,EAAE;IACzD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA,2BAZa,EAAE;IAAAA,eAAA,iCACS,IAAI;IAAAA,eAAA,+BAM/C;MACFC,gBAAgB,EAAE;IACpB,CAAC;IAIC,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAIC,KAAK,CAACG,sBAAsB,EAAE;MAChC,IAAI,CAACA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IAAI,GAAGsB,cAAc,CAACrB,MAAM,CAACC,UAAU,EAAE;MACzF;IACF;IAEA,IAAI,IAAI,CAACR,sBAAsB,EAAE;MAC9B,MAAM4B,cAAc,GAAG,IAAI,CAAChC,MAAM,CAACqB,cAAc,CAAC;QAAC,GAAG,IAAI,CAACjB,sBAAsB,CAACH,KAAK;QAAEuB,KAAK;QAAEC;MAAM,CAAC,CAAC;MACxG,IAAI,CAACrB,sBAAsB,CAAC6B,OAAO,EAAE;MACrC,IAAI,CAAC7B,sBAAsB,GAAG4B,cAAc;MAC5C,IAAI,CAACvB,oBAAoB,CAACL,sBAAsB,CAACM,IAAI,GAAGsB,cAAc,CAACrB,MAAM,CAACC,UAAU,EAAE;IAC7F;EACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-query.js","names":[],"sources":["../../../../src/adapter/resources/webgpu-query.ts"],"sourcesContent":["/*\nimport {Resource, Query, QueryProps} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\n\nexport type WebGPUQueryProps = QueryProps & {\n handle?: any;\n};\n\nconst DEFAULT_QUERY_PROPS: Required<WebGPUQueryProps> = {\n id: undefined,\n handle: undefined,\n userData: undefined,\n type: 'timestamp',\n count: 1,\n pipelineStatistics: []\n};\n\n/**\n * Immutable\n *\nclass WebGPUQuery extends Resource<WebGPUQueryProps> implements Query {\n readonly device: WebGPUDevice;\n readonly handle: GPUQuerySet;\n\n constructor(device: WebGPUDevice, props: WebGPUQueryProps) {\n super(device, props, DEFAULT_QUERY_PROPS);\n this.handle = this.props.handle as GPUQuerySet || this.createHandle();\n this.handle.label = this.props.id;\n }\n\n protected createHandle() {\n return this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count,\n pipelineStatistics: this.props.pipelineStatistics\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n}\n*/"],"mappings":""}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { RenderPass, cast } from '@luma.gl/api';
|
|
3
|
+
export default class WebGPURenderPass extends RenderPass {
|
|
4
|
+
constructor(device) {
|
|
5
|
+
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6
|
+
super(device, props);
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
_defineProperty(this, "handle", void 0);
|
|
9
|
+
_defineProperty(this, "pipeline", null);
|
|
10
|
+
this.device = device;
|
|
11
|
+
const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
|
|
12
|
+
const renderPassDescriptor = framebuffer.renderPassDescriptor;
|
|
13
|
+
this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
14
|
+
this.handle.label = this.props.id;
|
|
15
|
+
}
|
|
16
|
+
destroy() {}
|
|
17
|
+
end() {
|
|
18
|
+
this.handle.end();
|
|
19
|
+
}
|
|
20
|
+
setPipeline(pipeline) {
|
|
21
|
+
this.pipeline = cast(pipeline);
|
|
22
|
+
this.handle.setPipeline(this.pipeline.handle);
|
|
23
|
+
}
|
|
24
|
+
setBindings(bindings) {
|
|
25
|
+
var _this$pipeline, _this$pipeline2;
|
|
26
|
+
(_this$pipeline = this.pipeline) === null || _this$pipeline === void 0 ? void 0 : _this$pipeline.setBindings(bindings);
|
|
27
|
+
const bindGroup = (_this$pipeline2 = this.pipeline) === null || _this$pipeline2 === void 0 ? void 0 : _this$pipeline2._getBindGroup();
|
|
28
|
+
if (bindGroup) {
|
|
29
|
+
this.handle.setBindGroup(0, bindGroup);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
setIndexBuffer(buffer, indexFormat) {
|
|
33
|
+
let offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
34
|
+
let size = arguments.length > 3 ? arguments[3] : undefined;
|
|
35
|
+
this.handle.setIndexBuffer(cast(buffer).handle, indexFormat, offset, size);
|
|
36
|
+
}
|
|
37
|
+
setVertexBuffer(slot, buffer) {
|
|
38
|
+
let offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
39
|
+
this.handle.setVertexBuffer(slot, cast(buffer).handle, offset);
|
|
40
|
+
}
|
|
41
|
+
draw(options) {
|
|
42
|
+
if (options.indexCount) {
|
|
43
|
+
this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
|
|
44
|
+
} else {
|
|
45
|
+
this.handle.draw(options.vertexCount || 0, options.instanceCount, options.firstIndex, options.firstInstance);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
drawIndirect() {}
|
|
49
|
+
setParameters(parameters) {
|
|
50
|
+
const {
|
|
51
|
+
blendConstant,
|
|
52
|
+
stencilReference,
|
|
53
|
+
scissorRect,
|
|
54
|
+
viewport
|
|
55
|
+
} = parameters;
|
|
56
|
+
if (blendConstant) {
|
|
57
|
+
this.handle.setBlendConstant(blendConstant);
|
|
58
|
+
}
|
|
59
|
+
if (stencilReference) {
|
|
60
|
+
this.handle.setStencilReference(stencilReference);
|
|
61
|
+
}
|
|
62
|
+
if (scissorRect) {
|
|
63
|
+
this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
|
|
64
|
+
}
|
|
65
|
+
if (viewport) {
|
|
66
|
+
this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
pushDebugGroup(groupLabel) {
|
|
70
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
71
|
+
}
|
|
72
|
+
popDebugGroup() {
|
|
73
|
+
this.handle.popDebugGroup();
|
|
74
|
+
}
|
|
75
|
+
insertDebugMarker(markerLabel) {
|
|
76
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=webgpu-render-pass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","arguments","length","undefined","_defineProperty","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","end","setPipeline","pipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPURenderPipeline from './webgpu-render-pipeline';\n\nexport default class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();\n // @ts-expect-error\n const renderPassDescriptor = framebuffer.renderPassDescriptor;\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n}\n"],"mappings":";AACA,SAAgBA,UAAU,EAAkBC,IAAI,QAAO,cAAc;AAMrE,eAAe,MAAMC,gBAAgB,SAASF,UAAU,CAAC;EAOvDG,WAAWA,CAACC,MAAoB,EAA+B;IAAA,IAA7BC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC3D,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACI,eAAA;IAAAA,eAAA;IAAAA,eAAA,mBAHiB,IAAI;IAI1C,IAAI,CAACL,MAAM,GAAGA,MAAM;IACpB,MAAMM,WAAW,GAAGL,KAAK,CAACK,WAAW,IAAIN,MAAM,CAACO,aAAa,CAACC,qBAAqB,EAAE;IAErF,MAAMC,oBAAoB,GAAGH,WAAW,CAACG,oBAAoB;IAC7D,IAAI,CAACC,MAAM,GAAG,IAAI,CAACT,KAAK,CAACS,MAAM,IAAIV,MAAM,CAACW,cAAc,CAACC,eAAe,CAACH,oBAAoB,CAAC;IAC9F,IAAI,CAACC,MAAM,CAACG,KAAK,GAAG,IAAI,CAACZ,KAAK,CAACa,EAAE;EACnC;EAESC,OAAOA,CAAA,EAAS,CAAC;EAE1BC,GAAGA,CAAA,EAAS;IACV,IAAI,CAACN,MAAM,CAACM,GAAG,EAAE;EACnB;EAEAC,WAAWA,CAACC,QAAwB,EAAQ;IAC1C,IAAI,CAACA,QAAQ,GAAGrB,IAAI,CAAuBqB,QAAQ,CAAC;IACpD,IAAI,CAACR,MAAM,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