From 924a099cd828a635399e69f20da3c8cccaf6da61 Mon Sep 17 00:00:00 2001 From: Eric Renaud-Houde Date: Thu, 10 Oct 2024 15:33:21 -0400 Subject: [PATCH] Replaced DX11 HLSL shading language with the more accurate shading model 5.0 (SM_5_0). Signed-off-by: Eric Renaud-Houde --- CMakeLists.txt | 2 +- include/OpenColorIO/OpenColorTypes.h | 7 ++++-- src/OpenColorIO/GpuShaderClassWrapper.cpp | 2 +- src/OpenColorIO/GpuShaderUtils.cpp | 30 +++++++++++------------ src/OpenColorIO/ParseUtils.cpp | 4 +-- src/libutils/oglapphelpers/glsl.cpp | 2 +- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eaec4bef9..9b20aa0430 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ endif() # Project definition. project(OpenColorIO - VERSION 2.4.0 + VERSION 2.5.0 DESCRIPTION "OpenColorIO (OCIO) is a complete color management solution" HOMEPAGE_URL https://github.com/AcademySoftwareFoundation/OpenColorIO LANGUAGES CXX C) diff --git a/include/OpenColorIO/OpenColorTypes.h b/include/OpenColorIO/OpenColorTypes.h index 33e02d6d18..21243eb363 100644 --- a/include/OpenColorIO/OpenColorTypes.h +++ b/include/OpenColorIO/OpenColorTypes.h @@ -449,11 +449,14 @@ enum GpuLanguage GPU_LANGUAGE_GLSL_1_2, ///< OpenGL Shading Language GPU_LANGUAGE_GLSL_1_3, ///< OpenGL Shading Language GPU_LANGUAGE_GLSL_4_0, ///< OpenGL Shading Language - GPU_LANGUAGE_HLSL_DX11, ///< DirectX Shading Language + GPU_LANGUAGE_HLSL_SM_5_0, ///< DirectX High Level Shading Language LANGUAGE_OSL_1, ///< Open Shading Language GPU_LANGUAGE_GLSL_ES_1_0, ///< OpenGL ES Shading Language GPU_LANGUAGE_GLSL_ES_3_0, ///< OpenGL ES Shading Language - GPU_LANGUAGE_MSL_2_0 ///< Metal Shading Language + GPU_LANGUAGE_MSL_2_0, ///< Metal Shading Language + + // Deprecated enum(s) + GPU_LANGUAGE_HLSL_DX11 = GPU_LANGUAGE_HLSL_SM_5_0 }; /// Controls which environment variables are loaded into a Context object. diff --git a/src/OpenColorIO/GpuShaderClassWrapper.cpp b/src/OpenColorIO/GpuShaderClassWrapper.cpp index 35dce54add..e0c075a11d 100644 --- a/src/OpenColorIO/GpuShaderClassWrapper.cpp +++ b/src/OpenColorIO/GpuShaderClassWrapper.cpp @@ -31,7 +31,7 @@ std::unique_ptr GpuShaderClassWrapper::CreateClassWrapper case GPU_LANGUAGE_GLSL_1_2: case GPU_LANGUAGE_GLSL_1_3: case GPU_LANGUAGE_GLSL_4_0: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: case GPU_LANGUAGE_GLSL_ES_1_0: case GPU_LANGUAGE_GLSL_ES_3_0: default: diff --git a/src/OpenColorIO/GpuShaderUtils.cpp b/src/OpenColorIO/GpuShaderUtils.cpp index d439c9f859..03f90c579f 100644 --- a/src/OpenColorIO/GpuShaderUtils.cpp +++ b/src/OpenColorIO/GpuShaderUtils.cpp @@ -56,7 +56,7 @@ std::string getVecKeyword(GpuLanguage lang) } case GPU_LANGUAGE_MSL_2_0: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << "float" << N; break; @@ -98,7 +98,7 @@ void getTexDecl(GpuLanguage lang, samplerDecl = kw.str(); break; } - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { std::ostringstream t; t << "Texture" << N << "D " << textureName << ";"; @@ -166,7 +166,7 @@ std::string getTexSample(GpuLanguage lang, kw << "tex" << N << "D(" << samplerName << ", " << coords << ")"; break; } - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << textureName << ".Sample(" << samplerName << ", " << coords << ")"; break; @@ -345,7 +345,7 @@ std::string GpuShaderText::constKeyword() const str += " "; break; } - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { str += "static const"; str += " "; @@ -537,7 +537,7 @@ void GpuShaderText::declareFloatArrayConst(const std::string & name, int size, c } case LANGUAGE_OSL_1: case GPU_LANGUAGE_CG: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: case GPU_LANGUAGE_MSL_2_0: { nl << floatKeywordConst() << " " << name << "[" << size << "] = {"; @@ -589,7 +589,7 @@ void GpuShaderText::declareIntArrayConst(const std::string & name, int size, con nl << ");"; break; } - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: case GPU_LANGUAGE_MSL_2_0: { nl << intKeywordConst() << " " << name << "[" << size << "] = {"; @@ -940,7 +940,7 @@ std::string matrix3Mul(const T * m3x3, const std::string & vecName, GpuLanguage << getMatrixValues(m3x3, lang, false) << "), " << vecName << ")"; break; } - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << "mul(" << vecName << ", float3x3(" << getMatrixValues(m3x3, lang, true) << "))"; @@ -1006,7 +1006,7 @@ std::string matrix4Mul(const T * m4x4, const std::string & vecName, GpuLanguage << getMatrixValues(m4x4, lang, false) << "), " << vecName << ")"; break; } - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << "mul(" << vecName << ", float4x4(" << getMatrixValues(m4x4, lang, true) << "))"; @@ -1062,7 +1062,7 @@ std::string GpuShaderText::lerp(const std::string & x, break; } case GPU_LANGUAGE_CG: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << "lerp(" << x << ", " << y << ", " << a << ")"; break; @@ -1094,7 +1094,7 @@ std::string GpuShaderText::float3GreaterThan(const std::string & a, } case LANGUAGE_OSL_1: case GPU_LANGUAGE_MSL_2_0: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << float3Keyword() << "(" << "(" << a << "[0] > " << b << "[0]) ? 1.0 : 0.0, " @@ -1128,7 +1128,7 @@ std::string GpuShaderText::float4GreaterThan(const std::string & a, break; } case GPU_LANGUAGE_MSL_2_0: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << float4Keyword() << "(" << "(" << a << "[0] > " << b << "[0]) ? 1.0 : 0.0, " @@ -1173,7 +1173,7 @@ std::string GpuShaderText::float3GreaterThanEqual(const std::string& a, } case LANGUAGE_OSL_1: case GPU_LANGUAGE_MSL_2_0: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << float3Keyword() << "(" << "(" << a << "[0] >= " << b << "[0]) ? 1.0 : 0.0, " @@ -1207,7 +1207,7 @@ std::string GpuShaderText::float4GreaterThanEqual(const std::string& a, break; } case GPU_LANGUAGE_MSL_2_0: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { kw << float4Keyword() << "(" << "(" << a << "[0] >= " << b << "[0]) ? 1.0 : 0.0, " @@ -1251,7 +1251,7 @@ std::string GpuShaderText::atan2(const std::string & y, kw << "atan(" << y << ", " << x << ")"; break; } - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: { // note: Various internet sources claim that the x & y arguments need to be // swapped for HLSL (relative to GLSL). However, recent testing on Windows @@ -1285,7 +1285,7 @@ std::string GpuShaderText::sign(const std::string & v) const case GPU_LANGUAGE_GLSL_4_0: case GPU_LANGUAGE_GLSL_ES_1_0: case GPU_LANGUAGE_GLSL_ES_3_0: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: case GPU_LANGUAGE_MSL_2_0: { kw << "sign(" << v << ");"; diff --git a/src/OpenColorIO/ParseUtils.cpp b/src/OpenColorIO/ParseUtils.cpp index 9ec635bebb..b770afed0e 100644 --- a/src/OpenColorIO/ParseUtils.cpp +++ b/src/OpenColorIO/ParseUtils.cpp @@ -265,7 +265,7 @@ const char * GpuLanguageToString(GpuLanguage language) case GPU_LANGUAGE_GLSL_4_0: return "glsl_4.0"; case GPU_LANGUAGE_GLSL_ES_1_0: return "glsl_es_1.0"; case GPU_LANGUAGE_GLSL_ES_3_0: return "glsl_es_3.0"; - case GPU_LANGUAGE_HLSL_DX11: return "hlsl_dx11"; + case GPU_LANGUAGE_HLSL_SM_5_0: return "hlsl_sm_5.0"; case GPU_LANGUAGE_MSL_2_0: return "msl_2"; case LANGUAGE_OSL_1: return "osl_1"; } @@ -284,7 +284,7 @@ GpuLanguage GpuLanguageFromString(const char * s) else if(str == "glsl_4.0") return GPU_LANGUAGE_GLSL_4_0; else if(str == "glsl_es_1.0") return GPU_LANGUAGE_GLSL_ES_1_0; else if(str == "glsl_es_3.0") return GPU_LANGUAGE_GLSL_ES_3_0; - else if(str == "hlsl_dx11") return GPU_LANGUAGE_HLSL_DX11; + else if(str == "hlsl_sm_5.0") return GPU_LANGUAGE_HLSL_SM_5_0; else if(str == "osl_1") return LANGUAGE_OSL_1; else if(str == "msl_2") return GPU_LANGUAGE_MSL_2_0; diff --git a/src/libutils/oglapphelpers/glsl.cpp b/src/libutils/oglapphelpers/glsl.cpp index 16709fa3e7..0154effa35 100644 --- a/src/libutils/oglapphelpers/glsl.cpp +++ b/src/libutils/oglapphelpers/glsl.cpp @@ -468,7 +468,7 @@ std::string OpenGLBuilder::getGLSLVersionString() case GPU_LANGUAGE_GLSL_ES_3_0: return "#version 300 es"; case GPU_LANGUAGE_CG: - case GPU_LANGUAGE_HLSL_DX11: + case GPU_LANGUAGE_HLSL_SM_5_0: case LANGUAGE_OSL_1: default: // These are all impossible in OpenGL contexts.