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

[D3D9] The Void needs bits of IDirect3DShaderValidator9 implementation. #2045

Open
gofman opened this issue Apr 28, 2021 · 7 comments · May be fixed by #4398
Open

[D3D9] The Void needs bits of IDirect3DShaderValidator9 implementation. #2045

gofman opened this issue Apr 28, 2021 · 7 comments · May be fixed by #4398
Assignees
Labels

Comments

@gofman
Copy link
Contributor

gofman commented Apr 28, 2021

I've debugged 'The Void' Steam game some time ago (which was crashing at certain locations both with dxvk and Wine's d3d9) and figured that is the first known game which requires some bits of real IDirect3DShaderValidator9 implementation to work (I've put some details and PoC Wine implementation which adds the necessary bits to https://bugs.winehq.org/show_bug.cgi?id=47229).

The game disassembles and assembles back some shaders (I have no idea why). Some shaders fail to assemble back due to: 'dcl_texcoord10_pp v10' (only 10 inputs are supported in ps_3_0 and this is the eleventh) which result in the crash as the game doesn't consider D3DXAssembleShader() failures. With (partially) working shader validator the problematic shaders get rejected at the earlier stage (IIRC shader compilation from HLSL) and the game handles that fine.

The PoC patch for Wine's d3d9 attached to the Wine bug is enough to make game work.

For testing with the game, here is a save file and reproduction instructions: ValveSoftware/Proton#4527. Also, here is the cheat sheet which explains how to open dev console and get to any location at once: https://forum.ice-pick.com/viewtopic.php?f=28&t=9044. Without that I would probably never get to a problematic spot.

Also, WRT game testing, it creates the compiled shader cache and once you have passed the problematic place successfully
the next run won't trigger problematic behaviour (e. g., if you first run on Windows without dxvk and then with dxvk you won't reproduce it until the cache is cleared). So it is better to delete users/Public/Documents/My\ Games/Void/Cache/* before each run.

@misyltoad
Copy link
Collaborator

Thanks for putting this here, I have a branch for this that I forgot about 🐸

@K0bin K0bin added the d3d9 label Apr 30, 2021
@mz1193
Copy link

mz1193 commented Feb 20, 2022

Just curious, has there been any progress with this?

@robohappy
Copy link

Progress update on this issue?

@MisterManji
Copy link

It'd be great if there was a proton version with that patch that's supposed to make the game work past the problematic area pre-applied. It's way complicated for me to patch it myself.

@simifor
Copy link
Contributor

simifor commented Jul 29, 2023

Issue still happens with dxvk 2.2. @Joshua-Ashton could you share the name of the branch you had for this?

@Blisto91
Copy link
Contributor

https://github.com/doitsujin/dxvk/tree/d3d9-shader-val2
But it needs more work even when the compiler error is fixed.

@simifor
Copy link
Contributor

simifor commented Jul 31, 2023

There are a few errors that are easy to work around with:

Added "#include " to: ./src/dxvk/dxvk_buffer.h ./src/dxgi/dxgi_swapchain.cpp ./src/dxgi/dxgi_factory.cpp ./src/dxgi/dxgi_output.cpp ./src/dxgi/dxgi_main.cpp ./src/d3d10/d3d10_multithread.cpp

Added "#include " to: ./src/d3d10/d3d10_reflection.h

But then there's more complicated stuff like:

../../../src/d3d9/d3d9_shader_validator.h:118:37: error: cannot bind non-const lvalue reference of type ‘dxvk::DxsoCodeIter&’ to an rvalue of type ‘dxvk::DxsoCodeIter’

118 |       if (!m_ctx->decodeInstruction(DxsoCodeIter{ reinterpret_cast<const uint32_t*>(pdwInst) }))

So I changed:

      DxsoReader reader = { reinterpret_cast<const char*>(pdwInst) };

      if (m_state == D3D9ShaderValidatorState::ValidatingHeader)
        return ValidateHeader(pFile, Line, pdwInst, cdw);

      if (!m_ctx->decodeInstruction(DxsoCodeIter{ reinterpret_cast<const uint32_t*>(pdwInst) }))

into (which might not be correct):

      DxsoReader reader = { reinterpret_cast<const char*>(pdwInst) };
      DxsoCodeIter iter(reinterpret_cast<const uint32_t*>(pdwInst));

      if (m_state == D3D9ShaderValidatorState::ValidatingHeader)
        return ValidateHeader(pFile, Line, pdwInst, cdw);

      if (!m_ctx->decodeInstruction(iter))

Which allowed me to build dxvk, unfortunately, the game still dies with this.

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

Successfully merging a pull request may close this issue.

8 participants