Skip to content

Commit

Permalink
Replaced DX11 HLSL shading language with the more accurate shading mo…
Browse files Browse the repository at this point in the history
…del 5.0 (SM_5_0). (#2078)

Signed-off-by: Eric Renaud-Houde <eric.renaud.houde@gmail.com>
Co-authored-by: Doug Walker <doug.walker@autodesk.com>
  • Loading branch information
num3ric and doug-walker authored Dec 10, 2024
1 parent 4b87e85 commit 3132579
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
7 changes: 5 additions & 2 deletions include/OpenColorIO/OpenColorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/GpuShaderClassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ std::unique_ptr<GpuShaderClassWrapper> 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:
Expand Down
30 changes: 15 additions & 15 deletions src/OpenColorIO/GpuShaderUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 << ";";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 += " ";
Expand Down Expand Up @@ -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 << "] = {";
Expand Down Expand Up @@ -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 << "] = {";
Expand Down Expand Up @@ -940,7 +940,7 @@ std::string matrix3Mul(const T * m3x3, const std::string & vecName, GpuLanguage
<< getMatrixValues<T, 3>(m3x3, lang, false) << "), " << vecName << ")";
break;
}
case GPU_LANGUAGE_HLSL_DX11:
case GPU_LANGUAGE_HLSL_SM_5_0:
{
kw << "mul(" << vecName
<< ", float3x3(" << getMatrixValues<T, 3>(m3x3, lang, true) << "))";
Expand Down Expand Up @@ -1006,7 +1006,7 @@ std::string matrix4Mul(const T * m4x4, const std::string & vecName, GpuLanguage
<< getMatrixValues<T, 4>(m4x4, lang, false) << "), " << vecName << ")";
break;
}
case GPU_LANGUAGE_HLSL_DX11:
case GPU_LANGUAGE_HLSL_SM_5_0:
{
kw << "mul(" << vecName
<< ", float4x4(" << getMatrixValues<T, 4>(m4x4, lang, true) << "))";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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, "
Expand Down Expand Up @@ -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, "
Expand Down Expand Up @@ -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, "
Expand Down Expand Up @@ -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, "
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 << ");";
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ParseUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/libutils/oglapphelpers/glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3132579

Please sign in to comment.