You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Library compilation to support library reflection #657
Since compiled shaders already support reflection (using ID3D11LibraryReflection/ID3D12ShaderReflection)
Bytecode compiled with lib_6_1 could definitely also provide ID3D11LibraryReflection support.
Reflection data should match what's already in the D3D11 counterpart (eg: function name / parameters), since it's already quite exhaustive (and ideally use the same interface).
This is really useful in order to scan library for existing functions (when building authoring tools).
unfortunately, this function isn't directly available outside the codebase
The GetFunctionParameter issue looks unexpected. I notice we have no testing for it. 😞 Maybe Tex Riddell (@tex3d) has some insight, but I think it's worth creating a new issue regardless.
While we implemented some library reflection through the ID3D11LibraryReflection interface, there are fundamental differences between what a library is and what it's used for in D3D11 with FXC and DXBC vs. D3D12 with DXC and DXIL. One (DXBC) consists of shader snippets used exclusively for constructing function linking graphs at runtime in D3D11, and the other (DXIL) is more similar to a C++ library for use in offline linking of modules, as well as for DXR shaders and functions linked by drivers. As you point out, one difference is that DXIL libraries mangle functions in order to support function overloading.
It may not be worth it to attempt to make reflection match in more than some useful subset of ways. The implementation of DXIL library reflection in this interface was limited to known use cases that were needed for developers using them at the time (for DXR).
I agree we should create a new issue for GetFunctionParameter. Then we would like to know how high a priority this is for developers who would like to use it.
Activity
pow2clk commentedon Sep 11, 2020
Supported!
mrvux commentedon Nov 1, 2020
Thanks, I finally had time to try it, seems there is some partial support, also I could see a few issues
Taking this extremely simple code :
accessing reflection gives a mangled name in function desc :
func_desc.Name gives me :
�?Apply@ya?AV?$vector@M$02@v1@Tyler "-z-" Mulligan (@z)
Also seems parameter reflection is not working versus d3d12 counterpart :
D3D12_PARAMETER_DESC pdesc;
auto p = fr->GetFunctionParameter(0);
HRESULT hr = p->GetDesc(&pdesc);
hr returns an E_FAIL here
Should I actually post those as separate issues?
Thanks
pow2clk commentedon Nov 2, 2020
Hi mrvux (@mrvux)!
The name mangling is intentional I'm afraid. See this line where the mangled name return is tested:
DirectXShaderCompiler/tools/clang/unittests/HLSL/DxilContainerTest.cpp
Line 1280 in 075d3ce
To demangle it, you might consider the fairly simple approach taken by the internal code:
DirectXShaderCompiler/lib/DXIL/DxilUtil.cpp
Line 139 in 075d3ce
unfortunately, this function isn't directly available outside the codebase
The
GetFunctionParameterissue looks unexpected. I notice we have no testing for it. 😞 Maybe Tex Riddell (@tex3d) has some insight, but I think it's worth creating a new issue regardless.tex3d commentedon Nov 2, 2020
While we implemented some library reflection through the
ID3D11LibraryReflectioninterface, there are fundamental differences between what a library is and what it's used for in D3D11 with FXC and DXBC vs. D3D12 with DXC and DXIL. One (DXBC) consists of shader snippets used exclusively for constructing function linking graphs at runtime in D3D11, and the other (DXIL) is more similar to a C++ library for use in offline linking of modules, as well as for DXR shaders and functions linked by drivers. As you point out, one difference is that DXIL libraries mangle functions in order to support function overloading.It may not be worth it to attempt to make reflection match in more than some useful subset of ways. The implementation of DXIL library reflection in this interface was limited to known use cases that were needed for developers using them at the time (for DXR).
I agree we should create a new issue for
GetFunctionParameter. Then we would like to know how high a priority this is for developers who would like to use it.