Skip to contentSkip to conversation

New: r300g does not eliminate unread varyings

Bug 65416 [email protected] 1 participant 8 messages Jun 5, 2013 – Jul 13, 2013

lore
Share & tools
lore
#0 lore raw

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

Priority: medium
Bug ID: 65416
Assignee: [email protected]
Summary: r300g does not eliminate unread varyings
Severity: normal
Classification: Unclassified
OS: All
Reporter: [email protected]
Hardware: Other
Status: NEW
Version: git
Component: Drivers/Gallium/r300
Product: Mesa

Created attachment 80344
--> https://bugs.freedesktop.org/attachment.cgi?id=80344&action=edit
Example shaders

r300g tries to interpolate varyings written by the vertex shader even if the fragment shader does not read them. The attached program code illustrates this with two sample shaders.

The shaders in question were generated by Wine's fixed function pipeline replacement, generated from a fixed function setup set up by 3DMark 2000.

The visible issues caused by this are broken fog because the driver runs out of varyings and reduced performance due to the extra shader instructions.

An argument could be made that this is Wine's bug, and it should not generate such inefficient shaders. Doing this would be a major inconvenience though because the vertex and fragment shader are generated independently. As far as I can see the proprietary drivers optimize this inefficiency away.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw

[Bug 65416] r300g does not eliminate unread varyings

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

--- Comment #1 from Stefan Dösinger <[email protected]> --- Fwiw, I don't know if r600g is affected. The HW has enough varyings to run the unoptimized shaders, and the applications affected by this performance wise are CPU limited on my r600g system.

Wine has some checks to prevent writing texture coordinates in the vertex shader when there is no input to generate them. Unfortunately 3DMark 2000 and Unreal Tournament 2004 use a strange vertex processing setup that breaks those checks(D3DTSS_TEXCOORDINDEX of all texture stages is 0, thus they're reading the first texture coordinate input, which does exist).

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

[Bug 65416] r300g does not eliminate unread varyings

In reply to [email protected]

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

--- Comment #2 from Alex Deucher <[email protected]> ---
Couldn't this be done in a device independent manner in mesa when linking shaders? Drop outputs if there is no matching input in the subsequent shader stage?

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

[Bug 65416] r300g does not eliminate unread varyings

In reply to [email protected]

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

--- Comment #3 from Marek Olšák <[email protected]> ---
I think the GLSL compiler only eliminates unused user-defined varyings, unused legacy varyings are not eliminated. I'm taking this task.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

[Bug 65416] r300g does not eliminate unread varyings

In reply to [email protected]

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

--- Comment #4 from Stefan Dösinger <[email protected]> --- Cool, thanks!

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

[Bug 65416] r300g does not eliminate unread varyings

In reply to [email protected]

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

--- Comment #5 from Marek Olšák <[email protected]> ---
I have implemented it, but there is a problem. If I enable the optimization, EXT_separate_shader_objects must be disabled. Is it okay with you?

This is a valid sequence with EXT_sso:
glUseProgram(prog_with_vs_and_fs);
glUseShaderProgramEXT(prog_with_fs);

prog_with_vs_and_fs cannot be optimized, because the program object can be bound partially (in this case only the vertex shader from the program object is bound).

ARB_separate_shader_objects doesn't have this issue.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

[Bug 65416] r300g does not eliminate unread varyings

In reply to [email protected]

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

--- Comment #6 from Stefan Dösinger <[email protected]> --- I guess that's ok for wined3d's purposes. We don't use either extension right now, and if we ever use one of them we'll probably go with the ARB one anyway.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

[Bug 65416] r300g does not eliminate unread varyings

In reply to [email protected]

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

Marek Olšák <[email protected]> changed:

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

             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Marek Olšák <[email protected]> --- Fixed by a commit series which starts here:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=74edd56927801e8c646c7d5cddba397c2f54b4ef

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel