ConstantTable.SetValue problems

Started by
2 comments, last by JamieT187 9 years, 1 month ago

Hi guys,

What I'm trying to do :

Load a piece of shader byte code into my program, access the float values in the constant table, change those values, then output the modified shader. To do this I've been using the SetValue method http://sharpdx.org/documentation/api/m-sharpdx-direct3d9-constanttable-setvalue-4

The code runs fine but nothing seems to be happening to the constant table. I output the ConstantTable.Buffer to a file, but it's still the original data.

I've come to the conclusion that maybe it's not actually possible to change my shader byte code like this? Any help with this would be very much appreciated.

Or... If anyone knows a way to assemble a shader from a disassembled shader string, that also includes the constant table, I'd love to hear it.

Thanks

Advertisement

That function isn't changing the shader bytecode, it's modifying the device state. When you have those kinds of constants in a shader, they get mapped to a set of 256 constant registers (named c0-c255) that are supposed to contain the values that the shader can use. Those registers are part of the device and are shared by all shaders of the same type. So the idea is that when you're ready to draw with a particular shader, you bind the shader, set the constant registers to the appropriate values, and then draw.

Ahh ok, thanks MJP! I thought that might be the case...I wish I'd come here 2 days ago! lol :-/

Looks like I'll have to carry on reverse engineering the constant tables myself. I saw the SetValue function and decided to drop what I was doing and chase after that... Ah well never mind...

Thanks very much for the help.

Can I just confirm whether or not it's possible to assemble a shader from the disassembly string, that'll also include a constant table in bytecode output.

I'd like a clean way to be able to modify the default values in the constant table. Building one myself is seeming like a daunting task after spending so long on it already with no success.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb172707%28v=vs.85%29.aspx

This says... "ppShader [out] - Returns a buffer containing the created shader. This buffer contains the compiled shader code, as well as any embedded debug and symbol table information." ... Symbol Table is what I'm after, right? I've no idea how I'd generate that. This constant/symbol table info is commented out in the disassembly string.

Do I need to define something in the "Macro" or "IncludeFiles"? I've no idea how to use those parameters.

This topic is closed to new replies.

Advertisement