Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ message(STATUS "")
message(STATUS "Checking for GPU configuration...")
include(CheckSupportGL)

# DirectX 12 is only available on Windows.
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.

Not from this PR but maybe we should use this opportunity to also add the same option for OCIO_VULKAN_ENABLED.

if(WIN32)
option(OCIO_DIRECTX_ENABLED "Enable DirectX 12 GPU rendering support" ON)
else()
set(OCIO_DIRECTX_ENABLED OFF CACHE BOOL "Enable DirectX 12 GPU rendering support" FORCE)
endif()
mark_as_advanced(OCIO_DIRECTX_ENABLED)

# Vulkan is cross-platform but requires an external SDK, so it is off by
# default; enable explicitly with -DOCIO_VULKAN_ENABLED=ON.
option(OCIO_VULKAN_ENABLED "Enable Vulkan GPU rendering support" OFF)
mark_as_advanced(OCIO_VULKAN_ENABLED)


###############################################################################
# Check for ARM neon here because we need to know if ARM NEON is supported
Expand Down
2 changes: 2 additions & 0 deletions docs/quick_start/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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)

Expand Down
76 changes: 76 additions & 0 deletions share/cmake/modules/FindDirectX-Headers.cmake
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()
27 changes: 27 additions & 0 deletions share/cmake/modules/install/InstallDirectX-Headers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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)

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
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.

Not a blocker I think but may be nice to offer a way to specify a path manually for Windows systems without internet access (unless you already did and I missed it in the PR).

GIT_TAG v1.619.1
)

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)
set(DirectX-Headers_VERSION "1.619.1")
endif()
78 changes: 78 additions & 0 deletions share/cmake/utils/LocateDXCompilerRuntime.cmake
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()
12 changes: 6 additions & 6 deletions src/apps/ociochecklut/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ class ProcessorWrapper
m_gpu = gpu;
if (!m_oglApp)
{
m_oglApp = OCIO::OglApp::CreateOglApp("ociochecklut", 256, 20);
m_oglApp = OCIO::GraphicalApp::CreateApp("ociochecklut", 256, 20);

if (m_verbose)
{
m_oglApp->printGLInfo();
m_oglApp->printGraphicsInfo();
}
}

m_oglApp->setPrintShader(m_verbose);
m_oglApp->setShaderVerbose(m_verbose);
float image[4]{ 0.f, 0.f, 0.f, 0.f };
m_oglApp->initImage(1, 1, OCIO::OglApp::COMPONENTS_RGBA, image);
m_oglApp->createGLBuffers();
m_oglApp->initImage(1, 1, OCIO::GraphicalApp::COMPONENTS_RGBA, image);
m_oglApp->createBuffers();
OCIO::GpuShaderDescRcPtr shaderDesc = OCIO::GpuShaderDesc::CreateShaderDesc();
shaderDesc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_2);
m_gpu->extractGpuShaderInfo(shaderDesc);
Expand Down Expand Up @@ -98,7 +98,7 @@ class ProcessorWrapper
m_oglApp->redisplay();
m_oglApp->readImage(pixel.data());
}
OCIO::OglAppRcPtr m_oglApp;
OCIO::GraphicalAppRcPtr m_oglApp;
#else
void applyGPU(std::vector<float> &)
{
Expand Down
16 changes: 8 additions & 8 deletions src/apps/ocioconvert/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,18 @@ int main(int argc, const char **argv)

#ifdef OCIO_GPU_ENABLED
// Initialize GPU.
OCIO::OglAppRcPtr oglApp;
OCIO::GraphicalAppRcPtr oglApp;

if (usegpu || usegpuLegacy)
{
OCIO::OglApp::Components comp = OCIO::OglApp::COMPONENTS_RGBA;
OCIO::GraphicalApp::Components comp = OCIO::GraphicalApp::COMPONENTS_RGBA;
if (imgInput.getNumChannels() == 4)
{
comp = OCIO::OglApp::COMPONENTS_RGBA;
comp = OCIO::GraphicalApp::COMPONENTS_RGBA;
}
else if (imgInput.getNumChannels() == 3)
{
comp = OCIO::OglApp::COMPONENTS_RGB;
comp = OCIO::GraphicalApp::COMPONENTS_RGB;
}
else
{
Expand All @@ -383,7 +383,7 @@ int main(int argc, const char **argv)

try
{
oglApp = OCIO::OglApp::CreateOglApp("ocioconvert", 256, 20);
oglApp = OCIO::GraphicalApp::CreateApp("ocioconvert", 256, 20);
}
catch (const OCIO::Exception & e)
{
Expand All @@ -393,14 +393,14 @@ int main(int argc, const char **argv)

if (verbose)
{
oglApp->printGLInfo();
oglApp->printGraphicsInfo();
}

oglApp->setPrintShader(outputgpuInfo);
oglApp->setShaderVerbose(outputgpuInfo);

oglApp->initImage(imgInput.getWidth(), imgInput.getHeight(), comp, (float *)imgInput.getData());

oglApp->createGLBuffers();
oglApp->createBuffers();
}
#endif // OCIO_GPU_ENABLED

Expand Down
14 changes: 7 additions & 7 deletions src/apps/ociodisplay/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ float g_display_gamma{1.0f};
int g_channelHot[4]{1, 1, 1, 1}; // show rgb
int g_viewsMenuID;

OCIO::OglAppRcPtr g_oglApp;
OCIO::GraphicalAppRcPtr g_oglApp;

void UpdateOCIOGLState();

Expand Down Expand Up @@ -115,14 +115,14 @@ static void InitImageTexture(const char * filename)
}
}

OCIO::OglApp::Components comp = OCIO::OglApp::COMPONENTS_RGBA;
OCIO::GraphicalApp::Components comp = OCIO::GraphicalApp::COMPONENTS_RGBA;
if (img.getNumChannels() == 4)
{
comp = OCIO::OglApp::COMPONENTS_RGBA;
comp = OCIO::GraphicalApp::COMPONENTS_RGBA;
}
else if (img.getNumChannels() == 3)
{
comp = OCIO::OglApp::COMPONENTS_RGB;
comp = OCIO::GraphicalApp::COMPONENTS_RGB;
}
else
{
Expand Down Expand Up @@ -658,7 +658,7 @@ int main(int argc, char **argv)
else
#endif
{
g_oglApp = std::make_shared<OCIO::ScreenApp>("ociodisplay", 512, 512);
g_oglApp = std::make_shared<OCIO::ScreenOglApp>("ociodisplay", 512, 512);
}
}
catch (const OCIO::Exception &e)
Expand All @@ -669,11 +669,11 @@ int main(int argc, char **argv)

if (g_verbose)
{
g_oglApp->printGLInfo();
g_oglApp->printGraphicsInfo();
}

g_oglApp->setYMirror();
g_oglApp->setPrintShader(g_gpuinfo);
g_oglApp->setShaderVerbose(g_gpuinfo);

glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
Expand Down
Loading
Loading