0

Iam using glslang SDK in my code to compile shader programs online, however i get the following errors for my fragment shader:

GLSL Parsing Failed for: Text.frag ERROR: 0:6: 'location' : too large for fragment output ERROR: 1 compilation errors. No code generated.

GLSL Linking Failed for: Text.frag ERROR: 0:6: 'location' : too large for fragment output ERROR: 1 compilation errors. No code generated.

Assertion failed: node->getOp(), file C:\projects\glslang\SPIRV\GlslangToSpv.cpp, line 2412

my vertex shader:

#version 450
#extension GL_ARB_separate_shader_objects : enable

layout(location = 0) out vec3 fragColor;

vec2 positions[3] = vec2[](
    vec2(0.0, -0.5),
    vec2(0.5, 0.5),
    vec2(-0.5, 0.5)
);

vec3 colors[3] = vec3[](
    vec3(1.0, 0.0, 0.0),
    vec3(0.0, 1.0, 0.0),
    vec3(0.0, 0.0, 1.0)
);

void main() {
    gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
    fragColor = colors[gl_VertexIndex];
}

My fragment shader

#version 450
#extension GL_ARB_separate_shader_objects : enable

layout(location = 0) in vec3 fragColor;

layout(location = 0) out vec4 outColor;

void main() {
    outColor = vec4(fragColor, 1.0);
}
2
  • what happens if you make outcolor a vec3 instead? Commented Oct 27, 2020 at 20:24
  • @Makogan i tried that as well it gave me the same error, you can see the solution in the answer. Commented Oct 28, 2020 at 6:07

1 Answer 1

2

Iam using glslang SDK in my code to compile the shader programs online, apparently in the glslang code you have to tweak some limitation parameters manually for glslang to accept shader variables that are normally not accepted, this issue was fixed by setting maxDrawBuffers to true as the following

resources = DefaultTBuiltInResource;

resources.maxDrawBuffers = true;

I am not sure what exactly this does and why it is not set natively, but perhaps someone can explain this further.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.