2

I'm wondering if it's possible to get the Variable names of Texture2D and SamplerState. I know that I'm able to get those through the effects Framework. But I'm looking for a way without this Framework. Like the way with Constantbuffers (ShaderReflection). I want to make the HLSL Code like this

   Texture2D tex0;
   Texture2D bg;

Does anyone have an idea How I might be able to access the VariableNames without the EffectsFramework?

Rey
  • 85
  • 1
  • 9
  • I don't know the answer but I'm curious about this too. You might get a response if you ask on the [SharpDX forum](http://sharpdx.org/forum). – shoelzer Jun 20 '13 at 16:46

1 Answers1

2

Ok pretty simple here, first compile your shader to get bytecode.

Then create an instance of ShaderReflection

byte[] yourbytecode;
SharpDX.D3DCompiler.ShaderReflection sr;
sr = new ShaderReflection(yourbytecode);

To find how many resources are bound:

int ResourceCount = sr.Description.BoundResources;

Then to get details about it:

InputBindingDescription desc = sr.GetResourceBindingDescription(index);

It contains name, dimension and other usefule data.

mrvux
  • 8,523
  • 1
  • 27
  • 61