TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

I learned Vulkan and wrote a small game engine with it

625 pointsby eliasdaler12 months ago

24 comments

Animats12 months ago
This minimalism is very effective.<p>I took the opposite approach, and it has cause great pain. I&#x27;ve been writing a metaverse client in Rust. Right now, it&#x27;s running on another screen, showing an avatar riding a tram through a large steampunk city. I let that run for 12 hours before shipping a new pre-release.<p>This uses Vulkan, but it has WGPU and Rend3 on top. Rend3 offers a very clean API - you create meshes, 2d textures, etc., and &quot;objects&quot;, which reference the meshes and textures. Creating an object puts it on screen. Rust reference counting interlocks everything. It&#x27;s very straightforward to use.<p>All those layers create problems. WGPU tries to support web browsers, Vulkan, Metal, DX11 (recently dropped), DX12, Android, and OpenGL. So it needs a big dev team and changes are hard. WGPU&#x27;s own API is mostly like Vulkan - you still have to do your own GPU memory allocation and synchronization.<p>WGPU has lowest-common-denominator problems. Some of those platforms can&#x27;t support some functions. WGPU doesn&#x27;t support multiple threads updating GPU memory without interference, which Vulkan supports. That&#x27;s how you get content into the GPU without killing the frame rate. Big-world games and clients need that. Also, having to deal with platforms with different concurrency restrictions results in lock conflicts that can kill performance.<p>Rend3 is supposed to be a modest level of glue code to handle synchronization and allocation. Those are hard to do in a general way. Especially synchronization. Rend3 also does frustum culling (which is a big performance win; you&#x27;re not rendering what&#x27;s behind you) and tried to do occlusion culling (which was a performance lose because the compute to do that slowed things down). It also does translucency, which means a depth sort. (Translucent objects are a huge pain. I really need them; I work on worlds with lots of windows, which you can see out of and see in.)<p>The Rust 3D stack people are annoyed with me because I&#x27;ve been pounding on them to fix their stack for three years now. That&#x27;s all volunteer. Vulkan has money behind it and enough users to keep it maintained. Rend3 was recently abandoned by its creator, so now I have to go inside that and fix it. Few people do anything elaborate on WGPU - mostly it&#x27;s 2D games you could have done in Flash, or simple static 3D scenes. Commercial projects continue to use Unity or UE5.<p>If I went directly to Vulkan, I&#x27;d still have to write synchronization, allocation, frustrum culling, and translucency. So that&#x27;s a big switch.<p>Incidentally, Vulkano, the wrapper over Vulkan and Metal, has lowest-common-denominator problems too. It doesn&#x27;t allow concurrent updating of assets in the GPU. Both Vulkan and Metal support that. But, of course, Apple does it differently.
评论 #40605976 未加载
评论 #40602084 未加载
评论 #40609261 未加载
评论 #40601927 未加载
评论 #40609202 未加载
tombert12 months ago
I tried learning Vulkan a little more than a year ago and I have no desire to ever touch it again. It really bothers me that we&#x27;re deprecating OpenGL and replacing it with something that&#x27;s ridiculously hard to do anything simple (e.g. doing a spinning cube takes several hundred lines of code).<p>OpenGL was never &quot;easy&quot; but it was at least something a regular person could learn the basics of in a fairly short amount of time. You could go to any big book store, buy some intro to graphics programming book, and get some basic stuff rendering in an afternoon or two. I&#x27;m sure Vulkan is better in some regards but is simply not feasible to expect someone to learn it quickly.<p>Like, imagine the newest Intel&#x2F;ARM&#x2F;AMD chips came along and instead of being able to write C or C++, you&#x27;re being told &quot;We are dropping support for higher level languages so you can only write assembly on this now and it&#x27;ll be faster because you have more control!&quot; It would be correctly labeled as ridiculous.
评论 #40602110 未加载
评论 #40606378 未加载
评论 #40601714 未加载
评论 #40605940 未加载
评论 #40604207 未加载
jokoon12 months ago
I think vulkan is great, but its only purpose is to take full advantage of advanced GPU features. It also leads to better performance when using advanced GPU features compared to OpenGL.<p>Generally, I feel OpenGL is the recommended route if you don&#x27;t really aim for advanced rendering techniques.<p>There are plenty 2D &#x2F;lowpoly&#x2F;ps1-graphics games right now, and those don&#x27;t need to use vulkan.<p>Vulkan is an example of how the AAA gaming industry is skewed towards rendering quality and appearance. AAA game studios justify their budget with those very advanced engines and content, but there is a growing market of 2D&#x2F;low poly game, because players are tired and realized they want gameplay, not graphics.<p>Also if you are a game developer, you don&#x27;t want to focus on rendering quality, you want to focus on gameplay and features.
评论 #40598029 未加载
评论 #40597957 未加载
评论 #40597798 未加载
评论 #40604256 未加载
评论 #40598040 未加载
评论 #40599046 未加载
评论 #40606228 未加载
评论 #40597912 未加载
评论 #40604345 未加载
评论 #40598567 未加载
评论 #40605016 未加载
spicyusername12 months ago
Lots of good advice in this article.<p>One that stuck out to me: Don’t implement something unless you need it right now<p>This is a constant battle I fight with more junior programmers, who maybe have a few years of experience, but who are still getting there.<p>They are often obsessed with &quot;best-practices&quot; and whatever fancy new tool is trending, but they have trouble starting with the problem they need to solve and focusing on the minimum needed to just solve that problem.
评论 #40600808 未加载
评论 #40599002 未加载
评论 #40597627 未加载
评论 #40599519 未加载
评论 #40599799 未加载
评论 #40600170 未加载
评论 #40603743 未加载
评论 #40597970 未加载
评论 #40597789 未加载
评论 #40605028 未加载
评论 #40602684 未加载
edu12 months ago
The site seems hugged to death, cached: <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20240606103630&#x2F;https:&#x2F;&#x2F;edw.is&#x2F;learning-vulkan&#x2F;" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20240606103630&#x2F;https:&#x2F;&#x2F;edw.is&#x2F;le...</a>
评论 #40597403 未加载
rossant12 months ago
Great writeup! I learned Vulkan myself so that I could write a scientific data visualization engine (<a href="https:&#x2F;&#x2F;datoviz.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;datoviz.org&#x2F;</a> still quite experimental, will release a newer version soon). I had some knowledge of OpenGL before and learning Vulkan was SO hard. The learning resources weren&#x27;t that great 5 years ago. I took up the challenge and it was so much fun. It took me months to understand the role of the various dozens of abstractions. In the process I wrote a small wrapper around Vulkan (<a href="https:&#x2F;&#x2F;datoviz.org&#x2F;api&#x2F;vklite&#x2F;" rel="nofollow">https:&#x2F;&#x2F;datoviz.org&#x2F;api&#x2F;vklite&#x2F;</a>) to make it a bit less painful to work with (it supports a subset of the features, those that are the most required for scientific visualization purposes).
samiv12 months ago
This might come off as a surprise to some people but getting good performance with Vulkan (compared to say OpenGL) isn&#x27;t trivial because:<p>the Vulkan driver is missing that ~20k loc of code that OpenGL driver does for you to set up the rendering pipelines, render targets etc.<p>This is all code that already exists in the OpenGL driver and has been optimized for +20 years by the best people in the industry.<p>So when you start putting together the equivalent functionality that you get out of the box with OpenGL on top of Vulkan doing it the naive way doesn&#x27;t magically give you good perf, but you gotta put in some more work and then the real problems start stacking up such as making sure that you have all right fences etc synchronization primitives in place and so forth.<p>So only when you actually know what you&#x27;re doing and you&#x27;re capable of executing your rendering with good parallelism and correct synchronization can you start dreaming about the performance benefits of using Vulkan.<p>So for a hobbyist like myself.. I&#x27;m using OpenGL ES3 for the simplicity of it and because it&#x27;s already good enough for me and I have more pressing things to matter than spend time writing those pesky Vulkan vertex descriptor descriptor descriptors ;-)<p>Btw this is my engine:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ensisoft&#x2F;detonator">https:&#x2F;&#x2F;github.com&#x2F;ensisoft&#x2F;detonator</a>
评论 #40598641 未加载
评论 #40598478 未加载
评论 #40598709 未加载
评论 #40598863 未加载
wudangmonk12 months ago
Its great to have more Vulkan resources but unfortunately this one too suffers from the same problem as every other resource I&#x27;ve found on getting something on the screen with Vulkan.<p>They all introduce another layer of abstraction on top of Vulkan even before giving you the simple case without it. Its always use vk-bootstrap, volk, vma or someother library.<p>Is there a single resource anywhere that gives an example of doing the memory management manually because I havent found one, it seems like its either use vma or go figure out the spec are the only choices you are given. Is it too much to ask to just get the most basic example without having to add any libraries other than the Vulkan sdk itself?.
评论 #40599496 未加载
评论 #40601222 未加载
评论 #40600838 未加载
OnionBlender12 months ago
I&#x27;ve been trying to learn Vulkan on and off for years (I used to know OpenGL ES 2&amp;3 pretty well).<p>One thing I found difficult is understanding how to use things in a real engine rather than a sample. A lot of samples will allocate exactly what they need or allocate hundreds of something so that they&#x27;re unlikely to run out. When I was trying to learn DirectX, I found Microsoft&#x27;s MiniEngine helpful because it wasn&#x27;t overly complex but had things like a DescriptorAllocator that would manage allocating descriptors. Is there something similar for Vulkan?<p>Another thing I struggle with is knowing how to create good abstractions like materials, meshes, and how to decide in what order to render things. Are there any good engines or frameworks I should study in order to move beyond tutorials?
评论 #40599512 未加载
评论 #40599324 未加载
andrewmcwatters12 months ago
For the casual reader who is curious what it takes to write a &quot;Hello, Triangle!&quot; in Vulkan 1.3: <a href="https:&#x2F;&#x2F;github.com&#x2F;Planimeter&#x2F;game-engine-3d&#x2F;blob&#x2F;main&#x2F;src&#x2F;graphics_vulkan.cpp">https:&#x2F;&#x2F;github.com&#x2F;Planimeter&#x2F;game-engine-3d&#x2F;blob&#x2F;main&#x2F;src&#x2F;g...</a>
评论 #40599566 未加载
评论 #40599171 未加载
dynjo12 months ago
Highly recommend this guy’s channel, he livestreams building a Vulkan game engine and he has a crazy style too <a href="https:&#x2F;&#x2F;youtube.com&#x2F;@tokyospliff?si=CMF53295xeETykbP" rel="nofollow">https:&#x2F;&#x2F;youtube.com&#x2F;@tokyospliff?si=CMF53295xeETykbP</a>
评论 #40604956 未加载
评论 #40606992 未加载
archermarks12 months ago
Really nice article! I have some OpenGL familiarity and tried out Vulkan but bounced off of it due to all of the up-front complexity just getting something running. Might give it another shot now!
评论 #40597357 未加载
评论 #40601980 未加载
评论 #40597286 未加载
rychco12 months ago
I’ve been lurking &amp; following your project for months in the Graphics Programming discord as I work on my own hobby Vulkan engine. It’s been inspiring seeing all the progress you’ve made. I especially admire your willingness to ask questions &amp; share your work-in-progress so openly. Keep up the great work
评论 #40628009 未加载
amandasystems12 months ago
I really appreciate a “here’s how I did this” that also includes hints on how to avoid bikeshedding and essentially getting scared out of doing the thing.<p>In my experience being daunted ans not knowing where to start is a large part of the difficulty in doing difficult things.
wg012 months ago
Off topic kind of - Can an LLM generate such an article? Reading such in depth experiences and consolidating advice makes me think that web is made by humans and every other day,I spot something on the web that is clearly generated from some LLM.<p>Great write up. Inspiring.
评论 #40601954 未加载
Waterluvian12 months ago
Are there any examples of an academic attempt at putting as much of a game into the GPU as possible? Like, architecting a game in a way that pretty much everything, including game logic, could be implemented as a shader?
评论 #40607008 未加载
评论 #40606484 未加载
评论 #40603354 未加载
animal53112 months ago
The screenshots reflect my experience 10-15 years ago creating my own SDL OpenGL engine+game where lighting is the first really hard thing to get looking good for a beginner to intermediate developer.
uwagar12 months ago
life was a pleasure writing programs in IrisGL and then OpengGL :(
评论 #40602030 未加载
null_point12 months ago
Read through this last night. Loved the article! Blending the story of your personal experience with a pseudo, high-level tutorial was really interesting.
评论 #40628000 未加载
atan212 months ago
Great read! Elias always does great work.
layer812 months ago
Is this better than learning Klingon? ;)
brian_herman12 months ago
Those kitties are so cute!
评论 #40601992 未加载
koolala12 months ago
i learned webgpu and then it couldn&#x27;t hit 90fps
alunchbox12 months ago
hey just curious, any reason why some of these articles I see from time to time don&#x27;t apply some simply CSS? I don&#x27;t mind the raw html, I&#x27;m mostly wondering if there&#x27;s some benefit to it that I might not be aware of.
评论 #40598263 未加载
评论 #40598056 未加载