Odroid N2+ gl_Position or coordinates interpolation issue (perhaps precision?)
System information
- OS: (yocto poky)
- GPU: (Odroid N2+ G52)
- Kernel version: Linux readeasy 5.14.0 # 1 SMP Sun Aug 29 22:04:50 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
- Mesa version: OpenGL ES 3.1 Mesa 22.0.0-devel
Describe the context of an issue
I have a Qt application that runs on many platforms with their EGLFS plugin which is GBM + EGL + OpenGL ES 2.0. Part of application functionality is showing images and magnify them. On Odroid N2+ there is an issue with it.
With Qt I'm able to reproduce the issue with simple qmlscene application and simple qml file. ALso by renaming meson_dri.so I'm able to force mesa to use softpipe and prove that issue doesn't exist anymore. I was also able find example of GBP + EGL plain OpenGl application and modify it to present the issue without Qt. Unfortunately this example doesn't work with softpipe as it expects EGL_EXT_image_dma_buf_import extension to be supported. I'm not able quickly to update this example so that it works also with softpipe. But I'm sure the issue will go away then.
THE ISSUE:
SIMPLE EXAMPLE THAT WORK ON ANY OS WITHOUT COMPILATION: https://github.com/tolszak/panfrost_issue/tree/master
If need to debug c++ code please look at example below.
This is the source code of an example I prepared: https://github.com/tolszak/gbm_es2_demo/tree/odroid_issue
Just build it with cmake in source (not using shadowbuild directory) do to run subdirectory and invoke
./gbm_es2_demo
It should work on any Odroid N2 with latest mesa but I tested it on yocto based one as it was easiest to have something without compositor.
In the example I prepared I'm trying to show an image:
Vertex Shader is super simple:
#version 300 es
precision highp float;
layout(location = 0) in vec4 a_position;
layout(location = 1) in vec2 a_texCoord;
out vec2 v_texCoord;
void main()
{
gl_Position = a_position;
v_texCoord = a_texCoord;
}
Fragment shader too:
#version 300 es
precision highp float;
in vec2 v_texCoord;
layout(location = 0) out vec4 outColor;
uniform sampler2D s_texture;
void main()
{
outColor = texture2D( s_texture, v_texCoord );
}
That's the code that initializes vertex and texture coordinates:
GLfloat coord = 1.f * scale;
GLfloat vVertices[] = { -coord, coord, 0.0f, // Position 0
0.0f, 1.0f, // TexCoord 0
-coord, -coord, 0.0f, // Position 1
0.0f, 0.0f, // TexCoord 1
coord, -coord, 0.0f, // Position 2
1.0f, 0.0f, // TexCoord 2
coord, coord, 0.0f, // Position 3
1.0f, 1.0f // TexCoord 3
};
When the scale is 1 that's the output on screen:
And this nicely scales up to scale 15:
Then scale 16 looks as follows:
This "broken" one scale up to scale 31 when suddenly becomes black (I suppose the coordinate goes out of bounds somewhere):
Starting from scale 34 everything looks OK again:
When I comment out texture filtering:
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
The screen is black not matter which scale is set.
I don't know how to describe it better. If you think the case lacks of description please let me know or guide how to provide more content.