Sign in to follow this  

[DX10] Precompiled effect

Recommended Posts

n3Xus    951
Hello, I'm trying to speed up my game's loading time since I'm in the phase of testing out the map editor. The shader compilation takes the longest time, so I decided to precompile them for now. I used the effect compiler to compile my shader into one file (I use some kind of a "megashader" - all passes in one big file which #includes all required files, so I only create "one" big shader by calling D3DX10CreateEffectFromFile. I've tried digging around the documentation and google but I only came across a technique in which you precompile you vertex/pixel shaders then use the device with CreatePixel/VertexShader and pass the pointer to the precompiled data. Since I have just one big file in which all shaders are, I have no idea how to get each shader individually, better yet, is there a way I can load the entire ID3D10Effect from that file somehow (so I would end up like using D3DX10CreateEffectFromFile except without the compilation process)? And here is something that has been bothering me for a long time: I have only one technique in my shader for EVERYTHING, and it has around 25 passes now (the passes are not used in the "multipass" kind of a way, they are used for totaly unrelated stuff). Obviously from a design point of view it would be better to have 25 techniques, and multiple passes only if the material requires it. So the question is: does packing all passes into one technique decreases performance?

Share this post

Link to post
Share on other sites
MJP    19788
You don't have to compile the shaders yourself individually, you can just pre-compile the entire effect. There are two ways to do it:

1. Call D3DX10CompileFromFile, access the compiled shader bytecode from the ID3D10Blob, and then save it to a file.

2. Use fxc.exe to compile the effect and save the bytecode to a file.

Either way at runtime you can just use D3DX10CreateEffectFromFile and it will create a new effect from the bytecode without having to compile it.

As far as passes vs. far as I know there's no real technical difference between the two. I think it's just an organizational thing.

Share this post

Link to post
Share on other sites

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