Skip to contentSkip to conversation

New: Suspected loss of varyings between shaders

Bug 42435 [email protected] 1 participant 16 messages Oct 31, 2011 – Feb 26, 2012

lore
Share & tools
lore
#0 lore raw

https://bugs.freedesktop.org/show_bug.cgi?id=42435

Bug #: 42435
Summary: Suspected loss of varyings between shaders
Classification: Unclassified
Product: Mesa
Version: git
Platform: x86-64 (AMD64)
OS/Version: Linux (All)
Status: NEW
Severity: major
Priority: medium
Component: Drivers/Gallium/r600
AssignedTo: [email protected]
ReportedBy: [email protected]

Longer description, the test case, screenshots, and core from i965 crash are in attached archive.

In short:

I try to draw a 2D screenful of point sprites, emulating an ansi-colored terminal. Fragment shader receives texture coordinates for the character, its color and size of graphic in the texture via varyings.

R600g draws a black screen, while llvmpipe and fglrx draw what is supposed to be drawn. i965 crashes. non-llvm swrast fails to set gl_PointSize. R600c also draws a black screen.

Drawing varying values themselves I get bogus values for some of them.

Mesa version: 7.12.0~git20111027.0fbc8d30-0ubuntu0sarvatt~natty

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#1 lore raw

[Bug 42435] Suspected loss of varyings between shaders

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #1 from Alexander Sabourenkov <[email protected]> 2011-10-31 07:43:44 PDT --- Created attachment 52954
--> https://bugs.freedesktop.org/attachment.cgi?id=52954
Test case and stuff

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#3 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #3 from Alexander Sabourenkov <[email protected]> 2011-11-01 02:42:01 PDT --- Worked around the issue by moving all texture sampling to fragment shader. (even works on 965)

Also, just moving sampling outside conditional blocks did not change anything.

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#4 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #4 from Alexander Sabourenkov <[email protected]> 2011-11-01 15:27:29 PDT --- The workaround did not help r600g. Same black screen. In addition, the non-llvm swrast draws point sprites 60 pixels in size instead of requested 16 (my original shaders get texture sub-image size via varyings too), plus it draws solid-black-textured point sprites as single pixels. r600c (as of Oct 27 git, just before being axed) works though.

Not knowing whether any given black screen is a bug, or legitimate undefined behaviour that just happens to work on some other renderer is driving me mad.

I managed to cut down the test case to bare minimum.

Usage:

./testbed <shaderset> <mesadriver>

shaderset is either "working" or "failing" - loads similarly named shaders.

"working" shader set does texture sampling in fragment shader "failing" shader set does texture sampling in vertex shader and passes the color as a varying vec4.

mesadriver is:
hw - default, LIBGL_ALWAYS_SOFTWARE and LIBGL_DRIVERS_PATH unset. hw-alt - use .so from dri-alternates (x64-86 hardcoded, sorry). sw - LIBGL_ALWAYS_SOFTWARE=y
sw-alt - as above, but use .so from dri-alternates.

For the Oct 27 git these map to r600g, r600c, swrast, llvmpipe on my box.

Of those:

"failing" llvmpipe - works as intended, vertical colored bars (composed of 16x16 point sprites), one sprite is dark green - left unpainted intentionally. "working" llvmpipe - same (ok)
"failing" DRI - ok
"working" DRI - ok
"failing" r600g - all sprites black
"working" r600g - all sprites black
"failing" old-swrast - single pixels instead of 16x16, but looks like color is right
"working" old-swrast - same as "failing"

The hardware is rv770 9440.

I'd say there's a problem with r600g and a different one with old swrast.

There's also intermittent display corruption mainly on areas in xterm redrawn (but not those that get scrolled up) immediately after launching the testcase.

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#5 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #5 from Alexander Sabourenkov <[email protected]> 2011-11-01 15:28:43 PDT --- Created attachment 53025
--> https://bugs.freedesktop.org/attachment.cgi?id=53025
minimized test case

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#6 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #6 from Alexander Sabourenkov <[email protected]> 2011-11-01 17:31:52 PDT --- Created attachment 53028
--> https://bugs.freedesktop.org/attachment.cgi?id=53028
xterm corruption screenshot

xterm corruption screenshot, got it right after I first run those shaders:

#version 120
#line 2 0

uniform float posz;
uniform float width;
attribute vec2 posn;

varying float idx;

void main() { 
    vec2 posn2 = posz*posn;
    idx = posn2.x/width;
    gl_Position = gl_ModelViewProjectionMatrix*vec4(posn2.x, posn2.y, 0.0,
1.0);
    gl_PointSize = posz;
}

#version 120
#line 2 0
uniform sampler2D ansi;

varying float idx;

void main() {
    vec2 pc = gl_PointCoord;
    gl_FragColor = texture2D(ansi, vec2(0.5, 0));
}

- got grey screen as expected, and then reset fragment shader back to

#version 120
#line 2 0
uniform sampler2D ansi;

varying float idx;

void main() {
    vec2 pc = gl_PointCoord;
    gl_FragColor = texture2D(ansi, vec2(idx, 0));
}
Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#7 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #7 from Alexander Sabourenkov <[email protected]> 2011-11-01 17:53:45 PDT --- Further reducing shaders I got to this point:

#version 120
#line 2 0

varying float idx;

void main() { 
    vec2 posn2 = posz*posn;
    idx = 0.625;
    gl_Position = gl_ModelViewProjectionMatrix*vec4(128, 128, 0.0, 1.0);
    gl_PointSize = 128;
}

#version 120
#line 2 0
varying float idx;

void main() {
    gl_FragColor = vec4(idx, 0, 0, 1);
}

This is in fact very close to glsl-novertexdata from the piglit.

Which still does not work on r600g and swrast while working ok on r600c and llvmpipe.

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#8 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #8 from Alexander Sabourenkov <[email protected]> 2011-11-01 17:54:54 PDT --- Created attachment 53029
--> https://bugs.freedesktop.org/attachment.cgi?id=53029
piglit test case for the problem

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#9 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

Alexander Sabourenkov <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

  Attachment #53029|0                           |1

is obsolete| |

--- Comment #9 from Alexander Sabourenkov <[email protected]> 2011-11-01 18:03:56 PDT --- Created attachment 53030
--> https://bugs.freedesktop.org/attachment.cgi?id=53030
piglit test case for the problem as a patch

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#10 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

Alexander Sabourenkov <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

  Attachment #53030|0                           |1

is obsolete| |

--- Comment #10 from Alexander Sabourenkov <[email protected]> 2011-11-01 18:40:05 PDT --- Created attachment 53031
--> https://bugs.freedesktop.org/attachment.cgi?id=53031
piglit test case for the problem as a patch

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#11 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #11 from Alexander Sabourenkov <[email protected]> 2011-11-01 18:41:06 PDT --- Problem manifests itself only when gl_PointSize is set in the shader. Corrected patch attached.

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#12 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #12 from Vadim <[email protected]> 2011-11-01 21:56:03 PDT --- Created attachment 53033
--> https://bugs.freedesktop.org/attachment.cgi?id=53033
[PATCH] r600g: take into account PSIZE output for spi mapping

Does this patch help?

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#14 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

--- Comment #14 from Claudio Freire <[email protected]> 2012-02-25 14:26:24 PST --- I experience a similar situation with Ironlake and Mesa 8.0.1, only with far more complex shaders.

Apparently, in these shaders, all varyings get bogus data on the fragment shader.

The only workaround I can find is passing that data through the built-in varying in gl_TexCoord, although that's quite suboptimal for other drivers so I would prefer not to.

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
#15 lore raw

[Bug 42435] Suspected loss of varyings between shaders

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=42435

Alex Deucher <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #15 from Alex Deucher <[email protected]> 2012-02-26 07:29:38 PST --- r600g fixed in:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=16c0a3a9720c03c3d5cbfd66e2db63014dfc4f19

Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.