Skip to content

[linux] Enable Reflection on *nix platforms - #4810

Merged
Gregory Roth (pow2clk) merged 13 commits into
microsoft:mainfrom
pow2clk:linflection
Nov 24, 2022
Merged

[linux] Enable Reflection on *nix platforms#4810
Gregory Roth (pow2clk) merged 13 commits into
microsoft:mainfrom
pow2clk:linflection

Conversation

@pow2clk

Copy link
Copy Markdown
Collaborator

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

Greg Roth and others added 5 commits November 21, 2022 14:40
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.
@pow2clk

Copy link
Copy Markdown
Collaborator Author

Note that this is meant to be reviewed commit by commit

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@llvm-beanz Chris B (llvm-beanz) left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread 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}

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Collaborator Author

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.

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Collaborator Author

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.

Comment thread lib/HLSL/DxilContainerReflection.cpp Outdated
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc, PublicAPI api) {
IFRBOOL(pDesc != nullptr, E_INVALIDARG);
IFRBOOL(ResourceIndex < m_Resources.size(), E_INVALIDARG);
#ifdef _WIN32

Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/HLSL/DxilContainerReflection.cpp Outdated
}
else {
else
#endif // _WIN32

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here :(

@llvm-beanz Chris B (llvm-beanz) left a comment

Copy link
Copy Markdown
Collaborator

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.

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

What compiler is overly permissive now huh? huh? (or just quick to adopt
new language features?)
@AppVeyorBot

Copy link
Copy Markdown

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 >:(
@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@pow2clk
Gregory Roth (pow2clk) merged commit 14a55b7 into microsoft:main Nov 24, 2022
@pow2clk
Gregory Roth (pow2clk) deleted the linflection branch November 24, 2022 02:10
Comment on lines +15 to +17
// need to disable this as it is voilated by this header
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// need to disable this as it is voilated by this header
// need to disable this as it is violated by this header

@MarijnS95

Copy link
Copy Markdown
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support IDxcContainerReflection on Linux

4 participants