2

When using glslc --targe-env="vulkan1.1" -fentry-point="mainColor" test.frag, I get the error

test.frag: error: Linking fragment stage: Missing entry point: Each stage requires one entry point 

test.frag content :

#version 450

layout (location=0) in vec4 color;
layout (location=0) out vec4 fragColor;

void mainColor()
{
    fragColor = color;
}

void mainWhite()
{
    fragColor = vec4(1, 1, 1, 1);
}

What am I doing wrong ?
How to fix this compilation error ?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Calvin-Ruiz
  • 173
  • 1
  • 1
  • 9

1 Answers1

1

What am I doing wrong?

See Support multiple entry points in a single module #605:

GLSL only allows a single entry point per stage, so either 0 or 1 per compilation unit, and it must be called main(). [...]

and OpenGL Shading Language 4.60 Specification (HTML) - 3.8.2. Dynamically Uniform Expressions and Uniform Control Flow

[...] Uniform control flow is the initial state at the entry into main(), [...]

How to fix this compilation error?

Declare the main() function.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • The main function is changing, I want to compile with mainColor as main in one binary, and then mainWhite in another one. It's what -fentry-point is expected to do, no ? – Calvin-Ruiz Sep 30 '20 at 09:03
  • 1
    @Calvin-Ruiz Yes I know, this is possible in Vulkan as in SPIR-V, but it is not possible in GLSL: "*GLSL only allows a single entry point per stage, [...]"* – Rabbid76 Sep 30 '20 at 09:06
  • @Calvin-Ruiz This is not possible in the latest GLSL version (4.60), but may be it will be possible in the future. – Rabbid76 Sep 30 '20 at 09:16