-
Notifications
You must be signed in to change notification settings - Fork 81
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
Kill Usage of DirectX SDK (June 2010) #733
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D3DX is gone, so we have to use the standard D3DCompiler library. Sadly, the D3DCompiler only publicly offers an HLSL Compiler and not an assembler. However, after disassembling d3dx, I found that D3DX just dispatches assembler calls into an undocumented export in D3DCompile. We now use this to assemble the shaders from the assembly source. If someone wants to add support for HLSL shaders, it should probably be done in a separate program.
Hoikas
changed the title
WIP: Kill Usage of DirectX SDK (June 2010)
Kill Usage of DirectX SDK (June 2010)
Dec 8, 2020
dpogue
approved these changes
Dec 13, 2020
Manually merged master to fix conflicts. |
Manually merged master to fix conflicts. (again) |
Note for posterity: we'll clean-up the stubbed FindDirectX cmake module in an upcoming cmake pass. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This kills off usage of the DirectX SDK from June 2010 in favor of the DirectX support built into the Windows 8 SDK, which has come with Visual Studio since VS 2013. This change will allow us to avoid requiring yet another dependency and allow building on GitHub Actions, where the DXSDK is not preinstalled (unlike AppVeyor). This change means that the following components are no longer available:
The DxErr deprecation was handled by converting to the standard Win32
HRESULT
handling mechanisms. The DirectXHRESULT
s are now in the Windows SDK itself, so no special handler is needed.The Direct3D9X deprecation is a bit more problematic
and why this pull request is still a WIP draft. The nice matrix class was fairly easy to replace with the base matrix and withXMMATRIX
(in one particular place). The problem is withplDXVertexShader
,plDXPixelShader
, and with plShaderAssembler. The Plasma shaders are all written in assembly and built withD3DXAssembleShaderFromFile
, which is now gone. The closest analogue isD3DCompileFromFile
, which, per the documentation expects HLSL. I have yet to test compiling Plasma's shaders with this replacement method, but I suspect we will have to either rewrite the shaders in HLSL or find some other method forward.For now, this problem is blocking the PR.After a bit of reverse engineering, I've arrived at a solution to finish killing off the dependency on D3DX9. When assembling shaders, D3DX9 effectively forwards the entire shader to a function in D3Dcompiler_[0-9][0-9].dll named
D3DAssemble
. This function is not publicly documented, but it is exported from the June 2010 DX SDK compiler through modern Windows SDKs. I refactored plShaderAssembler.exe to load the pointer to this method and assemble the shaders with this function. The resulting assembled shader bytecode appears identical to what is currently checked in.I also removed support for assembling shaders at runtime from
plDXVertexShader
andplDXPixelShader
. I'm sure this was great when Cyan was developing the engine, but we've never changed the shaders. I think if we do, we'll want to operate at a level higher than assembly (eg HLSL) and therefore would need to rewrite the code anyway.Now that the final dependency on D3DX9 has been removed, I turned the DirectX SDK finder into a dumb list of libraries: d3d9 and D3Dcompiler. I'm not sure how clean that is--commentary welcome. The code now compiles without referencing the standalone DirectX SDK at all and appears to work correctly. As a bonus, I fixed an
ST::bad_format
error in plShaderAssembler.