https://bugs.winehq.org/show_bug.cgi?id=39578
Bug ID: 39578 Summary: hlsl float constant translate error if constant name like 'c873' Product: Wine Version: 1.7.54 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3dx9 Assignee: wine-bugs@winehq.org Reporter: gamiljydcome@gmail.com Distribution: ---
I use WINEDEBUG=+d3d_shader trace an broken 3d model game, i notice something wrong like follow:
trace:d3d_shader:shader_trace_init def c783 = 1.000000, 3.000000, 0.000000, 0.000000 warn:d3d_shader:shader_record_register_usage Shader using float constant 783 which is not supported.
But followed hlsl fragment can be translated correctly:
(hlsl)d3d_shader:shader_trace_init def c0 = -100.000000, 0.000000, 1.000000, 0.000000 ------------------------------------------ (glsl)d3d_shader:d3d_compiler const vec4 ps_lc0 = vec4(-1.00000000e+02, 0.00000000e+00, 1.00000000e+00, 0.00000000e+00);
The point is the diffrence between names: c783 c0. If hlsl fragment define variables names like c783 c771 c831 etc, then tanslate must be wrong.
I think 'def c783' is just a variables name, Right? If so it should be translate to 'const vec4 ps_lc783 = vec4...' although i don't know what's that really means.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #1 from Matteo Bruni matteo.mystral@gmail.com --- Strings like "def c783..." you mention are not HLSL but actually disassembled shader bytecode and c783 is a float constant register. The warning you get is thrown by wined3d, complaining that the shader is trying to use an unsupported register (you have at most 256 float constant registers in d3d9, that's for shader model 3 vertex shaders) and failing shader compilation.
That is the limit, at least, for hardware d3d devices. Software vertex processing relaxes many of those registry limits: https://msdn.microsoft.com/en-us/library/windows/desktop/bb147365%28v=vs.85%... . Wined3d doesn't support software vertex processing at the moment though.
What game are you trying to run?
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #2 from gamiljydcome@gmail.com --- Oh, sorry i thought "def c783..." is hlsl fragment.
So you mean "def c783..." must be supported by hardware, wine not implement software support yet? I can test this game under winxp/win7, that means m$ implement software support, right?
Does somebody patched this already or discussed?
The game is Illusion's School Mate 2.
https://bugs.winehq.org/show_bug.cgi?id=39578
gamiljydcome@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Distribution|--- |Debian
--- Comment #3 from gamiljydcome@gmail.com --- Hi, Matteo Bruni.
I make some time googled about wine shader model3.0 constant register limit and traced dlls/wined3d/shader.c. It seem like wine forece limit sm3.0 max number of float constant registers to be 256, my video card(Mobile Intel GM45 support dx10/sm4.0) does have 4096 registers detected by gl_info->limits.glsl_ps_float_constants. I don't know why.
At same time i googled some information about even if wine forced sm3.0 limit 256 float constant registers, most dx9/sm3 app may not practicality use all of them though wined3d shader bytecode like 'def c783...'.
So i think does wine could reorder to use the float constant registers array like 'def c0 ~ def c255' mapping the hlsl constant from app one by one, to avoid using more than 256 registers?
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #4 from Matteo Bruni matteo.mystral@gmail.com --- (In reply to gamiljydcome from comment #3)
Hi, Matteo Bruni.
I make some time googled about wine shader model3.0 constant register limit and traced dlls/wined3d/shader.c. It seem like wine forece limit sm3.0 max number of float constant registers to be 256, my video card(Mobile Intel GM45 support dx10/sm4.0) does have 4096 registers detected by gl_info->limits.glsl_ps_float_constants.
Yes, your GPU supports more uniforms than required by SM3, but that's unrelated. D3D9 doesn't accept hardware vertex shaders using more than 256 float constants, we have a test confirming that. It's a different story for vs_2_sw and vs_3_sw shaders, as I already mentioned. Wined3d currently lacks support for them.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #5 from gamiljydcome@gmail.com --- This Bug is Closed.
I've reported an bug(sort of not be) that wine just not implemention right now, and it's not the really problem cause the game i tested shows broken 3d model although i don't know where's the problem. Any way this bug is closed.
Thanks Matteo Bruni for you reply.
https://bugs.winehq.org/show_bug.cgi?id=39578
Matteo Bruni matteo.mystral@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Component|directx-d3dx9 |directx-d3d Resolution|--- |DUPLICATE Summary|hlsl float constant |Wined3d does not support |translate error if constant |vs_2_sw and vs_3_sw |name like 'c873' |software vertex shaders
--- Comment #6 from Matteo Bruni matteo.mystral@gmail.com --- (In reply to gamiljydcome from comment #5)
This Bug is Closed.
I've reported an bug(sort of not be) that wine just not implemention right now, and it's not the really problem cause the game i tested shows broken 3d model although i don't know where's the problem. Any way this bug is closed.
Thanks Matteo Bruni for you reply.
Np, although this bug is still valid. I'm resolving it as duplicate of bug 8051.
*** This bug has been marked as a duplicate of bug 8051 ***
https://bugs.winehq.org/show_bug.cgi?id=39578
mrdeathjr28@yahoo.es changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mrdeathjr28@yahoo.es
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #7 from gamiljydcome@gmail.com --- Hi, swswine.
The new temp patch indeed work. I have fellowed questions:
1. Does still HW vertex blend increase D3D9_MAX_VERTEX_SHADER_CONSTANTF to 1024?
2. I thinl my Intel have 4096 registers detected by gl_info->limits.glsl_ps_float_constants(dlls/wined3d/shader.c), So does it means i can change you patch 1024 to 4096 won't import potential bugs?
Thanks.
https://bugs.winehq.org/show_bug.cgi?id=39578
swswine@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |swswine@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #8 from swswine@gmail.com --- (In reply to gamiljydcome from comment #7)
Hi, swswine.
The new temp patch indeed work. I have fellowed questions:
- Does still HW vertex blend increase D3D9_MAX_VERTEX_SHADER_CONSTANTF to
1024?
Sorry, I did not understand the question. Could you please explain in some other words?
- I thinl my Intel have 4096 registers detected by
gl_info->limits.glsl_ps_float_constants(dlls/wined3d/shader.c), So does it means i can change you patch 1024 to 4096 won't import potential bugs?
Yes, log you sent previously says that 4096 uniform float constants are supported. When you are using my IVB patch without uniform buffers support, the actual number of uniform floats used in glsl shader is >2k.
Just to note, changing the limit even above your actual limit won't lead to an error immediately, only if some application will actually try to use more constants that GL supports.
If you will be changing the constants please mind that D3D9_MAX_VERTEX_SHADER_CONSTANTF in d3d9/d3d9_private.h is not the only place, there is also a structure initialization in wined3d/shader.c (see in the patch).
BTW maybe here https://bugs.winehq.org/show_bug.cgi?id=8051#c118 the fix has only partial effect due to this reason. It would be interesting if you can test Sims 2 with my patch (you can apply the temporary constants patch alone without IVB if Sims 2 is not using IVB); I don't have Sims 2 yet to test myself
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #9 from gamiljydcome@gmail.com ---
Sorry, I did not understand the question. Could you please explain in some other words?
Increase D3D9_MAX_VERTEX_SHADER_CONSTANTF to 1024, wined3d still use hardware shaders, not software shaders, right? If so and patch wined3d default enable max shader numbers of video card supported, should't be avoid sufferring many d3d app's strange problem using big float constant more than 256 but wined3d lack of software impl for now?
Yes, log you sent previously says that 4096 uniform float constants are supported. When you are using my IVB patch without uniform buffers support, the actual number of uniform floats used in glsl shader is >2k.
I'd like try to set D3D9_MAX_VERTEX_SHADER_CONSTANTF and vs_limits array max constants to 2048, 3072, 4096 just if hardware support and stable running without potential bug.
I'd like try to test Sims2 with you new patch.
Thanks.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #10 from swswine@gmail.com --- (In reply to gamiljydcome from comment #9)
Increase D3D9_MAX_VERTEX_SHADER_CONSTANTF to 1024, wined3d still use hardware shaders, not software shaders, right?
yes. There is currently no software shader emulation in Wine. In fact, MSDN says that in DirectX it was intended for debugging purposes, but apparently some games are using it for production.
If so and patch wined3d default enable max shader numbers of video card supported, should't be avoid sufferring many d3d app's strange problem using big float constant more than 256 but wined3d lack of software impl for now?
The app behaviour most likely won't suffer from increasing the constants number above the actual limit unless app actually tries to use this excessive number of constants. Most (or all) of applications won't freely adjust the number of constants depending on the number of constants supported: developers program shaders within the limits they have. They can make two versions for bigger and smaller limits though and choose the shader based on the device capabilities reported. It is one of the reasons why just setting and advertising bigger number of constants (whether it is supported by hardware or not) than native directx does is not a good idea. Please treat this patch as a workaround that fixes some specific games, not as a long term or by any means universal fix. The fix in this form won't ever go to wine for solid reasons.
Yes, log you sent previously says that 4096 uniform float constants are supported. When you are using my IVB patch without uniform buffers support, the actual number of uniform floats used in glsl shader is >2k.
I'd like try to set D3D9_MAX_VERTEX_SHADER_CONSTANTF and vs_limits array max constants to 2048, 3072, 4096 just if hardware support and stable running without potential bug.
You can set whatever bigger number there, you will be able to see any effect only if find some application which wants to use more than 1024 constants. If you apply this patch even with given 1024 limit, you can potentially have bug with some other games which may potentially be confused by non-standard constants limit advertised in capabilities.
This can be enhanced by reporting standard values but supporting more (e. g., actual limit supported by GL, or using UBOs which have much higher limit). I will do that if Matteo will confirm that it is a way to go (switch to UBO is much more difficult though in this case).
I'd like try to test Sims2 with you new patch.
That would be interesting I think.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #11 from gamiljydcome@gmail.com --- Created attachment 52873 --> https://bugs.winehq.org/attachment.cgi?id=52873 screenshot wrong renderring 3d model, Sims2
I've tested Sims.2.Nightlife with ivb patch and big float constant temp patch, no lucky.
1. Both non-ubo(Intel GM45) and ubo(Radeon firegl v5700) can't works fine, 3d mdoel renderring totally wrong. Radeon card much even worse. 2. Using wine-staging 1.55 no ivb patch, the game can't start, tips 'invalid hadle call' something.
But i don't think it's ivb patch's problem although don't know the cause. Maybe you should review the trace log if you would.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #12 from gamiljydcome@gmail.com --- Created attachment 52874 --> https://bugs.winehq.org/attachment.cgi?id=52874 WINEDEBUG=+d3d,+d3d_shader,+d3d9 Sims2 trace log, ~420M
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #13 from swswine@gmail.com --- (In reply to gamiljydcome from comment #12)
Created attachment 52874 [details] WINEDEBUG=+d3d,+d3d_shader,+d3d9 Sims2 trace log, ~420M
The first strange thing I found is: warn:d3d:state_cb_warn Constant buffers (STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL)) no supported.
I thought constant buffers are directx 11 feature, and d3d11 does not really works in wine for now. Can you check that the game is not using d3d11 (d3d10) interface actually? This can be checked looking at 'lsof -p <pid>', where <pid> is the pid of running game process and seeing if it is using any dlls from dx11. dx11 interface can be disabled in wine configuration utility, Libraries tab, setting override for d3d11 library (and d3d10 also) to disabled. I came through such a problem with some other game which was OK with dx9 but for some reason used dx11 interface if it was available.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #14 from swswine@gmail.com --- I see that there is a support for constant buffers but it requires ARB_UNIFORM_BUFFER object extension that your GL does not have. So it would probably easier to test the game on the newer GL. Still constant buffers AFAIK are D3D10 or D3D11 feature and the use of d3d10 or 11 in the game or wine prefix installation (if this is indeed the case) should be sorted out anyway.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #15 from gamiljydcome@gmail.com --- Created attachment 52881 --> https://bugs.winehq.org/attachment.cgi?id=52881 WINEDEBUG=+d3d,+d3d_shader,+d3d9 wrong renderring trace log ~430M (radeon firegl v5700)
(In reply to swswine from comment #14)
I see that there is a support for constant buffers but it requires ARB_UNIFORM_BUFFER object extension that your GL does not have. So it would probably easier to test the game on the newer GL.
The Sims 2 Nightlife released about 09/2005, so it just need dx9.0c and i checked wined3d lib by lsof using d3d9.dll.so indeed.
Anyway i disabled d3d10/d3d10_1/d3d10core/d3d11 throug winecfg, switch to radeon card (GL3.3 support), got a trace log with you patched version of course. If you would please review it.
The game shows 3d model even worse than intel card(GL2.1), more flicker,black block.
I still doubt it's about you patch (ivb and float register).
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #16 from swswine@gmail.com --- (In reply to gamiljydcome from comment #15)
Created attachment 52881 [details] WINEDEBUG=+d3d,+d3d_shader,+d3d9 wrong renderring trace log ~430M (radeon firegl v5700)
I still doubt it's about you patch (ivb and float register).
I've tried some sampler (demo) of Sims2 which allows some character creation. It behaves nearly as described in bug #8051: without constants increase patch it aborts on start. Using my patch it starts but the model in model customization screen (the only available in the demo) is showed in T pose and completely red (no texture). It look it is not due to the number of constants, it does not use much of them at all (just tries to clear 1024 constants on start and aborts on error, that's why patch helps partially). After that I could not find a clear reason for incorrect rendering by now. No shader creation errors, no unsupported features which I could think of as related (the game wants to use TANGENT vertex attribute somewhere, but I think it is unlikely the reason for the observed glitches, it normally should affect lighting effects only). So the reason of the glitches need to be searched further. I don't think rendering problem is about software shaders implementation, and it is surely not about the amount of supported constants.
https://bugs.winehq.org/show_bug.cgi?id=39578
Sergey Isakov isakov-sl@bk.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |isakov-sl@bk.ru
--- Comment #17 from Sergey Isakov isakov-sl@bk.ru --- Hi gamiljydcome@gmail.com , look please a bug 38277 may be it is related to your problem.
PS. May be you have a shorter name?
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #18 from gamiljydcome@gmail.com --- (In reply to Sergey Isakov from comment #17)
Hi gamiljydcome@gmail.com , look please a bug 38277 may be it is related to your problem.
PS. May be you have a shorter name?
Sorry I don't understand what problem you mean related to you bug post.
I've reported tow problem in this post. 1. big float shader reigisters (temp patched by swswine worked for some game but just a temporarry way) 2. Sims2 renderring models badly don't know really cause.
If it works for debian i'd like to test you patch using my intel/radeon card in 3DMark2001SE.
When i reigistered long ago i don't know howto make a short name.
https://bugs.winehq.org/show_bug.cgi?id=39578
--- Comment #19 from Sergey Isakov isakov-sl@bk.ru --- I mean that for that bug i write ~~~ +static void quirk_arb_constants(struct wined3d_gl_info *gl_info) +{ + TRACE("Using ARB vs constant limit(%u->%u) for GLSL.\n", + gl_info->limits.glsl_vs_float_constants, + gl_info->limits.arb_vs_native_constants); + gl_info->limits.glsl_vs_float_constants = gl_info->limits.arb_vs_native_constants; + TRACE("Using ARB ps constant limit(%u->%u) for GLSL.\n", + gl_info->limits.glsl_ps_float_constants, + gl_info->limits.arb_ps_native_constants); + gl_info->limits.glsl_ps_float_constants = gl_info->limits.arb_ps_native_constants; +} ~~~ It is the hack from Crossover. Looks like similar to your case. May be I am wrong.
https://bugs.winehq.org/show_bug.cgi?id=39578
Matteo Bruni matteo.mystral@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #20 from Matteo Bruni matteo.mystral@gmail.com --- (In reply to Sergey Isakov from comment #19)
It is the hack from Crossover.
...
Looks like similar to your case. May be I am wrong.
Yep, that has nothing to do with this bug.