shaderc icon indicating copy to clipboard operation
shaderc copied to clipboard

Entry point renaming functionality missing?

Open QuantumDeveloper opened this issue 5 years ago • 8 comments

Using glslangValidator user can do entry point renaming (useful for GLSL) glslangValidator -e myEntry --source-entrypoint main Seems shaderc is missing this functionality? Would be useful when several GLSL shaders is present inside one file to implement something like effects framework

QuantumDeveloper avatar Nov 04 '19 09:11 QuantumDeveloper

I believe that functionality exists in Glslang for HLSL, not for GLSL? I can't make it work with GLSL.

I tried a trivial fragment shader in GLSL with this command line:

      glslangValidator -V a.frag --sep a -e main -o a.spv

But I got:

     a.frag
     ERROR: Source entry point must be "main"

If I use -H instead of -o a.spv then it does emit expected output:

                          Capability Shader
           1:             ExtInstImport  "GLSL.std.450"
                          MemoryModel Logical GLSL450
                          EntryPoint Fragment 4  "main" 9
                          ExecutionMode 4 OriginUpperLeft
                          Source GLSL 450
                          Name 4  "main"
                          Name 9  "o"
                          Decorate 9(o) Location 0
           2:             TypeVoid
           3:             TypeFunction 2
           6:             TypeFloat 32
           7:             TypeVector 6(float) 4
           8:             TypePointer Output 7(fvec4)
        9(o):      8(ptr) Variable Output
          10:    6(float) Constant 1065353216
          11:    7(fvec4) ConstantComposite 10 10 10 10
     4(main):           2 Function None 3
           5:             Label
                          Store 9(o) 11
                          Return
                          FunctionEnd

That may be a problem with Glslang. I don't even know if --source-entrypoint is supposed to work for anything other than HLSL.

dneto0 avatar Nov 08 '19 17:11 dneto0

I acknowledge this would be a useful feature for GLSL.

dneto0 avatar Nov 08 '19 17:11 dneto0

Note the example given in the OP is taken from https://github.com/KhronosGroup/glslang/issues/605 which showed how to do this for GLSL.

johnkslang avatar Nov 09 '19 02:11 johnkslang

More detail is now in https://github.com/KhronosGroup/glslang/issues/1970#issuecomment-552056323.

Note this is all showing how to create SPIR-V with different entry-point names, not changing the rules of GLSL that require the GLSL source to have an entry-point of "void main()".

johnkslang avatar Nov 09 '19 02:11 johnkslang

@johnkslang Sorry, I didnt really get how to rename entrypoint to main during SPIR-V compilation using shaderc. I am not using it from command line, but directly from code. Could you please give an example how to do described manipulation using shaderc?

QuantumDeveloper avatar Jan 23 '20 10:01 QuantumDeveloper

Is this glslang functionality exposed through shaderc? I'm not a shaderc expert.

johnkslang avatar Jan 23 '20 18:01 johnkslang

I didint find this in shaderc headers (at least in C interop interface)

QuantumDeveloper avatar Jan 23 '20 20:01 QuantumDeveloper

My best guess is to classify this as an enhancement request for shaderc, @dneto0.

johnkslang avatar Jan 24 '20 13:01 johnkslang