LukasBanana / XShaderCompiler

Shader cross compiler to translate HLSL (Shader Model 4 and 5) to GLSL
BSD 3-Clause "New" or "Revised" License
351 stars 48 forks source link

Multiple outputs in ESSL3.0 #69

Closed mlomb closed 7 years ago

mlomb commented 7 years ago

Input shader:

struct Output {
    float4 SV_A : SV_Target0;
    float4 SV_B : SV_Target1;
    float4 SV_C : SV_Target2;
};

Output main() {
    Output output;
    return output;
}

Output shader (ESSL300):

#version 300 es

out highp vec4 SV_Target0;
out highp vec4 SV_Target1;
out highp vec4 SV_Target2;

void main()
{

}

When compiling:

In ESSL 3.0 specification (4.3.8.2):

If there is more than one output, the location must be specified for all outputs.

So it should specify the location if there is more than one output (or the auto binding is enabled).

Sidenote: The spec also says:

Fragment shaders cannot have input layout qualifiers. ... Vertex shaders cannot have output layout qualifiers.

But the autoBinding add the layout qualifier anyway.

Spec: https://www.khronos.org/registry/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf

LukasBanana commented 7 years ago

Thanks for the report. As you can see, I haven't work a lot with ESSL so far. I know there are a lot of differences between GLSL and ESSL, but I haven't had the time yet to gather much experience with ESSL.

LukasBanana commented 7 years ago

Fixed with 56aee09.

mlomb commented 7 years ago

I have problems trying to compile the same shader again, seems like it doesn't work when autoBinding is disabled. The location should be there even if the autoBinding is disabled, at least for ESSL3.0/1/2.

Also, doing some tests with the autoBinding enabled I found that the uniform blocks doesn't support binding:

layout(std140, row_major, binding = 0) uniform UBO
{
    highp mat4 some_matrix;
};
LukasBanana commented 7 years ago

Feel free re-open this issue. I'll take care of it tomorrow.

mlomb commented 7 years ago

I can't reopen the issue if the owner (you) close it.

LukasBanana commented 7 years ago

I maybe ran over this a little fast, so I'll take a closer look at it as soon as I can. Thanks and kind regards, Lukas

LukasBanana commented 7 years ago

Should be fixed now with c268e07. The binding qualifier is only generated if -EB is enabled and the output ESSL version is at least 310. Let me know if there's still something wrong on this. Lukas

mlomb commented 7 years ago

Everything seems to be working fine :)