Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format of compiled directx9 shader files?

Is the format of compiled pixel and vertex shader object files as produced by fxc.exe documented anywhere either officially or unofficially?

I'd like to be able to read the constant name to register assignments from the shader files. I know that the effects framework in D3DX can do this, but I need to avoid using D3DX as it may not be installed on user's machines and I don't need it for anything else so I want to avoid them having to run the directx update.

If the effects framework can do it, then so can I if I can find out the file format but I can' seem to find it documented anywhere.

(this is for use in directx9)

like image 458
jcoder Avatar asked Mar 30 '10 13:03

jcoder


People also ask

What shader language does DirectX use?

HLSL is the C-like high-level shader language that you use with programmable shaders in DirectX. For example, you can use HLSL to write a vertex shader, or a pixel shader, and use those shaders in the implementation of the renderer in your Direct3D application.

Does DirectX use shaders?

DirectX supports shaders and its implementation since version 8.0. The first support started with Vertex and Pixel Shaders written in Assembler language.


1 Answers

From MSDN:

Asm Shader Reference (Windows)

Shader Binary Format

The bitwise layout of the shader instruction stream is defined in D3d9types.h. If you want to design your own shader compiler or construction tools and you want more information about the shader token stream, refer to the Direct3D 9 Driver Development Kit (DDK).

So you can either look through 'D3d9type.h' and try to figure it out that way (had a quick look and could see the enums/types you should need, but not how its structured), or download the DDK and read the official documentation.


Some more info can be found here: Direct3D Shader Codes (expand the tree on the left hand side of the screen to get all the info).

like image 141
Grant Peters Avatar answered Sep 22 '22 02:09

Grant Peters