Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL 3.3 and the shaders errors #1

Open
lemirep opened this issue Feb 7, 2014 · 3 comments
Open

OpenGL 3.3 and the shaders errors #1

lemirep opened this issue Feb 7, 2014 · 3 comments
Assignees

Comments

@lemirep
Copy link

lemirep commented Feb 7, 2014

Hey there,

I just tried your new version and unfortunately it ends with a segfault on my pc.
I don't know since which commit the issue started to appear, but a few months back it wasn't there.
There seems to be some king of error with OpenGL 3.3 and the shaders.
Anyway, nothing urgent but you might want to look at it sometime.

Below is my log output :

Showing a total of 343000 points.
QSGContext::initialize: stencil buffer support missing, expect rendering errors
QOpenGLShader::compile(Vertex): Vertex shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated

*** Problematic Vertex shader source code ***

define lowp

define mediump

define highp

void setPosition();
void main(void)
{
    setPosition();
}

attribute highp   vec2      vertexCoordsArray;
attribute highp   vec3      pmvMatrix1;
attribute highp   vec3      pmvMatrix2;
attribute highp   vec3      pmvMatrix3;
void setPosition(void)
{
    highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3);
    vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0);
    gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z);
}

Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile
QOpenGLShader::compile(Fragment): Fragment shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated

*** Problematic Fragment shader source code ***

define lowp

define mediump

define highp

lowp vec4 srcPixel();
void main()
{
    gl_FragColor = srcPixel();
}

lowp vec4 srcPixel()
{
    return vec4(0.98, 0.06, 0.75, 1.0);
}

Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile
QOpenGLShader::link: "Vertex and Fragment shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.
"
Errors linking simple shader: Vertex and Fragment shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.

QOpenGLShader::compile(Vertex): Vertex shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated

*** Problematic Fragment shader source code ***

define lowp

define mediump

define highp

lowp vec4 srcPixel();
void main()
{
    gl_FragColor = srcPixel();
}

varying   highp   vec2      textureCoords;
uniform           sampler2D imageTexture;
lowp vec4 srcPixel()
{

return texture2D(imageTexture, textureCoords);
}


Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile
QOpenGLShader::link: "Vertex and Fragment shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.
"
Errors linking blit shader: Vertex and Fragment shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.

QOpenGLShader::compile(Fragment): Fragment shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated

*** Problematic Fragment shader source code ***

define lowp

define mediump

define highp

lowp vec4 srcPixel();
void main()
{
    gl_FragColor = srcPixel();
}

uniform   lowp    vec4      fragmentColor;
lowp vec4 srcPixel()
{
    return fragmentColor;
}

Warning: "" failed to compile!
QOpenGLShader::compile(Vertex): Vertex shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated

*** Problematic Fragment shader source code ***

define lowp

define mediump

define highp

lowp vec4 srcPixel();
void main()
{
    gl_FragColor = srcPixel();
}

uniform   lowp    vec4      fragmentColor;
lowp vec4 srcPixel()
{
    return fragmentColor;
}

Warning: "" failed to compile!
QOpenGLShader::compile(Vertex): Vertex shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated

*** Problematic Vertex shader source code ***

define lowp

define mediump

define highp

uniform mediump vec3 sdli;
uniform mediump vec3 pli;
uniform mediump float pliw;
uniform mediump float srli;
uniform mediump float crli;
uniform mediump float ccrli;
uniform mediump float k0;
uniform mediump float k1;
uniform mediump float k2;
uniform mediump vec4 acm[2];
uniform mediump vec4 dcm[2];
uniform mediump vec4 scm[2];
uniform mediump vec4 ecm[2];
uniform mediump float srm[2];
uniform bool viewerAtInfinity;
uniform bool twoSided;
varying mediump vec4 qColor;
varying mediump vec4 qSecondaryColor;
void qLightVertex(vec4 vertex, vec3 normal)
{
int i, material;
vec3 toEye, toLight, h;
float angle, spot, attenuation;
vec4 color, scolor;
vec4 adcomponent, scomponent;
if (!twoSided || normal.z >= 0.0) {
material = 0;
} else {
material = 1;
normal = -normal;
}
color = ecm[material];
scolor = vec4(0, 0, 0, 0);
if (viewerAtInfinity)
toEye = vec3(0, 0, 1);
else
toEye = normalize(-vertex.xyz);
if (pliw == 0.0)
toLight = normalize(pli);
else
toLight = normalize(pli - vertex.xyz);
angle = max(dot(normal, toLight), 0.0);
adcomponent = acm[material] + angle * dcm[material];
if (angle != 0.0) {
h = normalize(toLight + toEye);
angle = max(dot(normal, h), 0.0);
if (srm[material] != 0.0)
scomponent = pow(angle, srm[material]) * scm[material];
else
scomponent = scm[material];
} else {
scomponent = vec4(0, 0, 0, 0);
}
if (crli != 180.0) {
spot = max(dot(normalize(vertex.xyz - pli), sdli), 0.0);
if (spot < ccrli) {
adcomponent = vec4(0, 0, 0, 0);
scomponent = vec4(0, 0, 0, 0);
} else {
spot = pow(spot, srli);
adcomponent *= spot;
scomponent *= spot;
}
}
if (pliw != 0.0) {
attenuation = k0;
if (k1 != 0.0 || k2 != 0.0) {
float len = length(pli - vertex.xyz);
attenuation += k1 * len + k2 * len * len;
}
color += adcomponent / attenuation;
scolor += scomponent / attenuation;
} else {
color += adcomponent;
scolor += scomponent;
}
float alpha = dcm[material].a;
qColor = vec4(clamp(color.rgb, 0.0, 1.0), alpha);
qSecondaryColor = clamp(scolor, 0.0, 1.0);
}
attribute highp vec4 vertex;
attribute highp vec3 normal;
attribute highp vec4 texcoord;
uniform highp mat4 matrix;
uniform highp mat4 modelView;
uniform highp mat3 normalMatrix;
varying highp vec4 qt_TexCoord0;
void main(void)
{
gl_Position = matrix * vertex;
highp vec4 tvertex = modelView * vertex;
highp vec3 norm = normalize(normalMatrix * normal);
qLightVertex(tvertex, norm);
qt_TexCoord0 = texcoord;
}


QOpenGLShader::compile(Fragment): Fragment shader failed to compile with the following errors:
ERROR: error(#272) Implicit version number 110 not supported by GL3 forward compatible context
ERROR: error(#273) 1 compilation errors. No code generated

*** Problematic Fragment shader source code ***

define lowp

define mediump

define highp

uniform sampler2D tex;
uniform bool separateSpecular;
varying mediump vec4 qColor;
varying mediump vec4 qSecondaryColor;
varying highp vec4 qt_TexCoord0;

void main(void)
{
mediump vec4 col = texture2D(tex, qt_TexCoord0.st);
if (separateSpecular) {
gl_FragColor = clamp(col * qColor + vec4(qSecondaryColor.xyz, 0.0), 0.0, 1.0);
} else {
mediump vec4 lcolor = clamp(qColor + vec4(qSecondaryColor.xyz, 0.0), 0.0, 1.0);
gl_FragColor = col * lcolor;
}
}


QOpenGLShader::link: "Error: No shaders attached to current program
"
QGLLitMaterialEffect::setActive(): could not link shader program
Effect set from QML, should copy properties
MultiBillboard: OpenGL version 3 . 3

@dragly
Copy link
Owner

dragly commented Feb 7, 2014

Thanks for the feedback! It seems that Qt's own shaders don't contain the correct GLSL version information, and with OpenGL 3.3, the standard requires this. Currently both Qt's own shaders and mine are being compiled (and I think they both have to in order for other 3D objects to be shown together with the billboards).

What hardware are you using? I'm guessing you might have an AMD graphics card, because I have not seen this error on any cards from NVIDIA.

I'll look into providing a solution so that you can easily disable OpenGL 3.3 for now. In the meantime, change the following two lines in main.cpp

f.setMajorVersion(3);
f.setMinorVersion(3);

to

f.setMajorVersion(2);
f.setMinorVersion(3);

This will use OpenGL 2.3 without the geometry shader

@dragly dragly self-assigned this Feb 7, 2014
@lemirep
Copy link
Author

lemirep commented Feb 7, 2014

I'm using an AMD 7660D (APU) with the fglrx drivers on OpenSuse 13.1 which should support OpenGL 4.3. It works perfectly using OpenGL 2.3 though not with geometry shaders rendering.
I'm actually having between 5 and 10 fps with the cpu drawing method and 34300 points.
After searching a bit, it seems to be Qt bug not resolved yet. As Qt3D is currently being rewritten we can hope this bug will be resolved along the way.
I guess the AMD drivers are more strict than those from NVIDIA.
https://bugreports.qt-project.org/browse/QTBUG-23741

@dragly
Copy link
Owner

dragly commented Feb 8, 2014

Yes, then that's definitely it. AMD probably enforces the standard more strictly. It's strange though, that there's not even a warning with NVIDIA. Or perhaps Qt3D doesn't show warnings unless there also are some errors. I'm looking forward to see the rewrite of Qt3D. Let's hope it's fixed then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants