Sign in to follow this  

Compile shader fragments offline

This topic is 4069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I would like to compile a bunch of shader fragments offline (written in HLSL), to store it in a binary format (for obfuscation & performance purposes). like you could compile an effect or (vertex/pixel) shader with the fxc/psa/vsa tools.... I tried a lot of different synthaxes with FragmentLinker.fx (from the SDK), but I failed. (I tried to use the shader fragment name or the function name as entry point but it keeps saying "no no") What I am doing wrong ?

Share this post


Link to post
Share on other sites
Unfortunately, the D3DX fragment linker is pretty defunct. It has been pretty much abandoned in past years. Considering that it usually struggles to work correctly with normal usage, I bet it's not going to be too cooperative with what you want [wink]

You can try writing your own fragment linker (it's really not hard - and you can make a much more specialized and useful version for yourself) with this offline compilation in mind. If you don't want to do that, you could always just try encrypting your files (for the obfuscation part).

Share this post


Link to post
Share on other sites
What I want is simple: I don't want to have my shader fragments in HLSL format in my games ressources files, but in pcode (d3d asm) format.

Like you could compile a full ID3DXEffect with fxc.exe, I just want to have my shader fragments in binary formats (for release).

Encrypting HLSL code in the games's ressources could be practicable, but since you only have to trap D3DX calls to grab the HLSL code, means 0 obfuscation. But it's not the first motivation.

My approach is since you can do an offline compilation of ID3DXEffect using HLSL shaders, I was supposing that offering the same possiblities for shader fragments was natural.

But if you can't offline compile shader fragments and load them at runtime in their binary format :/

Share this post


Link to post
Share on other sites
Quote:
Original post by bjone
But if you can't offline compile shader fragments and load them at runtime in their binary format :/

Yea, unfortunately, it doesn't seem to be possible. What you could do is write your own fragment linker, generate all possible permutations of your shaders as a pre-process step, compile all of them, and then load them at run-time as necessary.

I suppose you could also use the Fragment-Linker itself to do this, since it gives you back a pixel or vertex shader interface, which you can then use to get the linked code (IDirect3D[Pixel|Vertex]Shader::GetFunction()). Grab that code, save it to a file, and then re-load it at runtime.

Share this post


Link to post
Share on other sites

This topic is 4069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this