ThreeJS' examples' WebGPU backend don't work
Categories
(Core :: Graphics: WebGPU, defect)
Tracking
()
People
(Reporter: ErichDonGubler, Unassigned)
References
(Depends on 2 open bugs, Blocks 1 open bug, )
Details
User Story
Status and triage notes: https://hackmd.io/qNR5JQJQRamArlF1G3neBA
| Reporter | ||
Comment 1•2 years ago
•
|
||
Blockers I observed:
- The vast majority of examples are blocked by failing to parse
diagnosticdirectives (bug 1882800). - Many examples emitted errors because the
GPUDevice.createQuerySetAPI is not yet exposed (bug 1838729). Many of these crashed after these errors were emitted many times over a few seconds. π¬ - Automatic type conversion (bug 1829879)
compute / particles / snow / externalseems to fail on a CORS error. π³ Not sure if that's a bug on our end yet.compute / texture / pingponghas some issues with awriteTex: texture_storage_2d<rgba16float, write>argument, not sure why yet.- Many examples emitted errors with
GPUQueue.copyExternalImageToTexture: 'source' member of GPUImageCopyExternalImage could not be converted to any of: ImageBitmap, HTMLCanvasElement, OffscreenCanvas.(ETA: bug 1921454) loader / gltf / compressedand many others emitted this error:GPUDevice.createTexture: 'etc2-rgb8unorm-srgb' (value of 'format' member of GPUTextureDescriptor) is not a valid value for enumeration GPUTextureFormat.(ETA: bug 1917059)
| Reporter | ||
Comment 2•2 years ago
|
||
Ah, the texture_storage_2d<β¦, write> error must be that our implementation of WGSL doesn't yet support the readonly_and_readwrite_storage_textures extension. Filed bug 1916464 to track this.
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Comment 3•1 year ago
|
||
Ah, the GPUQueue.copyExternalImageToTexture error is bug 1921454.
| Reporter | ||
Comment 4•1 year ago
|
||
Ah, the etc2-rgb8unorm-srgb error is bug 1917059.
Comment 5•1 year ago
•
|
||
As part of Bug 1914934, I checked all the other examples (158 total), 19 are still failing:
Missing unrestricted_pointer_parameters language extension (https://github.com/gfx-rs/wgpu/issues/5158)
https://threejs.org/examples/?q=webgpu#webgpu_compute_texture_pingpong
Shader validation error: Function [3] 'computePingPongWGSL' is invalid
ββ compute:48:1
β
48 β β fn computePingPongWGSL ( readTex: texture_storage_2d<rgba16float, read>, writeTex: texture_storage_2d<rgba16float, write>, index: u32 ) {
β ^^^^^^^^ naga::Expression [1]
49 β β
50 β β let posX = index % 512;
51 β β let posY = index / 512;
Β· β
55 β β
56 β β textureStore( writeTex, indexUV, vec4f( color * 1.05, 1 ) );
β β°ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ^ naga::Function [3]
β
= Image store parameters are invalid
= Not a global variable
i32 constructor needs to support abstract floats (https://github.com/gfx-rs/wgpu/issues/7312)
https://threejs.org/examples/?q=webgpu#webgpu_lights_tiled
Shader 'fragment' parsing error: abstract floating-point values cannot be automatically converted to integers
ββ wgsl:142:192
β
142 β nodeVar13 = textureLoad( nodeUniform13, vec2<i32>( ( lightIndexes.value[ u32( ( ( ( nodeVar2.x + ( nodeVar2.y * 46.0 ) ) * 2.0 ) + f32( ( ( i ) / 4 ) ) ) ) ][ u32( ( ( i ) % 4 ) ) ] - 1 ), i32( 0.0 ) ), u32( 0u ) );
β ^^^^^^^^^^ see msg
Odd issue
https://threejs.org/examples/?q=webgpu#webgpu_materials
Spams console with:
Uncaught TypeError: can't access property "mipLevelCount", textureData.texture is undefined
However, if you reload the window a couple of times, it starts working; sounds like the example is trying to use the texture but it hasn't been loaded yet.
importExternalTexture is missing (needed for video frame import; Bug 1827116)
https://threejs.org/examples/?q=webgpu#webgpu_materials_video
Uncaught DOMException: VideoFrame constructor: The video is not ready yet
Uncaught TypeError: device.importExternalTexture is not a function
https://threejs.org/examples/?q=webgpu#webgpu_video_frame
https://threejs.org/examples/?q=webgpu#webgpu_video_panorama
Uncaught TypeError: device.importExternalTexture is not a function
Fixed recently by https://github.com/gfx-rs/wgpu/pull/7058, should work with the next wgpu update
https://threejs.org/examples/?q=webgpu#webgpu_custom_fog_background
https://threejs.org/examples/?q=webgpu#webgpu_postprocessing_dof
https://threejs.org/examples/?q=webgpu#webgpu_reflection
https://threejs.org/examples/?q=webgpu#webgpu_skinning_instancing
Shader validation error: Entry point main at Fragment is invalid
ββ fragment_Gaussian_blur:77:13
β
77 β nodeVar3 = textureLoad( nodeUniform3, vec2<u32>(tsl_coord_clampS_clamp_2dT(nodeVarying3) * vec2<f32>(nodeVar4)), u32( 0 ) );
β ^^^^^^^^^^^ naga::Expression [42]
β
= Expression [42] is invalid
= Image sample or level-of-detail index's type of [41] is not an integer scalar
indirect draw (https://github.com/gfx-rs/wgpu/pull/7140)
https://threejs.org/examples/?q=webgpu#webgpu_struct_drawindirect
Uncaught TypeError: passEncoderGPU.drawIndirect is not a function
https://threejs.org/examples/?q=webgpu#webgpu_particles
Uncaught TypeError: passEncoderGPU.drawIndexedIndirect is not a function
3D render attachments (https://github.com/gfx-rs/wgpu/issues/4764)
https://threejs.org/examples/?q=webgpu#webgpu_postprocessing_3dlut
https://threejs.org/examples/?q=webgpu#webgpu_rendertarget_2d-array_3d
https://threejs.org/examples/?q=webgpu#webgpu_volume_cloud
https://threejs.org/examples/?q=webgpu#webgpu_volume_lighting
https://threejs.org/examples/?q=webgpu#webgpu_volume_lighting_rectarea
https://threejs.org/examples/?q=webgpu#webgpu_volume_perlin
Uncaptured WebGPU error: Texture usages TextureUsages(RENDER_ATTACHMENT) are not allowed on a texture of dimensions D3
2D-array render attachments (https://github.com/gfx-rs/wgpu/issues/7313)
https://threejs.org/examples/?q=webgpu#webgpu_rendertarget_2d-array_3d
In a pass parameter, caused by: The color attachment at index 0's texture view is not renderable:, caused by: The dimension of this texture view is not 2D. View dimension: D2Array
Updated•1 year ago
|
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Comment 6•1 year ago
|
||
I've made Bugzilla entries for each of the blockers in comment 5 that are definitely WGPU's fault, and added them to this bug's dependencies. That ought to help us prioritize those issues. π
| Reporter | ||
Updated•1 year ago
|
Comment 7•1 year ago
|
||
Even with bug 1930972, https://threejs.org/examples/?q=webgpu#webgpu_struct_drawindirect fails with:
Shader validation error: Function [0] 'compute' is invalid
ββ compute:27:1
β
27 β β fn compute ( drawBuffer: ptr< storage, DrawBuffer, read_write >, ) {
28 β β
29 β β drawBuffer.vertexCount = 3u;
30 β β atomicStore(&drawBuffer.instanceCount, 0u);
31 β β drawBuffer.firstVertex = 0u;
32 β β drawBuffer.firstInstance = 0u;
33 β β drawBuffer.offset = 0u;
β β°βββββββββββββββββββββββββββββββββββββββββββββββ^ naga::ir::Function [0]
β
= Argument 'drawBuffer' at index 0 is a pointer of space Storage { access: StorageAccess(LOAD | STORE) }, which can't be passed into functions.
Comment 8•1 year ago
|
||
That is another instance of Bug 1952974.
Updated•1 year ago
|
Comment 9•1 year ago
|
||
https://threejs.org/examples/?q=webgpu#webgpu_lights_tiled is now working.
Updated triage notes: https://hackmd.io/qNR5JQJQRamArlF1G3neBA
Updated•1 year ago
|
Comment 10•1 year ago
|
||
(In reply to Teodor Tanasoaia [:teoxoy] from comment #8)
That is another instance of Bug 1952974.
Should the upstream example be adjusted to check for this extension and fail more gracefully?
Also, is it possible to improve our error message so that it might be clearer what's going on?
| Reporter | ||
Comment 11•1 year ago
|
||
:jrmuizel:
Should the upstream example be adjusted to check for this extension and fail more gracefully?
Absolutely. If they used requires unrestricted_pointer_parameters; in their shaders, diagnostics would be better. This bad diagnostic experience is actually one of the downsides we considered at length in the GPU for Web committee in W3C; making it so one isn't required to opt into a language sure seemed and seems like a recipe for no web authors actually doing it. π
See also: https://www.w3.org/TR/WGSL/#language-extensions-sec
Also, is it possible to improve our error message so that it might be clearer what's going on?
Yes, though it's not clear that the effort to improve the diagnostic is significantly less than simply supporting the extension in the first place.
I'll leave the NI for Teo open in case he wants to add something.
Updated•1 year ago
|
Comment 12•1 year ago
|
||
With a nightly containing bug 1962269 https://threejs.org/examples/?q=webgpu#webgpu_skinning_instancing fails with:
Shader validation error: Entry point main at Fragment is invalid
ββ fragment_Gaussian_blur:77:13
β
77 β nodeVar3 = textureLoad( nodeUniform3, vec2<u32>( tsl_coord_clampS_clamp_2dT( nodeVarying3 ) * vec2<f32>( nodeVar4 ) ), u32( 0 ) );
β ^^^^^^^^^^^ naga::ir::Expression [42]
β
= Expression [42] is invalid
= Image sample or level-of-detail index's type of [41] is not an integer scalar
Comment 13•1 year ago
|
||
It looks like the validator is missing support for the textureLoad overloads with sample_index: u32.
https://github.com/gfx-rs/wgpu/pull/7058 only addressed the level params.
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Comment 14•1 year ago
|
||
Filed bug 1962481 to track the sample index typing bug.
Updated•1 year ago
|
Comment 15•1 year ago
|
||
I tested the examples that should be fixed by Bug 1952976, Bug 1952979 and Bug 1962481 locally with the latest wgpu update (Bug 1963329) and they are all working now.
We are now down to 6 examples that don't work.
Updated triage notes: https://hackmd.io/qNR5JQJQRamArlF1G3neBA
Updated•1 year ago
|
Comment 16•11 months ago
|
||
I tried all examples on macOS and added the findings to the same hackmd doc.
The 2 new issues the examples are running into are: Bug 1958017 (macOS only) and Bug 1834395 (platform agnostic).
Updated•11 months ago
|
| Reporter | ||
Comment 17•6 months ago
|
||
External texture support has landed, but these demos are still not working:
- https://threejs.org/examples/?q=webgpu#webgpu_materials_video
- https://threejs.org/examples/?q=webgpu#webgpu_video_panorama
https://threejs.org/examples/?q=webgpu#webgpu_video_frame also still doesn't work, but that's expected, since bug 1749539 isn't implemented yet.
Description
•