DirectX 9 Pixel Shader Assembler Source Code

Nick

Veteran
Hi,

Does anyone know if there is an open-source assembler for ps 2.0 assembly? Or perhaps someone knows where I can find the parsing rules? I would like to use this for my own emulator. The Cg compiler is not usable because it is not DX9 compatible.

Thanks.
 
If you wan't to know how to translate assembly code into DWORD tokens, you'll have to use DDK, or inspect d3dtypes9.h.
 
Thanks MDolenc,

The d3d9types header seems to contain some interesting definitions, but it's not very useful.

What do you mean by DWORD tokens, the ID of the tokens? This is of little use to me, as it is implementation specific. What I actually need is some code to translate the shader code into separate (intermediate) instructions, i.e. a list of structures filled with the opcode type, registers and their modifiers, co-issued instructions, etc. From that point on I can quite easily emulate them in software.

I know how to build such a parser myself, so if this code is not freely available, the parsing algebra itself would be sufficient. Writing it from scratch by only using the SDK documentation is quite difficult because of the loose descriptions (no details) and the many exceptions. Some instructions don't even have a precise definition of their operation.

I'm not sure wether I can find this information in any DDK. As far as I know, the shader assembler front-end is integrated in DirectX and not handled by the driver? If I'm wrong, could you please show me where I could find the reference implementation of the DirectX 9 driver?

Kind regards,

Nick
 
There's a Microsoft DX9 shader specification document out there somwhere. It was leaked from Betaplace last year. It's not on Betaplace any longer, so you'd have to scout this forum or google.
 
Oops, I know where the token confusion came from...

I thought you meant lexical tokens, like idetifiers, string literals, etc. What you meant were the tokens tokens that represent the intermediate code instructions send to the driver, right?

If this is the case, then the DDK won't help me here, as I need the front-end of the compiler (the part that translates the source code into the driver tokens or another intermediate representation) which is part of the DirectX runtime instead of the back-end of the compiler (which is responsible for converting the intermediate code into executable machine code) which is part of the driver. Sorry for the confusion.

So do you have any idea if and where I could find the compiler front-end code or it's parser grammar? I can find nearly any programming language's grammar on the internet, but I don't know where to look for shader assembly...

Thanks a lot,

Nick
 
790 said:
There's a Microsoft DX9 shader specification document out there somwhere. It was leaked from Betaplace last year. It's not on Betaplace any longer, so you'd have to scout this forum or google.
Thanks 790, so what you're saying is that there is some in-depth documentation about shaders that is not in the SDK documentation? That would be great. I did a few quick searches on google and this site but found nothing (I just recently became a member). Could you help me find it?

Cheers,

Nick
 
Found it!

Martin Ecker's XEngine (xengine.sourceforge.net) has scanner definition and parser grammar files of all kinds of shaders for Flex++ and Bison++. Exactly what I needed!
 
Back
Top