Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX] ShaderReflection

This topic is 2857 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.

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)

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:

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!

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!