3

I would like to know if there's any way I can attach application-specific metadata to my global variables in HLSL shaders. I know that HLSL supports annotations on global variables, but I can't find any way of reading those annotations (presumably via the reflection API) without using the Effects Framework, which my application doesn't use. Is there any way of attaching application-specific metadata to global variables in HLSL? (Preferably without inferring special meaning from the variables' names.)

Use case: I want my application to be able to detect whether a float4 global is being used as a color or as a simple 4-float vector. In the case where it's a color, the application would display the variable using a color-picker in the UI.

Walt D
  • 4,491
  • 6
  • 33
  • 43

1 Answers1

0

If you are not using the Effects Framework (in D3DX), you can use the Effects for DX11 library to read the values for these annotations. This is library is not a part of the DirectX SDK itself, and thus, it not specifically deprecated like D3DX. In fact, it's stated intended purpose is:

Effects 11 is being provided as a porting aid for older code that makes use of the Effects 10 (FX10) API or Effects 9 (FX9) API in the deprecated D3DX9 library. See MSDN for a list of differences compared to the Effects 10 (FX10) library.

Other than annotations, there is no built-in way to attach meta-data to variables, other than with naming schemes (or other such implicit hints).

MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78