SasanTV / Celeris

GNU General Public License v3.0
16 stars 11 forks source link

Fixing DirectX11 CompileFromFile Errors on Windows #5

Open JustinBonus opened 1 year ago

JustinBonus commented 1 year ago

Noting a bug + make-shift user solution + potential permanent solution for others regarding DirectX11 libraries / run-time compilation. This repositories owner knows about part of the issue, seen in both the User Manual for Celeris and: https://github.com/SasanTV/Celeris/issues/1

--- Issue:

Though Celeris app worked out-of-the-box on my Windows 10 Home system, it threw a 'CompileFromFile' error on a Windows 10 Enterprise system when loading a simulation via a cml file. It causes the same issues on a Wine emulation of Windows10 with Ubuntu 18.04.

I believe this is a D3DCompileFromFile() vs D3DX11CompileFromFile() issue. The latter is used in engine.cpp of the source code. Windows 8+ does not support D3DX11 SDK libraries natively, though games / visual studio sometimes install them. See: https://gamedev.stackexchange.com/questions/136165/d3dx11compilefromfile-function-problem-directx11

--- Quick fix for users:

Download the the D3DX files from the following MS 2010 web link, as mentioned in the Celeris User Manual. Ignore that the dxwebsetup.exe is for Windows 7: https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=35&tduid=(d5c34b75227807aea00cad2fc302b7da)(256380)(2459594)(TnL5HPStwNw-wC6WISUgqQM1hpaZ1Sq5Fg)()

This might fix things immediately for you, but it did not work on my system. However, it was fixed for me by:

right-click on the dxwebsetup.exe Properties Compatibility Run this program in compatibility mode for : Windows XP (Service Pack 2/3) [Or whichever Windows XP version is available for you] Apply OK Try the Celeris.exe again

If it doesn't work still, you can check if DirectX is configured properly with command 'dxdiag' (called from the Windows search bar).

--- Potential code fix:

When using D3DX11CompileFromFile() or D3DCompileFromFile() in engine.cpp, may need to add

include

or

include

respectively to the file for the desired function. Ideally, swap D3DX11CompileFromFile() -> D3DCompileFromFile(), making any necessary changes for the function arguments https://learn.microsoft.com/en-us/windows/win32/direct3d11/d3dx11compilefromfile?redirectedfrom=MSDN   https://learn.microsoft.com/en-us/windows/win32/api/d3dcompiler/nf-d3dcompiler-d3dcompilefromfile 

It would be better to do the latter D3DCompileFromFile() way as it is the modern DirectX approach. May also need to move HLSL / FX files around in the folders. See: https://walbourn.github.io/hlsl-fxc-and-d3dcompile/

collinjroland commented 1 month ago

FYI the MS 2010 web link mentioned in this comment and in the Celeris user manual is no longer accessible. I am also experiencing issues with DirectX11 libraries on a Windows 11 Home machine, will keep digging.

EDIT

Installed DirectX 11 using this link and Celeris seems to be functional now