Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced DX11 HLSL shading language with the more accurate SM_5_0 #2078

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remember exactly but didn't you mention the use of OCIO_DEPRECATED macro? Would it work here? Looking at the attribute [[depracated]] I think it should but not sure about the other fallback methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed my previous comment about this because I thought it might be needlessly disruptive.

If we did want it however, it would require modifications to the macro for MSVC: the fix for __cplusplus in Aras P's other PR, and the deletion of __declspec(deprecated(msg)) which doesn't work with enums.

};

/// 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";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remember... so let me know if any precautions are needed here as this change would cause cache id invalidation.

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
Loading