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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ message(STATUS "")
message(STATUS "Checking for GPU configuration...")
include(CheckSupportGL)

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


###############################################################################
# Check for ARM neon here because we need to know if ARM NEON is supported
Expand Down
19 changes: 19 additions & 0 deletions share/cmake/modules/install/InstallDirectXHeaders.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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
GIT_TAG v1.619.1
)

FetchContent_MakeAvailable(DirectX-Headers)
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
131 changes: 92 additions & 39 deletions src/libutils/oglapphelpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

if(NOT OCIO_GL_ENABLED)
message(WARNING "GL component missing. Skipping oglapphelpers.")
if(NOT OCIO_GL_ENABLED AND NOT (WIN32 AND OCIO_DIRECTX_ENABLED))
message(WARNING "GL component missing and DirectX disabled. Skipping oglapphelpers.")
return()
endif()

set(SOURCES
glsl.cpp
oglapp.cpp
graphicalapp.cpp
)
set(INCLUDES
glsl.h
oglapp.h
graphicalapp.h
)

if(OCIO_GL_ENABLED)
list(APPEND SOURCES
glsl.cpp
oglapp.cpp
)
list(APPEND INCLUDES
glsl.h
oglapp.h
)
endif()

if(WIN32 AND OCIO_DIRECTX_ENABLED)
list(APPEND SOURCES
dxapp.cpp
hlsl.cpp
)
list(APPEND INCLUDES
dxapp.h
dxutils.h
hlsl.h
)
endif()

if(APPLE)

list(APPEND SOURCES
Expand All @@ -31,7 +52,7 @@ if(APPLE)

endif()

add_library(oglapphelpers STATIC ${SOURCES})
add_library(oglapphelpers STATIC ${INCLUDES} ${SOURCES})
set_target_properties(oglapphelpers PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(oglapphelpers PROPERTIES OUTPUT_NAME OpenColorIOoglapphelpers)

Expand All @@ -56,47 +77,55 @@ set_target_properties(oglapphelpers PROPERTIES
target_include_directories(oglapphelpers
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS}
${GLUT_INCLUDE_DIR}
)

if(OCIO_GL_ENABLED)
target_include_directories(oglapphelpers
PRIVATE
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS}
${GLUT_INCLUDE_DIR}
)
endif()

if(${OCIO_USE_GLVND})
if(${OCIO_EGL_HEADLESS})
target_include_directories(oglapphelpers
PRIVATE
${OPENGL_EGL_INCLUDE_DIRS}
)
target_link_libraries(oglapphelpers
PRIVATE
OpenColorIO
OpenGL::OpenGL
OpenGL::GLU
${GLEW_LIBRARIES}
${GLUT_LIBRARIES}
OpenGL::EGL
target_link_libraries(oglapphelpers
PRIVATE
OpenColorIO
)

if(OCIO_GL_ENABLED)
if(${OCIO_USE_GLVND})
if(${OCIO_EGL_HEADLESS})
target_include_directories(oglapphelpers
PRIVATE
${OPENGL_EGL_INCLUDE_DIRS}
)
target_link_libraries(oglapphelpers
PRIVATE
OpenGL::OpenGL
OpenGL::GLU
${GLEW_LIBRARIES}
${GLUT_LIBRARIES}
OpenGL::EGL
)
else()
target_link_libraries(oglapphelpers
PRIVATE
OpenGL::OpenGL
OpenGL::GLU
${GLEW_LIBRARIES}
${GLUT_LIBRARIES}
)
endif()
else()
# if OCIO_USE_GLVND is OFF, OCIO_EGL_HEADLESS is also OFF
target_link_libraries(oglapphelpers
PRIVATE
OpenColorIO
OpenGL::OpenGL
OpenGL::GLU
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${GLUT_LIBRARIES}
)
endif()
else()
# if OCIO_USE_GLVND is OFF, OCIO_EGL_HEADLESS is also OFF
target_link_libraries(oglapphelpers
PRIVATE
OpenColorIO
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${GLUT_LIBRARIES}
)
)
endif()
endif()

if(APPLE)
Expand All @@ -111,6 +140,30 @@ if(APPLE)
)
endif()

if(OCIO_GL_ENABLED)
target_compile_definitions(oglapphelpers
PUBLIC
OCIO_GL_ENABLED
)
endif()

if(WIN32 AND OCIO_DIRECTX_ENABLED)
include(InstallDirectXHeaders)
target_compile_definitions(oglapphelpers
PUBLIC
OCIO_DIRECTX_ENABLED
)
target_link_libraries(oglapphelpers
PUBLIC
Microsoft::DirectX-Headers
PRIVATE
d3d12
dxgi
dxcompiler
dxguid
)
endif()

if(${OCIO_EGL_HEADLESS})
target_include_directories(oglapphelpers
PRIVATE
Expand Down
Loading