@luma.gl/webgpu 9.0.0-alpha.2 → 9.0.0-alpha.20
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/LICENSE +32 -0
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -1
- package/dist/adapter/helpers/convert-texture-format.d.ts +1 -1
- package/dist/adapter/helpers/convert-texture-format.js +0 -1
- package/dist/adapter/helpers/convert-texture-format.js.map +1 -1
- package/dist/adapter/helpers/generate-mipmaps.d.ts +1 -1
- package/dist/adapter/helpers/generate-mipmaps.js +1 -8
- package/dist/adapter/helpers/generate-mipmaps.js.map +1 -1
- package/dist/adapter/helpers/get-bind-group.d.ts +1 -1
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +0 -9
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +3 -17
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.d.ts +1 -1
- package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +50 -47
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts +2 -3
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +11 -25
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +2 -3
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +6 -23
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +4 -4
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +10 -22
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +2 -6
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.d.ts +2 -2
- package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js +1 -8
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +3 -3
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +9 -27
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-query.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +3 -3
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +16 -29
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +5 -2
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +24 -42
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts +2 -2
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +7 -6
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts +3 -3
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +1 -15
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +2 -2
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +3 -19
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts +2 -4
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +8 -29
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +8 -8
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +42 -71
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/adapter/webgpu-types.js.map +1 -1
- package/dist/dist.dev.js +3061 -0
- package/dist/glsl/glsllang.js +0 -1
- package/dist/glsl/glsllang.js.map +1 -1
- package/dist/index.cjs +1442 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist.min.js +17 -0
- package/package.json +18 -9
- package/src/adapter/helpers/generate-mipmaps.ts +1 -1
- package/src/adapter/helpers/get-bind-group.ts +1 -1
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +3 -3
- package/src/adapter/helpers/webgpu-parameters.ts +55 -46
- package/src/adapter/resources/webgpu-buffer.ts +5 -9
- package/src/adapter/resources/webgpu-command-encoder.ts +16 -14
- package/src/adapter/resources/webgpu-compute-pass.ts +8 -8
- package/src/adapter/resources/webgpu-compute-pipeline.ts +3 -2
- package/src/adapter/resources/webgpu-external-texture.ts +2 -2
- package/src/adapter/resources/webgpu-framebuffer.ts +11 -10
- package/src/adapter/resources/webgpu-query.ts +2 -2
- package/src/adapter/resources/webgpu-render-pass.ts +11 -8
- package/src/adapter/resources/webgpu-render-pipeline.ts +28 -11
- package/src/adapter/resources/webgpu-sampler.ts +10 -3
- package/src/adapter/resources/webgpu-shader.ts +6 -4
- package/src/adapter/resources/webgpu-texture.ts +5 -4
- package/src/adapter/webgpu-canvas-context.ts +12 -8
- package/src/adapter/webgpu-device.ts +51 -38
- package/src/index.ts +2 -5
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/init.d.ts +0 -2
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -4
- package/dist/init.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/init.ts +0 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Copyright (c) 2020 Urban Computing Foundation
|
|
2
|
+
|
|
3
|
+
This software includes parts initially developed by Uber and open sourced under MIT license.
|
|
4
|
+
Copyright (c) 2015 Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This software includes parts of PhiloGL (https://github.com/philogb/philogl)
|
|
7
|
+
under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
|
|
8
|
+
|
|
9
|
+
This software includes adaptations of some postprocessing code from
|
|
10
|
+
THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
|
|
11
|
+
THREE.js parts Copyright © 2010-2018 three.js authors.
|
|
12
|
+
|
|
13
|
+
Additional attribution given in specific source files.
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in
|
|
23
|
+
all copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
31
|
+
THE SOFTWARE.
|
|
32
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"accessor-to-format.js","names":[],"sources":["../../../src/adapter/helpers/accessor-to-format.ts"],"sourcesContent":["/*\nimport {assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\ntype Accessor = Record<string, any>;\n\nconst FORMAT_TO_ACCESSOR: Record<GPUVertexFormat, Accessor> = {\n uchar2: {type: 'uchar', size: 2},\n uchar4: {type: 'uchar', size: 4},\n char2: {type: 'char', size: 2},\n char4: {type: 'char', size: 4},\n uchar2norm: {type: 'uchar', size: 2, normalized: true},\n uchar4norm: {type: 'uchar', size: 4, normalized: true},\n char2norm: {type: 'char', size: 2, normalized: true},\n char4norm: {type: 'char', size: 4, normalized: true},\n ushort2: {type: 'ushort', size: 2},\n ushort4: {type: 'ushort', size: 4},\n short2: {type: 'short', size: 2},\n short4: {type: 'short', size: 4},\n ushort2norm: {type: 'ushort', size: 2, normalized: true},\n ushort4norm: {type: 'ushort', size: 4, normalized: true},\n short2norm: {type: 'short', size: 1, normalized: true},\n short4norm: {type: 'short', size: 1, normalized: true},\n half2: {type: 'half', size: 2},\n half4: {type: 'half', size: 4},\n float: {type: 'float', size: 1},\n float2: {type: 'float', size: 2},\n float3: {type: 'float', size: 3},\n float4: {type: 'float', size: 4},\n uint: {type: 'uint', size: 1, integer: true},\n uint2: {type: 'uint', size: 2, integer: true},\n uint3: {type: 'uint', size: 3, integer: true},\n uint4: {type: 'uint', size: 4, integer: true},\n int: {type: 'int', size: 1, integer: true},\n int2: {type: 'int', size: 2, integer: true},\n int3: {type: 'int', size: 3, integer: true},\n int4: {type: 'int', size: 4, integer: true}\n};\n\n/**\n * Convert from WebGPU attribute format strings to accessor {type, size, normalized, integer}\n * @param {*} format\n *\nexport function mapWebGPUFormatToAccessor(format) {\n const accessorDefinition = FORMAT_TO_ACCESSOR[format];\n assert(accessorDefinition, 'invalid attribute format');\n return Object.freeze(accessorDefinition);\n}\n\n/**\n * Convert from accessor {type, size, normalized, integer} to WebGPU attribute format strings\n * @param {*} format\n *\nexport function mapAccessorToWebGPUFormat(accessor) {\n const {type = GL.FLOAT, size = 1, normalized = false, integer = false} = accessor;\n assert(size >=1 && size <=4);\n // `norm` suffix (uchar4norm)\n const norm = normalized ? 'norm' : '';\n // size 1 is ommitted in format names (float vs float2)\n const count = size === 1 ? '' : size;\n switch (type) {\n case GL.UNSIGNED_BYTE:\n switch (size) {\n case 2:\n case 4:\n return `uchar${count}${norm}`;\n }\n case GL.BYTE:\n switch (size) {\n case 2:\n case 4:\n return `char${count}${norm}`;\n }\n case GL.UNSIGNED_SHORT:\n switch (size) {\n case 2:\n case 4:\n return `ushort${count}${norm}`;\n }\n case GL.SHORT:\n switch (size) {\n case 2:\n case 4:\n return `short${count}${norm}`;\n }\n case GL.HALF_FLOAT:\n switch (size) {\n case 2:\n case 4:\n return `half${count}`;\n }\n case GL.FLOAT:\n return `float${count}`;\n case GL.UNSIGNED_INT:\n return `uint${count}`;\n case GL.INT:\n return `int${count}`;\n }\n throw new Error('illegal accessor');\n}\n*/"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"convert-texture-format.js","names":["getWebGPUTextureFormat","format","includes","Error"],"sources":["../../../src/adapter/helpers/convert-texture-format.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {TextureFormat} from '@luma.gl/api';\n\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format: TextureFormat): GPUTextureFormat {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format as GPUTextureFormat;\n}\n"],"mappings":"AAIA,OAAO,SAASA,sBAAsBA,CAACC,MAAqB,EAAoB;EAC9E,IAAIA,MAAM,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE;IAC5B,MAAM,IAAIC,KAAK,CAAC,mBAAmB,CAAC;EACtC;EACA,OAAOF,MAAM;AACf"}
|
|
@@ -4,11 +4,8 @@ const FS_GEN_MIPMAP = "#version 450\nlayout(set = 0, binding = 0) uniform sample
|
|
|
4
4
|
export class WebGPUMipmapGenerator {
|
|
5
5
|
constructor(device, glslang) {
|
|
6
6
|
_defineProperty(this, "device", void 0);
|
|
7
|
-
|
|
8
7
|
_defineProperty(this, "mipmapSampler", void 0);
|
|
9
|
-
|
|
10
8
|
_defineProperty(this, "mipmapPipeline", void 0);
|
|
11
|
-
|
|
12
9
|
this.device = device;
|
|
13
10
|
this.mipmapSampler = device.createSampler({
|
|
14
11
|
minFilter: 'linear'
|
|
@@ -32,9 +29,8 @@ export class WebGPUMipmapGenerator {
|
|
|
32
29
|
}]
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
generateMipmappedTexture(imageBitmap) {
|
|
37
|
-
|
|
33
|
+
const textureSize = {
|
|
38
34
|
width: imageBitmap.width,
|
|
39
35
|
height: imageBitmap.height,
|
|
40
36
|
depth: 1
|
|
@@ -52,7 +48,6 @@ export class WebGPUMipmapGenerator {
|
|
|
52
48
|
texture: srcTexture
|
|
53
49
|
}, textureSize);
|
|
54
50
|
const commandEncoder = this.device.createCommandEncoder({});
|
|
55
|
-
|
|
56
51
|
for (let i = 1; i < mipLevelCount; ++i) {
|
|
57
52
|
const passEncoder = commandEncoder.beginRenderPass({
|
|
58
53
|
colorAttachments: [{
|
|
@@ -86,10 +81,8 @@ export class WebGPUMipmapGenerator {
|
|
|
86
81
|
passEncoder.draw(4);
|
|
87
82
|
passEncoder.endPass();
|
|
88
83
|
}
|
|
89
|
-
|
|
90
84
|
this.device.queue.submit([commandEncoder.finish()]);
|
|
91
85
|
return texture;
|
|
92
86
|
}
|
|
93
|
-
|
|
94
87
|
}
|
|
95
88
|
//# sourceMappingURL=generate-mipmaps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"generate-mipmaps.js","names":["VS_GEN_MIPMAP","FS_GEN_MIPMAP","WebGPUMipmapGenerator","constructor","device","glslang","_defineProperty","mipmapSampler","createSampler","minFilter","mipmapPipeline","createRenderPipeline","vertexStage","module","createShaderModule","code","compileGLSL","entryPoint","fragmentStage","primitiveTopology","colorStates","format","generateMipmappedTexture","imageBitmap","textureSize","width","height","depth","mipLevelCount","Math","floor","log2","max","texture","createTexture","size","usage","GPUTextureUsage","COPY_DST","SAMPLED","OUTPUT_ATTACHMENT","queue","copyImageBitmapToTexture","srcTexture","commandEncoder","createCommandEncoder","i","passEncoder","beginRenderPass","colorAttachments","attachment","createView","baseMipLevel","loadValue","r","g","b","a","bindGroup","createBindGroup","layout","getBindGroupLayout","bindings","binding","resource","setPipeline","setBindGroup","draw","endPass","submit","finish"],"sources":["../../../src/adapter/helpers/generate-mipmaps.ts"],"sourcesContent":["// luma.gl, MIT license\n// Forked from Kangz/mipmapper.js under MIT license Copyright 2020 Brandon Jones\n// https://gist.github.com/Kangz/782d5f1ae502daf53910a13f55db2f83\n\n// @ts-nocheck this is written against outdated WebGPU API, needs an update pass\n\nconst VS_GEN_MIPMAP = `\\#version 450\nconst vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\nlayout(location = 0) out vec2 vTex;\nvoid main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n vTex = gl_Position / 2.0f + vec2(0.5f);\n}`;\n\nconst FS_GEN_MIPMAP = `#version 450\nlayout(set = 0, binding = 0) uniform sampler imgSampler;\nlayout(set = 0, binding = 1) uniform texture2D img;\nlayout(location = 0) in vec2 vTex;\nlayout(location = 0) out vec4 outColor;\nvoid main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n}`;\n\n/** WebGPU does not have built-in mipmap creation */\nexport class WebGPUMipmapGenerator {\n device: GPUDevice;\n mipmapSampler: GPUSampler;\n mipmapPipeline: GPURenderPipeline;\n\n constructor(device: GPUDevice, glslang) {\n this.device = device;\n\n this.mipmapSampler = device.createSampler({ minFilter: 'linear' });\n\n this.mipmapPipeline = device.createRenderPipeline({\n vertexStage: {\n module: device.createShaderModule({\n code: glslang.compileGLSL(VS_GEN_MIPMAP, 'vertex')\n }),\n entryPoint: 'main'\n },\n fragmentStage: {\n module: device.createShaderModule({\n code: glslang.compileGLSL(FS_GEN_MIPMAP, 'fragment')\n }),\n entryPoint: 'main'\n },\n primitiveTopology: 'triangle-strip',\n colorStates: [{\n format: 'rgba8unorm',\n }]\n });\n }\n\n generateMipmappedTexture(imageBitmap: ImageBitmap) {\n const textureSize = {\n width: imageBitmap.width,\n height: imageBitmap.height,\n depth: 1,\n }\n const mipLevelCount = Math.floor(Math.log2(Math.max(imageBitmap.width, imageBitmap.height))) + 1;\n\n // Populate the top level of the srcTexture with the imageBitmap.\n const texture = this.device.createTexture({\n size: textureSize,\n format: 'rgba8unorm',\n usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.SAMPLED | GPUTextureUsage.OUTPUT_ATTACHMENT,\n mipLevelCount\n });\n this.device.queue.copyImageBitmapToTexture({ imageBitmap }, { texture: srcTexture }, textureSize);\n\n const commandEncoder = this.device.createCommandEncoder({});\n for (let i = 1; i < mipLevelCount; ++i) {\n const passEncoder = commandEncoder.beginRenderPass({\n colorAttachments: [{\n attachment: texture.createView({\n baseMipLevel: i,\n mipLevelCount: 1\n }),\n loadValue: { r: 1.0, g: 0.0, b: 0.0, a: 0.0 },\n }],\n });\n\n const bindGroup = this.device.createBindGroup({\n layout: this.mipmapPipeline.getBindGroupLayout(0),\n bindings: [{\n binding: 0,\n resource: this.mipmapSampler,\n }, {\n binding: 1,\n resource: texture.createView({\n baseMipLevel: i - 1,\n mipLevelCount: 1\n }),\n }],\n });\n\n passEncoder.setPipeline(this.mipmapPipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4);\n passEncoder.endPass();\n }\n\n this.device.queue.submit([commandEncoder.finish()]);\n return texture;\n }\n}\n"],"mappings":";AAMA,MAAMA,aAAa,mRAMjB;AAEF,MAAMC,aAAa,wRAOjB;AAGF,OAAO,MAAMC,qBAAqB,CAAC;EAKjCC,WAAWA,CAACC,MAAiB,EAAEC,OAAO,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACtC,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACG,aAAa,GAAGH,MAAM,CAACI,aAAa,CAAC;MAAEC,SAAS,EAAE;IAAS,CAAC,CAAC;IAElE,IAAI,CAACC,cAAc,GAAGN,MAAM,CAACO,oBAAoB,CAAC;MAChDC,WAAW,EAAE;QACXC,MAAM,EAAET,MAAM,CAACU,kBAAkB,CAAC;UAChCC,IAAI,EAAEV,OAAO,CAACW,WAAW,CAAChB,aAAa,EAAE,QAAQ;QACnD,CAAC,CAAC;QACFiB,UAAU,EAAE;MACd,CAAC;MACDC,aAAa,EAAE;QACbL,MAAM,EAAET,MAAM,CAACU,kBAAkB,CAAC;UAChCC,IAAI,EAAEV,OAAO,CAACW,WAAW,CAACf,aAAa,EAAE,UAAU;QACrD,CAAC,CAAC;QACFgB,UAAU,EAAE;MACd,CAAC;MACDE,iBAAiB,EAAE,gBAAgB;MACnCC,WAAW,EAAE,CAAC;QACZC,MAAM,EAAE;MACV,CAAC;IACH,CAAC,CAAC;EACJ;EAEAC,wBAAwBA,CAACC,WAAwB,EAAE;IACjD,MAAMC,WAAW,GAAG;MAClBC,KAAK,EAAEF,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AAE,IAAI,CAAClD,cAAc,CAACmD,kBAAkB,CAAC,CAAC,CAAC;QACjDC,QAAQ,EAAE,CAAC;UACTC,OAAO,EAAE,CAAC;UACVC,QAAQ,EAAE,IAAI,CAACzD;QACjB,CAAC,EAAE;UACDwD,OAAO,EAAE,CAAC;UACVC,QAAQ,EAAE/B,OAAO,CAACkB,UAAU,CAAC;YAC3BC,YAAY,EAAEN,CAAC,GAAG,CAAC;YACnBlB,aAAa,EAAE;UACjB,CAAC;QACH,CAAC;MACH,CAAC,CAAC;MAEFmB,WAAW,CAACkB,WAAW,CAAC,IAAI,CAACvD,cAAc,CAAC;MAC5CqC,WAAW,CAACmB,YAAY,CAAC,CAAC,EAAER,SAAS,CAAC;MACtCX,WAAW,CAACoB,IAAI,CAAC,CAAC,CAAC;MACnBpB,WAAW,CAACqB,OAAO,EAAE;IACvB;IAEA,IAAI,CAAChE,MAAM,CAACqC,KAAK,CAAC4B,MAAM,CAAC,CAACzB,cAAc,CAAC0B,MAAM,EAAE,CAAC,CAAC;IACnD,OAAOrC,OAAO;EAChB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAMvE;;;GAGG;
|
|
1
|
+
{"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAMvE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAM1H;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAM/F"}
|
|
@@ -11,28 +11,21 @@ export function getBindGroup(device, bindGroupLayout, layout, bindings) {
|
|
|
11
11
|
}
|
|
12
12
|
export function getShaderLayoutBinding(layout, bindingName) {
|
|
13
13
|
const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);
|
|
14
|
-
|
|
15
14
|
if (!bindingLayout) {
|
|
16
15
|
log.warn("Binding ".concat(bindingName, " not set: Not found in shader layout."))();
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
return bindingLayout;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
function getBindGroupEntries(bindings, layout) {
|
|
23
20
|
const entries = [];
|
|
24
|
-
|
|
25
21
|
for (const [bindingName, value] of Object.entries(bindings)) {
|
|
26
22
|
const bindingLayout = getShaderLayoutBinding(layout, bindingName);
|
|
27
|
-
|
|
28
23
|
if (bindingLayout) {
|
|
29
24
|
entries.push(getBindGroupEntry(value, bindingLayout.location));
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
return entries;
|
|
34
28
|
}
|
|
35
|
-
|
|
36
29
|
function getBindGroupEntry(binding, index) {
|
|
37
30
|
if (binding instanceof Buffer) {
|
|
38
31
|
return {
|
|
@@ -42,7 +35,6 @@ function getBindGroupEntry(binding, index) {
|
|
|
42
35
|
}
|
|
43
36
|
};
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
if (binding instanceof Sampler) {
|
|
47
39
|
return {
|
|
48
40
|
binding: index,
|
|
@@ -54,7 +46,6 @@ function getBindGroupEntry(binding, index) {
|
|
|
54
46
|
resource: cast(binding).handle.createView()
|
|
55
47
|
};
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
throw new Error('invalid binding');
|
|
59
50
|
}
|
|
60
51
|
//# sourceMappingURL=get-bind-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"get-bind-group.js","names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","concat","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView"],"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BindingLayout, Binding} from '@luma.gl/api';\nimport {Buffer, Sampler, Texture, log, cast} from '@luma.gl/api';\nimport type WebGPUBuffer from '../resources/webgpu-buffer';\nimport type WebGPUSampler from '../resources/webgpu-sampler';\nimport type WebGPUTexture from '../resources/webgpu-texture';\n\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGroupLayout, bindings: Binding[]): GPUBindGroupLayout {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(\n device: GPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n layout: ShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, layout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\n\nexport function getShaderLayoutBinding(layout: ShaderLayout, bindingName: string): BindingLayout {\n const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings: Record<string, Binding>, layout: ShaderLayout): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(layout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(binding: Binding, index: number): GPUBindGroupEntry {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: cast<WebGPUBuffer>(binding).handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: cast<WebGPUSampler>(binding).handle\n };\n } else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: cast<WebGPUTexture>(binding).handle.createView()\n };\n }\n throw new Error('invalid binding');\n}\n"],"mappings":"AAEA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,GAAG,EAAEC,IAAI,QAAO,cAAc;AAShE,OAAO,SAASC,mBAAmBA,CAACC,MAAiB,EAAEC,MAA0B,EAAEC,QAAmB,EAAsB;EAC1H,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AAKpC;AAKA,OAAO,SAASC,YAAYA,CAC1BJ,MAAiB,EACjBK,eAAmC,EACnCJ,MAAoB,EACpBC,QAAiC,EACnB;EACd,MAAMI,OAAO,GAAGC,mBAAmB,CAACL,QAAQ,EAAED,MAAM,CAAC;EACrD,OAAOD,MAAM,CAACQ,eAAe,CAAC;IAC5BP,MAAM,EAAEI,eAAe;IACvBC;EACF,CAAC,CAAC;AACJ;AAEA,OAAO,SAASG,sBAAsBA,CAACR,MAAoB,EAAES,WAAmB,EAAiB;EAC/F,MAAMC,aAAa,GAAGV,MAAM,CAACC,QAAQ,CAACU,IAAI,CAACC,OAAO,IAAIA,OAAO,CAACC,IAAI,KAAKJ,WAAW,CAAC;EACnF,IAAI,CAACC,aAAa,EAAE;IAClBd,GAAG,CAACkB,IAAI,YAAAC,MAAA,CAAYN,WAAW,2CAAwC,EAAE;EAC3E;EACA,OAAOC,aAAa;AACtB;AAMA,SAASJ,mBAAmBA,CAACL,QAAiC,EAAED,MAAoB,EAAuB;EACzG,MAAMK,OAA4B,GAAG,EAAE;EAEvC,KAAK,MAAM,CAACI,WAAW,EAAEO,KAAK,CAAC,IAAIC,MAAM,CAACZ,OAAO,CAACJ,QAAQ,CAAC,EAAE;IAC3D,MAAMS,aAAa,GAAGF,sBAAsB,CAACR,MAAM,EAAES,WAAW,CAAC;IACjE,IAAIC,aAAa,EAAE;MACjBL,OAAO,CAACa,IAAI,CAACC,iBAAiB,CAACH,KAAK,EAAEN,aAAa,CAACU,QAAQ,CAAC,CAAC;IAChE;EACF;EAEA,OAAOf,OAAO;AAChB;AAEA,SAASc,iBAAiBA,CAACP,OAAgB,EAAES,KAAa,EAAqB;EAC7E,IAAIT,OAAO,YAAYnB,MAAM,EAAE;IAC7B,OAAO;MACLmB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAE;QACRC,MAAM,EAAE1B,IAAI,CAAee,OAAO,CAAC,CAACY;MACtC;IACF,CAAC;EACH;EACA,IAAIZ,OAAO,YAAYlB,OAAO,EAAE;IAC9B,OAAO;MACLkB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAEzB,IAAI,CAAgBe,OAAO,CAAC,CAACY;IACzC,CAAC;EACH,CAAC,MAAM,IAAIZ,OAAO,YAAYjB,OAAO,EAAE;IACrC,OAAO;MACLiB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAEzB,IAAI,CAAgBe,OAAO,CAAC,CAACY,MAAM,CAACC,UAAU;IAC1D,CAAC;EACH;EACA,MAAM,IAAIvB,KAAK,CAAC,iBAAiB,CAAC;AACpC"}
|
|
@@ -2,16 +2,12 @@ import { decodeVertexFormat } from '@luma.gl/api';
|
|
|
2
2
|
export function getVertexBufferLayout(layout, bufferMap) {
|
|
3
3
|
const vertexBufferLayouts = [];
|
|
4
4
|
const usedAttributes = new Set();
|
|
5
|
-
|
|
6
5
|
for (const mapping of bufferMap) {
|
|
7
6
|
const vertexAttributes = [];
|
|
8
7
|
let stepMode = 'vertex';
|
|
9
8
|
let byteStride = 0;
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const byteOffset = mapping.byteOffset || 0;
|
|
12
10
|
if ('attributes' in mapping) {
|
|
13
|
-
const arrayStride = mapping.byteStride;
|
|
14
|
-
|
|
15
11
|
for (const interleaved of mapping.attributes) {
|
|
16
12
|
const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);
|
|
17
13
|
stepMode = attributeLayout.stepMode || 'vertex';
|
|
@@ -24,21 +20,20 @@ export function getVertexBufferLayout(layout, bufferMap) {
|
|
|
24
20
|
}
|
|
25
21
|
} else {
|
|
26
22
|
const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);
|
|
27
|
-
byteStride = decodeVertexFormat(attributeLayout.format).byteLength
|
|
23
|
+
byteStride = decodeVertexFormat(attributeLayout.format).byteLength;
|
|
24
|
+
stepMode = attributeLayout.stepMode || 'vertex';
|
|
28
25
|
vertexAttributes.push({
|
|
29
26
|
format: attributeLayout.format,
|
|
30
27
|
offset: byteOffset,
|
|
31
28
|
shaderLocation: attributeLayout.location
|
|
32
29
|
});
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
vertexBufferLayouts.push({
|
|
36
32
|
arrayStride: mapping.byteStride || byteStride,
|
|
37
33
|
stepMode: stepMode || 'vertex',
|
|
38
34
|
attributes: vertexAttributes
|
|
39
35
|
});
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
for (const attribute of layout.attributes) {
|
|
43
38
|
if (!usedAttributes.has(attribute.name)) {
|
|
44
39
|
vertexBufferLayouts.push({
|
|
@@ -52,14 +47,12 @@ export function getVertexBufferLayout(layout, bufferMap) {
|
|
|
52
47
|
});
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
|
-
|
|
56
50
|
return vertexBufferLayouts;
|
|
57
51
|
}
|
|
58
52
|
export function getBufferSlots(layout, bufferMap) {
|
|
59
53
|
const usedAttributes = new Set();
|
|
60
54
|
let bufferSlot = 0;
|
|
61
55
|
const bufferSlots = {};
|
|
62
|
-
|
|
63
56
|
for (const mapping of bufferMap) {
|
|
64
57
|
if ('attributes' in mapping) {
|
|
65
58
|
for (const interleaved of mapping.attributes) {
|
|
@@ -68,30 +61,23 @@ export function getBufferSlots(layout, bufferMap) {
|
|
|
68
61
|
} else {
|
|
69
62
|
usedAttributes.add(mapping.name);
|
|
70
63
|
}
|
|
71
|
-
|
|
72
64
|
bufferSlots[mapping.name] = bufferSlot++;
|
|
73
65
|
}
|
|
74
|
-
|
|
75
66
|
for (const attribute of layout.attributes) {
|
|
76
67
|
if (!usedAttributes.has(attribute.name)) {
|
|
77
68
|
bufferSlots[attribute.name] = bufferSlot++;
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
|
-
|
|
81
71
|
return bufferSlots;
|
|
82
72
|
}
|
|
83
|
-
|
|
84
73
|
function findAttributeLayout(layout, name, attributeNames) {
|
|
85
74
|
const attribute = layout.attributes.find(attribute => attribute.name === name);
|
|
86
|
-
|
|
87
75
|
if (!attribute) {
|
|
88
76
|
throw new Error("Unknown attribute ".concat(name));
|
|
89
77
|
}
|
|
90
|
-
|
|
91
78
|
if (attributeNames.has(name)) {
|
|
92
79
|
throw new Error("Duplicate attribute ".concat(name));
|
|
93
80
|
}
|
|
94
|
-
|
|
95
81
|
attributeNames.add(name);
|
|
96
82
|
return attribute;
|
|
97
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"get-vertex-buffer-layout.js","names":["decodeVertexFormat","getVertexBufferLayout","layout","bufferMap","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","byteOffset","interleaved","attributes","attributeLayout","findAttributeLayout","name","push","format","offset","shaderLocation","location","byteLength","arrayStride","attribute","has","getBufferSlots","bufferSlot","bufferSlots","add","attributeNames","find","Error","concat"],"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"sourcesContent":["import type {ShaderLayout, BufferMapping, AttributeLayout} from '@luma.gl/api';\nimport {decodeVertexFormat} from '@luma.gl/api';\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferMap The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(layout: ShaderLayout, bufferMap: BufferMapping[]): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferMapping`\n for (const mapping of bufferMap) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n const byteOffset = mapping.byteOffset || 0;\n\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n // const arrayStride = mapping.byteStride; TODO \n for (const interleaved of mapping.attributes) {\n const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: attributeLayout.format,\n offset: byteOffset + byteStride,\n shaderLocation: attributeLayout.location\n });\n\n byteStride += decodeVertexFormat(attributeLayout.format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);\n byteStride = decodeVertexFormat(attributeLayout.format).byteLength;\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: attributeLayout.format,\n offset: byteOffset,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode: stepMode || 'vertex',\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes\n for (const attribute of layout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat(attribute.format).byteLength,\n stepMode: attribute.stepMode || 'vertex',\n attributes: [{\n format: attribute.format,\n offset: 0,\n shaderLocation: attribute.location\n }]\n });\n }\n }\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(layout: ShaderLayout, bufferMap: BufferMapping[]): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferMapping`\n for (const mapping of bufferMap) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes) {\n usedAttributes.add(interleaved.name);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of layout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(layout: ShaderLayout, name: string, attributeNames: Set<string>): AttributeLayout {\n const attribute = layout.attributes.find(attribute => attribute.name === name);\n if (!attribute) {\n throw new Error(`Unknown attribute ${name}`);\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n"],"mappings":"AACA,SAAQA,kBAAkB,QAAO,cAAc;AAS/C,OAAO,SAASC,qBAAqBA,CAACC,MAAoB,EAAEC,SAA0B,EAA2B;EAC/G,MAAMC,mBAA4C,GAAG,EAAE;EACvD,MAAMC,cAAc,GAAG,IAAIC,G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C,GAAGW,UAAU,EAAE;IAC5C;EACF;EAEA,OAAOC,WAAW;AACpB;AAOA,SAASb,mBAAmBA,CAACb,MAAoB,EAAEc,IAAY,EAAEc,cAA2B,EAAmB;EAC7G,MAAMN,SAAS,GAAGtB,MAAM,CAACW,UAAU,CAACkB,IAAI,CAACP,SAAS,IAAIA,SAAS,CAACR,IAAI,KAAKA,IAAI,CAAC;EAC9E,IAAI,CAACQ,SAAS,EAAE;IACd,MAAM,IAAIQ,KAAK,sBAAAC,MAAA,CAAsBjB,IAAI,EAAG;EAC9C;EACA,IAAIc,cAAc,CAACL,GAAG,CAACT,IAAI,CAAC,EAAE;IAC5B,MAAM,IAAIgB,KAAK,wBAAAC,MAAA,CAAwBjB,IAAI,EAAG;EAChD;EACAc,cAAc,CAACD,GAAG,CAACb,IAAI,CAAC;EACxB,OAAOQ,SAAS;AAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAexC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAsJ9D,CAAC;AAgCF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
|
|
@@ -2,68 +2,72 @@ function addDepthStencil(descriptor) {
|
|
|
2
2
|
descriptor.depthStencil = descriptor.depthStencil || {
|
|
3
3
|
format: 'depth24plus',
|
|
4
4
|
stencilFront: {},
|
|
5
|
-
stencilBack: {}
|
|
5
|
+
stencilBack: {},
|
|
6
|
+
depthWriteEnabled: undefined,
|
|
7
|
+
depthCompare: undefined
|
|
6
8
|
};
|
|
9
|
+
return descriptor.depthStencil;
|
|
7
10
|
}
|
|
8
|
-
|
|
9
11
|
export const PARAMETER_TABLE = {
|
|
10
12
|
cullMode: (parameter, value, descriptor) => {
|
|
13
|
+
descriptor.primitive = descriptor.primitive || {};
|
|
11
14
|
descriptor.primitive.cullMode = value;
|
|
12
15
|
},
|
|
13
16
|
frontFace: (parameter, value, descriptor) => {
|
|
17
|
+
descriptor.primitive = descriptor.primitive || {};
|
|
14
18
|
descriptor.primitive.frontFace = value;
|
|
15
19
|
},
|
|
16
20
|
depthWriteEnabled: (parameter, value, descriptor) => {
|
|
17
|
-
addDepthStencil(descriptor);
|
|
18
|
-
|
|
21
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
22
|
+
depthStencil.depthWriteEnabled = value;
|
|
19
23
|
},
|
|
20
24
|
depthCompare: (parameter, value, descriptor) => {
|
|
21
|
-
addDepthStencil(descriptor);
|
|
22
|
-
|
|
25
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
26
|
+
depthStencil.depthCompare = value;
|
|
23
27
|
},
|
|
24
28
|
depthFormat: (parameter, value, descriptor) => {
|
|
25
|
-
addDepthStencil(descriptor);
|
|
26
|
-
|
|
29
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
30
|
+
depthStencil.format = value;
|
|
27
31
|
},
|
|
28
32
|
depthBias: (parameter, value, descriptor) => {
|
|
29
|
-
addDepthStencil(descriptor);
|
|
30
|
-
|
|
33
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
34
|
+
depthStencil.depthBias = value;
|
|
31
35
|
},
|
|
32
36
|
depthBiasSlopeScale: (parameter, value, descriptor) => {
|
|
33
|
-
addDepthStencil(descriptor);
|
|
34
|
-
|
|
37
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
38
|
+
depthStencil.depthBiasSlopeScale = value;
|
|
35
39
|
},
|
|
36
40
|
depthBiasClamp: (parameter, value, descriptor) => {
|
|
37
|
-
addDepthStencil(descriptor);
|
|
38
|
-
|
|
41
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
42
|
+
depthStencil.depthBiasClamp = value;
|
|
39
43
|
},
|
|
40
44
|
stencilReadMask: (parameter, value, descriptor) => {
|
|
41
|
-
addDepthStencil(descriptor);
|
|
42
|
-
|
|
45
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
46
|
+
depthStencil.stencilReadMask = value;
|
|
43
47
|
},
|
|
44
48
|
stencilWriteMask: (parameter, value, descriptor) => {
|
|
45
|
-
addDepthStencil(descriptor);
|
|
46
|
-
|
|
49
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
50
|
+
depthStencil.stencilWriteMask = value;
|
|
47
51
|
},
|
|
48
52
|
stencilCompare: (parameter, value, descriptor) => {
|
|
49
|
-
addDepthStencil(descriptor);
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
54
|
+
depthStencil.stencilFront.compare = value;
|
|
55
|
+
depthStencil.stencilBack.compare = value;
|
|
52
56
|
},
|
|
53
57
|
stencilPassOperation: (parameter, value, descriptor) => {
|
|
54
|
-
addDepthStencil(descriptor);
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
59
|
+
depthStencil.stencilFront.passOp = value;
|
|
60
|
+
depthStencil.stencilBack.passOp = value;
|
|
57
61
|
},
|
|
58
62
|
stencilFailOperation: (parameter, value, descriptor) => {
|
|
59
|
-
addDepthStencil(descriptor);
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
64
|
+
depthStencil.stencilFront.failOp = value;
|
|
65
|
+
depthStencil.stencilBack.failOp = value;
|
|
62
66
|
},
|
|
63
67
|
stencilDepthFailOperation: (parameter, value, descriptor) => {
|
|
64
|
-
addDepthStencil(descriptor);
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
69
|
+
depthStencil.stencilFront.depthFailOp = value;
|
|
70
|
+
depthStencil.stencilBack.depthFailOp = value;
|
|
67
71
|
},
|
|
68
72
|
sampleCount: (parameter, value, descriptor) => {
|
|
69
73
|
descriptor.multisample = descriptor.multisample || {};
|
|
@@ -78,16 +82,11 @@ export const PARAMETER_TABLE = {
|
|
|
78
82
|
descriptor.multisample.alphaToCoverageEnabled = value;
|
|
79
83
|
},
|
|
80
84
|
colorMask: (parameter, value, descriptor) => {
|
|
81
|
-
addColorState(descriptor);
|
|
82
|
-
const targets = descriptor.fragment.targets;
|
|
85
|
+
const targets = addColorState(descriptor);
|
|
83
86
|
targets[0].writeMask = value;
|
|
84
87
|
},
|
|
85
88
|
blendColorOperation: (parameter, value, descriptor) => {
|
|
86
89
|
addColorState(descriptor);
|
|
87
|
-
const targets = descriptor.fragment.targets;
|
|
88
|
-
targets[0].blend = targets[0].blend || {};
|
|
89
|
-
targets[0].blend.color = targets[0].blend.color || {};
|
|
90
|
-
targets[0].blend.color.operation = value;
|
|
91
90
|
}
|
|
92
91
|
};
|
|
93
92
|
const DEFAULT_PIPELINE_DESCRIPTOR = {
|
|
@@ -103,32 +102,36 @@ const DEFAULT_PIPELINE_DESCRIPTOR = {
|
|
|
103
102
|
module: undefined,
|
|
104
103
|
entryPoint: 'main',
|
|
105
104
|
targets: []
|
|
106
|
-
}
|
|
105
|
+
},
|
|
106
|
+
layout: 'auto'
|
|
107
107
|
};
|
|
108
|
-
export function applyParametersToRenderPipelineDescriptor(pipelineDescriptor
|
|
109
|
-
|
|
108
|
+
export function applyParametersToRenderPipelineDescriptor(pipelineDescriptor) {
|
|
109
|
+
let parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
110
|
+
Object.assign(pipelineDescriptor, {
|
|
111
|
+
...DEFAULT_PIPELINE_DESCRIPTOR,
|
|
110
112
|
...pipelineDescriptor
|
|
111
113
|
});
|
|
112
114
|
setParameters(pipelineDescriptor, parameters);
|
|
113
115
|
}
|
|
114
|
-
|
|
115
116
|
function setParameters(pipelineDescriptor, parameters) {
|
|
116
117
|
for (const [key, value] of Object.entries(parameters)) {
|
|
117
118
|
const setterFunction = PARAMETER_TABLE[key];
|
|
118
|
-
|
|
119
119
|
if (!setterFunction) {
|
|
120
120
|
throw new Error("Illegal parameter ".concat(key));
|
|
121
121
|
}
|
|
122
|
-
|
|
123
122
|
setterFunction(key, value, pipelineDescriptor);
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
|
-
|
|
127
125
|
function addColorState(descriptor) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (descriptor.fragment
|
|
131
|
-
|
|
126
|
+
var _descriptor$fragment, _descriptor$fragment2, _descriptor$fragment3, _descriptor$fragment4, _descriptor$fragment5;
|
|
127
|
+
descriptor.fragment.targets = ((_descriptor$fragment = descriptor.fragment) === null || _descriptor$fragment === void 0 ? void 0 : _descriptor$fragment.targets) || [];
|
|
128
|
+
if (!Array.isArray((_descriptor$fragment2 = descriptor.fragment) === null || _descriptor$fragment2 === void 0 ? void 0 : _descriptor$fragment2.targets)) {
|
|
129
|
+
throw new Error('colorstate');
|
|
130
|
+
}
|
|
131
|
+
if (((_descriptor$fragment3 = descriptor.fragment) === null || _descriptor$fragment3 === void 0 ? void 0 : (_descriptor$fragment4 = _descriptor$fragment3.targets) === null || _descriptor$fragment4 === void 0 ? void 0 : _descriptor$fragment4.length) === 0) {
|
|
132
|
+
var _descriptor$fragment$;
|
|
133
|
+
(_descriptor$fragment$ = descriptor.fragment.targets) === null || _descriptor$fragment$ === void 0 ? void 0 : _descriptor$fragment$.push({});
|
|
132
134
|
}
|
|
135
|
+
return (_descriptor$fragment5 = descriptor.fragment) === null || _descriptor$fragment5 === void 0 ? void 0 : _descriptor$fragment5.targets;
|
|
133
136
|
}
|
|
134
137
|
//# sourceMappingURL=webgpu-parameters.js.map
|