-
Notifications
You must be signed in to change notification settings - Fork 121
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
Use reflection to get DXIL library shader exports #1710
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# FindDXC | ||
# ----------- | ||
# | ||
# Find the DXC includes and library. | ||
# | ||
# This module defines the following variables: | ||
# | ||
# DXC_FOUND : True if DXC was found. | ||
# DXC_INCLUDE_DIR : The location of the DXC header file. | ||
# DXC_LIBRARY_PATH : Location of the DXC library. | ||
# DXC_DLL_PATH : Location of the DXC DLL. | ||
|
||
if (${D3D12_SUPPORT}) | ||
|
||
# Find the build architecture. | ||
set(DXC_ARCH "") | ||
if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") | ||
set(DXC_ARCH "arm64") | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(DXC_ARCH "x64") | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
set(DXC_ARCH "x86") | ||
endif() | ||
|
||
if(DXC_ARCH) | ||
|
||
set(DXC_SDK_DIR "${CMAKE_BINARY_DIR}/external/DXC") | ||
set(DXC_SDK_URL "https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2407/dxc_2024_07_31.zip") | ||
|
||
# Suppress warning on newer versions of CMake related to FetchContent file timestamp behavior. | ||
if (${CMAKE_VERSION} VERSION_GREATER "3.24") | ||
cmake_policy(SET CMP0135 NEW) | ||
endif() | ||
|
||
message(STATUS "Fetching DXC files from ${DXC_SDK_URL}") | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
DXC_SDK | ||
URL ${DXC_SDK_URL} | ||
SOURCE_DIR ${DXC_SDK_DIR} | ||
) | ||
FetchContent_MakeAvailable(DXC_SDK) | ||
|
||
if(DEFINED CACHE{DXC_INCLUDE_DIR} AND NOT EXISTS "${DXC_INCLUDE_DIR}/dxcapi.h") | ||
message("Current DXC_INCLUDE_DIR '${DXC_INCLUDE_DIR}' does not contain 'dxcapi.h'. Resetting DXC_INCLUDE_DIR.") | ||
unset(DXC_INCLUDE_DIR CACHE) | ||
endif() | ||
find_path(DXC_INCLUDE_DIR NAME "dxcapi.h" PATHS "${DXC_SDK_DIR}/inc") | ||
mark_as_advanced(DXC_INCLUDE_DIR) | ||
|
||
# If the cached library path doesn't exist or arch doesn't match, unset variable. | ||
if(DEFINED CACHE{DXC_LIBRARY_PATH} AND NOT EXISTS "${DXC_LIBRARY_PATH}") | ||
message("Current DXC_LIBRARY_PATH '${DXC_LIBRARY_PATH}' does not exist. Resetting DXC_LIBRARY_PATH.") | ||
unset(DXC_LIBRARY_PATH CACHE) | ||
endif() | ||
find_library(DXC_LIBRARY_PATH NAME "dxcompiler.lib" PATHS "${DXC_SDK_DIR}/lib/${DXC_ARCH}" NO_DEFAULT_PATH) | ||
mark_as_advanced(DXC_LIBRARY_PATH) | ||
|
||
# If the cached DLL path doesn't exist or arch doesn't match, unset variable. | ||
if(DEFINED CACHE{DXC_DLL_PATH} AND NOT EXISTS "${DXC_DLL_PATH}") | ||
message("Current DXC_DLL_PATH '${DXC_DLL_PATH}' does not exist. Resetting DXC_DLL_PATH.") | ||
unset(DXC_DLL_PATH CACHE) | ||
endif() | ||
find_file(DXC_DLL_PATH NAME "dxcompiler.dll" PATHS "${DXC_SDK_DIR}/bin/${DXC_ARCH}" NO_DEFAULT_PATH) | ||
mark_as_advanced(DXC_DLL_PATH) | ||
|
||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(DXC REQUIRED_VARS DXC_LIBRARY_PATH DXC_DLL_PATH DXC_INCLUDE_DIR) | ||
|
||
endif() # D3D12_SUPPORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
if (${D3D12_SUPPORT} AND "${DXC_FOUND}") | ||
|
||
# Setup dst folders for each build config | ||
set(DXC_DST_DBG ${CMAKE_CURRENT_BINARY_DIR}/Debug) | ||
set(DXC_DST_REL ${CMAKE_CURRENT_BINARY_DIR}/Release) | ||
set(DXC_DST_REL_WITH_DBG_INFO ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo) | ||
set(DXC_DST_MIN_SIZE_REL ${CMAKE_CURRENT_BINARY_DIR}/MinSizeRel) | ||
set(DXC_DST_INSTALL ${CMAKE_INSTALL_BINDIR}) | ||
|
||
# Copy dxcompiler.dll to dst build folder | ||
file(COPY ${DXC_DLL_PATH} DESTINATION ${DXC_DST_DBG}) | ||
file(COPY ${DXC_DLL_PATH} DESTINATION ${DXC_DST_REL}) | ||
file(COPY ${DXC_DLL_PATH} DESTINATION ${DXC_DST_REL_WITH_DBG_INFO}) | ||
file(COPY ${DXC_DLL_PATH} DESTINATION ${DXC_DST_MIN_SIZE_REL}) | ||
|
||
# Copy dxcompiler.dll to install folder | ||
install(FILES ${DXC_DLL_PATH} DESTINATION ${DXC_DST_INSTALL}) | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's a lot of machinery here - do we know how it might affect perf to do this work?
Wondering if any of these things can be a 1-time init and reusable thing? For instance all
DxcCreateInstance
callsThere 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 did not do any specific performance measuring. This code should only run during unoptimized DXR or EI replay where performance is already heavily affected.
The
dxc_utils
object could be reused but I don't know whether that is a heavy-weight operation. The other classes are based on the incoming DXIL library so the code would need to compare the DXIL library's bytes to detect if previous objects or results could be reused.