SharpDx and d3dcompiler_XX.dll

Started by
4 comments, last by Ryan_001 9 years, 8 months ago

A few months ago, as my first real foray into C# programming, I wrote a small program/dll that allowed me to compile .hlsl and .fx files directly into COFF files that I could link into my program. It worked great for a few months. Now I'm having a small problem.

In writing the dll I used the SharpDx package to get access to the D3DCompiler API. It seems by default this uses an older version of the d3dcompiler_XX.dll (I think its version 43, I don't remember exactly). I need to use a more recent version of the compiler dll, in particular I would like to use d3dcompiler_47.dll. Being somewhat of a noob when it comes to C#, I haven't been able to figure how to do it. Googling didn't turn up anything useful and I tried copying d3dcompiler_47.dll to various directories with no avail. Anyone have and ideas?

Advertisement

If you are using nuget packages and building desktop applications, it will link by default the old DirectX June 2010 runtime. In order to use more recent d3dcompiler_47.dll (deployed on Windows8.x), you need to setup a config variable in your project

If you are referencing manually binaries, simply link against DirectX11_2-net40

I used the nuget packages, and read through the link you provided (much appreciated) but was still unable to get it to use the newer d3dcompiler_47.dll. I never used C# before this so I'm probably making a silly mistake. I added an App.config file (using the project->add new item wizard) and in there added <SharpDXDirectXVersion>DirectX11_2</SharpDXDirectXVersion>. I'm not sure if I'm not doing the right thing, or if I added it to the wrong place, and TBH I don't even know what a config variable is.

You need to add it to your csproj like it is done in this sample

On another note, why not precompile with fxc and embed .cso files (compiled shader object) instead? This is what I do.

That worked, thank-you very much smile.png

@Fredricvo: This does 1 better. I used C# because its works as an custom build step integrated with VS. So I add the .hlsl or .fx files as you would, but under 'item type' I select my task instead of the default hlsl compiler. It compiles the code and instead of saving it as a .cso file as COFF object which can be directly linked into the executable, and which is done automatically. I can give it whatever variable name I want and even use namespaces. It's really easy. I don't need to worry about custom build steps or anything, its all handled automatically for me.

I should also add. There are only two problems I have with it. 1st is that effects are deprecated for the newer compiler; which both annoys and baffles me to no end. Also the MSBuild scripting is not well documented, and so there are still small quirks that I need to work out. The latter I can fix, the former... serves me right for using MS I guess...

This topic is closed to new replies.

Advertisement