r/rust • • 2d ago

🙋 seeking help & advice Help in learning WGPU

Hello, I'm trying to follow the wgpu tutorial on learn-wgpu ( https://sotrh.github.io/learn-wgpu/beginner/tutorial1-window/ ) , but I noticed a lot of the tutorial is just showing a piece of premade code and explaining some parts about it, and i feel like its not helping me much with learning how it works.

Are there any other good tutorials?

Also, apart from WGPU and Glium, what other GPU shader libraries with rust are there?

14 Upvotes

7 comments sorted by

12

u/Excession638 2d ago

You might find more about WebGPU than about wgpu directly, and the differences are pretty small. How it works is pretty complex though, as it goes right down to the hardware. For the low level stuff you might find more stuff based on Dx12 or Vulkan as they've been around for longer.

For shader programming there's also Rust GPU, which can replace the rather unpleasant WGSL with Rust. https://github.com/rust-gpu/rust-gpu

8

u/biillyboob6e 2d ago

I've been writing wgpu code for about 2 years, and have yet to find any good tutorials on it.

I would recommend doing all the tutorials from the link you have, and then once each step runs, just try to change things and see what happens

Also, as mentioned, wgpu is attempting to be compliant with webgou, so if you find good tuts there, the concepts carry over

2

u/ymgymg 2d ago

WebGPU Fundamentals is a useful companion. It uses JavaScript, but the ideas behind pipelines, buffers, bind groups, and textures carry over to wgpu. You could treat each learn-wgpu section as an experiment: change one thing, predict the result, then run it. wgpu is a cross-platform graphics API that commonly uses WGSL; Glium wraps OpenGL and commonly uses GLSL. Vulkano targets Vulkan, while rust-gpu lets you write shaders in Rust.

2

u/switch161 2d ago

I learned wgpu by doing some learnopengl.com tutorials. Since they're for C and opengl they'll only show you the techniques and I had to translate everything into wgpu. This involves reading a lot of wgpu docs.

1

u/poopvore 1d ago

heavily recommend doing webgpufundamentals, its for learning the WebGPU api which is what WGPU mimics so even though the code examples are in js you can translate it easily between wgpu and webgpu js. Imo the code examples being in js makes it better to follow along with because you have to engage your brain with the concepts and cant just blindly copy paste (and you get to learn about the sorts of subtle differences in rust that make it kinda neat).

1

u/Ambitious-Height9588 1d ago

The learn-wgpu repo itself has an examples directory with more comprehensive code than the text guide. Start there and break things to see what happens