Bug 84004 - Bizarre vertex shader results (warped geometry) unless a never executed if-branch is added.
Summary: Bizarre vertex shader results (warped geometry) unless a never executed if-br...
Status: RESOLVED INVALID
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Ian Romanick
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-17 15:19 UTC by Luca Deltodesco
Modified: 2017-03-26 09:34 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
GLSL code for the 3 vertex shaders, work-around highlighted in each case. (17.05 KB, text/plain)
2014-09-17 15:19 UTC, Luca Deltodesco
Details
screenshot with workaround in place. (1.95 MB, image/png)
2014-09-17 15:20 UTC, Luca Deltodesco
Details
Screenshot without workaround in place (559.07 KB, image/png)
2014-09-17 15:21 UTC, Luca Deltodesco
Details
GLSL and IR dumps for the 3 vertex shaders without workarounds (90.24 KB, text/plain)
2014-09-18 10:04 UTC, Luca Deltodesco
Details
GLSL and IR dumps for the 3 vertex shaders with workarounds (91.39 KB, text/plain)
2014-09-18 10:05 UTC, Luca Deltodesco
Details

Description Luca Deltodesco 2014-09-17 15:19:08 UTC
Created attachment 106438 [details]
GLSL code for the 3 vertex shaders, work-around highlighted in each case.

WebGL, chrome + firefox on various devices (all 64bit linux + intel graphics)

Devices:

1)
Ubuntu 14.04
Intel Core i5 2500K
Mesa git a3306f02  2014-09-08 from Xorg-edgers ppa
Chrome 37 + Firefox 32

2)
Chrome book pixel
Intel Core i5 3427U
Mesa 10.3.0-devel git 1751a9b
Chrome 37

3)
Fedora 20
Intel Core i7 3612QM
Mesa 10.1.5
Chrome 37

Behaviour:

Geometry rendered with 3 particular vertex shaders ends up coming out with seemingly completely randomn positions, with triangles stretched all over the screen in a crazy mess.

Adding a single if branch (whose condition is always false) to the shaders fixes behaviour.

Behaviour does not occur on windows with intel drivers, or on windows/mac/linux with nvidia drivers. Status with ATI drivers is unknown.

Our shaders are written in CG compiled to GLSL, so apologies upfront for atrocious GLSL code. The relevant areas are highlighted. Producing a single reproducible can be done if required, though it would take some time, please let me know if the GLSL code is insufficient.

Screenshot without workaround: https://drive.google.com/file/d/0B0DebLXzXCcQYVJEQ0RQSjR6QlU
Screenshot with workaround: https://drive.google.com/file/d/0B0DebLXzXCcQalF5WVZiWjBlY2s
Comment 1 Luca Deltodesco 2014-09-17 15:20:58 UTC
Created attachment 106439 [details]
screenshot with workaround in place.
Comment 2 Luca Deltodesco 2014-09-17 15:21:17 UTC
Created attachment 106440 [details]
Screenshot without workaround in place
Comment 3 Luca Deltodesco 2014-09-17 15:23:22 UTC
For quick referenece, the work-around in each case for the 3 vertex shaders consists of:


if (distance < -10.0)
{
   devicePos = 0.0;
}


where distance is a local variable resulting from a call to length(_) ( and so can never be less than -10.0) and devicePos is another local variable used later in the function. The particular choice was not important, only that our compile step to GLSL from CG did not strip the if-branch from the code.
Comment 4 Ian Romanick 2014-09-17 21:13:55 UTC
Can you provide the output of the with and without work-around shaders with the following environment variables set?

    INTEL_DEBUG=vs MESA_GLSL=dump

Looking at differences in the IR and the final generated assembly might shed some light on the situation.  The most likely scenario is one of the optimization passes is making a bad choice...
Comment 5 Luca Deltodesco 2014-09-18 10:04:49 UTC
Created attachment 106493 [details]
GLSL and IR dumps for the 3 vertex shaders without workarounds

No assembly was found for these 3 shaders in the logs.
Comment 6 Luca Deltodesco 2014-09-18 10:05:24 UTC
Created attachment 106494 [details]
GLSL and IR dumps for the 3 vertex shaders with workarounds

No assembly dumps were found for these 3 shaders in the logs.
Comment 7 Timothy Arceri 2016-02-23 08:40:59 UTC
Does this still happen with a recent version of Mesa?

Its little hard to do anything about this just with the shaders an example app would be useful.

There is nothing obvious in the dumps either.
Comment 8 Timothy Arceri 2017-03-26 09:34:21 UTC
It's been over a year since more information was requested, and a lot longer since the bug was filed. Assuming this was has been fixed and the bug is no longer valid.


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.