简体   繁体   English

阅读DirectX 11 API的HLSL语义和注释?

[英]Reading HLSL semantics & annonations with DirectX 11 API?

I have an shader (in .fx file) that has parts like that (which are using SAS ): 我有一个着色器(在.fx文件中),具有诸如(使用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++. 我正在使用DirectX 11,并且程序使用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. 我可以通过简单地手工解析.fx文件并寻找: ... <...>模式来做到这一点。 Or maybe DirectX 11 API has some dedicated methods or approach for that. 也许DirectX 11 API为此提供了一些专用方法或方法。

Additional reading of all shaders by hand to look for semantics & annotations looks like a little over-kill. 手动阅读所有着色器以寻找语义和注解似乎有点过头了。

Effects for D3D11 was moved out of the DirectX SDK (now Windows SDK) and into an open source project hosted on GitHub, FX11 . D3D11的效果已从DirectX SDK(现在为Windows SDK)中移出,并移入了托管在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. 要了解着色器的语义,您可以通过D3D11Reflect使用D3D Shader Reflection API,这些API仍是SDK的一部分。 These APIs are only for .hlsl shaders however and do not support all the additional features of the FX framework. 这些API仅适用于.hlsl着色器,但不支持FX框架的所有其他功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM