Bug 99730 - Metro Redux game(s) needs override for midshader extension declaration
Summary: Metro Redux game(s) needs override for midshader extension declaration
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 77449
  Show dependency treegraph
 
Reported: 2017-02-09 13:06 UTC by Eero Tamminen
Modified: 2018-08-13 03:08 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
drirc patch (654 bytes, patch)
2017-02-09 13:06 UTC, Eero Tamminen
Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Eero Tamminen 2017-02-09 13:06:26 UTC
Created attachment 129435 [details] [review]
drirc patch

Use-case:
- Install Steam & Metro 2033 Redux game
- Run game and switch it to High gfx quality
- Run again with warnings enabled

Actual outcome (from apitrace replay):
- This:
--------------------
warning: compilation failed
warning: 0:16(1): error: #extension directive is not allowed in the middle of a shader
warning: link failed
warning: error: linking with uncompiled shader
warning: link failed
warning: error: linking with uncompiled shader
--------------------
- And tens of these during startup & browsing game options:
--------------------
warning: glGetError(glUseProgram) = GL_INVALID_OPERATION
warning: program validation failed
--------------------

That shader seems to be used only during loading & menus, and I didn't notice any obvious rendering issues, but may be still better to add drirc workaround for it.  See attached patch for an example.

Note: I don't have Metro Last Light Redux, but it may have the same issue and same binary name.  Earlier non-Redux version of MetroLL didn't have this issue, and has different binary name.
Comment 1 Eero Tamminen 2017-02-09 13:34:52 UTC
PS. At least on Intel SKL with latest Mesa, something weird happens when switching between gfx quality levels.  Trying e.g. to switch to "Very high" level (by exiting the video options with ESC) freezes the game for few minutes after which it back to viddeo options.

Can somebody reproduce that behavior?
Comment 2 Grigori Goronzy 2017-02-09 14:17:20 UTC
> At least on Intel SKL with latest Mesa, something weird happens when switching between gfx quality levels.  Trying e.g. to switch to "Very high" level (by exiting the video options with ESC) freezes the game for few minutes after which it back to viddeo options.

The game seems to recreate *all* shaders in this case. The game also starts a prompt to ask the user to accept the new settings with a 30 second timeout and if there's no input in the meantime, it will reset to the old settings. However, due to the shader compiler hang, the prompt never actually displays.

This used to be a problem with radeonsi, but with the more recent optimizations to shader compilation, it now typically takes less than 30 seconds to recover from the hang, so it mostly works.
Comment 3 Eero Tamminen 2017-02-09 16:14:31 UTC
Thanks!  I guess this is one of the use-cases that actually *requires* shader compiler cache to work, so that user can (on second try) actually exit from the gfx options.  Should I file (a separate) bug about that too?
Comment 4 Timothy Arceri 2018-04-13 06:04:36 UTC
Is this still a problem? If so can you rebase the patch and send it to the list?
Comment 5 Eero Tamminen 2018-04-13 12:40:19 UTC
(In reply to Timothy Arceri from comment #4)
> Is this still a problem? If so can you rebase the patch and send it to the
> list?

I don't know, I haven't had time to try any Steam stuff for several months. Unfortunately it seems that I won't have time for that in next few months either.

I assume the second issue (gfx level change failing because shader compilation takes too long), will now succeed at least on second try due to shader cache being enabled by default.
Comment 6 vadym 2018-08-06 10:21:53 UTC
Hi Euro,

Got the same issue with the Metro Last Light Redux:

: GLSL source for fragment shader 498:
: #version 400
struct vec1 {
	float x;
};
struct uvec1 {
	uint x;
};
struct ivec1 {
	int x;
};
subroutine void SubroutineType();
layout(std140) uniform;
layout(location = 0) out  vec4 PixOutput0;
#define Output0 PixOutput0
#ifdef GL_ARB_conservative_depth
#extension GL_ARB_conservative_depth : enable
layout (depth_greater) out float gl_FragDepth;
#endif
void main()
{
    Output0 = vec4(vec4(1.00000000000, 1.00000000000, 1.00000000000, 1.00000000000)).xyzw;
    gl_FragDepth = vec4(1.00000000000).x;
    return;
}

: Info Log:
0:16(1): error: #extension directive is not allowed in the middle of a shader


I didn't noticed any visual issues (but suppose it should be fixed anyway). Last Night Redux is run with the same binary name (metro) as in case of Metro 2033 redux. So your patch fixes both cases. I re-based and tested your patch and confirm it fixes the issue.

Can you please send the patch for review ? Or just let me know it you want me to send it.
Comment 7 Eero Tamminen 2018-08-06 10:31:53 UTC
(In reply to vadym from comment #6)
> I didn't noticed any visual issues (but suppose it should be fixed anyway).
> Last Night Redux is run with the same binary name (metro) as in case of
> Metro 2033 redux. So your patch fixes both cases. I re-based and tested your
> patch and confirm it fixes the issue.

Thanks for testing!

As it fixes both, the name attribute in patch should state that too, e.g:
name="Metro 2033 Redux / Last Light Redux"


> Can you please send the patch for review ? Or just let me know it you want
> me to send it.

Unfortunately I still don't have time for Steam stuff, so if you could update the patch and do that, it would be great!


Patch description should contain:
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99730
Comment 8 vadym 2018-08-06 12:56:19 UTC
(In reply to Eero Tamminen from comment #7)
> (In reply to vadym from comment #6)
> > I didn't noticed any visual issues (but suppose it should be fixed anyway).
> > Last Night Redux is run with the same binary name (metro) as in case of
> > Metro 2033 redux. So your patch fixes both cases. I re-based and tested your
> > patch and confirm it fixes the issue.
> 
> Thanks for testing!
> 
> As it fixes both, the name attribute in patch should state that too, e.g:
> name="Metro 2033 Redux / Last Light Redux"
> 
> 
> > Can you please send the patch for review ? Or just let me know it you want
> > me to send it.
> 
> Unfortunately I still don't have time for Steam stuff, so if you could
> update the patch and do that, it would be great!
> 
> 
> Patch description should contain:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99730

Patch pushed for review https://patchwork.freedesktop.org/patch/242827/
Comment 9 Timothy Arceri 2018-08-13 03:08:01 UTC
Fixed by:

commit e0de26eacc93f431962533f50d57e58335843d6b
Author: vadym.shovkoplias <vadim.shovkoplias@gmail.com>
Date:   Mon Aug 6 15:52:13 2018 +0300

    drirc: Allow extension midshader for Metro Redux
    
    This fixes both Metro 2033 Redux and Metro Last Light Redux
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99730
    Signed-off-by: Eero Tamminen <eero.t.tamminen@intel.com>
    Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com>
    Reviewed-by: Tapani Pälli <tapani.palli@intel.com>


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.