[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 |
Chris B (llvm-beanz)
left a comment
There was a problem hiding this comment.
The vast majority of this looks very straightforward to me.
| 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.
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.
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.
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.
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.
| _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.
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.
| } | ||
| else { | ||
| else | ||
| #endif // _WIN32 |
There was a problem hiding this comment.
Same here :(
Chris B (llvm-beanz)
left a comment
There was a problem hiding this comment.
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.
What compiler is overly permissive now huh? huh? (or just quick to adopt new language features?)
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 >:(
| // 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.
Gregory Roth (@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.
| // 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