views:

22

answers:

1

I am currently working on a little graphics demo (using DirectX) which is primarily based around an HLSL shader I am working on. Using the D3DX10CreateEffectFromFile I am loading (and compiling the shader) at runtime as I find it easier for tweaking.

However, once I am done I'd like to do some combination of the following:

  • Pre-compile the shader so the demo starts up faster for the user
  • Bury (compile into the executable) the compiled shader (or maybe just the source if necessary)

Primarily, I want to do this because I want the demo to just be one file that can be very easily copied around.

One thing I could easily do is just put the source text right into a cpp but that would be very tedious I needed to update it later.

Is it possible to do something like this (using Visual Studio, DirectX, HLSL)?

+1  A: 

As pointed out in that link you can simply add it as a binary resource to the exe.

Personally, though, I'd go with something like having a big binary file. The start of the file has a table of contents. Basically a shader ID and an offset. The offset then corresponds to where the binary compiled data starts. You can put 4 bytes at the top of each compiled shader that says how long it is as well. Inserting a new shader can get troublesome though as it does require moving a fair whack of data around but seeing as its an offline process its not really a problem.

Goz