Live data from Hacker News

How I learned Vulkan and wrote a small game engine with it (2024)

edw.is

61–70 of 107 posts

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#61
post #56

Earlier quoted context omitted.

As someone who has done this since DX7, what you’re looking for is WebGPU either Dawn (Google) or wgpu-native (Firefox). WebGPU works. It’s 99% there across platforms for use. There’s another wrapper abstraction we all love and use called BGFX that is nice to work with. Slightly higher level than Vulkan or Metal but lower than OpenGL. Works on everything, consoles, fridges, phones, cars, desktops, digital signage. My…

Personally I'm not interested in the web as a platform. The APIs themselves I'm interested in, but as a target I think the web needs to die for everything that isn't a document.

I never mentioned the web as a target, rather devices. You don’t need a browser, you need a window or a surface to draw on and use C/C++/Rust/C# to write your code.

WebGPU is a standard, not necessarily for the web alone.

At no point does a browser ever enter the picture.

https://eliemichel.github.io/LearnWebGPU/index.html

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#62
post #7

Earlier quoted context omitted.

`wgpu` in Rust is an excellent middle ground, matching the abstraction level of WebGPU. More capable than OpenGL, but you don’t have to deal with things like resource barriers and layout transitions. The reason you don’t is that it does an amount of bookkeeping for you at runtime, only supports using a single, general queue per device, and several other limitations that only matter when you want to max out the capabi…

How easy is it to integrate wgpu if the rest of your game is developed with a language that isn't rust? (e.g. C# or C++)

Webgpu.h is, AIUI, part of the webgpu spec. Both Dawn (Google’s C++ implementation used in Chrome) and wgpu (Mozilla’s implementation used in Firefox) can be used as concrete implementation of those headers.

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#63
post #9

Earlier quoted context omitted.

Interesting. I wouldn't actually mind learning how to do that; any tips on how/where to get started?

If you want to render 2d vs 3d there are different tradeofs, a 3d renderer has to do interpolation of attributes over triangles, a 2d renderer doesn't and as a result can render ngons without having to triangulate them. I'm just going to dump some links really quick, which should get anyone started. Getting a framebuffer on screen: https://github.com/zserge/fenster I would recommend something like SDL if you want a m…

This is a gold mine, thank you.

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#64
post #4

My opinions of Vulkan have not changed significantly since this was posted a year ago https://news.ycombinator.com/item?id=40601605 I'm sure Vulkan is fun and wonderful for people who really want low level control of the graphic stack, but I found it completely miserable to use. I still haven't really found a graphics API that works at the level I want that I enjoyed using; I would like to get more into graphics prog…

[deleted]

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#65
post #45

Earlier quoted context omitted.

If I were starting a new project, would it be unwise to just use OpenGL? It's what I'm used to, but people seem to talk about it as if it's deprecated or something. I know it is on Apple, but let's just assume I don't care about Apple specifically.

OpenGL is fine, it has the same issues now it had before but none of it really comes from "old age" or being deprecated in any way. It's not as debuggable and much harder to get good performance out of than the lower level APIs but beyond that it's still great. Honestly, starting out with OpenGL and moving to DX12 (which gets translated to Vulkan on Linux very reliably) is not a bad plan overall; DX12 is IMO a nicer…

What do you think makes DX12 better API than Vulkan?

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#66
post #56

Earlier quoted context omitted.

Personally I'm not interested in the web as a platform. The APIs themselves I'm interested in, but as a target I think the web needs to die for everything that isn't a document.

I never mentioned the web as a target, rather devices. You don’t need a browser, you need a window or a surface to draw on and use C/C++/Rust/C# to write your code. WebGPU is a standard, not necessarily for the web alone. At no point does a browser ever enter the picture. https://eliemichel.github.io/LearnWebGPU/index.html

It sounds like the standard did itself a disfavor by its name, more interesting in how you describe it.

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#67
post #66

Earlier quoted context omitted.

I never mentioned the web as a target, rather devices. You don’t need a browser, you need a window or a surface to draw on and use C/C++/Rust/C# to write your code. WebGPU is a standard, not necessarily for the web alone. At no point does a browser ever enter the picture. https://eliemichel.github.io/LearnWebGPU/index.html

It sounds like the standard did itself a disfavor by its name, more interesting in how you describe it.

Well, it started off with “all the right intentions” of providing low-level access to the GPU for browsers to expose as an alternative to WebGL (and OpenGL ES like API’s of old).

However, throw a bunch of engineers in a room…

When wgpu got mature enough, they needed a way to expose the rust API for other needs. The C wrapper came. Then for testing and other needs, wgpu-native. I’m not a member of either team so I can’t say why for sure but because of those decisions, we have this powerful abstraction available pretty much on anything that can draw a web page. And since it’s just exposing the buffers and things that Vulkan, Metal, etc are already based on, it’s damned fast.

The added benefit is you get WGSL as your shading language which can translate into any and all the others.

The downsides are it provides NO WINDOW support as that needs to be provided by the platform, i.e. you. Good news is the tests and stuff use glfw and it’s the same setup to get Vulkan working as it is to get WebGPU working. Make window, probe it, make surface/swap chain, start your threads.

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#68

Earlier quoted context omitted.

SDL 3.0 introduced their GPU API a year or so ago, which is an abstraction layer on top of vulkan/others, might want to check it out. Although after writing an entire engine with it, I ended up wanting more control, more perf, and to not be limited by the lowest common denominator limits of the various backends, and just ended up switching back to a Vulkan-based engine. However, I took a lot of learnings from the SDL…

SDL GPU is extremely disappointing in that it follows the Vulkan 1.0 model of static pipelines and rigid workflows. Using Vulkan 1.3 with a few extensions is actually far more ergonomic beyond a basic "Hello, World" than using SDL GPU.

That might exclude a lot of your user base. For example a big chunk of Android users, or Linux workstation users in enterprise settings who are on older LTS distributions.

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#69
post #66

Earlier quoted context omitted.

I never mentioned the web as a target, rather devices. You don’t need a browser, you need a window or a surface to draw on and use C/C++/Rust/C# to write your code. WebGPU is a standard, not necessarily for the web alone. At no point does a browser ever enter the picture. https://eliemichel.github.io/LearnWebGPU/index.html

It sounds like the standard did itself a disfavor by its name, more interesting in how you describe it.

The WebGPU spec identifies squarely as a web standard: "WebGPU is an API that exposes the capabilities of GPU hardware for the Web." There are also no mentions of non-web applications.

The It's true that you can use Dawn and wgpu from native code but that's all outside the spec.

Re: How I learned Vulkan and wrote a small game engine with it (2024)

#70

Earlier quoted context omitted.

I'm working with SDL GPU now, and while it's nice, it hasn't quite cracked the cross platform nut yet. You still need to maintain and load platform-specific shaders for each incompatible ecosystem, or you need a set of "source of truth" HLSL shaders that your build system processes into platform-specific shaders, through a set of disparate tools that you have to download from all over the place, that really should be…

I thought shaders just needed to be compiled to spir-v

My comment was specifically about cross-platform. Apple operating systems don't know what spir-v is.
Post reply on HN