2
u/SpicyCactuar Jul 20 '24
Looks amazing!
If you don't mind the question, what did you use to display the diagnostics UI? I quickly skimmed through the code but couldn't find it.
In any case, great stuff!
3
u/gomkyung2 Jul 20 '24
If your application calls Apple Metal API, you can pass the environment variable MTL_HUD_ENABLED=1 at the launch to show diagnostics HUD.
1
u/SpicyCactuar Jul 20 '24
I see. I'm not a regular Mac user but I'll take this into account in future Metal ventures.
Thanks!
3
u/OkidoShigeru Jul 20 '24 edited Jul 20 '24
Very nice work. Looking at your Xcode capture though it looks like MoltenVK is letting you down a little bit here by treating your subpass as another render pass, with a store and then load.
Not sure it of Molten exposes this but spirv-cross (the tool used by Molten to convert spir-v to MSL) provides an option to treat input attachment loads as framebuffer fetch instead - there are some limitations to this though, your input attachment indices need to match exactly your colour attachment indices from earlier sub passes and you can’t use depth as an input attachment (in the engine I work on we work around this by just writing out z in the fragment shader to a single channel colour attachment and using that as input attachment in subsequent sub passes).
Thinking about it more as I write this I can see why Molten can’t do this, those limitations make it impossible to apply this in the general case and you very much need to know ahead of time if this will work when the shaders are compiled, which obviously you couldn’t…
EDIT: yep, looks like this is an open issue for MoltenVK https://github.com/KhronosGroup/MoltenVK/issues/1374
1
12
u/gomkyung2 Jul 19 '24
I’ve created a minimal deferred rendering demo using Vulkan (no loading any models or textures). Vulkan’s sophisticated and explicit resource management ensures that G-buffer memory consumption is incredibly low! I’ve uploaded the source code and detailed explanations of the render pass, including data flow visualizations, to my GitHub repository. Feel free to check it out!