Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WGSLNodeBuilder: Sampler for compute shader #30033

Merged
merged 6 commits into from
Dec 8, 2024

Conversation

Spiri0
Copy link
Contributor

@Spiri0 Spiri0 commented Dec 4, 2024

Enables the use of samplers in compute shaders because textureSampleLevel is usable in compute shaders.

Arrays are not currently taken into account by the wgslTypeLib. However, with the struct extension mrdoob#29908, arrays will also become important as a type.
Since textureSampleLevel is usable in compute shaders, this small PR allows sampler to be used in compute shaders for this purpose
Copy link

github-actions bot commented Dec 4, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.11
78.98
339.11
78.98
+0 B
+0 B
WebGPU 484.77
134.58
484.81
134.6
+45 B
+14 B
WebGPU Nodes 484.23
134.49
484.28
134.51
+45 B
+18 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465
112.04
465
112.04
+0 B
+0 B
WebGPU 554.1
150
554.15
150.02
+45 B
+17 B
WebGPU Nodes 509.98
139.72
510.03
139.73
+45 B
+15 B

@Mugen87 Mugen87 added this to the r172 milestone Dec 7, 2024
@sunag sunag changed the title Sampler for compute shader WGSLNodeBuilder: Sampler for compute shader Dec 8, 2024
@sunag sunag merged commit 3a581bf into mrdoob:dev Dec 8, 2024
12 checks passed
Spiri0 added a commit to Spiri0/three.js that referenced this pull request Dec 12, 2024
…ilder.js

The depth textures were excluded from the sampling by the compare. But depth textures are sampleable in WebGPU. But even if you don't sample, you can use the sampler for textureSampleLevel. Instead of screen coordinates like you have to use in the case of textureLoad, you can use uv coordinates with textureSampleLevel and mip 0, which is very practical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants