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
已解决! 转到解答。
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
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
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.
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