Questions tagged [webgpu]

API that exposes GPU capabilities to web browsers. Use this tag with questions on programming against WebGPU.

Links:

76 questions
0
votes
1 answer

Why webgpu stencil buffer 2d clipping result invisible when antialias enabled?

Here is normal stencil buffer 2d clipping result and one extra triangle: const code = ` struct VSIn { @location(0) pos: vec4f, }; struct VSOut { @builtin(position) pos: vec4f, }; @vertex fn vs(vsIn: VSIn) -> VSOut { var vsOut: VSOut; …
plantain
  • 43
  • 1
  • 8
0
votes
1 answer

How to bloom effect in WebGPU without FBO?

In WebGL we are able to render to framebufferobject and then use it as a texture so that another shader module is able to load it and calculate bloom effect. In WebGPU we no longer get framebufferobject. The responsibilities of FBO are split into…
jiyinyiyong
  • 4,586
  • 7
  • 45
  • 88
0
votes
0 answers

webgpu/types dependency conflict in package.lock.json

I have a dependency conflict in my project, I am getting this error: node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:18:23 - error TS4090: Conflicting definitions for '@webgpu/types/dist' found; In package.lock.json, there's clearly a…
0
votes
0 answers

Bevy - Render to wgpu::Texture

I am looking for an elegant and hopefully bevy-esque way of rendering to a wgpu::Texture. The reason is that I'm am implementing a WebXR libary and the WebXRFramebuffer must be rendered to in immersive XR. let framebuffer = //get framebuffer from…
chantey
  • 4,252
  • 1
  • 35
  • 40
0
votes
1 answer

SDF WebGPU. How to modify the code for SDF purpose like in ShaderToy.com?

I want to create a WebGPU version of Shadertoy, but I can't to prepare the code correctly. How to draw in @fragment shader for SDF in WebGPU ? I clipped space [-1,1, 1,1, -1,-1, 1,-1] of canvas but what I need to do next ?
Teamur
  • 67
  • 1
  • 4
0
votes
1 answer

What are WEBGPU workgroup_size limits?

I have simple compute shader like: @compute @workgroup_size(x, y, z) fn main(@builtin(global_invocation_id) global_id : vec3) { ... } where x, y and z are some integers. But I suppose the size of a data, I want to handle will be super…
Nikolai
  • 656
  • 6
  • 19
0
votes
1 answer

How can I declare and use a *constant* array in a WGSL vertex shader?

Background I'm trying to render a single triangle by encoding the vertices directly in my WGSL vertex shader. My idea was to have a global constant array, TRI_VERTICES contain the vertices of the triangle, from which I will look up the appropriate…
statusfailed
  • 738
  • 4
  • 15
0
votes
1 answer

The undetected support of timestamp-query extension when using Chrome canary and WebGPU

Description Hi guys! I am studying to use Tensorflow.js to run DNN in the Web browser with WebGPU feature. Example #1 So, I first use the MobileNet example (Source) of Tensorflow.js as an initial point. However, the example does not use the WebGPU…
0
votes
1 answer

Are GPUCommandBuffer reusable? How to update input data buffers between invocations?

It seems to me that I have to create a new GPUCommandBuffer every time I want to run the computation with different input values (either uniform or storage). I tried loading new data into an existing staging buffer (with mapAsync) and running an…
Tobia
  • 17,856
  • 6
  • 74
  • 93
0
votes
1 answer

WebGPU best practices with setPipeline and optimization

I'm learning WebGPU for the first time and, in the tutorials I'm following, I see that setPipeline is called on each rendering pass. I'm wondering if there's a performance hit if the pipeline is changed between passes? Most of the tutorials I'm…
Mike
  • 716
  • 4
  • 10
0
votes
0 answers

How to disable filtering on canvas with webgpu context

I use webgpu to render to canvas. I need pixelated result but got blurred. I tried to disable it with css .canvas { image-rendering: pixelated; transform: scale(32); transform-origin: top left; } What I got: blurred image What I…
Defernus
  • 11
  • 3
0
votes
1 answer

How to use a random number within WGSL?

I'm trying to create a fragment shader in a WebGPU application for rendering a black white image noise. White_noise (wikipedia) For this I just want each pixel to have a random color value like this: [[stage(fragment)]] fn main() -> [[location(0)]]…
Michael Hilus
  • 1,647
  • 2
  • 21
  • 42
0
votes
1 answer

Deriving transformation matrix in wgsl shader

Deriving the transformation matrix is a fairly common requirement for shaders. Are there and wgsl standard libraries for doing this sort of thing? i.e. even mat4x4 - mat4x4 multiplication would be useful! I've written a rough draft below, but it…
0
votes
1 answer

WebGPU: change texture at runtime

I know how to change matrices using queue.writeBuffer. But what is the correct/recommend way to switch textures or samplers inside the rendering loop? Or do I need one pipeline per texture? thx in advance
Peter Grundmann
  • 115
  • 1
  • 10
-1
votes
2 answers

Does webGPU sort the fragments by depth?

I imagine this may be obvious and implicit to someone familiar with 3d graphics, but having read through the webgpu documentation (https://www.w3.org/TR/webgpu/) I have not been able to figure out the order in which fragment shader outputs are…
Jatentaki
  • 11,804
  • 4
  • 41
  • 37