0

I have an shader (in .fx file) that has parts like that (which are using SAS):

cbuffer UpdatePerObject : register(b1)
{
    float4x4 worldViewIT : WorldViewInverseTranspose < string UIWidget = "MyName"; >;
    float4x4 world : World < string UIWidget = "None"; >;
};

I am using DirectX 11 and my program is in C++.

Different shaders will need different matrices, textures, etc. I want to set them to those shaders based on their semantics & annotations.

I can do it by simply parsing the .fx file by hand and looking for : ... <...> pattern. Or maybe DirectX 11 API has some dedicated methods or approach for that.

Additional reading of all shaders by hand to look for semantics & annotations looks like a little over-kill.

Wandering Fool
  • 2,170
  • 3
  • 18
  • 48
PolGraphic
  • 3,233
  • 11
  • 51
  • 108

1 Answers1

1

Effects for D3D11 was moved out of the DirectX SDK (now Windows SDK) and into an open source project hosted on GitHub, FX11.

To get at semantics for a shader you can use the D3D Shader Reflection APIs via D3D11Reflect which are still part of the SDK. These APIs are only for .hlsl shaders however and do not support all the additional features of the FX framework.

mattnewport
  • 13,728
  • 2
  • 35
  • 39
  • So, without using 3rd-party libraries I am no longer able to do it with DirectX 11 (as I was in e.g. DirectX 9)? I just need to get the semantic name for my matrix from shader (in `.fx` or in `.hlsl`). – PolGraphic Aug 13 '15 at 19:13
  • It's not exactly a 3rd party library, it's from Microsoft and is based on the FX support that used to ship as part of the SDK. They pulled out much of what used to constitute D3DX to open source libraries as well. This was done in part because when the DirectX SDK moved into the Windows SDK they would have been limited in when they could release updates to the helper libraries. – mattnewport Aug 13 '15 at 19:28
  • 2
    If you just want to get at semantics for a shader file (rather than FX specific information) use the D3DReflect APIs: https://msdn.microsoft.com/en-us/library/windows/desktop/ff728670(v=vs.85).aspx – mattnewport Aug 13 '15 at 19:29
  • Thank you. Can you include that link in the answer too? It might be helpful for others. – PolGraphic Aug 13 '15 at 19:34