Closed SIsilicon closed 1 year ago
Yes, it looks like they are using the cb0 register in the vertex shader and the cb1 register in the fragment shader
#if BGFX_SHADER_LANGUAGE_HLSL >= 400 && BGFX_SHADER_TYPE_FRAGMENT
cbuffer __placeholder__ : REGISTER(b, 0) {};
#endif
You can add this code to the front of the shader (or in the header file) to occupy the cb0 register in the fragment shader, so that the uniform variables are automatically assigned to the cb1 register
Would this be a solution or workaround? Will it be added to bgfx_shader.sh
by default in the next release?
This is a workaround. Actually it's not quite right, but it works. This code will be added to bgfx_shader.sh in the next release, but I'm still looking for a better solution.
Whenever I attempt to use a uniform in the fragment shader, it acts as if all its values are zero (never set). After digging into the Direct3D shader assembly, I notice that the one Minecraft has uses CB1 constant buffer in the fragment shader (
dcl_constantbuffer CB1[1], immediateIndexed
), while the one made when compiling uses CB0 (dcl_constantbuffer CB0[2], immediateIndexed
). This same constant buffer is used in the Vertex shaders. Maybe that has something to do with it?