Shader_Minifier icon indicating copy to clipboard operation
Shader_Minifier copied to clipboard

Interface Block identifiers not renamed

Open therontarigo opened this issue 2 years ago • 3 comments

Given Interface Block GLSL syntax:

buffer block_name{
  int member_name[];
};

block_name and member_name are not renamed.

therontarigo avatar Feb 24 '23 03:02 therontarigo

Some examples from https://www.khronos.org/opengl/wiki/Interface_Block_(GLSL):

uniform MatrixBlock
{
  mat4 projection;
  mat4 modelview;
} matrices;

The instance name (matrices) should also be treated as a global variable. To access projection, we have to use matrices.projection. So this should be the same renaming approach as for structs (https://github.com/laurentlb/Shader_Minifier/issues/290).

uniform MatrixBlock
{
  mat4 projection;
  mat4 modelview;
};

Here, when there's no instance name, projection should be treated as a global variable.

If we rename the block name (MatrixBlock), it should be exported to a macro as the name can be used from the OpenGL side.

laurentlb avatar Apr 12 '24 10:04 laurentlb

In this situation //[ //] allows a good workaround:

//[
uniform u{//]
  mat4 projection;    // minifier now sees these as global vars
  mat4 modelview;
//[
};//]

combined with adding u to --no-renaming-list.

therontarigo avatar Apr 12 '24 15:04 therontarigo

#335 solves this for me, I just tested it for buffer block. Much appreciated! Manually naming the block itself to a short name and adding it to no-renaming-list is still needed; probably that should be handled in the same way as for simple uniforms.

therontarigo avatar Apr 12 '24 17:04 therontarigo