Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text is not displaying in Empire Earth II #57

Closed
HerMajestyDrMona opened this issue Oct 26, 2022 · 30 comments · Fixed by #59
Closed

Text is not displaying in Empire Earth II #57

HerMajestyDrMona opened this issue Oct 26, 2022 · 30 comments · Fixed by #59

Comments

@HerMajestyDrMona
Copy link

I'm developing an unofficial patch for Empire Earth II. I have recently received many messages from players who are unable to play the game, due that the text is not displaying in game. All these players have new laptops with Intel CPUs. Most of these players are refunding their laptops for this reason.

After reading this page, I learnt that Intel is now using D3D9On12 in their drivers:

We use a D3D9on12 mapping layer, which maps graphics commands from DX9 to DX12. We do extensive compatibility and performance testing, and partner closely with Microsoft* and ISV’s (Independent Software Vendors) to optimize this solution continuously. Intel has been shipping this solution since our 12th Gen Intel® Core™ processor launch in 2021, and we'll continue to invest heavily in this technology for both integrated and discrete graphics solutions.

I managed to re-produce the issue on my computer using ForceD3D9On12 d3d9.dll. My unofficial patch already supports d3d8to9, so d3d9.dll could be placed in the game folder and was loaded successfully.

Screenshots showing the issue:

image

image

Steps to reproduce the problem:

  • Install the game.
  • Install unofficial patch.
  • * Edit file UnofficialVersionConfig.txt and add: UseWorkingDirectoryWorkaround=1.
  • Paste d3d9.dll from ForceD3D9On12 to the game folder.

* This step is required, so the Launcher copies the game executable to to the main game folder (as EE3.exe), instead of starting the game process from a different location. This is needed because otherwise the game would load d3d9.dll from the SysWOW64 directory.

As the patch developer, I'm usually trying to fix similar issues myself, using dozens of workarounds, assembly, etc. However this time it looks like the problem is in D3D9On12 itself, so maybe somebody could please check if this can be resolved? After all, the issue is quite serious since players who buy new laptops can't play the game.

@mirh
Copy link

mirh commented Oct 26, 2022

I suspect developers would rather prefer an apitrace of the issue (if it even works in this scenario that is).
Or I don't know then if they'd go the extra stretch of actually trying games...

@jenatali
Copy link
Member

Indeed, an apitrace or D3D9 PIX capture would be helpful.

@HerMajestyDrMona
Copy link
Author

HerMajestyDrMona commented Oct 26, 2022

Sorry, I thought that being able to reproduce the problem is important. This is what e.g. Nvidia asked me to provide in the past.

Unfortunately, I was unable to record apitrace for DX12, because apitrace's d3d9.dll doesn't support "Direct3DCreate9On12" calls.
However, I have some interesting results! Thanks for recommending me this program.

OK, so first of all, the traces can be downloaded here:
https://mega.nz/file/cQ8VSKYB#QDWU9hWwHKz-SXS_YDpHOszHIHYkQJFs505xBIhITSs

There is file "Commands used.txt" with additional information from me, and the commands used.

I was able to record two traces:

  1. DX8 (D3D8 no extra wrappers)
  2. DX9 (D3D8to9)

While recording, the text was displaying correctly in both cases.

When watching the replay, the DX8 version seems not to be displaying the text, just as with the DX12 bug. The DX9 version seems to display correctly.

apitrace_dx8

Is this helpful enough to take a look on this issue?

@jenatali I am not very familiar with DirectX debugging (I'm not even a professional programmer). If necessary, could you please guide me how to create a D3D9 PIX capture?

EDIT:

I tried PIX, but it can only record x64 processes, while old games are obviously x86:
image

@vdwtanner
Copy link
Collaborator

For the traces, try recording them without using the Force9on12 workaround. We can force d3d9 to load the 9on12 during playback of the trace on our end. In one rare case I've seen this make a difference in whether or not the trace reproed the issue, but generally this should work fine.

For d3d9 pix, you will need to download the DirectX 2010 June SDK. Once that installs, you should be able to run d3d9 pix by searching for "PIXWin" from the start menu. Then you can create a "New Experiment" to run your game and capture the issue with F12, or whichever method you chose.

In your edit, that is modern, d3d12 PIX. Much nicer tool, but as you can see it only supports x64 and d3d12 applications. D3D11 is supported by forcing 11on12.

@HerMajestyDrMona
Copy link
Author

HerMajestyDrMona commented Oct 28, 2022

@vdwtanner Thank you for the reply. I can confirm, that none of apitraces attached by me in this post are forcing the D3D9to12 workaround.
The first record is a pure DirectX 8, and the second is d3d8to9 (that's the only way to get this game running on DX9).

I only mentioned that I tried to record with the forced D3D9to12, because I was attempting to "fix" this issue by modifying d3d8to9. It's very likely that d3d9on12 does something incorrectly at function: IDirect3DDevice9::DrawIndexedPrimitive.

Example call from the game is:
57692 IDirect3DDevice9::DrawIndexedPrimitive(this = 0x68b7560, PrimitiveType = D3DPT_TRIANGLELIST, BaseVertexIndex = 0, MinVertexIndex = 0, NumVertices = 80, startIndex = 0, primCount = 40) = D3D_OK

If I set this function in d3d8to9 to do nothing, just return D3D_OK, then the text is also not displaying in game on DX9 version.

Another possibility is a problem at function:
hr = ProxyInterface->SetFVF(Handle);

For example, when I modified flag D3DFVF_DIFFUSE to be D3DFVF_SPECULAR, then all text in DX9 version of the game displayed in white font color.

I also read this article: "A Simple Blit Function For DirectX 8" and it seems like the game is doing something similar, since all 3 flags are matching D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1.

I hope these information might be at least a bit useful.

I will try the d3d9 pix and edit my post if I'll success with it.

EDIT:
Here it is: https://mega.nz/file/9d8GWJiS#1Ygy8ZXqA_9Xtamhfo1Gd2Q6UMf2ypfE9QB_-nZRixc
File: EE2_d3d8to9.PIXRun (655 MB).
Seems to replay correctly (the text is displayed).

Is it possible that I force d3d9on12 on this stream (for testing purposes), or it's rather some complicated procedure?

@XDamianX-coder
Copy link

XDamianX-coder commented Oct 30, 2022

I have found, with great help of @HerMajestyDrMona , that the issue can be solved via changing default graphic card (NVidia control panel) from Optimus to dedicated graphic card. This allows to launch correctly many old games.
I can confirm that I had this problem on Intel graphics.

@Squall-Leonhart
Copy link

thats not a fix, its a workaround and has no relevance to intel only configurations.

@calsch03
Copy link

calsch03 commented Nov 17, 2022

I think it's important that this issue is addressed. When I buy a new PC I find it important that I'm still able to enjoy older games. It's a big part of what makes PC gaming special. To return to games you've been playing for years and see them run better on a new PC.

@LordLoewenherz
Copy link

Empire Earth 2 is one of my favourite games. I really hope that this problem can be fixed.

@vdwtanner
Copy link
Collaborator

I spent some time looking at the PIX capture (thanks for that!), and so far something that I'm seeing which looks odd is that the game appears to be trying to set the ZRange min to .000453 instead of 0 when drawing text. This is causing it to be clipped. Still need to repeat some tests with 9on12 disabled to see if that is the same for d3d9 but somehow still draws correctly, but as of right now it seems like it may be an app bug that mysteriously works on native d3d9 drivers.

@Squall-Leonhart
Copy link

keep in mind, there are faster ways than using 9on12 available, that do not have such problems, such as DGVoodoo.

This removes the need to use a D3D(8) > 9 wrapper, before the 9on12 layer, and doesn't have the inherent performance issues that comes from not having a vendor optimized DDI in the driver.

@HerMajestyDrMona
Copy link
Author

HerMajestyDrMona commented Dec 1, 2022

I spent some time looking at the PIX capture (thanks for that!), and so far something that I'm seeing which looks odd is that the game appears to be trying to set the ZRange min to .000453 instead of 0 when drawing text. This is causing it to be clipped. Still need to repeat some tests with 9on12 disabled to see if that is the same for d3d9 but somehow still draws correctly, but as of right now it seems like it may be an app bug that mysteriously works on native d3d9 drivers.

Thank you for checking it! I'm not sure where this ZRange is set in the game. Do you maybe know what DirectX function is called to draw this text with the Zrange parameter? If modifying some value to 0 could be done by D3D8to9, that would be already great.

This game was natively programmed for DX 8, so some differences might also come from there. However, all of available DX8to9 converters somehow manage to render it correctly on DX 9. None of them use the game specific fixes for it.

keep in mind, there are faster ways than using 9on12 available, that do not have such problems, such as DGVoodoo.
This removes the need to use a D3D(8) > 9 wrapper, before the 9on12 layer, and doesn't have the inherent performance issues that comes from not having a vendor optimized DDI in the driver.

It's not the matter of using 9on12, but the matter of being forced to use it in the newest Intel GPUs.
DGVoodoo isn't a great solution for EE2, as it creates dozens of other graphical issues (or simply doesn't convert all API calls as good as D3D8to9 and even D3D9on12). Besides that it's not an open source solution that would allow us me to apply other fixes such as fixing the take screenshot function.

@Squall-Leonhart
Copy link

Squall-Leonhart commented Dec 1, 2022

DGVoodoo isn't a great solution for EE2, as it creates dozens of other graphical issues (or simply doesn't convert all API calls as good as D3D8to9 and even D3D9on12).

DGVoodoo works fine with EE2, it implements a near complete implementation of D3D class 7, 8 and 9 hardware replicating those capabilities in D3D11 and 12, issues found would be flaws in the game itself, as vdwtanner has already identified some.

Besides that it's not an open source solution that would allow us me to apply other fixes such as fixing the take screenshot function.

D3D8 to 11 would be ideal then.

@HerMajestyDrMona
Copy link
Author

HerMajestyDrMona commented Dec 1, 2022

DGVoodoo works fine with EE2.

It doesn't, at least not on all configurations. It's easy to write "fine" if you're looking at the game for the first time, but experienced players will catch smaller or bigger problems immediately.

DGVoodoo has problems with rendering fonts too, e.g. in Anno 1404 or EE2 itself.

Also, I don't see a reason of talking about DgVoodoo in a GitHub thread related to D3D9on12. Such "tips" are not helping to solve the core issue, and are not helping to improve D3D9on12 if that's an issue related to it.

D3D8 to 11 would be ideal then.

Maybe if it wasn't crashing the game with the -->Failed to create Direct3D Device. Cannot continue. error on start. If it can't even create a Direct3D device, then it's hard to believe everything else would work fine.

@Squall-Leonhart
Copy link

Squall-Leonhart commented Dec 1, 2022

Also, I don't see a reason of talking about DgVoodoo in a GitHub thread related to D3D9on12. Such "tips" are not helping to solve the core issue, and are not helping to improve D3D9on12 if that's an issue related to it.

9on12 will never work as a vendor developed DDI would. Ever.

@HerMajestyDrMona
Copy link
Author

HerMajestyDrMona commented Dec 1, 2022

9on12 will never work as a vendor developed DDI would. Ever.

For now D3D8to9 works best with EE2, and D3D8on12 has no visible graphical issues in game, except these unfortunate texts. I believe D3D9to12 is the most futuristic way for THIS game.
For games with multiplayer lobby where people are waiting for games/friends and use ALT+TAB all the time, it's also important that the game has no noticeable delay or doesn't crash after several ALT+TAB calls. Most of the other wrappers apply dozens of undocumented workarounds that may simply stop working (e.g. after windows updates) and leave people with problems again. I also updated my previous comment with screenshots.

@HerMajestyDrMona
Copy link
Author

Thank you @vdwtanner !

It's awesome to have this issue fixed. Now people with newest Intel processors will be able to play again.

Do you by any chance know ETA when such fixes for D3D9on12 appear in Windows Update?

@HerMajestyDrMona
Copy link
Author

@XDamianX-coder Could you please tell me what exactly you changed in the NVIDIA control panel to fix the on-start crash? Did you change the Optimus profile for the game (selected "Empire Earth II" from the list), or globally? If you find some time, please visit the Support Chat in UP1.5 so I can ask some extra questions. We're currently trying to use NVAPI to edit the Nvidia profile to fix this problem, but it's weird because it looks like Nvidia is already auto-selected for it...

@vdwtanner
Copy link
Collaborator

Hi @HerMajestyDrMona, unfortunately I don't know the exact timeline for when it'll be generally available in a public update (as this isn't a security fix and it seems to be mostly tied to older apps with low usage it's hard to justify servicing the change outside of the general OS update cadence, and I'm not privy to all the details there). It will be available to insider flights sooner than general release of course, but in the short term the best option for your users might be to just build the open source version of 9on12 and have that in the same directory as the game's exe. That said, they would likely need to play in windowed mode. The open source version doesn't support exclusive fullscreen right now. The ground work has been laid for better support, but it's not enabled yet (no timeline on when that will come to fruition as of now).

@HerMajestyDrMona
Copy link
Author

@vdwtanner Thank you for explanation! The most important part is that it will come to insider builds, so the "future of the game" is safe :)

I was trying to compile D3D9on12 before, but for the 32bit version it wasn't putting the WinPixEventRuntime.dll in my build output folder. Maybe I was doing something wrong, but WinPix was automatically "downloaded" by VS 2022, just that DLL missing. I will try again and see what's going on.

@vdwtanner
Copy link
Collaborator

@HerMajestyDrMona That's expected, WinPIX (D3D12 PIX) is 64bit only, so there isn't a 32bit dll. All of the code that needs that dll is disabled in 32 bit. (You'll see some warnings about it in the build log iirc)

@HerMajestyDrMona
Copy link
Author

@vdwtanner Thanks a lot! It makes sense why it was crashing for me the last time I tried to use my compiled version of D3D9On12. I was running in the fullscreen mode instead of windowed. I've recently added a nicely working borderless windowed mode to the game, so it's now starting correctly.
The only issue left is the low FPS problem. I can't get more than 28-30 FPS on my Ryzen 5950X/RTX2070 machine. The CPU usage isn't that high, and the GPU clock seems to be running with reduced speed. Strange. Seems like the D3D9On12 version that comes with Windows is much better optimized. Are there any other factors that could cause this issue?

@vdwtanner
Copy link
Collaborator

@HerMajestyDrMona You are correct, there are a few pieces that we swap out internally that use unstable APIs. There has been some work to make the open source version more similar in that regard (but using new, stable APIs), but it's not generally available at this time. I would suggest making sure you've pulled the latest changes though as Jesse has made some nice performance improvements lately, and make sure that you are building in release mode.

@HerMajestyDrMona
Copy link
Author

Yes, I "git cloned" D3D9On12 around 2 hours ago, so it should be all available :) And yes, I compiled it as Release.
I only wonder if these Intel Iris Xe Graphics users would get the same performance as me (28FPS), or it would drop to like 5 FPS for them. I guess we won't know until somebody shares a feedback :)

@Squall-Leonhart
Copy link

Iris and Arc have had the native d3d9 driver ported from the legacy igp driver, and use either it or dxvk in the newest drivers.

@HerMajestyDrMona
Copy link
Author

Iris and Arc have had the native d3d9 driver ported from the legacy igp driver, and use either it or dxvk in the newest drivers.

Do you mean Intel has updated their drivers to support d3d9 without d3d9on12? Or it's some custom workaround method? Do you have any source to this?

@Squall-Leonhart
Copy link

Squall-Leonhart commented Dec 13, 2022

https://game.intel.com/story/intel-arc-graphics-directx9/

3959 adds the igd9trinity dlls to the driver package

@HerMajestyDrMona
Copy link
Author

https://game.intel.com/story/intel-arc-graphics-directx9/

Thank you for sharing this. Did you get any chance / possibility to test it? They don't mention that they don't use D3D9On12 anymore, just that some titles got better support. But I guess this is what they meant?

I really hope they activate the native DX9 support to all games, not just selected titles that they tested.

Thank you for sharing this information. Just now, I was working on an integrated fix with a "magic" name:

Screenshot 2022-12-13 220112

But I'll pause for now :)

@Squall-Leonhart
Copy link

I don't have an Xe handy, however a Twitter user has been testing it out on some questionable japanese sims and posting his findings

https://mobile.twitter.com/mumeisaba555/

@HerMajestyDrMona
Copy link
Author

I found a solution for the low FPS problem in the compiled open-source version of D3D9on12.

It seems like it was as easy as checking the already-existing option "Disable V-Sync in DirectX 9".

All this option does it setting:
Output.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

Instead of:
Output.PresentationInterval = D3DPRESENT_INTERVAL_ONE;

The V-sync can later be enabled in the Graphics Control panel (e.g. Nvidia Control Panel), and it works just fine.

I integrated a fix for this problem with Unofficial Patch 1.5. A guide how to enable it is available here: Temporary fix for the missing text problem in Empire Earth II.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants