🔒 Locked
HLSL Assembly
Advertisement
Original Post
Hi, Is there anywhere a definition of the hlsl assembly BINARY structure? I need to read a hlsl binary and understand the opcodes that i'm reading. (I'm aware it's quite reverse of common usage) Appereciate any help :) Cheers!
http://msdn.microsoft.com/en-us/library/ms800355.aspx
This was linked from the wine FAQ and I had a quick look at it some weeks ago - I guess this is what you are looking for
PS: I wish there was something like that for OpenGL ES 2.0 :(
This was linked from the wine FAQ and I had a quick look at it some weeks ago - I guess this is what you are looking for
PS: I wish there was something like that for OpenGL ES 2.0 :(
MJP:
Thanks but i was aiming to do it in real time anyway (my app needs to really understand the binary on the fly - not manually using pix) :)
J-Fox:
Wow! Thanks a lot for that great link, i searched quite a lot and didn't find it - you just saved me a whole lot of work! =]
Thanks but i was aiming to do it in real time anyway (my app needs to really understand the binary on the fly - not manually using pix) :)
J-Fox:
Wow! Thanks a lot for that great link, i searched quite a lot and didn't find it - you just saved me a whole lot of work! =]
Great Failure...
It seems that the documentation is only relevant to SM1,2,3
and NOT to SM4 :/
[Edited by - yoelshoshan on May 19, 2009 8:17:38 AM]
It seems that the documentation is only relevant to SM1,2,3
and NOT to SM4 :/
[Edited by - yoelshoshan on May 19, 2009 8:17:38 AM]
DieterVW:
Mostly educational purposes:
1. Looking in games Shaders, and learning a thing or two =]
2. Changing a game behaviour from outside
Reversing it is of course an option, But i prefer to see if there's available info on this anywhere before i start.
Mostly educational purposes:
1. Looking in games Shaders, and learning a thing or two =]
2. Changing a game behaviour from outside
Reversing it is of course an option, But i prefer to see if there's available info on this anywhere before i start.
Quote:
Original post by DieterVW
Hey guys,
I was wondering what you're interested in doing since for sm 4.0+ we do not make the assembler available publicly. In addition, the header blob(s) format is also not published since it could change at any time.
Dieter
Actually, moreover, if I recall correctly, Direct3D 10 doesn't allow assembly for shaders at all =/ Though I guess that makes sense because it allows GPUs to use whatever internal language the manufacturer wants.
EDIT: um, that sounds like I tried to mean that the GPUs use the same assembly as Direct3D pre-10 did =P My point was that not all assembly instructions may be easily translatable (at least in the future), or that it may end up missing on a lot of instructions the manufacturer may want to add (something the compiler wouldn't miss because that would be part of the device-specific driver), etc.
I didn't mention the exact info i'm trying to extract from the binary.
What i'm looking for is the Resource Binding information,
"... with an assembly language-like instruction set, input and output registers for inter-stage communication, general purpose registers ..., and a set of RESOURCE BINDING points for attaching memory resources such as texture images."
(i can extract the input and output registers from the DDI layer)
Quoting from here:
Direct3d10_web.pdf
What i'm looking for is the Resource Binding information,
"... with an assembly language-like instruction set, input and output registers for inter-stage communication, general purpose registers ..., and a set of RESOURCE BINDING points for attaching memory resources such as texture images."
(i can extract the input and output registers from the DDI layer)
Quoting from here:
Direct3d10_web.pdf
Right, there is no way for you to compile a shader from assembly. The hardware vendors do a JIT when you call CreateShader and compile the IL to their own instruction set. Plus, the HLSL compiler provides great feedback and does its best to make sure that the shaders you write will work. Writing in assembly is full of gotchyas now since there are many limitations with regards to how instructions can be used in order to ensure good performance.
The good news is that we provide an API for looking at a compiled shader and getting the resource binding information. This means that you shouldn't have to go through the effort of trying to figure out how the blob works. Besides, the blob could change at any time with any SDK release (and it does) so, the effort you'd go through reverse engineering it wouldn't be worth much.
The reflection API gives lots of other information too, such as instruction counts, variable names, binding slots, data types, and much much more.
Here are some links to get you started:
http://msdn.microsoft.com/en-us/library/dd607334(VS.85).aspx
D3DCompiler.h -> D3DReflect
For a compiled 4.0 target shader, request type __uuidof(ID3D10ShaderReflection)
For a compiled 4.1 target shader, request type __uuidof(ID3D10ShaderReflection1)
For a compiled 5.0 target shader, request type __uuidof(ID3D11ShaderReflection)
The reflection API can be found in the following headers:
d3d10shader.h
d3d10_1shader.h
d3d11shader.h
Top level interface (DX10):
http://msdn.microsoft.com/en-us/library/bb173835(VS.85).aspx
Hopefully this will fill the gap for you.
Dieter
The good news is that we provide an API for looking at a compiled shader and getting the resource binding information. This means that you shouldn't have to go through the effort of trying to figure out how the blob works. Besides, the blob could change at any time with any SDK release (and it does) so, the effort you'd go through reverse engineering it wouldn't be worth much.
The reflection API gives lots of other information too, such as instruction counts, variable names, binding slots, data types, and much much more.
Here are some links to get you started:
http://msdn.microsoft.com/en-us/library/dd607334(VS.85).aspx
D3DCompiler.h -> D3DReflect
For a compiled 4.0 target shader, request type __uuidof(ID3D10ShaderReflection)
For a compiled 4.1 target shader, request type __uuidof(ID3D10ShaderReflection1)
For a compiled 5.0 target shader, request type __uuidof(ID3D11ShaderReflection)
The reflection API can be found in the following headers:
d3d10shader.h
d3d10_1shader.h
d3d11shader.h
Top level interface (DX10):
http://msdn.microsoft.com/en-us/library/bb173835(VS.85).aspx
Hopefully this will fill the gap for you.
Dieter
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement