-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[linux] Enable Reflection on *nix platforms #4810
Conversation
Needed for the impending enabling on *nix platforms
A file included by the source that implemented various ToString converters of reflection data to strings itself depended on those declarations, which it only found because of the unique way MSVC processes templates. By moving the definitions and declarations into their own header and source files, everyone gets what they need without ouroborosing.
Creates the DirectX-Headers submodule and adds the needed defines to allow them to be used. As yet makes no use of these headers
The check for the file stream that is meant to represent the filechecked source file wasn't sufficient to detect a non-existent file. By expanding the error check, it can produce a helpful message. Also initialize the failure code so it isn't random
This flips the switch, removing or repositioning many ifdefs and including previously excluded files in the build.
Note that this is meant to be reviewed commit by commit |
❌ Build DirectXShaderCompiler 1.0.2269 failed (commit 9968374372 by @pow2clk) |
❌ Build DirectXShaderCompiler 1.0.2271 failed (commit fbc8f9aff5 by @pow2clk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vast majority of this looks very straightforward to me.
external/CMakeLists.txt
Outdated
CACHE STRING "Location of DirectX-Headers source") | ||
if (NOT DEFINED DirectX-Headers_SOURCE_DIR) | ||
if (IS_DIRECTORY ${DXC_DIRECTX_HEADERS_DIR}) | ||
add_subdirectory(${DXC_DIRECTX_HEADERS_DIR} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually use any of the targets created by the subproject or do we just use the static headers?
If we just use the static headers we should instead be able to just have our FindD3D12 CMake module fall back to the submodule headers. That should simplify the CMake logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we do not. However, I greatly prefer the approach that DirectX-Headers takes to defining dx guids as it allows the same guid structure to have the same address across multiple files which ours does not.
I chose not to take that step with this change, but I want to take it going forward when I try to better consolidate the efforts to make non-Windows platforms look a bit more like Windows for DirectX purposes, which is a goal both projects share.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their GUID handling is all header defined too, right? The source for it just sets a single preprocessor define then includes headers.
If we want to migrate to use it we could define that ourselves, or we depend on their static archive target. The concern I have about their static archive target is that it means filtering target dependencies through the other CMake targets. If we're only doing that on Linux it feels like we might be introducing some extra complexity. Would we shift to using the submodule headers on Windows too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean to shift to using submodule headers on Windows as it would garner us certain advantages, not the least of which being easy access to more recent headers.
You make a good point that we could just as easily recreate dxguid.cpp. Regardless of where we land on Windows using these headers, that's a sufficient argument to simplify this.
lib/HLSL/DxilContainerReflection.cpp
Outdated
@@ -2389,10 +2360,13 @@ HRESULT DxilModuleReflection::_GetResourceBindingDesc(UINT ResourceIndex, | |||
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc, PublicAPI api) { | |||
IFRBOOL(pDesc != nullptr, E_INVALIDARG); | |||
IFRBOOL(ResourceIndex < m_Resources.size(), E_INVALIDARG); | |||
#ifdef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
splitting a conditional like this is pretty gross... Is there no way to make the if
statement valid on Linux?
If not, you could make the if return after the memcpy, which would eliminate the need for an else block.
lib/HLSL/DxilContainerReflection.cpp
Outdated
if (api != PublicAPI::D3D12) { | ||
memcpy(pDesc, &m_Resources[i], sizeof(D3D11_SHADER_INPUT_BIND_DESC)); | ||
} | ||
else { | ||
else | ||
#endif // _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a bigger issue with our find_package usage, but this change all looks good to me. We can sort out the find_package issues later.
✅ Build DirectXShaderCompiler 1.0.2279 completed (commit 126748665a by @pow2clk) |
❌ Build DirectXShaderCompiler 1.0.2281 failed (commit f85bbbe6e8 by @pow2clk) |
What compiler is overly permissive now huh? huh? (or just quick to adopt new language features?)
✅ Build DirectXShaderCompiler 1.0.2286 completed (commit 4f2a084d32 by @pow2clk) |
Loathe as I am to push one more commit onto this. I don't want to propagate a misconception. I meant to remove this earlier and caught it from one final self-review >:(
✅ Build DirectXShaderCompiler 1.0.2289 completed (commit 6bd150e02e by @pow2clk) |
✅ Build DirectXShaderCompiler 1.0.2290 completed (commit 75fa6db0ea by @pow2clk) |
✅ Build DirectXShaderCompiler 1.0.2291 completed (commit 7b368d6d5a by @pow2clk) |
// need to disable this as it is voilated by this header | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pow2clk Didn't we disable this warning altogether as discussed in #3793 (review), or is it now enabled by default on newer compilers (since I only commented out, instead of leaving an unconditional -Wnon-virtual-dtor
)?
#pragma once | ||
|
||
#ifndef _WIN32 | ||
// need to disable this as it is voilated by this header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// need to disable this as it is voilated by this header | |
// need to disable this as it is violated by this header |
Thanks for this! Tested on Linux and works a treat, at least for reflecting compute group sizes which we previously couldn't to on our Linux build system! |
This adds the DirectX-Headers repo as a submodule to grant the shader reflection structs
that are needed to enable the functionality on non-windows platforms. No real
changes related to the reflection code had to be made so much as the newly enabled
code had to be made to work on the platform compilers, namely clang. These changes
come first with one separated out for a particularly gnarly issue with a circular dependency
involving the RDAT dumping code.
Thereafter, the submodule is added, the reflection code is enabled for functionality and
tests and a small incidental improvement to error reporting when the data dir isn't found
was made because it's driven me crazy one too many times.
Fixes #4358