Bug 99843 - Geometry Shader - Incorrect Output
Summary: Geometry Shader - Incorrect Output
Status: RESOLVED MOVED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/r600 (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-16 20:24 UTC by dan
Modified: 2019-09-18 19:22 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Typical output (1.74 MB, image/jpeg)
2017-02-16 20:24 UTC, dan
Details
Trace (108.40 KB, application/octet-stream)
2017-02-17 17:01 UTC, dan
Details

Description dan 2017-02-16 20:24:35 UTC
Created attachment 129684 [details]
Typical output

Hi,

I am developing a cross-platform application. I have recently found an issue that is only present when it is tested on a Ubuntu machine. I have managed to find a minimal example that shows the issue as follows:

The vertex shader:

#version 150
in vec2 pos;

void main(void)
{
    gl_Position = vec4(pos, 0.0, 1.0);
}


The fragment shader:

#version 150
out vec4 outColour;

void main(void)
{
    outColour = vec4(1.0f, 1.0f, 1.0f, 1.0f);
}


The geometry shader:

#version 150
layout(points) in;
layout(line_strip, max_vertices = 13) out;
uniform mat4 vpMatrix;

void main()
{
    for(int i = 0; i < 13; i++)
    {
        float polygonAngle = (i * 30) + 90.0f;
        vec4 vertexPosition = vec4((sin(radians(polygonAngle)) * 0.5f) + gl_in[0].gl_Position.x, (cos(radians(polygonAngle)) * 0.5f) + gl_in[0].gl_Position.y, 0.0f, 1.0f);
        gl_Position = vpMatrix * vertexPosition;
        EmitVertex();
    }
    EndPrimitive();
}

The problem occurs when the shader program is used with multiple VBO's. For example:

3 separate VBO's are created with {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f} as the data. Then, for each repaint:

for(int i = 0; i < 3; i++)
{
    Bind array buffer i.
    glDrawArrays(GL_POINTS, 0, 1);
}

This produces strange results for the third polygon (shown in the attached image Output.JPG).

If tested on a Windows 10 machine (exactly the same hardware) or an OSX machine, the results are as expected (3 regular polygons with 12 sides).
Comment 1 Nicolai Hähnle 2017-02-16 21:13:38 UTC
Interesting, thanks for the report.

Is this really an issue of having separate VBOs, or does the issue also occur when you use separate draw calls with a single VBO? Or a single draw call?

Do you have a simple program that reproduces this? Alternatively, an apitrace is likely to help.
Comment 2 dan 2017-02-16 22:13:54 UTC
I've just tried with multiple draw calls using the same VBO and it appears this does also cause the error. However, it appears there has to be 3 or more calls to cause the error (1 and 2 calls produce the expected output).

Apologies for that. It was the way my application works that led me down that path.

I currently do not have a simple program that demonstrates the error. I have amended the application I've been writing to call the test shaders as I was trying to work out what was wrong with my application. I could probably create something. What is the usual format to provide this in?

Thanks.
Comment 3 Ilia Mirkin 2017-02-16 22:16:57 UTC
https://github.com/apitrace/apitrace

This can be used to record (and replay) all the GL commands sent down to the driver.
Comment 4 dan 2017-02-17 17:00:30 UTC
I created a minimal test program that simply draws the 3 polygons (12 sided). I have used apitrace with this test program to generate a trace and I'll upload this shortly. Thanks.
Comment 5 dan 2017-02-17 17:01:45 UTC
Created attachment 129697 [details]
Trace
Comment 6 Tom St Denis 2017-02-17 23:53:57 UTC
What hardware is this on?  I wonder if it's a dup of 99850 (which was found on a Carrizo).
Comment 7 Ilia Mirkin 2017-02-17 23:55:58 UTC
FWIW it appears to render correctly on both nouveau (GK208) as well as i965 (SKL).
Comment 8 dan 2017-02-18 06:42:44 UTC
The hardware is Radeon HD 4890.
Comment 9 Grazvydas Ignotas 2017-02-19 17:46:00 UTC
Also good on radeonsi (POLARIS10) and i965 (HSW).
Comment 10 Gert Wollny 2017-06-22 17:07:23 UTC
Looks good on Barts (6870)  (mesa-git 903e1047) that actually uses r600g.

When replaying the trace I see an api issue message though: 

1430: message: api issue 1: FBO incomplete: no attachments and default width or height is 0 [-1]
Comment 11 dan 2017-11-01 15:24:50 UTC
Hi,

Is it likely this will be looked into or are there no plans to look into issues for older cards?
Comment 12 Ilia Mirkin 2017-11-01 15:30:22 UTC
No one has been able to reproduce, tried on various hardware including a Radeon 6870 (BARTS).

Without more information, it's unlikely that anything will happen. At the very least (a) recheck on mesa master and if it's still broken, (b) supply information about your GPU.
Comment 13 dan 2017-11-06 07:56:40 UTC
Hi,

It is still a problem. I detailed the card in comment 8 (HD 4890). Could you advise what other information you would need about the GPU?

Thanks.
Comment 14 dan 2017-11-06 10:10:06 UTC
The 4890 has a RV790 GPU.

I've run the trace again and also see an error similar to the one Gert mentioned:

1639 Message api issue 1: FBO incomplete: no attachments and default width or height is 0 [-1].

There are also more errors reported around glDrawArrays as follows:

major api error 2: GL_INVALID_ENUM in glGetIntegerV(pname=GL_TEXTURE_BINDING_CUBE_MAP_ARRAY)

warning: dumping of normalized attribute (vertexCoord) not yet supported

warning: dumping of normalized attribute (textureCoord) not yet supported
Comment 15 dan 2017-11-06 20:09:30 UTC
I was reading about the R600 driver and came across a TODO page that suggested testing using piglit.

I downloaded and compiled this. I ran the "shader.py" test and it gave the following results:

skip: 26496  Pass: 6567  Warn: 2  Fail:496  Crash: 5

I'm not sure if piglit is a good measure on this but the number of fails seems very high.
Comment 16 GitLab Migration User 2019-09-18 19:22:49 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/597.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.