Live data from Hacker News

WebGPU Fundamentals

webgpufundamentals.org

161–170 of 211 posts

Re: WebGPU Fundamentals

#161
post #73

I wish they had kept the c/c++ syntax style for WGSL, the rust syntax is just awful and alienating.

Not sure how it remotely looks “awful and alienating”. It looks like basically every recent language to me (swift/kotlin/rust/typescript). I feel like you just saw something that has the same numeric type names as Rust and jumped to conclusions.

Re: WebGPU Fundamentals

#162
post #123
post #85

Earlier quoted context omitted.

Because it's really cool to try out experimental instruments other poeple have made by simply opening a webpage, without having to execute untrusted native code that could have bad consequences.

Instead, you're executing untrusted browser code, which is hardly better.

I don't understand how you can possibly say this with a straight face.

Re: WebGPU Fundamentals

#163
It is sad that WebGPU has pretty poor support under Linux apparently. Even more so, that it builds on Vulkan which isn't fully supported on older architectures (like Haswell.)

Re: WebGPU Fundamentals

#164

Earlier quoted context omitted.

> Because after seeing WebUSB and WebGPU I think my personal limit has been reached. Sure, but where do you draw the line really? For me, having WebUSB and WebMIDI for example is useful, I want to be able to interact with synths over MIDI in the browser, or be able to access other accessories. I also love the idea of GPU access, so my personal limit has not been reached. Multiply this by every vendor, developer and u…

I want to be able to interact with synths over MIDI in the browser Help me understand why this is. Is it because there aren't native programs for the platform you're using? Is it to allow plug-ins or other abilities that wouldn't otherwise be available? Is it so that you can sync up with other musicians and play together in a way that wouldn't be possible without a browser? choose a browser that doesn't implement tho…

> Help me understand why this is. Is it because there aren't native programs for the platform you're using?

Easier to create, easier to share and run. Mainly easier to create because the ones I'm sharing small MIDI sequencer experiments with are also web developers, so we just send each other links where we can run stuff direction from, and we can help each other out as we all use the same technology. Really easy to understand what the other is doing too, as you just open up the source of the page and that's it.

I've played around with other languages/runtimes for doing the same thing, but nothing is as fast to implement as with JavaScript, probably mostly due to familiarity.

Re: WebGPU Fundamentals

#165
post #19

Question for discussion: when have we reached the point where the Browser Feature-creep is too much and we say "okay, a browser probably doesn't need this"? Because after seeing WebUSB and WebGPU I think my personal limit has been reached.

It will stop once it's easier, more reliable and more secure to run someone's code outside your browser.

Re: WebGPU Fundamentals

#166

Earlier quoted context omitted.

From personal experience, if you're trying to make a game that cares about its frame rate, do not ever use the DOM for anything, ever. It routinely takes several frames to layout a single absolutely positioned element. I recommend the second option. Rasterize your font with stb_truetype to a bitmap, and draw quads yourself

I'm curious, isn't something like a HUD a perfect thing to render in a DOM overlay? It shouldn't matter that much if it takes a few frames to layout and/or update your ammo count or whatever.

It wouldn't matter if the DOM layout engine ran on a separate thread, but it runs on the main thread, so it blocks your games update loop for a few frames every time you shoot, or whatever.

Now, that's not to say it has to be that way; real engines have a separate render thread that would sort of solve that problem. And they run the game update code in parallel, and all kinds of other stuff. But, by the time you have all that stuff, you can probably rasterize a font and draw quads ;)

But don't take my word for it. Maybe it's better now. Make a thing that moves some divs around in a requestAnimationFrame callback and take a look at the profile. I bet 2% of the time the layout engine takes 30ms+ to do basically nothing

Re: WebGPU Fundamentals

#168
post #167

Ah, this brings back memories of being blocked by Jonathan Blow on Twitter for poking fun at him for being really mean to the people who worked on WebGPU. https://i.imgur.com/ZDgXBXH.png

What is the “pollution” by WebGPU that he was referring to?

Re: WebGPU Fundamentals

#169

How do I render text with GPU? Do I render text on texture with CPU and then send that texture to GPU? Do I vectorize it and draw millions of tiny triangles to approximate those vectors? It's interesting for me to explore WebGPU as a canvas for app development, but it's not obvious to me how to draw text and text is everywhere.

One of the most exciting features of WebGPU, especially over WebGL, is the ability to run compute shaders. That opens up an entire class of 2D vector graphics rendering techniques using compute shaders, including Vello. It's still in early stages, but the current code does include text rendering. There's a very rough demo at https://levien.com/vello-demo (the demo doesn't do variable fonts but the code can), and we'l…

Is it (will it be) possible to use Vello from C++ or is this firmly Rust only?

Re: WebGPU Fundamentals

#170
post #116

Earlier quoted context omitted.

This is usually done with shaders and a circle of buffers which maintain state.

Total graphics / shaders / GPU noob here. Does that mean you'll essentially get free visualisations (albeit non-sensical ones) as a byproduct of your computations?

If you wanted to do compute in a shader before WebGPU with WebGL instead, then I think the answer is kind of yes. It wasn't "for free" without any code but it was required to do. But now WebGPU supports compute shaders properly so you don't have to do compute in a shader that produces textures.
Post reply on HN