23 Replies
.
1. is webgpu like vulkan, in that the render pipeline is immutable and must be fully recreated when something like the Blend State needs to change?
1) yes
okay so the second question is
let's say I create the render pipeline, then I create a Texture2D in my engine, then I destroy the render pipeline to recreate it after a graphics settings change
do I lose the Texture2D?
not unless youre doing something weird with it, the texture2d is attached to the device/engine/whatever webgpu calls it i forget but its device in vulkan
webgpu from what ive seen is pretty similar to vulkan except it sacrifices ultra-flexibility in exchange for reasonable defaults and a good api, and actually being truly cross-platform
It seems like the current vertex/fragment shader being used is also immutable?
like you can't change it without rebuilding the render pipeline?
yes, though you can use uniforms/push constants, whatever to change the behavior a bit
but yes
that fact is actually a big problem in modern games turns out, because games will have to rebuild pipelines constantly because of it
theres pipeline caching to help a bit ( i think webgpu has it? ) where aspects of the pipeline get cached and the creating again is faster
Yeah....I don't know how the hell I'd do a Unity-like material system with that
Clearly Unity does it in Vulkan though
theyll make a pipeline for every combination that gets used
if you have ten materials in the scene youll have ten pipelines
and rebind to a new one for each thing you render
That sounds....
Unbelievably painful
this is why things like elden ring are so infamous for having terrible "shader" compilation times
yeah the "shader compilation" is usually rebuilding pipelines whenever you change scenes
The Khronos Group
You Can Use Vulkan Without Pipelines Today
Deploying and developing royalty-free open standards for 3D graphics, Virtual and Augmented Reality, Parallel Computing, Neural Networks, and Vision Processing
yeah vulkan has some stuff to help there but webgpu doesnt yet
khronos is slowly realising that making driver implementation easy by requiring the developer to do everything tends to come at a cost in the software written against it
and it isnt supported on all graphics cards - theres a thing with vulkan to make the api work without deeper support but it just does caching in the background for you
interesting, it was actually nintendo that wrote that https://github.com/KhronosGroup/Vulkan-ExtensionLayer/blob/main/layers/shader_object.cpp
huh didnt know that
im hoping webgpu moves to shader objects too but my hopes arent high
(its the only thing keeping me back from migrating to webgpu for the portability)
And I'm guessing you NEED a vert + frag shader to build a render pipeline
yup
fuuuuuuck
I'm going to need to build an entire system around this
webgpu doesnt have mesh shading so you cant do task + mesh + frag as an alternative
you can reuse the vert and frag bits at least across pipelines
I was going to set up the render pipeline as soon as the engine initializes, before loading game assets
but that won't work
because like
shaders are assets