Jump to content

  • Log In with Google      Sign In   
  • Create Account


[SlimDX] ShaderReflection


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 SGStino   Members   -  Reputation: 119

Like
0Likes
Like

Posted 23 December 2011 - 07:42 AM

I'm trying to get a look at ShaderReflection but i get an exception on its constructor.

ShaderBytecode bytecode = ShaderBytecode.CompileFromFile(selectedFile, "fx_5_0", ShaderFlags.None, EffectFlags.None);
var text = bytecode.Disassemble();
ShaderReflection reflection = new ShaderReflection(bytecode);
selectedFile is the MiniTri 11 fx file. The disassemble seems to work.

I tried to enable unmanaged debug, but as its a "SlimDX.D3DCompiler.D3DCompilerException", i'd guess it originates in "D3DCompiler_43.dll".

but all i get is :

A first chance exception of type 'SlimDX.D3DCompiler.D3DCompilerException' occurred in SlimDX.dll
An unhandled exception of type 'SlimDX.D3DCompiler.D3DCompilerException' occurred in SlimDX.dll
Additional information: E_FAIL: An undetermined error occurred (-2147467259)



Sponsor:

#2 SGStino   Members   -  Reputation: 119

Like
0Likes
Like

Posted 26 December 2011 - 02:14 PM

oh noes, reflection doesn't work on effects but only on shaders. :'(

#3 Starnick   Members   -  Reputation: 1147

Like
0Likes
Like

Posted 26 December 2011 - 05:20 PM

What are you trying to accomplish with shader reflection?

In order to use the reflection API with an effect, you're going to have to get the byte code for the individual shader fragments that make up each effect pass, e.g. after compiling an effect, given an EffectPass:

EffectPass pass; //From your effect

EffectShaderVariable shaderVar = pass.VertexShaderDescription.Variable;
ShaderDescription shDesc;
shaderVar.GetShaderDescription(0, out shDesc);
ShaderReflection reflect = new ShaderReflection(shDesc.Bytecode);

//Do something with the reflection object

//Don't forget to dispose of these afterwards, otherwise the slimdx object table will report them as a leak!
reflect.Dispose();
shDesc.Signature.Dispose();
shDesc.Bytecode.Dispose();

The above would be reflecting over the vertex shader in the given pass, e.g. say you want to create an input layout up front when loading your effect you can use the ShaderReflection to examine the inputs.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS