-
Notifications
You must be signed in to change notification settings - Fork 490
Add DirectX 12 GPU backend for automated unit testing on Windows #2271
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
Open
num3ric
wants to merge
9
commits into
AcademySoftwareFoundation:main
Choose a base branch
from
num3ric:dx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5372cc5
Add DirectX 12 GPU backend for automated unit testing on Windows
num3ric 371630e
Fix post-rebase issues found in code review
num3ric ffcd17f
Minor additional comments, formatting and fixes.
num3ric 437d93c
Speed up DX12 GPU test backend (~19%)
num3ric ce23df7
Several small fixes tidying up the recently-added GPU test infrastruc…
num3ric 4e0e8ab
Integrate DirectX-Headers with OCIO's external-package pattern
num3ric 3a9330d
Improve dxcompiler.dll diagnostics and allow overriding its path
num3ric 43043d4
Minor comment tweaks in LocateDXCompilerRuntime.cmake.
num3ric 07afd28
Use OCIO_DirectX-Headers_RECOMMENDED_VERSION in InstallDirectX-Header…
num3ric 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -287,6 +287,8 @@ Here are the most common OCIO-specific CMake options (the default values are sho | |
| - ``-DOCIO_BUILD_TESTS=ON`` (Set to OFF to not build the unit tests) | ||
| - ``-DOCIO_BUILD_GPU_TESTS=ON`` (Set to OFF to not build the GPU unit tests) | ||
| - ``-DOCIO_USE_HEADLESS=OFF`` (Set to ON to do headless GPU rendering) | ||
| - ``-DOCIO_DIRECTX_ENABLED=ON`` (Windows only; set to OFF to disable the DirectX 12 GPU rendering backend used by ``test_dx``. Forced OFF on non-Windows platforms.) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default-enabled for windows platforms, but let me know if you prefer leaving it off by default for now. |
||
| - ``-DOCIO_VULKAN_ENABLED=OFF`` (Set to ON to enable the Vulkan GPU rendering backend used by ``test_vulkan``. Requires the Vulkan SDK to be installed and findable by CMake.) | ||
| - ``-DOCIO_WARNING_AS_ERROR=ON`` (Set to OFF to turn off warnings as errors) | ||
| - ``-DOCIO_BUILD_DOCS=OFF`` (Set to ON to build the documentation) | ||
|
|
||
|
|
||
This file contains hidden or 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,76 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright Contributors to the OpenColorIO Project. | ||
| # | ||
| # Locate DirectX-Headers (header-only, Windows only) | ||
| # | ||
| # Variables defined by this module: | ||
| # DirectX-Headers_FOUND - Indicate whether the package was found or not | ||
| # DirectX-Headers_INCLUDE_DIR - Location of the header files | ||
| # DirectX-Headers_VERSION - Package version | ||
| # | ||
| # Global targets defined by this module: | ||
| # Microsoft::DirectX-Headers | ||
| # | ||
| # DirectX-Headers can be supplied by the caller through any of the standard | ||
| # CMake mechanisms: | ||
| # -- Set -DDirectX-Headers_DIR to the directory containing directx-headers-config.cmake | ||
| # -- Set -DDirectX-Headers_ROOT to the install prefix (with include/directx/ underneath) | ||
| # -- Set -DDirectX-Headers_INCLUDE_DIR to the directory containing directx/d3d12.h | ||
| # | ||
| # When OCIO_INSTALL_EXT_PACKAGES is not ALL, this module first tries to locate | ||
| # an existing install via the upstream CMake config, then falls back to a | ||
| # manual header search. If still not found and OCIO_INSTALL_EXT_PACKAGES is | ||
| # MISSING (the default), OCIO's ocio_install_dependency() pathway will invoke | ||
| # InstallDirectX-Headers.cmake to build it via FetchContent. | ||
| # | ||
|
|
||
| if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) | ||
| # Prefer the upstream CMake config (installed as lower-case). | ||
| find_package(directx-headers ${DirectX-Headers_FIND_VERSION} CONFIG QUIET) | ||
|
|
||
| if(directx-headers_FOUND) | ||
| set(DirectX-Headers_FOUND TRUE) | ||
| if(directx-headers_VERSION) | ||
| set(DirectX-Headers_VERSION ${directx-headers_VERSION}) | ||
| endif() | ||
| else() | ||
| # Fall back to locating the public header directly (e.g. when the | ||
| # headers were installed without the CMake config, or are provided | ||
| # by a vendored copy). | ||
| find_path(DirectX-Headers_INCLUDE_DIR | ||
| NAMES | ||
| directx/d3d12.h | ||
| HINTS | ||
| ${DirectX-Headers_ROOT} | ||
| PATH_SUFFIXES | ||
| include | ||
| ) | ||
| endif() | ||
|
|
||
| # If OCIO can install the package itself, demote REQUIRED so a missing | ||
| # dependency here does not abort configuration before the install step. | ||
| if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) | ||
| set(DirectX-Headers_FIND_REQUIRED FALSE) | ||
| endif() | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(DirectX-Headers | ||
| REQUIRED_VARS | ||
| DirectX-Headers_INCLUDE_DIR | ||
| VERSION_VAR | ||
| DirectX-Headers_VERSION | ||
| ) | ||
| endif() | ||
|
|
||
| ############################################################################### | ||
| ### Create target (only needed for the manual-header-search fallback; the | ||
| ### upstream CMake config already defines Microsoft::DirectX-Headers). | ||
|
|
||
| if(DirectX-Headers_FOUND AND NOT TARGET Microsoft::DirectX-Headers AND DirectX-Headers_INCLUDE_DIR) | ||
| add_library(Microsoft::DirectX-Headers INTERFACE IMPORTED GLOBAL) | ||
| set_target_properties(Microsoft::DirectX-Headers PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES "${DirectX-Headers_INCLUDE_DIR}" | ||
| ) | ||
|
|
||
| mark_as_advanced(DirectX-Headers_INCLUDE_DIR DirectX-Headers_VERSION) | ||
| endif() |
This file contains hidden or 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,32 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright Contributors to the OpenColorIO Project. | ||
| # | ||
| # Install DirectX-Headers (header-only, Windows only) | ||
| # https://github.com/microsoft/DirectX-Headers | ||
| # | ||
| ############################################################################### | ||
|
|
||
| include(FetchContent) | ||
|
|
||
| if(OCIO_DirectX-Headers_RECOMMENDED_VERSION) | ||
| set(DirectX-Headers_VERSION ${OCIO_DirectX-Headers_RECOMMENDED_VERSION}) | ||
| else() | ||
| set(DirectX-Headers_VERSION ${DirectX-Headers_FIND_VERSION}) | ||
| endif() | ||
|
|
||
| set(FETCHCONTENT_BASE_DIR "${CMAKE_BINARY_DIR}/ext/build/DirectX-Headers") | ||
| set(DIRECTX_HEADERS_BUILD_TEST OFF CACHE BOOL "" FORCE) | ||
|
|
||
| FetchContent_Declare(DirectX-Headers | ||
| GIT_REPOSITORY https://github.com/microsoft/DirectX-Headers.git | ||
|
remia marked this conversation as resolved.
|
||
| GIT_TAG v${DirectX-Headers_VERSION} | ||
| ) | ||
|
|
||
| FetchContent_MakeAvailable(DirectX-Headers) | ||
|
|
||
| # Signal success to ocio_install_dependency so ocio_handle_dependency does not | ||
| # abort at the next required-check. FetchContent_MakeAvailable has just created | ||
| # the Microsoft::DirectX-Headers target via the upstream CMakeLists. | ||
| if(TARGET Microsoft::DirectX-Headers) | ||
| set(DirectX-Headers_FOUND TRUE) | ||
| endif() | ||
This file contains hidden or 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,78 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright Contributors to the OpenColorIO Project. | ||
| # | ||
| # Locate the dxcompiler.dll + dxil.dll runtime pair needed to run D3D12 shader | ||
| # compilation at test time, and surface their file version. | ||
| # | ||
| # Inputs: | ||
| # OCIO_DXCOMPILER_DLL - Optional user-supplied path to dxcompiler.dll. | ||
| # When set, overrides the Windows SDK Redist/D3D | ||
| # search. Useful when the SDK-bundled DLL is too old. | ||
| # | ||
| # Outputs: | ||
| # DXCOMPILER_DLL - Path to dxcompiler.dll (cache variable). | ||
| # DXIL_DLL - Path to the adjacent dxil.dll (cache variable, may | ||
| # be left unset if not found next to dxcompiler.dll). | ||
|
|
||
| set(OCIO_DXCOMPILER_DLL "" CACHE FILEPATH | ||
| "Optional explicit path to dxcompiler.dll (e.g. from a newer DirectX Shader Compiler release). \ | ||
| Overrides the automatic Windows SDK Redist/D3D search." | ||
| ) | ||
|
|
||
| if(OCIO_DXCOMPILER_DLL) | ||
| if(NOT EXISTS "${OCIO_DXCOMPILER_DLL}") | ||
| message(FATAL_ERROR "OCIO_DXCOMPILER_DLL=${OCIO_DXCOMPILER_DLL} does not exist.") | ||
| endif() | ||
| set(DXCOMPILER_DLL "${OCIO_DXCOMPILER_DLL}" CACHE FILEPATH | ||
| "Path to dxcompiler.dll (user-supplied via OCIO_DXCOMPILER_DLL)" FORCE) | ||
| else() | ||
| find_file(DXCOMPILER_DLL | ||
| NAMES dxcompiler.dll | ||
| PATHS | ||
| # Note: x64 hardcoded; update if ARM64 Windows support is needed. | ||
| "$ENV{WindowsSdkDir}Redist/D3D/x64" | ||
| "C:/Program Files (x86)/Windows Kits/10/Redist/D3D/x64" | ||
| NO_DEFAULT_PATH | ||
| DOC "Path to dxcompiler.dll from Windows SDK" | ||
| ) | ||
| endif() | ||
|
|
||
| if(DXCOMPILER_DLL) | ||
| get_filename_component(_dxc_dll_dir "${DXCOMPILER_DLL}" DIRECTORY) | ||
| find_file(DXIL_DLL | ||
| NAMES dxil.dll | ||
| HINTS "${_dxc_dll_dir}" | ||
| NO_DEFAULT_PATH | ||
| ) | ||
|
|
||
| # Report the found dxcompiler.dll version so crash reports can identify | ||
| # mismatched or outdated DXC builds without re-running diagnostics. | ||
| string(REPLACE "'" "''" _dxc_dll_ps "${DXCOMPILER_DLL}") | ||
| execute_process( | ||
| COMMAND powershell -NoProfile -Command | ||
| "(Get-Item -LiteralPath '${_dxc_dll_ps}').VersionInfo.FileVersion" | ||
| OUTPUT_VARIABLE _dxc_version | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| ) | ||
| if(_dxc_version) | ||
| message(STATUS "Found dxcompiler.dll (version ${_dxc_version}): ${DXCOMPILER_DLL}") | ||
| else() | ||
| message(STATUS "Found dxcompiler.dll (version unknown): ${DXCOMPILER_DLL}") | ||
| endif() | ||
| message(STATUS | ||
| "If test_dx crashes during shader compilation, the Windows SDK's dxcompiler.dll " | ||
| "may be too old to produce signed DXIL on this system. Replace it with a newer " | ||
| "build from https://github.com/microsoft/DirectXShaderCompiler/releases, or set " | ||
| "-DOCIO_DXCOMPILER_DLL=<path> to point at a specific dxcompiler.dll." | ||
| ) | ||
| else() | ||
| message(WARNING | ||
| "OCIO_DIRECTX_ENABLED is ON but dxcompiler.dll was not found in the " | ||
| "Windows SDK Redist/D3D path. test_dx will fail at runtime unless " | ||
| "dxcompiler.dll and dxil.dll are on PATH. Install the Windows SDK " | ||
| "redistributable components, set -DOCIO_DXCOMPILER_DLL=<path> to supply " | ||
| "a specific dxcompiler.dll, or set -DOCIO_DIRECTX_ENABLED=OFF to " | ||
| "disable the DirectX 12 backend." | ||
| ) | ||
| endif() |
This file contains hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.