crosire / d3d8to9 Goto Github PK
View Code? Open in Web Editor NEWA D3D8 pseudo-driver which converts API calls and bytecode shaders to equivalent D3D9 ones.
License: BSD 2-Clause "Simplified" License
A D3D8 pseudo-driver which converts API calls and bytecode shaders to equivalent D3D9 ones.
License: BSD 2-Clause "Simplified" License
Several games and emulators do not work with this change.
The Game now works with the latest release of d3d8to9. However, All of the vehicles In the Game seem to be rendered Incorrectly.
As Opposed to:
Though The Game Is Playable, I thought It wouldn't hurt to Issue an Issue.
EDIT: The Issue affects cars at proximity only.
Hint: Cars at proximity are reflective.
D3DXAssembleShader can't handle D3DXASM_DEBUG flag - this introduces additional comment lines, which throws off the d3d8to9 regex'es.
So I've been following this project silently for about a year and a half for now as it interested me in the project I'm working on.
I have no c++ knowledge of any sorts, since I am primarily a Java programmer, but I hope I can help with one issue with vertex shaders.
For the longest time, the hardware shaders (Unreal Engine 2 combines vertex and pixel shaders) for some of the effects have not been being rebuilt properly. In d3d8, the shaders work fine, but in d3d8to9 it rebuilds the vertex shaders with wrong instructions.
Take for example: the hardware shader DynamicHologram, this is how it appears in editor
(I'm using quote since the code tag does not want to work with it)
vs.1.1
; Get the Position
mov r3, v0; Add big rare flicker
mul r3.z, r3, c21; Add small frequent flicker
add r3.xyz, r3, c22////////// Distort /////////
// Position distort
mul r1, v0, c16.x
add r1.xy, r1.zx, r1.yz// Time distort
mov r2, c17
mad r1, r2.x, c16.y, r1
frc r1.xy, r1 // 0 to 1// Turn linear into sawtooth
add r1, r1, -c20.y // -.5 to .5
max r7, r1, -r1 // .5 to 0 to .5// Distort
mul r4, r7, c16.zzww // z = Amp w = 0
mul r4, r4, r3
mov r4.z, r3.z
mov r4.w, c20.z////////// Scan /////////
mov r5, r3
mov r5.z, c18.y////////// Combine /////////
// If z > Scan then Distort
sge r0.x, r3.z, c18.x// if z < distort and > Scan then scan
slt r0.y, r3.z, c18.x
sge r0.z, r3.z, c18.y
mul r0.y, r0.y, r0.z// if z < Scan then scan
slt r0.z, r3.z, c18.ymul r1, r4, r0.x
mad r1, r5, r0.y, r1
mad r3, r3, r0.z, r1////////// Transform /////////
;transform position
dp4 r4.x, r3, c0
dp4 r4.y, r3, c1
dp4 r4.z, r3, c2
dp4 r4.w, r3, c3/*;; CAMERA SCAN (in screen space)
; Interpolate with scan position
; Compare world space position
sge r5.x, r3.z, c31.x
; Get 1- scan
add r5.y, c20.z, -r5.x
mul r6, r5.x, c30
mad r4, r5.y, r4, r6
;; END CAMERA SCAN
*/mov oPos, r4
;transform normal
dp3 r0.x, v1, c5
dp3 r0.y, v1, c6
dp3 r0.z, v1, c7;normalize normal
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w;compute world space position
dp4 r1.x, v0, c11
dp4 r1.y, v0, c12
dp4 r1.z, v0, c13
dp4 r1.w, v0, c14;vector from point to eye
add r2, c10, -r1;normalize e
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w; eye dot n
dp3 r1, r2, r0
/*
mov r8, c16.y
mad r7, r8, c20.y, c20.y
max r7, r7, c20.y
mul r3, r1, r7
mul r3, r3, c15.x
mad r3, r1, c15.y, r3
*/
mul r3, r1, c15.y
add oT0.x, r3, c[20] ; add const offset held in c[20]; Base Texture
mov oT1, v2// Get Speed
mov r5, c25
mul r5, r5, c26.z; Scale Noise Texture 2
;mul r6, r4, c26.y
mul r6, v0.zx, c26.y// Add direction
mad oT2.xy, r5, c28, r6.yx; Use the Dot as brightness and add flicker
mul oD0, r1, c22.xmov oFog.x, c20.x
But this is how d3d8to9 parses it
vs_1_1 dcl_position v0 dcl_blendweight v1 dcl_blendindices v2 mov r7, c0 /* initialize register r7 */ mov r6, c0 /* initialize register r6 */ mov r5, c0 /* initialize register r5 */ mov r4, c0 /* initialize register r4 */ mov r3, c0 /* initialize register r3 */ mov r2, c0 /* initialize register r2 */ mov r1, c0 /* initialize register r1 */ mov r0, c0 /* initialize register r0 */ mov oT2, c0 /* initialize output register oT2 */ mov oT1, c0 /* initialize output register oT1 */ mov oT0, c0 /* initialize output register oT0 */ mov oD0, c0 /* initialize output register oD0 */ mov r3, v0 mul r3.z, r3, c21 add r3.xyz, r3, c22 mul r1, v0, c16.x add r1.xy, r1.zxxx, r1.yzzz mov r2, c17 mad r1, r2.x, c16.y, r1 frc r1.xy, r1 add r1, r1, -c20.y max r7, r1, -r1 mul r4, r7, c16.zzww mul r4, r4, r3 mov r4.z, r3.z mov r4.w, c20.z mov r5, r3 mov r5.z, c18.y sge r0.x, r3.z, c18.x slt r0.y, r3.z, c18.x sge r0.z, r3.z, c18.y mul r0.y, r0.y, r0.z slt r0.z, r3.z, c18.y mul r1, r4, r0.x mad r1, r5, r0.y, r1 mad r3, r3, r0.z, r1 dp4 r4.x, r3, c0 dp4 r4.y, r3, c1 dp4 r4.z, r3, c2 dp4 r4.w, r3, c3 mov oPos, r4 dp3 r0.x, v1, c5 dp3 r0.y, v1, c6 dp3 r0.z, v1, c7 dp3 r0.w, r0, r0 rsq r0.w, r0.w mul r0, r0, r0.w dp4 r1.x, v0, c11 dp4 r1.y, v0, c12 dp4 r1.z, v0, c13 dp4 r1.w, v0, c14 add r2, c10, -r1 dp3 r2.w, r2, r2 rsq r2.w, r2.w mul r2, r2, r2.w dp3 r1, r2, r0 mul r3, r1, c15.y add oT0.x, r3, c20 mov oT1, v2 mov r5, c25 mul r5, r5, c26.z mul r6, v0.zxxx, c26.y mad oT2.xy, r5, c28, r6.yxxx mul oD0, r1, c22.x mov oFog /* removed swizzle */, c2.x /* select single component */0.x
Note the last line on each one: the engine's version has
mov oFog, c20.x
d3d8to9 inserts a comment and changes it to
mov oFog /* removed swizzle */, c2.x /* select single component */0.x
and leaves the old 0.x after the inserted comment
It also errors out in the log for d3d8to9 with
Failed to reassemble shader:
...\Star Wars Republic Commando\GameData\System\memory(69,71): error X2000: syntax error : unexpected float '0'
In the game's log it writes
Log: CreateVertexShader failed(88760B59).
I looked up the error and 88760B59 means invalid data (D3DXERR_INVALIDDATA).
Now, if I go in game and change the last line from
mov oFog.x, c20.x
to
mov oFog.x, c2.x
d3d8to9 builds the shader just fine and it works in game.
This is what it outputs with that change
vs_1_1 dcl_position v0 dcl_blendweight v1 dcl_blendindices v2 mov r7, c0 /* initialize register r7 */ mov r6, c0 /* initialize register r6 */ mov r5, c0 /* initialize register r5 */ mov r4, c0 /* initialize register r4 */ mov r3, c0 /* initialize register r3 */ mov r2, c0 /* initialize register r2 */ mov r1, c0 /* initialize register r1 */ mov r0, c0 /* initialize register r0 */ mov oT2, c0 /* initialize output register oT2 */ mov oT1, c0 /* initialize output register oT1 */ mov oT0, c0 /* initialize output register oT0 */ mov oD0, c0 /* initialize output register oD0 */ mov r3, v0 mul r3.z, r3, c21 add r3.xyz, r3, c22 mul r1, v0, c16.x add r1.xy, r1.zxxx, r1.yzzz mov r2, c17 mad r1, r2.x, c16.y, r1 frc r1.xy, r1 add r1, r1, -c20.y max r7, r1, -r1 mul r4, r7, c16.zzww mul r4, r4, r3 mov r4.z, r3.z mov r4.w, c20.z mov r5, r3 mov r5.z, c18.y sge r0.x, r3.z, c18.x slt r0.y, r3.z, c18.x sge r0.z, r3.z, c18.y mul r0.y, r0.y, r0.z slt r0.z, r3.z, c18.y mul r1, r4, r0.x mad r1, r5, r0.y, r1 mad r3, r3, r0.z, r1 dp4 r4.x, r3, c0 dp4 r4.y, r3, c1 dp4 r4.z, r3, c2 dp4 r4.w, r3, c3 mov oPos, r4 dp3 r0.x, v1, c5 dp3 r0.y, v1, c6 dp3 r0.z, v1, c7 dp3 r0.w, r0, r0 rsq r0.w, r0.w mul r0, r0, r0.w dp4 r1.x, v0, c11 dp4 r1.y, v0, c12 dp4 r1.z, v0, c13 dp4 r1.w, v0, c14 add r2, c10, -r1 dp3 r2.w, r2, r2 rsq r2.w, r2.w mul r2, r2, r2.w dp3 r1, r2, r0 mul r3, r1, c15.y add oT0.x, r3, c20 mov oT1, v2 mov r5, c25 mul r5, r5, c26.z mul r6, v0.zxxx, c26.y mad oT2.xy, r5, c28, r6.yxxx mul oD0, r1, c22.x mov oFog /* removed swizzle */, c2.x
// approximately 55 instruction slots used
Redirecting 'IDirect3DDevice8::CreatePixelShader(0F9C7C58, 11CC17B0, 11D866C0)' ...
Disassembling shader and translating assembly to Direct3D 9 compatible code ...
Dumping translated shader assembly:ps_1_3 tex t0 tex t1 tex t2 dp3_sat r1, t1, c0 mul r0, r1, t0 mul r0.xyz, r0, t2
- mov r0.w, t0.w
mul r0.xyz, r0, v0
mul r0, r0, c1// approximately 8 instruction slots used (3 texture, 5 arithmetic)
Now, I do not know c++ or directx at all, so I don't know how to fix it in d3d8to9, but this is the information I've collected on this issue, I only wanted to submit this once I had everything and had time to try everything.
A few other vertex shaders do not recompile correctly, but I do not know exactly which ones they are.
The primary ones that do not recompile are ones used for bump mapping, specularity, and the one hologram shader that is used on a lot of different objects throughout the game.
If anyone needs more information, like the raw log files, pictures, or the code to other shaders feel free to ask.
Hi, is it possible for the wrapper not to give me any logs ? # #
Hello,
I have been testing your d3d8to9 code. Thanks for creating this, it help me get several games working on Windows 10! However, I found an issue with the game Haegemonia Legions of Iron. After a bit of troubleshooting I found the issue in your code. It seems that you set up a default vertex when the Direct3D8::CreateDevice API is called. This seems to be not needed (based on Micrososft documentation) and it causes a graphics issue with Haegemonia. I attached an updated d3d8to9_base.cpp file where this issue is fixed.
I also updated the d3d8types.cpp to fix a few minor issues and help with compatibility. Both of these changes are in the attached zip file.
Thanks,
Elisha
i got silent hill 2 up 'n workin fine but today out of nowhere it became very estranged
https://i.gyazo.com/734c744ddb6283ddf6ced89dac229c70.mp4
here are what my silent hill 2 files look like
https://i.gyazo.com/93054759c2d569167afe2fb3d54d8c1b.png
scripts
https://i.gyazo.com/77d0402df6973867dee0055b99f1cbe7.png
data
https://i.gyazo.com/c174b88aa9677b25889297a41d92a570.png
this is very infuriating honestly and it makes me Angery, please come up with a solution quick if you can and are willing to. other things to note are that the sound does not work yet CGI cutscene sounds do? and the loading screen is just filled with question marks and whatnot
There seems to be missing textures on Hitman 2 Silent Assassin when using this wrapper/converter.
Here is what I get with d3d8to9:
Here is what it is supposed to look like:
I think this problem is different than the problem with Rayman 3: Hoodlum Havoc because when I try other converters, like the one here, it works fine. I am hoping someone can look into this as I need this converter to play the game in Windows 10.
I'm trying to play Rayman 3: Hoodlum Havoc with d3d8to9, and I've run into a bit of an issue. When in any area of the game apart from the menu, various parts of the scenery can be highly deformed or appear completely invisible:
For comparison, this scene is supposed to look like this:
On some in game objects, the textures used are also incorrect (not sure if it's using the wrong texture or it is mapped incorrectly onto the model). Additionally, one in game object can even appear to be using the model of another object (the gem in this picture is actually a crown):
For comparison, this scene is supposed to look like this:
This can be fixed while still using d3d8to9 by opening the file C:\Windows\Ubisoft\Ubi.ini and changing the line TnL=1 to TnL=0. After analysing the EXE, it seems that all this is doing is setting d3d to use Software Vertex Processing (but I could be wrong). The downside of this is that the framerate tanks to 20fps or less.
I'm using a GTX 970 with the latest drivers, if that's any help.
Can you add latest compiled DLL to releases page? Thanks.
So a free game by Locomalito - Hydorah, does not size the game's window properly when using d3d8.dll + Reshade's d3d9.dll. What happens is only a quarter of the screen is visible in the game window--zoomed way in, while the rest is cut off and you can't see it.
Very strange.
It shouldn't be doing this? The game supports multiple screen sizing modes, and every single one of them behaves the same way, no matter the window size, be it small or fullscreen.
Remove d3d8.dll and reshade, everything is fine again. Hydorah is dx 8.
I wanted to file this issue with d3d8to9 since I have not had time to figure out the issue and hoping someone help out or give me a suggestion.
The issue is that d3d8to9 will cause Max Payne to crash. I have figure out why it is crashing and how to fix it but the fix causes issues with Haegemonia: Legions of Iron and Haegemonia: The Solon Heritage.
What is happening is that when Max Payne loads up it calls the ValidateDevice()
function which returns an error. At this point Max Payne simply exits with an error. If the ValidateDevice()
function is hard coded to always return D3D_OK
then Max Payne runs fine. However this is obviously not a proper fix and besides that it causes display glitches in the two aforementioned Haegemonia games.
The second change I found that will allow Max Payne to run correctly is to call SetFVF()
from the CreateDevice()
function (see here where this was removed a while back). When SetFVF()
is called here than the ValidateDevice()
function correctly returns D3D_OK
(even without hard coding it). However this change also causes the same display glitches in the two Haegemonia games.
Whatever I do to fix Max Payne seems to cause an issue in Haegemonia. I cannot seem to get them both to work at the same time. However I know it is possible to get both working because I tested with enbConverter and it works with both games.
Here is the error I am getting from Max Payne:
Here is what the display glitch in Haegemonia looks like (notice the distortion at the bottom):
Here is what it is supposed to look like:
Printscreen: http://prntscr.com/fpukbm
Verison: 3.0.0 downloaded from the website.
Any ideas what could be causing this?
PC: Windows 8 Pro, DX End User Runtime said its up to date, so dx9.0c is on the system.
At the moment code uses the highest bit in vertex shader handle/pointer to identify whether it's a shader - this makes the code incompatible with large addresses. Do you think bottom 1 or 2 bits could be used for this instead (with some handle shifting if the entity is not a pointer). It should be pretty safe to assume these allocations are 4 byte aligned.
Hi is there currently support for 64bit? Looking at the solution there is only x86 build configuration. Thanks
First of all, do note I don't have this issue backed by anything but theory.
Something that has been bugging me out for a while - feels like if (myRef <= 3)
might not be safe in all cases and sometimes it may leave device in semi-corrupted case. To visualise this, let's consider three cases:
_current_rendertarget
and _current_depthstencil
are not null:_current_rendertarget
and _current_depthstencil
are null:_current_rendertarget
and _current_depthstencil
is not null:Fixing this is trivial enough, albeit introduces even more thread unsafety to already thread unsafe device code (this should be considered a separate issue however). What do you think?
The games i play like serious sam benefit so heavily from aa that I really cannot go back just for more frames. Is there no way to log what is blocking it?
With the recent commits, would that warrant a new release too?
Hello. After the last changes, the converter doesn't longer throw an error when "d3dx9_43.dll is missing", when users don't install required DirectX 9 SDKs. In some games it causes graphics bugs like missing/deformed textures: http://i.imgur.com/KwbVZLA.jpg
I would rather want to see an error on game start, than experiencing graphics bugs. Is there any option to force d3dx9_43.dll loading, just as it used to be in previous versions of d3d8to9?
I tried adding d3dx9.lib to additional dependencies, but it doesn't seem to help (still not "missing .dll" error).
In my modified version of d3d8to9, this is what happens when FSAA in Republic Commando is turned on. I've put debug prints as I was trying to figure out why it was crashing. This is as far as I got.
Redirecting 'IDirect3DDevice8::Reset(053CC2E8, 24BF0FD8)' ...
Multi-Sampling is: D3DMULTISAMPLE_8_SAMPLES
Swap effect is: D3DSWAPEFFECT_FLIP
Redirecting 'IDirect3D8::CreateDevice(09012A30, 0, 1, 00230BDA, 70, 24BF0FD8, 24BF0FD4)' ...
Multi-Sampling is: D3DMULTISAMPLE_8_SAMPLES
Swap effect is: D3DSWAPEFFECT_FLIP
Create Device past ConvertPresentParameters
Create Device failed! Reason: D3DERR_INVALIDCALL
It seems to be something to do with Directx 8 vs Directx 9 as it fails when the ProxyInterface tries to create the device.
No matter the setting, if it's above 0 then it will crash. This issue also applies to the current and past versions of d3d8to9.
Here is where it crashes:
d3d8to9/source/d3d8to9_base.cpp
Line 204 in acd25ce
G-Sync and Vice City work properly with native D3D8 but using the wrapper introduces tearing indicative of running without adaptive sync or V-sync. This includes the newest version, v1.5.0, released 12 hours before this report.
Hello,
With using ThirteenAG/Aero52's Silent Hill 2 Widescreen Fix and activating the d3d8to9 feature I've noticed two visual oddities that come up:
If using integrated graphics all of the FMV cutscenes will be tinted completely red:
And in one of the in-game cutscenes the lighting/shaders on James' body is cranked up too much (this happens using Nvidia, AMD, or integrated graphics):
I intend to do a speedrun playthrough soon of the game to see if there are any other spots that have been affected by the lighting issue when d3d8to9 is enabled.
I'm not sure if this is within the ballpark of fixes for ReShade but would like to address them for posterity.
Thank you
In 8678d6f a workaround was added for erroneous lock flags by changing D3DPOOL_MANAGED
to D3DPOOL_DEFAULT
. This poses a problem for games that use D3DPOOL_MANAGED
to avoid the hassle of re-initializing data (i.e on resolution change).
In native D3D8 games that use managed and even incorrect lock flags, the program will continue running fine. Is this not the case in D3D9? Could it perhaps be modified to only use the default pool if D3DUSAGE_DYNAMIC
is already present?
I had some trouble when trying to use d3d8to9. I used visual studio 2017, but it didn't open the .dll file that came with the d3d8to9 download. Also, directx user runtime didnt install for me. I use windows 7. All i'm trying to do is run my older games with Reshade 3. Can someone give me some CLEAR instructions on how to use d3d8to9?
On my NVIDIA Quadro M2000, given this input :
ps.1.3
mad r0, t1,v0,c0
mul r1, r0,t0
mov r0.rgb, r1
+sub r0.a, 1-v0,-v0
d3d8to9 generates this log :
Disassembling shader and translating assembly to Direct3D 9 compatible code ...
Dumping translated shader assembly:ps_1_3 mad r0, t1, v0, c0 mul r1, r0, t0 mov r0.xyz, r1 + sub r0.w, 1-v0, -v0
// approximately 3 instruction slots used
Failed to reassemble shader:
[...]\build\win32\Debug\memory(2,5): error X5036: Read of uninitialized components(*) in t1: *r/0 *g/1 *b/2 *a/3
[...]\build\win32\Debug\memory(3,5): error X5036: Read of uninitialized components(*) in t0: *r/0 *g/1 *b/2 *a/3
What can be done to fix this?
So, i have been using Dxtory for a long time. and the game likes to crash before it starts. i have the latest version of Shaders. But i found a temp salution. Load game first, then load Dxtory. no crash logs yet to be found..
Maybe im looking at the wrong place?
Dxtory Version: 2.0.142
Reshade 3.0.8
Hi, I've just been using d3d8to9 for the first time and am getting missing textures through out the game:
Before: http://imgur.com/zujLRLe
After: http://imgur.com/ZO0PU7B
Also the in-game movies are just a black screen with audio, the game never crashes and works fine otherwise.
Is there a log file somewhere i'm missing that might tell me whats causing the missing textures?
cheers
Do you reckon implementing this as an opt-in feature could have any advantages other than screenshoting not being broken with DWM?
The removal of managed pool could possibly be the trickiest part.
Would you consider logging the disassembled shader before it gets updated?
#ifndef D3D8TO9NOLOG LOG << "> Dumping disassembled shader:" << std::endl << std::endl << SourceCode << std::endl; #endif
This helped me personally to troubleshoot issue #70
At least in serious sam. It worked before unless i alt tabbed.
Now its completely useless to force driver aa in the nvidia control panel.
This in Indiana Jones and the Emporer's Tomb.
All the intro and cut-scene movies are in .bik format and while using d3d8to9 the audio plays during the videos but the screen is black.
Any idea what could be causing this?
The description at the top of the repo should have the link: https://reshade.me/d3d8to9
Using d3d8to9 with Republic Commando causes a crash after a brief white screen.
d3d8.log gives me this:
Redirecting 'Direct3DCreate8(220)' ...
> Passing on to 'Direct3DCreate9':
Redirecting 'IDirect3D8::CreateDevice(0270E010, 0, 1, 000D0F4E, 32, 005FF3B8, 005FF510)' ...
Redirecting 'Direct3DCreate8(220)' ...
> Passing on to 'Direct3DCreate9':
Redirecting 'Direct3DCreate8(220)' ...
> Passing on to 'Direct3DCreate9':
Redirecting 'IDirect3D8::CreateDevice(0270E010, 0, 1, 00120DE4, 70, 0D21FF98, 0D21FF94)' ...
I tried on a fresh install, as I was initially using the Republic Commando Graphics Fix, but this did not change anything. I also disabled driver-level graphics settings, as well as RTSS.
From what I see, wrappers do not attempt to synchronize reference counters with their underlying types (eg. GetSurfaceLevel should probably return the same interface every time it gets called on the same texture but in this case, each time a new wrapper is constructed) and it's hidden in the implementation by returning real resource refcounts from AddRef
/Release
, with wrappers' destruction dictacted by their own refcounts.
Direct3DDevice8::Release
seems to be an exception here and I'm not sure if this is intentional. It's being deleted only if underlying type's refcount is 0, which probably causes wrapper's memory to leak a lot (and therefore break Direct3D8
refcounting). Shouldn't it call its own delete on its own refcounter, like all the other interfaces?
When seeking for solutions on how to reduce the amount of false positives from virustotal (and real AVs, because that was an issue too), I noticed that in 100% cases I tested just adding Version resource to the file increases credibility of the file to AVs.
For example, a test DLL of mine which is totally empty (literally only contains DllMain with return TRUE;
):
w/out metadata: https://www.virustotal.com/file/ad8dddc65e47c1a1f611534334bc6d9b201e9391ded632f3001066482684e447/analysis/1480339650/
with metadata: https://www.virustotal.com/file/4ffa0342f533e9669102865bffa9270ce24919027748057925a9b0df9327d0fc/analysis/1480339793/
This also helps d3d8to9 a lot - in #5 I mentioned that v140 created DLL with d3d8.log
enabled I get 8 (!!) hits - with metadata that is down to only two. With file logging disabled and metadata embedded I got no hits at all!
I would gladly add that to the compiled DLL which is already being redistributed with the game (together with the original license file to conform to BSD-2 license rules), but I don't want to copyright it with your name without you acknowledging it =)
Unfortunately one of the check-ins today is causing a crash. It seems to be this check-in a7b2a63 "Remove standalone DirectX SDK dependency". If I revert this check-in the crash goes away.
The updated code for the dynamic loading of d3d9_43.dll in this check in seems fine and the three API calls D3DXAssembleShader
, D3DXDisassembleShader
and D3DXLoadSurfaceFromSurface
seem to work ok. I am guessing it is something in (or missing in) "d3dx9.hpp". Somehow removing the SDK "d3dx9shader.h" and replacing it with "d3dx9.hpp" is causing an issue.
The crash only happens when the game is exiting. It seems to run fine (normal) otherwise.
I did not have time to fully troubleshoot it. Here is the crash I am seeing:
The following vertex shader assembly line fails :
mad oFog /* removed swizzle */, -r3, c150.z, c150.w
It can be fixed by adding this regexp to Direct3DDevice8::CreateVertexShader() :
SourceCode = std::regex_replace(SourceCode, std::regex("mad (oFog|oPts)(.*), (-?)([crv][0-9]+(?![\\.0-9])), (.+)\\n"), "mad $1$2, $3$4.x /* select single component */, $5\n");
The result is :
mad oFog /* removed swizzle */, -r3.x /* select single component */, c150.z, c150.w
..which succesfully compiles. (Not sure if the .x
component is the right choice.)
Test-case : Cxbx-Reloaded, running Morrowind.
Continuing from the previous issue:
(Recap)
d3d8to9 is changing modifiers for pixel shaders and not restoring their effect. Rather, it's just stripping them off on pixel shaders.
The pixel shader for DOT3DiffSpec (HardwareShaders.Bump.DOT3DiffSpec) is:
;; PC
ps.1.3
tex t0 ; base map
tex t1 ; bump map
tex t2 ; light vector from normalizer cube map
tex t3 ; half angle vector; N.L
dp3_sat r0, t1_bx2, t2_bx2; (N.H)
dp3_sat r1, t1_bx2, t3_bx2; Multiply by bump color
; Add baked + vertex lighting
mad r0.rgb, r0, v1, v0; approximate (N.H)^16
; [(N.H)^2 - 0.75] * 4 == (N.H)^16
mad_x2_sat r1, r1.a, r1.a, -c0; Set the color of the specular
mul_sat r1.rgb, r1, v1; Mulitply specular by specular mask
;;;mul r1, r1, t1.a; Self Illumination
;;;lrp r0, t0.a, t0, r0; [(N.L) * base] + (N.H)^16
; Diffuse and Spec
mad_sat r0, r0, t0, r1
The important line is mad_x2_sat r1, r1.a, r1.a, -c0
d3d8to9 is producing:
ps_1_3 tex t0 tex t1 tex t2 tex t3 dp3_sat r0, t1_bx2, t2_bx2 dp3_sat r1, t1_bx2, t3_bx2 mad r0.xyz, r0, v1, v0 mad_x2_sat r1, r1.w, r1.w, c0 /* removed modifier - */ mul_sat r1.xyz, r1, v1 mad_sat r0, r0, t0, r1
Now the line is mad_x2_sat r1, r1.w, r1.w, c0 /* removed modifier - */
It removes the modifier and does not restore the effect of it. Removing the - sign from the pixel shader and running the game without d3d8to9 produces the same effect.
Commenting out lines 1733-1734 causes the editor to crash upon loading the shader and a error produced in the log.
..\Star Wars Republic Commando\GameData\System\memory(9,5): error X5539: (third source param) Modifiers are not allowed on constants for ps_1_x.
What it's supposed to look like:
What it looks like with d3d8to9:
What it looks like without d3d8to9 and a - sign removed from one shader:
(I am using my own mod that does not change shaders, only textures; the problem is universal)
If anyone needs more info feel free to ask.
I've been using this tool with UT2004 without any issues up to 1.8.0, but 1.9.0 broke switching out of the game, as it now crashes with an error message upon reentering the game. Win7 x64, GTX 1060 398.36.
Hi.
Yesterday I decided to install Windows 10 build 17133. It is supposed to be Redstone 4 RTM version.
I'm developing Unofficial Patch for Empire Earth 2 and I am using d3d8to9, because it fixes stability problems and allows using the Nvidia GPU on laptops with Optimus. More about this problem.
Unfortunately, as fast as I installed the Windows 10 update - I noticed that the game can not be maximized with d3d8to9. It seems to work fine in the normal DX8 mode. As first I thought it's Nvidia GPU problem, but then I noticed that it's the same when I'm trying to run it on the Intel HD GPU.
I recorded a video showing the problem: https://www.youtube.com/watch?v=sqgRPujYiI0
Please don't get surprised that there is no d3d8.dll file - I called it UP15.dll, to allow users to easy switch between two versions.
I tested it on many d3d8to9 versions (since 2016) with the same results.
I know this isn't really a d3d8to9 issue, because it worked just fine on the older Windows version, but I bet Microsoft will never fix it, so I already should find a workaround...
Does anybody know what part of d3d8to9 I should focus on when trying to debug this problem? I would very appreciate any tips, especially from @elishacloud who has already proven many times that there are no impossible things to fix :)
Currently Direct3DDevice8::CreateImageSurface
puts the surface in D3DPOOL_SYSTEMMEM
pool. However MSDN dx8->dx9 migration guide says
D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by IDirect3DDevice8::CreateImageSurface.
So is SYSTEMMEM usage here intentional or an oversight?
When investigating on why both d3d8to9 and ENB's d3d8 wrapper flat out crash with a dx8 thrash driver in Need for Speed III (from THIS PATCH) I noticed a couple issues, but the most important fact is that this code loves to do stuff like:
device->GetBackBuffer(0, &surface);
surface->Release();
global_myBackbuffer = surface;
Since d3d8to9 creates a new wrapper class in GetBackBuffer
, the call to Release
destroys it and any attempts to use this surface fail miserably.
Should this be considered severe API misuse and not handled, or is this something to fix on d3d8to9 side? I mean, this is obviously not how you should be managing reference counters but this doesn't seem to crash with a real dx8 device at all. Maybe device wrapper should account for such odd behaviour, store its backbuffer surface wrappers in an array and return those on demand? This should probably match real device behaviour more closely.
EDIT:
Said game also seems to crash consistently inside Direct3DDevice8::SetCurrentTexturePalette
but that seems like a different issue. What's worse, it instantiates itself with D3DCREATE_MULTITHREADED
and who knows how thread unsafe d3d8to9 device wrapper really is.
Pixel shader input :
dp3 r0.rgb, c0_bx2, t0_bx2
d3d8to9 output :
mov r0.xyz, c0 /* added line */
dp3 r0.xyz, r0.xyz_bx2 /* changed c0 to r0.xyz */, t0_bx2
This fails with :
> Failed to reassemble shader :
error X2004 : invalid swizzle 'xyz_bx2'
error X5027 : Invalid src swizzle for first source param.
heyo.
recently beat first silent hill, hell of a job to emulate, but now im having trouble setting up the PC director's cut with the widescreen fix
every cutscene ingame looks like this
its pretty annoying and i havent seem to find any success in fixing it.
i think it might have something to do with the fact that i use integrated graphics but id like to know if there's a way to combat this and have it working properly with the widescreen fix.
i looked through this thread but didnt find anything
#24
thanks
hey crosire , d3d8to9 doesnt helped me to fix dat bug , i tried all cracks and versions of games , still transparent cars :/
yknow those stalker guys. Its £5 on gog https://www.gog.com/game/firestarter
issues such as randomly stretched to horizon polygons, flickering out of existance monitors and just straight up crashes to desktop.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.