Sign in to follow this  

[SlimDX] ShaderReflection

This topic is 2213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

[code]
ShaderBytecode bytecode = ShaderBytecode.CompileFromFile(selectedFile, "fx_5_0", ShaderFlags.None, EffectFlags.None);
var text = bytecode.Disassemble();
ShaderReflection reflection = new ShaderReflection(bytecode);[/code]
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 :

[quote name="Trace Output"]
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)[/quote]

Share this post


Link to post
Share on other sites
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:

[code]
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();
[/code]

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.

Share this post


Link to post
Share on other sites

This topic is 2213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this