Bug 23946 - Wine GLSL support
Summary: Wine GLSL support
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:
URL: http://www.daionet.gr.jp/~masa/rthdri...
Whiteboard:
Keywords:
: 23960 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-09-14 14:56 UTC by Sven Arvidsson
Modified: 2010-08-01 12:54 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Sven Arvidsson 2009-09-14 14:56:11 UTC
GLSL support in Wine often results in a massive amount of errors and a mostly black screen:

fixme:d3d_shader:print_glsl_info_log Error received from GLSL shader #1:
fixme:d3d_shader:print_glsl_info_log     Unresolved symbols
fixme:d3d_shader:set_glsl_shader_program >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from Find glsl program uniform locations @ ../../../dlls/wined3d/glsl_shader.c / 4151
fixme:d3d_shader:set_glsl_shader_program >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from glUseProgramObjectARB(programId) @ ../../../dlls/wined3d/glsl_shader.c / 4165
fixme:d3d_shader:hardcode_local_constants >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from Hardcoding local constants @ ../../../dlls/wined3d/glsl_shader.c / 3702
fixme:d3d_shader:shader_glsl_select >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from glUseProgramObjectARB @ ../../../dlls/wined3d/glsl_shader.c / 4293
fixme:d3d_shader:shader_glsl_select >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from glUseProgramObjectARB @ ../../../dlls/wined3d/glsl_shader.c / 4293
fixme:d3d_shader:shader_glsl_load_constants >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from glUniform4fvARB @ ../../../dlls/wined3d/glsl_shader.c / 667
fixme:d3d_shader:shader_glsl_load_constants >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from glUniform4fvARB @ ../../../dlls/wined3d/glsl_shader.c / 667

This example comes from rthdribl, a DirectX 9 demo. It has a silver rating in Wines AppDB so should work without problems:
http://appdb.winehq.org/objectManager.php?sClass=application&iId=10203

rthdribl:
http://www.daionet.gr.jp/~masa/rthdribl/index.html

mfc42.dll is also needed for it to run
http://www.dll-files.com/dllindex/dll-files.shtml?mfc42
Comment 1 Brian Paul 2009-09-14 16:30:27 UTC
OK, I think I found the issue here.

Mesa links multiple shaders by concatenating them together then recompiling.
When the shaders contain #version directives the extra/redundant #version lines caused a preprocessor failure.

Mesa commit b8b774c775b672c89f1f4007c7b9575052d85739 removes the extra #version directives.  I'll merge the fix to Mesa/master in a little while...

Comment 2 Brian Paul 2009-09-14 16:43:44 UTC
There's another issue but it's a problem with Wine.

The following vertex program is illegal:

!!ARBvp1.0
PARAM C[66] = { program.env[0..65] };
ADDRESS A0;PARAM zero = {0.0, 0.0, 0.0, 0.0};
ARL A0.x, zero.x;
MOV result.position, C[A0.x + 65];
END

The problem is the offset in "A0.x + 65" is too large.

From the GL_ARB_vertex_program specification:

"""
(26) What limits should be imposed on the constants that can be added to
or subtracted from the address register for relative addressing?  Negative
offsets are sometimes useful for shifting down in an array.

  RESOLVED:  -64 to +63 should be sufficient for the time being.  Offset
  sizes are limited to allow offsets to be baked into device-dependent
  instruction encodings.
"""

So 65 is illegal according to the GL spec, but when I tested with NVIDIA's driver, offsets up to 255 work without error.  Hmmm.
Comment 3 Henri Verbeet 2009-09-15 00:25:29 UTC
(In reply to comment #2)
> There's another issue but it's a problem with Wine.
> 
> The following vertex program is illegal:
> 
> !!ARBvp1.0
> PARAM C[66] = { program.env[0..65] };
> ADDRESS A0;PARAM zero = {0.0, 0.0, 0.0, 0.0};
> ARL A0.x, zero.x;
> MOV result.position, C[A0.x + 65];
> END
> 
> The problem is the offset in "A0.x + 65" is too large.
>
We use that during wined3d starup to detect if the GL implementation will accept offsets outside the -64 to +63 range. We try to avoid them if the implementation doesn't support them, but that's not always easily possible.

Comment 4 Brian Paul 2009-09-15 07:53:31 UTC
Do most other GL drivers allow a larger range of offsets?  We could easily raise them in Mesa.
Comment 5 Henri Verbeet 2009-09-15 08:52:23 UTC
(In reply to comment #4)
> Do most other GL drivers allow a larger range of offsets?  We could easily
> raise them in Mesa.
> 
Nvidia and fglrx do, I'm not completely sure about Apple.
Comment 6 Ian Romanick 2009-09-16 07:38:23 UTC
(In reply to comment #4)
> Do most other GL drivers allow a larger range of offsets?  We could easily
> raise them in Mesa.

It looks like all the hardware we support should handle at least signed 7-bit offsets.  I'm not 100% sure about r200, though.
Comment 7 Brian Paul 2009-09-16 07:49:43 UTC
Perhaps we should add a ctx->Const.Vertex/FragmentProgram.MaxAddrOffset field rather than hard-code a value in the parser.

The range would be [-MaxAddrOffset-1 , MaxAddrOffset].
Comment 8 Pauli 2009-09-16 07:55:10 UTC
(In reply to comment #6)
> (In reply to comment #4)
> > Do most other GL drivers allow a larger range of offsets?  We could easily
> > raise them in Mesa.
> 
> It looks like all the hardware we support should handle at least signed 7-bit
> offsets.  I'm not 100% sure about r200, though.
> 

I did check the r200 and registers support 8bits for offset but vertex program compiler doesn't support negative values. I don't know if that is software or hardware limit.
Comment 9 Ian Romanick 2009-09-16 08:17:03 UTC
I'm closing this bug since Brian fixed the original issue.  I've opened a new bug (bug #23975) for the enhancement to increase the range of supported relative address offsets.  I'll try to incorporate this in the next round of assembly shader work (currently on the asm-shader-rework-2 branch).
Comment 10 Sven Arvidsson 2009-09-16 09:01:58 UTC
*** Bug 23960 has been marked as a duplicate of this bug. ***
Comment 11 Roland Scheidegger 2009-09-16 10:34:49 UTC
(In reply to comment #8)
> (In reply to comment #6)
> > (In reply to comment #4)
> > > Do most other GL drivers allow a larger range of offsets?  We could easily
> > > raise them in Mesa.
> > 
> > It looks like all the hardware we support should handle at least signed 7-bit
> > offsets.  I'm not 100% sure about r200, though.
> > 
> 
> I did check the r200 and registers support 8bits for offset but vertex program
> compiler doesn't support negative values. I don't know if that is software or
> hardware limit.

I'm pretty sure when I wrote that code in the r200 driver it didn't work with fglrx. I think I quickly tried negative offsets but couldn't get it to work, hence the driver emitting a warning and just using index 0... It is possible though I made some mistake.
Comment 12 Alex Deucher 2009-09-16 11:42:04 UTC
(In reply to comment #11)
> 
> I'm pretty sure when I wrote that code in the r200 driver it didn't work with
> fglrx. I think I quickly tried negative offsets but couldn't get it to work,
> hence the driver emitting a warning and just using index 0... It is possible
> though I made some mistake.
> 

I can probably dig up the r2xx vertex specs if there is anyone interested in pursuing this.
Comment 13 Ian Romanick 2009-09-16 15:44:14 UTC
(In reply to comment #11)
> (In reply to comment #8)
> > I did check the r200 and registers support 8bits for offset but vertex program
> > compiler doesn't support negative values. I don't know if that is software or
> > hardware limit.
> 
> I'm pretty sure when I wrote that code in the r200 driver it didn't work with
> fglrx. I think I quickly tried negative offsets but couldn't get it to work,
> hence the driver emitting a warning and just using index 0... It is possible
> though I made some mistake.

This only comes up if baseReg + offset is less than zero.  For example, if the base index of "foo" is >= 4, the following code is fine:

    MOV    R0, foo[A0.x - 4];

We could probably modify the placement algorithm in prog_parameter_layout.c to account for this.  Alex or Roland (or someone working on the r200 driver) should probably submit enhancement bugs for these issues.

Note that the r300 driver seems to have the same behavior.
Comment 14 Vinson Lee 2010-08-01 12:54:50 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > Do most other GL drivers allow a larger range of offsets?  We could easily
> > raise them in Mesa.
> > 
> Nvidia and fglrx do, I'm not completely sure about Apple.

An offset of 64 or -65 does not compile with Apple.


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.