D3DXCompileShader Failing on User Computer

Started by
11 comments, last by MysteryX 7 years, 9 months ago

I have DX9 code working perfectly fine on my computer. However, some users are telling me that they're getting an error opening up and compiling HLSL files. Here's where the files get compiled.

https://github.com/mysteryx93/AviSynthShader/blob/master/Src/D3D9RenderImpl.cpp#L379

One such user told me he's using Windows 7 Ultimate 64bit (6.1 Build 7601), DirectX version 11.
Why is this failing for some users?
Advertisement
Could it be that you created a debug build instead of release?
Not sure what else it could be.

Another approach with better performance would be to "ship"/ release with precompiled shaders.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Debug build works fine and I shipped release.

I was previously shipping compiled shaders but some shaders have many variants and pre-compiling with all the variants would become complicated while they compile on the fly very quickly.

It would be very helpful if we knew exactly what error they were getting. You might want to instrument your code so that if it fails to compile a shader, it logs all of the input parameters as well as the resulting error code.

As an random guess as to what could be wrong, your code appears to be multi-threaded, so some sort of race condition could potentially cause it to misbehave much more often on some PCs than others due to timing differences.

One thing I was thinking about is that I'm using a deprecated function. They recommend to use D3DCompile instead. After doing some search, with D3DCompile, some users on Windows 7 get an error they're missing D3dcompiler_47.dll so it's not any better.

Writing a log would be complicated... I'd have to write the code for it and send it to that user. It can be done but I'd first want to get an idea of where it could be failing.

Yes the code is multi-threaded. In this case, it is failing during the initialization phase that is being called here. In his case, a single instance of the class gets created so there cannot be a race condition during initialization.

Any other idea? Is there some kind of system or DLL dependency for calling this function?

If you're using the dxsdk, you need to distribute the redist folder along with your app, so that the user can install the required DLLs.
Either that, or you do a dodgey and package up all the required DLLs alongside your app.

That's what I'm thinking, that there's some dependency that must be installed. It's working fine for everything else, but compiling the HLSL files requires something that is missing. Does anyone know what DLL dependency that would be?

You're using D3DXCompileShader and hence D3DX, which is an optional addition to DirectX and thus requires the redist (https://www.microsoft.com/en-us/download/details.aspx?id=8109)

Basically your users need the suite of D3DX9_**.dll's (but probably d3dx9_43.dll and d3dx9_31.dll would be good enough, depending if you passed the legacy 9_31 flag to the D3DXCompileShader call). Also as mentioned you should log both the HR of the call and the LPD3DXBUFFER for the error message.

d3dx9_24.dll
d3dx9_25.dll
d3dx9_26.dll
d3dx9_27.dll
d3dx9_28.dll
d3dx9_29.dll
d3dx9_30.dll
d3dx9_31.dll
d3dx9_32.dll
d3dx9_33.dll
d3dx9_34.dll
d3dx9_35.dll
d3dx9_36.dll
D3DX9_37.dll
D3DX9_38.dll
D3DX9_39.dll
D3DX9_40.dll
D3DX9_41.dll
D3DX9_42.dll
D3DX9_43.dll

I'm also using D3DXLoadSurfaceFromSurface. According to them, it works when running an older script containing only .cso files but fails with the newer script containing .hlsl files.

It's it's *only* D3DXCompileShader that fails and it has all these dependencies, then another option is to instead use D3DCompile and to ship D3dcompiler_47.dll with it.

And then I need to install the Windows SDK just for this...

It's it's *only* D3DXCompileShader that fails and it has all these dependencies, then another option is to instead use D3DCompile and to ship D3dcompiler_47.dll with it.

D3DX* are just wrappers around D3D functions, or helpers. D3DXCompileShader probably calls D3DCompile internally, and requires D3dcompiler_##.dll

This topic is closed to new replies.

Advertisement