Questions tagged [wgpu-rs]

wgpu-rs is a Rust implementation of the WebGPU specification.

wgpu-rs is a Rust wrapper around wgpu-core which provides back-ends for

  • DirectX 11 and 12
  • Vulkan
  • Metal
  • OpenGL (experimental)

wgpu-rs is released on Github under the Mozilla Public License 2.0. Examples and basic information can be found in the README and on the Wiki page.

An excellent Tutorial for how to get started can be found here.

55 questions
6
votes
1 answer

Is it possible to index dynamically into a WebGPU storage buffer?

I'm trying write a WGSL shader that reads an octree that is stored in a storage buffer. The problem is, the compiler doesn't like the dynamic index I'm calculating to access leaves in the storage buffer. wgpu produces the following validation…
iLoch
  • 741
  • 3
  • 11
  • 32
4
votes
2 answers

Window resize "jitter" using wgpu-ris and winit

I'm experimenting with some rust code that is a slight re-structuring of the code shown in the Learn WGPU tutorial, including the addition of a uniform transform to draw objects at fixed (pixel) locations and sizes. I notice that when I resize my…
plast1k
  • 793
  • 8
  • 15
3
votes
1 answer

Setting Scissor Rectangle before Clearing

I am currently converting some code from using OpenGL to WGPU, and I have hit a problem I can't seem to resolve. In my original code, I set the scissor rectangle before clearing the render area, as I want to keep most of my framebuffer intact and…
3
votes
1 answer

Set color for the whole mesh but not every vertex

I want to optimize size of vertex buffer. Currently my layout for VBO is: x y | r g b a It's consumed by shader like this: struct VertexInput { @location(0) position: vec2, @location(1) color: vec4, } And I'm storing mesh in buffer…
FoxPro
  • 2,054
  • 4
  • 11
  • 34
3
votes
1 answer

How can I change uniforms during a render pass in wgpu?

I'm currently working in wgpu in order to reap the efficiency benefits over OpenGl. A common pattern in my previous graphics code is to draw many meshes with separate buffers, separate uniform data, but the same shaders. It looks something like this…
john01dav
  • 1,842
  • 1
  • 21
  • 40
2
votes
1 answer

write_buffer doesn't write to buffer instead outputting zeros WGPU

Hello I have recently began learning compute shaders with wgpu and I'm having little difficulties figuring out how to correctly write data into a buffer. I have created a small buffer mapped to the cpu with this code. let array_buffer =…
LAYTOR
  • 381
  • 4
  • 12
2
votes
1 answer

Compute Shaders in Google chrome and Apple M1

I have a working physics simulator written in wgpu/rust that works when I am running from the command line. However, when I try to run on the chrome v114 (supported according to what I saw online), I get the following error saying the max number of…
Pap113
  • 37
  • 1
  • 7
2
votes
1 answer

WGSL atomics with multiple compute passes

I'm having an issue with atomics in wgpu / WGSL but I'm not sure if it's due to a fundamental misunderstanding or a bug in my code. I have a input array declared in WGSL as struct FourTileUpdate { // (u32 = 4 bytes) data: array
2
votes
1 answer

Why can I only have a single Texture binding in my wgpu bind group?

I currently have a BindGroup and BindGroupLayout which looks like this: let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { label: None, entries: &[wgpu::BindGroupLayoutEntry { binding: 0, …
frankenapps
  • 5,800
  • 6
  • 28
  • 69
2
votes
0 answers

How to use ggez + imgui + wgpu?

In my game I need to render some in-game textures into UI (I'm using ggez 0.8.1 and imgui 0.8.0). As ggez 0.8.1 uses wgpu for rendering I need to use wgpu backend for imgui. So there's my question: how can I render imgui's DrawData inside ggez's…
mertwole
  • 49
  • 4
2
votes
1 answer

gfx-rs/wgpu wgsl examples uses @ instead of [[]]

I have been learning wgpu over the past few days and I have one point of confusion. When I browse athe wgpu examples (https://github.com/gfx-rs/wgpu/tree/master/wgpu/examples) they use this syntax for their shaders: struct VertexOutput { …
2
votes
2 answers

wgpu doesn't render with alpha channels

I am trying to render a semi-transparent png-image with wgpu. I have an issue where some of the pixels that shouldn't be showing are showing. For example in the left of my image there is a gray (128, 128, 128) block, which has alpha value of 0,…
joohei
  • 33
  • 5
2
votes
2 answers

wgpu Compute Write Direct to Surface Texture View

I am relatively new to using gpu apis, even newer to wgpu, and wanted to mess around with compute shaders drawing to a surface. However, it seems that this is not allowed directly? During run time upon attempting to create a binding to the texture…
BayL
  • 23
  • 4
1
vote
1 answer

WGSL get different results even using the same data

I am new to WGSL. I am following the tuorial of wgpu to write my first traingle. The correct shader is like this // Vertex shader struct VertexOutput { @builtin(position) clip_position: vec4, @location(0) position:…
qiuweikang
  • 47
  • 4
1
vote
0 answers

type numbers to names in wgsl

I have recently tried to save a arrayLength(&inArr) into i32 but I ended up getting this error. ┌─ gpu_test:24:9 │ 24 │ outArr[i] = arrLen; │ ^^^^^^^^^ naga::Expression [40] Entry point main at Compute is invalid …
LAYTOR
  • 381
  • 4
  • 12
1
2 3 4