I continue my work on porting an OpenGLES based engine to Vulkan. Now it has come to setting uniforms within a shader. Currently, when the engine user wants to change a uniform he writes the new value into a central buffer. Shortly before the drawcall the engine then takes the buffer and issues a glUniform* call for every entry.
I want to use GL_KHR_vulkan_glsl to compile the existing GLSL shaders into Spirv so as little as possible changes for the engine user.
Problem is that GL_KHR_vulkan_glsl doesn’t allow uniforms outside a uniform block which I currently use heavily. Thus, my intention is to replace the glUniform mechanism with something GL_KHR_vulkan_glsl compatible. Currently two methods come to my mind:
Just wrap all uniforms in something like a default block which is then updated from an ubo once a drawcall.
Replace all glUniform calls by push constants.
The generation of the GLSL code is partially automated, at least when it comes to the generation of the declarations of the uniforms. The GLSL code that accesses the uniforms on the other hand is written by the engine user. That means using a method that merely changes the declaration is acceptable if the way they are accessed within the shader does not change.
I expect several hundred drawcalls a frame with up to 12 uniforms of which roughly half may change from drawcall to drawcall.
Can you tell me if one of the above options is optimal from a performance viewpoint as far as you can tell or do you have a different proposal?