Sign in to follow this  
jbb

Reading shader constant definitions (d3d9)

Recommended Posts

Is there any way to map shader external variable names to their constant register number given a shader file that has been pre compiled using fxc.exe without using the d3dx library? I'd rather not use that library in my application as I have no other need for it, and it significantly complicates deployment of my program if I use it. I can't find anything in the core of directx9, or any documentation at all on the format of the compiled shader object files so was wondering if anyone could point me to any relevant information, or suggest a better approach. I'm currently setting explicit constant numbers on my variables and accessing them by index in the C++ code which works well but seems a bit fragile and not very scalable in future when I have more shaders with different parameters,

Share this post


Link to post
Share on other sites
I had an idea while sleeping...

As part of my build I'm already running a script to compile my shaders by using fxc.exe. I could instead make a small program which uses D3DX to compile the shaders and write them out to a file, and at that point I can get at the constant table and write that out in my own format too. I have no problem with using D3DX on my build machine, I just don't want end users to need it for this. Does that make sense as a thing to do?

One question then, this sounds like I just need a command line utility with no window. Is there any way to use a direct3d device that will be needed for this without having a window? I guess I could make a hidden window but that seems inelegent somehow.

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
I don't believe the bytecode format is documented, at least on the D3D side of things.


The shader IL tokens are documented in the Windows DDK, but the convention of mapping symbols to registers is not (it is purely D3D side stuff). It is conceivable that the system uses comment tokens interleaved with the actual instructions for that (but I haven't checked this).

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