From f207c81aa2e4b82eddd08fb27e39e5104b325a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Mon, 24 Aug 2020 16:11:50 +0100 Subject: [PATCH 1/9] Remove duplicated -t flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/apps/ociochecklut/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/apps/ociochecklut/main.cpp b/src/apps/ociochecklut/main.cpp index 9175c240e9..5b5be81438 100644 --- a/src/apps/ociochecklut/main.cpp +++ b/src/apps/ociochecklut/main.cpp @@ -197,7 +197,6 @@ int main (int argc, const char* argv[]) "-t", &test, "Test a set a predefined RGB values", "-v", &verbose, "Verbose", "--help", &help, "Print help message", - "-t", &test, "Test a set a predefined RGB values\n", "--gpu", &usegpu, "Use GPU instead of CPU\n", "--gpulegacy", &usegpuLegacy, "Use the legacy (i.e. baked) GPU color processing " "instead of the CPU one (--gpu is ignored)", From 172992060857b22ae04c556bf52bc1fe1237af7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Mon, 24 Aug 2020 16:12:13 +0100 Subject: [PATCH 2/9] Remove extra carriage return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/apps/ociochecklut/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/ociochecklut/main.cpp b/src/apps/ociochecklut/main.cpp index 5b5be81438..a9acaea1b7 100644 --- a/src/apps/ociochecklut/main.cpp +++ b/src/apps/ociochecklut/main.cpp @@ -197,7 +197,7 @@ int main (int argc, const char* argv[]) "-t", &test, "Test a set a predefined RGB values", "-v", &verbose, "Verbose", "--help", &help, "Print help message", - "--gpu", &usegpu, "Use GPU instead of CPU\n", + "--gpu", &usegpu, "Use GPU instead of CPU", "--gpulegacy", &usegpuLegacy, "Use the legacy (i.e. baked) GPU color processing " "instead of the CPU one (--gpu is ignored)", "--gpuinfo", &outputgpuInfo, "Output the OCIO shader program", From 03d449538a96c4bb9798c555a0b53cf859d5307a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Mon, 24 Aug 2020 16:13:16 +0100 Subject: [PATCH 3/9] Add LUT inverse direction flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/apps/ociochecklut/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/apps/ociochecklut/main.cpp b/src/apps/ociochecklut/main.cpp index a9acaea1b7..882f2aea12 100644 --- a/src/apps/ociochecklut/main.cpp +++ b/src/apps/ociochecklut/main.cpp @@ -185,6 +185,7 @@ int main (int argc, const char* argv[]) bool verbose = false; bool help = false; bool test = false; + bool invlut = false; bool usegpu = false; bool usegpuLegacy = false; bool outputgpuInfo = false; @@ -197,6 +198,7 @@ int main (int argc, const char* argv[]) "-t", &test, "Test a set a predefined RGB values", "-v", &verbose, "Verbose", "--help", &help, "Print help message", + "--inv", &invlut, "Apply LUT in inverse direction", "--gpu", &usegpu, "Use GPU instead of CPU", "--gpulegacy", &usegpuLegacy, "Use the legacy (i.e. baked) GPU color processing " "instead of the CPU one (--gpu is ignored)", @@ -256,6 +258,7 @@ int main (int argc, const char* argv[]) OCIO::FileTransformRcPtr t = OCIO::FileTransform::Create(); t->setSrc(inputfile.c_str()); t->setInterpolation(OCIO::INTERP_BEST); + t->setDirection(invlut ? OCIO::TRANSFORM_DIR_INVERSE : OCIO::TRANSFORM_DIR_FORWARD); ProcessorWrapper proc(outputgpuInfo); try From c329bb75e684d3d93ef5dafc3398ecaf3b6371a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Mon, 24 Aug 2020 20:44:50 +0100 Subject: [PATCH 4/9] Fix ociochecklut --gpu not working correctly for LUT1D MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In OglApp::applyGPU, call to updateImage() update the currently bound GL_TEXTURE_2D target, by doing so, the latter sampling of a 1DLUT that was allocated as a GL_TEXTURE_2D (because of it's size), will sample the wrong texture. Solution proposed is to call OglApp::setShader() again after image was updated. Signed-off-by: Rémi Achard --- src/apps/ociochecklut/main.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/apps/ociochecklut/main.cpp b/src/apps/ociochecklut/main.cpp index 882f2aea12..5add05d328 100644 --- a/src/apps/ociochecklut/main.cpp +++ b/src/apps/ociochecklut/main.cpp @@ -56,18 +56,17 @@ class ProcessorWrapper float image[4]{ 0.f, 0.f, 0.f, 0.f }; m_oglApp->initImage(1, 1, OCIO::OglApp::COMPONENTS_RGBA, image); m_oglApp->createGLBuffers(); - OCIO::GpuShaderDescRcPtr shaderDesc; if (legacyGpu) { - shaderDesc = OCIO::GpuShaderDesc::CreateLegacyShaderDesc(32); + m_shaderDesc = OCIO::GpuShaderDesc::CreateLegacyShaderDesc(32); } else { - shaderDesc = OCIO::GpuShaderDesc::CreateShaderDesc(); + m_shaderDesc = OCIO::GpuShaderDesc::CreateShaderDesc(); } - shaderDesc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_3); - m_gpu->extractGpuShaderInfo(shaderDesc); - m_oglApp->setShader(shaderDesc); + m_shaderDesc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_3); + m_gpu->extractGpuShaderInfo(m_shaderDesc); + m_oglApp->setShader(m_shaderDesc); #endif // OCIO_GPU_ENABLED } @@ -89,6 +88,7 @@ class ProcessorWrapper { #ifdef OCIO_GPU_ENABLED m_oglApp->updateImage(pixel.data()); + m_oglApp->setShader(m_shaderDesc); m_oglApp->reshape(1, 1); m_oglApp->redisplay(); m_oglApp->readImage(pixel.data()); @@ -97,6 +97,7 @@ class ProcessorWrapper #ifdef OCIO_GPU_ENABLED OCIO::OglAppRcPtr m_oglApp; + OCIO::GpuShaderDescRcPtr m_shaderDesc; #endif // OCIO_GPU_ENABLED OCIO::ConstCPUProcessorRcPtr m_cpu; From b97ce1d7544fce8e6e239164de5b2ed8ff0457cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Mon, 24 Aug 2020 20:45:27 +0100 Subject: [PATCH 5/9] Fixing pkgconfig file installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/OpenColorIO/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index babc5b213e..28ff0f6122 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -157,7 +157,7 @@ if(NOT WIN32) set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") configure_file(res/OpenColorIO.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${libdir}/pkgconfig) endif() # TODO: Install the OpenColorIO-config.cmake. From 88da49dea975e974e1fc14927fb909045655b0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Tue, 25 Aug 2020 07:49:34 +0100 Subject: [PATCH 6/9] Fix resources binding directly from inside drawing method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/apps/ociochecklut/main.cpp | 13 ++++++------- src/libutils/oglapphelpers/oglapp.cpp | 5 +++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/apps/ociochecklut/main.cpp b/src/apps/ociochecklut/main.cpp index 5add05d328..882f2aea12 100644 --- a/src/apps/ociochecklut/main.cpp +++ b/src/apps/ociochecklut/main.cpp @@ -56,17 +56,18 @@ class ProcessorWrapper float image[4]{ 0.f, 0.f, 0.f, 0.f }; m_oglApp->initImage(1, 1, OCIO::OglApp::COMPONENTS_RGBA, image); m_oglApp->createGLBuffers(); + OCIO::GpuShaderDescRcPtr shaderDesc; if (legacyGpu) { - m_shaderDesc = OCIO::GpuShaderDesc::CreateLegacyShaderDesc(32); + shaderDesc = OCIO::GpuShaderDesc::CreateLegacyShaderDesc(32); } else { - m_shaderDesc = OCIO::GpuShaderDesc::CreateShaderDesc(); + shaderDesc = OCIO::GpuShaderDesc::CreateShaderDesc(); } - m_shaderDesc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_3); - m_gpu->extractGpuShaderInfo(m_shaderDesc); - m_oglApp->setShader(m_shaderDesc); + shaderDesc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_3); + m_gpu->extractGpuShaderInfo(shaderDesc); + m_oglApp->setShader(shaderDesc); #endif // OCIO_GPU_ENABLED } @@ -88,7 +89,6 @@ class ProcessorWrapper { #ifdef OCIO_GPU_ENABLED m_oglApp->updateImage(pixel.data()); - m_oglApp->setShader(m_shaderDesc); m_oglApp->reshape(1, 1); m_oglApp->redisplay(); m_oglApp->readImage(pixel.data()); @@ -97,7 +97,6 @@ class ProcessorWrapper #ifdef OCIO_GPU_ENABLED OCIO::OglAppRcPtr m_oglApp; - OCIO::GpuShaderDescRcPtr m_shaderDesc; #endif // OCIO_GPU_ENABLED OCIO::ConstCPUProcessorRcPtr m_cpu; diff --git a/src/libutils/oglapphelpers/oglapp.cpp b/src/libutils/oglapphelpers/oglapp.cpp index 644606d01e..7b39710361 100644 --- a/src/libutils/oglapphelpers/oglapp.cpp +++ b/src/libutils/oglapphelpers/oglapp.cpp @@ -111,6 +111,11 @@ void OglApp::redisplay() std::swap(pts[1], pts[3]); } + // Bind OpenGL resources before drawing + + m_oglBuilder->useAllTextures(); + m_oglBuilder->useAllUniforms(); + glEnable(GL_TEXTURE_2D); glClearColor(0.2f, 0.2f, 0.2f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); From 3fc9deb87934e04a10831871175cdd2367e47756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Tue, 25 Aug 2020 07:50:11 +0100 Subject: [PATCH 7/9] Fix pkgconfig installation on non-windows platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/OpenColorIO/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index 28ff0f6122..fe73763698 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -152,10 +152,12 @@ if(NOT WIN32) # Install the pkg-config file. + include(GNUInstallDirs) + set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix "\${prefix}") - set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") - set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + set(exec_prefix "${prefix}") + set(libdir "${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") + set(includedir "${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR}") configure_file(res/OpenColorIO.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${libdir}/pkgconfig) endif() From 2a3aa1a7c2aad24235fd8584e14f8e4f29b94a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Wed, 26 Aug 2020 07:51:50 +0100 Subject: [PATCH 8/9] Fix pkgconfig generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/OpenColorIO/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index fe73763698..7343b919cc 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -155,11 +155,11 @@ if(NOT WIN32) include(GNUInstallDirs) set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix "${prefix}") - set(libdir "${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") - set(includedir "${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + set(exec_prefix "\${prefix}") + set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") + set(includedir "\${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR}") configure_file(res/OpenColorIO.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${libdir}/pkgconfig) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() # TODO: Install the OpenColorIO-config.cmake. From 5b99448b0b129f5226c82a7ace61e3cbe7b62731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Wed, 26 Aug 2020 19:05:13 +0100 Subject: [PATCH 9/9] Activate correct texture unit before uploading image (by @hodoulp) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard --- src/libutils/oglapphelpers/oglapp.cpp | 21 ++++++++------------- src/libutils/oglapphelpers/oglapp.h | 3 --- tests/gpu/GPUUnitTest.cpp | 2 -- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/libutils/oglapphelpers/oglapp.cpp b/src/libutils/oglapphelpers/oglapp.cpp index 7b39710361..4b0888cfb7 100644 --- a/src/libutils/oglapphelpers/oglapp.cpp +++ b/src/libutils/oglapphelpers/oglapp.cpp @@ -67,8 +67,10 @@ void OglApp::initImage(int imgWidth, int imgHeight, Components comp, const float void OglApp::updateImage(const float * image) { - const GLenum format = m_components == COMPONENTS_RGB ? GL_RGB : GL_RGBA; + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_imageTexID); + + const GLenum format = m_components == COMPONENTS_RGB ? GL_RGB : GL_RGBA; glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, m_imageWidth, m_imageHeight, 0, format, GL_FLOAT, &image[0]); } @@ -111,10 +113,11 @@ void OglApp::redisplay() std::swap(pts[1], pts[3]); } - // Bind OpenGL resources before drawing - - m_oglBuilder->useAllTextures(); - m_oglBuilder->useAllUniforms(); + // Update the uniform values in case one changed. + if (m_oglBuilder) + { + m_oglBuilder->useAllUniforms(); + } glEnable(GL_TEXTURE_2D); glClearColor(0.2f, 0.2f, 0.2f, 0.0f); @@ -219,14 +222,6 @@ void OglApp::setShader(GpuShaderDescRcPtr & shaderDesc) m_oglBuilder->useAllUniforms(); } -void OglApp::updateUniforms() -{ - if (m_oglBuilder) - { - m_oglBuilder->useAllUniforms(); - } -} - void OglApp::printGLInfo() const noexcept { std::cout << std::endl diff --git a/src/libutils/oglapphelpers/oglapp.h b/src/libutils/oglapphelpers/oglapp.h index ef1ba96d15..2919fd82cf 100644 --- a/src/libutils/oglapphelpers/oglapp.h +++ b/src/libutils/oglapphelpers/oglapp.h @@ -103,9 +103,6 @@ class OglApp // application it should be called by the glutReshapeFunc callback using the windows size. void reshape(int width, int height); - // To be called after changing dynamic properties and before calling redisplay. - void updateUniforms(); - // Process the image. void virtual redisplay(); diff --git a/tests/gpu/GPUUnitTest.cpp b/tests/gpu/GPUUnitTest.cpp index ca0b587346..155af81985 100644 --- a/tests/gpu/GPUUnitTest.cpp +++ b/tests/gpu/GPUUnitTest.cpp @@ -571,8 +571,6 @@ int main(int, char **) { // Call the retest callback. test->retestSetup(idx - 1); - // Update uniforms with dynamic properties. - app->updateUniforms(); } // Process the image texture into the rendering buffer.