OpenGL: glLinkProgram fails when isampler2D used on iMX6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OpenGL: glLinkProgram fails when isampler2D used on iMX6

Jump to solution
1,644 Views
hartmutbehrensf
Contributor I

Hi,

 

The vertex and fragment shaders shown below fail to link on the iMX6. However, the shader program log is empty and no other error is generated/shown. When functionality related to isampler2D is removed, then the shader links successfully again.

 

Does anyone know what is going on here or have a work-around for this ?

 

 

QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);

QString vsrc =

"#ifdef GL_ES\n"

"precision mediump float;\n"

"precision mediump sampler2D;\n"

"precision mediump isampler2D;\n"

"#endif\n"

"in vec4 vertex;\n"

"in vec2 texCoord;\n"

"flat out int materialID;\n"

"out vec2 texc;\n"

"uniform int rotIndex;\n"

"uniform sampler2D floatSampler;\n"

"uniform isampler2D intSampler;\n"

"\n"

"int getRotoationIndex(void);\n"

"mat4 getRotationMatrix(int Index);\n"

"mat4 getRotationMatrix(void);\n"

"\n"

"int getMaterialId(int Index);\n"

"int getMaterialId(void);\n"

"\n"

"int getRotationIndex(void) { return rotIndex; }\n"

"mat4 getRotationMatrix(void) { return getRotationMatrix(getRotationIndex()); }\n"

"mat4 getRotationMatrix(int index) { return mat4(texelFetch(floatSampler, ivec2(0+5*index,0), 0), texelFetch(floatSampler, ivec2(1+5*index,0), 0), texelFetch(floatSampler, ivec2(2+5*index,0), 0), texelFetch(floatSampler, ivec2(3+5*index,0), 0)); }\n"

"\n"

"int getMaterialId(int index) { return int(texelFetch(intSampler, ivec2(4+5*index,0), 0).r); }\n"

"int getMaterialId(void) { return getMaterialId(getRotationIndex()); }\n"

"\n"

"void main(void)\n"

"{\n"

" mat4 rotMatrix = getRotationMatrix(rotIndex);\n"

" gl_Position = rotMatrix * vertex;\n"

" materialID = getMaterialId();\n"

" texc = texCoord;\n"

"}\n";

#endif

 

QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);

QString fsrc =

"#ifdef GL_ES\n"

"precision mediump float;\n"

"precision mediump sampler2D;\n"

"precision mediump isampler2D;\n"

"#endif\n"

"in vec2 texc;\n"

"flat in int materialID;"

"out vec4 fragColor;\n"

"uniform sampler2D tex;\n"

"void main(void)\n"

"{\n"

" if (materialID == 1) {\n"

" fragColor = mix(texture(tex, texc), vec4(1.0, 0.0, 0.0, 0.5), 0.4);\n"

" }\n"

" if (materialID == 7) {\n"

" fragColor = mix(texture(tex, texc), vec4(0.0, 0.0, 1.0, 0.5), 0.4);\n"

" }\n"

"}\n";

Original Attachment has been moved to: GLWidget.cpp.zip

Original Attachment has been moved to: GLWidget.h.zip

Tags (2)
0 Kudos
Reply
1 Solution
1,299 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Hartmut,

iSampler2d is part of EXT_gpu_shader4: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_gpu_shader4.txt 

Mx6Devices support OpenGL ES3.x based on EXT_gpu_shader5: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_gpu_shader5.txt 

You can see the changes for specific functionality, however I think the main change is that the shading lenguage had changed dramatically using multisample instead of sampler variant.

regards

View solution in original post

0 Kudos
Reply
3 Replies
1,299 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Hartmut

iSampler2d is part of EXT_gpu_shader4 that is not supported on current GPU for i.Mx6 devices, EXT_gpu_shader5  is supported on OpenGL ES 2.0 and 3.0 API based on khronos, as suggestion try to use gSampler2D instead.

Regards

0 Kudos
Reply
1,299 Views
hartmutbehrensf
Contributor I

Dear Bio_TICFSL,

So what you are trying to tell me is that the iMX6 deviates from the OpenGL ES3.0 spec in this regard ? https://www.khronos.org/registry/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf  and https://www.khronos.org/registry/OpenGL/specs/es/3.0/es_spec_3.0.pdf  explicitly state that isampler2D is supported by 3.0.

Is there any other functionality that is provided for by OpenGL ES3.0 but not supported by iMX6 ?

Thank you for the suggestion, I'll implement a work-around for lack of isampler2D support.

0 Kudos
Reply
1,300 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Hartmut,

iSampler2d is part of EXT_gpu_shader4: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_gpu_shader4.txt 

Mx6Devices support OpenGL ES3.x based on EXT_gpu_shader5: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_gpu_shader5.txt 

You can see the changes for specific functionality, however I think the main change is that the shading lenguage had changed dramatically using multisample instead of sampler variant.

regards

0 Kudos
Reply