Skip to content

Commit 86a2aac

Browse files
hodoulpMorteezaIngthor Hjalmarssonmichdolan
authored
Port from main to RB-2.1 - Adds Metal Support to ociodisplay and enables running GPU tests with Metal backend (#1538) (#1559)
* Adds Metal Support to ociodisplay and enables running GPU tests with Metal backend (#1538) * * Adds Metal Shading Language (MSL) Generation support Signed-off-by: Morteza Mostajabodaveh <[email protected]> Co-authored-by: Ingthor Hjalmarsson <[email protected]> Signed-off-by: Morteza Mostajab <[email protected]> * * Fixes warnings triggered due to unused variables. Signed-off-by: Morteza Mostajabodaveh <[email protected]> Signed-off-by: Morteza Mostajab <[email protected]> * * Fixes compilation error on Mac and Windows: - vector of const objects causing compiler errors on windows. - Wrong string was used for Metal language python binding. Signed-off-by: Morteza Mostajab <[email protected]> * * Removes class wrapping interface from OpenColorIO interface and move it to implementation * Adding more tests for metal code path * Proper generated Metal code indentation * Fixes a few coding style inconsistencies and unneeded include files Signed-off-by: Morteza Mostajab <[email protected]> * Remove the unneeded empty line to reset OpenColorIO.h to what it was before the metal change. Signed-off-by: Morteza Mostajab <[email protected]> * * switching from c-like getFunctionParameters function to c++-like one since it is not in the opencolorio interface anymore. Signed-off-by: Morteza Mostajab <[email protected]> * Missing include causing compiler errors on windows Signed-off-by: Morteza Mostajab <[email protected]> * * Fixes and improvements follow up to change that was trying to move metal related code in implementation, and hide them from OCIO interface. Signed-off-by: Morteza Mostajab <[email protected]> * - remove unused variables. Signed-off-by: Morteza Mostajab <[email protected]> * * Adds support for uniform parameters and proper handling of them in metal code. * Adds two new tests for uniforms and helper functions. Signed-off-by: Morteza Mostajab <[email protected]> * * making declaration parsing more C++-like. Functions like sscanf are problematic when it comes to multiple platform support and may not be safe Signed-off-by: Morteza Mostajab <[email protected]> * * Switching from clf/lut1d_half_domain_raw_half_set.clf to clf/lut1d_long.clf. Due to decimal number outputting difference between different platforms, some tests were failing. Signed-off-by: Morteza Mostajab <[email protected]> * * Moving Metal only functionalities to MetalClassWrappingInterface * remove unnecessary functions and data types * code clean up and quality improvement Signed-off-by: Morteza Mostajab <[email protected]> * * Adds support for uniforms that are array * Removing getTextureKeyword() and getTextureDeclaration() as they are not needed. * code clean up and quality improvement Signed-off-by: Morteza Mostajab <[email protected]> * Remove unnecessary changes to GpuShaderUtils_tests.cpp Signed-off-by: Morteza Mostajab <[email protected]> * * Removed unnecessary included files Signed-off-by: Morteza Mostajab <[email protected]> * Removing unnecessary include Signed-off-by: Morteza Mostajab <[email protected]> * * Apply style improvement suggestions Signed-off-by: Morteza Mostajab <[email protected]> * * changed from msl_metal to msl_2 so it matches with `GpuLanguageFromString` function. Signed-off-by: Morteza Mostajab <[email protected]> * Move MetalShaderClassWrappingInterface to a separate file and generalise it Signed-off-by: Morteza Mostajab <[email protected]> * header files inlcudes clean up Signed-off-by: Morteza Mostajab <[email protected]> * Still the else path is needed in case we set language from MSL2 to something else. Signed-off-by: Morteza Mostajab <[email protected]> * [minor] Showing the GpuShaderClassWrapper.h also in the vc15 aftereffect project. Signed-off-by: Morteza Mostajab <[email protected]> * Run ClassWrapper function for all backends. It only produces code in metal shading language code generation case. operator= for GpuShaderClassWrapper Signed-off-by: Morteza Mostajab <[email protected]> * use factory pattern instead of updateClassWrappingInterface Signed-off-by: Morteza Mostajab <[email protected]> * Replace assignment operator with clone function that is more explicit. Signed-off-by: Morteza Mostajab <[email protected]> * use Assignment operator instead of setting members in clone member function Signed-off-by: Morteza Mostajab <[email protected]> * add include guards. Signed-off-by: Morteza Mostajab <[email protected]> * make output of MetalShaderClassWrapper::operator= non-const Signed-off-by: Morteza Mostajab <[email protected]> * Update default branch name (#1532) Signed-off-by: Michael Dolan <[email protected]> Co-authored-by: Patrick Hodoul <[email protected]> Signed-off-by: Morteza Mostajab <[email protected]> * Adsk Contrib - Default to C++14 and remove OIIO from ocioperf (#1516) * Adsk Contrib - Default to C++14 and remove OIIO from ocioperf Signed-off-by: Patrick Hodoul <[email protected]> * Fix cmake breaks Signed-off-by: Patrick Hodoul <[email protected]> * Fix bit-depths Signed-off-by: Patrick Hodoul <[email protected]> * Fix Linux build break Signed-off-by: Patrick Hodoul <[email protected]> * Improve the image generation Signed-off-by: Patrick Hodoul <[email protected]> * Improve the image generation Signed-off-by: Patrick Hodoul <[email protected]> Signed-off-by: Morteza Mostajab <[email protected]> * Add metal rendering support to ociodisplay Signed-off-by: Morteza Mostajab <[email protected]> * Adds support for metal only input texture Signed-off-by: Morteza Mostajab <[email protected]> * Returning correct value for maximum texture width Signed-off-by: Morteza Mostajab <[email protected]> * Add GPU rendering tests for metal renderer Fixes incorrect shader generation code for arrays in uniform buffer Adds support for vector comparison in Metal Signed-off-by: Morteza Mostajab <[email protected]> * Fixes failing test_cpu_exec test Fixes compilation error on Linux, older clang compiler Makes the app working on x64 Macs Signed-off-by: Morteza Mostajab <[email protected]> * Add support for test that apply color correction multiple times with different setups replaces asserts with exception Disables fast math to get more accurate results Signed-off-by: Morteza Mostajab <[email protected]> * Matching the uniform buffer size elements for array of ints and float to fix two gpu tests Signed-off-by: Morteza Mostajab <[email protected]> * enables -gpuinfo to print shader Signed-off-by: Morteza Mostajab <[email protected]> * Revert "Matching the uniform buffer size elements for array of ints and float to fix two gpu tests" This reverts commit c1695e2. Signed-off-by: Morteza Mostajab <[email protected]> * Enables uniform data binding for metal without touching OCIO interface Signed-off-by: Morteza Mostajab <[email protected]> * set dummy buffers for the vectors that are empty. Signed-off-by: Morteza Mostajab <[email protected]> * Update metal test to reflect latest changes in metal shader generator Signed-off-by: Morteza Mostajab <[email protected]> * Improving coding style Adds metal gpu unit tests to the one executing Signed-off-by: Morteza Mostajab <[email protected]> * Updating the test so it reflects latest code changes. Signed-off-by: Morteza Mostajab <[email protected]> * sets the opengl state even when no valid ocio config is loaded. Signed-off-by: Morteza Mostajab <[email protected]> * Handles metal resources lifecycles correctly. Fixes the crash on transform change. Signed-off-by: Morteza Mostajab <[email protected]> * Applying improvements to code and minor fixes Signed-off-by: Morteza Mostajab <[email protected]> * Disable testing NaN and Infinity on Apple Silicon that causes test failures and precision errors Signed-off-by: Morteza Mostajab <[email protected]> * make the condition for disabling NaN and INFs more accurate. Signed-off-by: Morteza Mostajab <[email protected]> * Improving code quality Fixing possible texture mem leaks Signed-off-by: Morteza Mostajab <[email protected]> Co-authored-by: Ingthor Hjalmarsson <[email protected]> Co-authored-by: Patrick Hodoul <[email protected]> Co-authored-by: Michael Dolan <[email protected]> Signed-off-by: Patrick Hodoul <[email protected]> * Fix Linux warning Signed-off-by: Patrick Hodoul <[email protected]> Co-authored-by: Morteza Mostajab <[email protected]> Co-authored-by: Ingthor Hjalmarsson <[email protected]> Co-authored-by: Michael Dolan <[email protected]>
1 parent ffba80b commit 86a2aac

File tree

21 files changed

+1695
-55
lines changed

21 files changed

+1695
-55
lines changed

src/OpenColorIO/GpuShaderClassWrapper.cpp

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
namespace OCIO_NAMESPACE
99
{
1010

11+
std::string GetArrayLengthVariableName(const std::string& variableName)
12+
{
13+
return variableName + "_count";
14+
}
15+
1116
std::string MetalShaderClassWrapper::generateClassWrapperHeader(GpuShaderText& kw) const
1217
{
1318
if(m_className.empty())
@@ -27,7 +32,11 @@ std::string MetalShaderClassWrapper::generateClassWrapperHeader(GpuShaderText& k
2732
std::string separator = "";
2833
for(const auto& param : m_functionParameters)
2934
{
30-
kw.newLine() << separator << param.type << " " << param.name;
35+
kw.newLine() << separator << (param.m_isArray ? "constant " : "") << param.m_type << " " << param.m_name;
36+
if(param.m_isArray)
37+
{
38+
kw.newLine() << ", int " << GetArrayLengthVariableName(param.m_name.substr(0, param.m_name.find('[')));
39+
}
3140
separator = ", ";
3241
}
3342
kw.dedent();
@@ -37,21 +46,35 @@ std::string MetalShaderClassWrapper::generateClassWrapperHeader(GpuShaderText& k
3746
kw.indent();
3847
for(const auto& param : m_functionParameters)
3948
{
40-
size_t openAngledBracketPos = param.name.find('[');
41-
bool isArray = openAngledBracketPos != std::string::npos;
42-
if(!isArray)
43-
kw.newLine() << "this->" << param.name << " = " << param.name << ";";
49+
size_t openAngledBracketPos = param.m_name.find('[');
50+
if(!param.m_isArray)
51+
{
52+
kw.newLine() << "this->" << param.m_name << " = " << param.m_name << ";";
53+
}
4454
else
4555
{
46-
size_t closeAngledBracketPos = param.name.find(']');
47-
std::string variableName = param.name.substr(0, openAngledBracketPos);
56+
size_t closeAngledBracketPos = param.m_name.find(']');
57+
std::string variableName = param.m_name.substr(0, openAngledBracketPos);
4858

4959
kw.newLine() << "for(int i = 0; i < "
50-
<< param.name.substr(openAngledBracketPos+1, closeAngledBracketPos-openAngledBracketPos-1)
60+
<< GetArrayLengthVariableName(variableName)
5161
<< "; ++i)";
62+
kw.newLine() << "{";
5263
kw.indent();
5364
kw.newLine() << "this->" << variableName << "[i] = " << variableName << "[i];";
5465
kw.dedent();
66+
kw.newLine() << "}";
67+
68+
kw.newLine() << "for(int i = "
69+
<< GetArrayLengthVariableName(variableName)
70+
<< "; i < "
71+
<< param.m_name.substr(openAngledBracketPos+1, closeAngledBracketPos-openAngledBracketPos-1)
72+
<< "; ++i)";
73+
kw.newLine() << "{";
74+
kw.indent();
75+
kw.newLine() << "this->" << variableName << "[i] = 0;";
76+
kw.dedent();
77+
kw.newLine() << "}";
5578
}
5679
}
5780
kw.dedent();
@@ -79,7 +102,11 @@ std::string MetalShaderClassWrapper::generateClassWrapperFooter(GpuShaderText& k
79102
std::string separator = "";
80103
for(const auto& param : m_functionParameters)
81104
{
82-
kw.newLine() << separator << param.type << " " << param.name;
105+
kw.newLine() << separator << (param.m_isArray ? "constant " : "") << param.m_type << " " << param.m_name;
106+
if(param.m_isArray)
107+
{
108+
kw.newLine() << ", int " << GetArrayLengthVariableName(param.m_name.substr(0, param.m_name.find('[')));
109+
}
83110
separator = ", ";
84111
}
85112
kw.newLine() << separator << kw.float4Keyword() << " inPixel)";
@@ -92,13 +119,18 @@ std::string MetalShaderClassWrapper::generateClassWrapperFooter(GpuShaderText& k
92119
separator = "";
93120
for(const auto& param : m_functionParameters)
94121
{
95-
size_t openAngledBracketPos = param.name.find('[');
122+
size_t openAngledBracketPos = param.m_name.find('[');
96123
bool isArray = openAngledBracketPos != std::string::npos;
97124

98125
if(!isArray)
99-
kw.newLine() << separator << param.name;
126+
{
127+
kw.newLine() << separator << param.m_name;
128+
}
100129
else
101-
kw.newLine() << separator << param.name.substr(0, openAngledBracketPos);
130+
{
131+
kw.newLine() << separator << param.m_name.substr(0, openAngledBracketPos);
132+
kw.newLine() << ", " << GetArrayLengthVariableName(param.m_name.substr(0, openAngledBracketPos));
133+
}
102134
separator = ", ";
103135
}
104136
kw.dedent();

src/OpenColorIO/GpuShaderClassWrapper.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ class MetalShaderClassWrapper : public GpuShaderClassWrapper
6161
struct FunctionParam
6262
{
6363
FunctionParam(const std::string& type, const std::string& name) :
64-
type(type),
65-
name(name)
64+
m_type(type),
65+
m_name(name)
6666
{
67+
size_t openAngledBracketPos = name.find('[');
68+
m_isArray = openAngledBracketPos != std::string::npos;
6769
}
6870

69-
std::string type;
70-
std::string name;
71+
std::string m_type;
72+
std::string m_name;
73+
bool m_isArray;
7174
};
7275

7376
std::string getClassWrapperName(const std::string &resourcePrefix, const std::string& functionName);

src/OpenColorIO/GpuShaderUtils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,16 @@ std::string GpuShaderText::declareVarStr(const std::string & name, float v)
435435
return floatDecl(name) + " = " + getFloatString(v, m_lang);
436436
}
437437

438+
std::string GpuShaderText::vectorCompareExpression(const std::string& lhs, const std::string& op, const std::string& rhs)
439+
{
440+
std::string ret = lhs + " " + op + " " + rhs;
441+
if(m_lang == GPU_LANGUAGE_MSL_2_0)
442+
{
443+
ret = "any( " + ret + " )";
444+
}
445+
return ret;
446+
}
447+
438448
void GpuShaderText::declareVarConst(const std::string & name, bool v)
439449
{
440450
newLine() << constKeyword() << declareVarStr(name, v) << ";";

src/OpenColorIO/GpuShaderUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class GpuShaderText
7676
std::string intKeyword() const;
7777

7878
std::string colorDecl(const std::string& name) const;
79+
80+
std::string vectorCompareExpression(const std::string& lhs, const std::string& op, const std::string& rhs);
7981

8082
//
8183
// Scalar & arrays helper functions.

src/OpenColorIO/ops/gradingprimary/GradingPrimaryOpGPU.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void AddGPLogForwardShader(GpuShaderCreatorRcPtr & shaderCreator,
165165
<< " + " << props.pivot << ";";
166166

167167
// Not sure if the if helps performance, but it does allow out == in at the default values.
168-
st.newLine() << "if ( " << props.gamma << " != " << st.float3Const(1.f) << " )";
168+
st.newLine() << "if ( " << st.vectorCompareExpression(props.gamma, "!=", st.float3Const(1.f)) << " )";
169169
st.newLine() << "{";
170170
st.indent();
171171
st.newLine() << st.float3Decl("normalizedOut")
@@ -206,7 +206,7 @@ void AddGPLogInverseShader(GpuShaderCreatorRcPtr & shaderCreator,
206206
st.newLine() << "}";
207207

208208
// Not sure if the if helps performance, but it does allow out == in at the default values.
209-
st.newLine() << "if ( " << props.gamma << " != " << st.float3Const(1.f) << " )";
209+
st.newLine() << "if ( " << st.vectorCompareExpression(props.gamma, "!=", st.float3Const(1.f)) << " )";
210210
st.newLine() << "{";
211211
st.indent();
212212
st.newLine() << st.float3Decl("normalizedOut")
@@ -307,7 +307,7 @@ void AddGPLinForwardShader(GpuShaderCreatorRcPtr & shaderCreator,
307307

308308
// Not sure if the if helps performance, but it does allow out == in at the default values.
309309
// Although note that the log-to-lin in Tone Op also prevents out == in.
310-
st.newLine() << "if ( " << props.contrast << " != " << st.float3Const(1.f) << " )";
310+
st.newLine() << "if ( " << st.vectorCompareExpression(props.contrast, "!=", st.float3Const(1.f)) << " )";
311311
st.newLine() << "{";
312312
st.indent();
313313

@@ -345,7 +345,7 @@ void AddGPLinInverseShader(GpuShaderCreatorRcPtr & shaderCreator,
345345

346346
// Not sure if the if helps performance, but it does allow out == in at the default values.
347347
// Although note that the log-to-lin in Tone Op also prevents out == in.
348-
st.newLine() << "if ( " << props.contrast << " != " << st.float3Const(1.f) << " )";
348+
st.newLine() << "if ( " << st.vectorCompareExpression(props.contrast, "!=", st.float3Const(1.f)) << " )";
349349
st.newLine() << "{";
350350
st.indent();
351351
// NB: The sign(outColor.rgb) is a vec3, preserving the sign of each channel.
@@ -446,7 +446,7 @@ void AddGPVideoForwardShader(GpuShaderCreatorRcPtr & shaderCreator,
446446
<< " + " << props.pivotBlack << ";";
447447

448448
// Not sure if the if helps performance, but it does allow out == in at the default values.
449-
st.newLine() << "if ( " << props.gamma << " != " << st.float3Const(1.f) << " )";
449+
st.newLine() << "if ( " << st.vectorCompareExpression(props.gamma, "!=", st.float3Const(1.f)) << " )";
450450
st.newLine() << "{";
451451
st.indent();
452452
st.newLine() << st.float3Decl("normalizedOut")
@@ -486,7 +486,7 @@ void AddGPVideoInverseShader(GpuShaderCreatorRcPtr & shaderCreator,
486486
st.newLine() << "}";
487487

488488
// Not sure if the if helps performance, but it does allow out == in at the default values.
489-
st.newLine() << "if ( " << props.gamma << " != " << st.float3Const(1.f) << " )";
489+
st.newLine() << "if ( " << st.vectorCompareExpression(props.gamma, "!=", st.float3Const(1.f)) << " )";
490490
st.newLine() << "{";
491491
st.indent();
492492
st.newLine() << st.float3Decl("normalizedOut")

src/apps/ociodisplay/main.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ namespace OCIO = OCIO_NAMESPACE;
3131
#include <GL/gl.h>
3232
#include <GL/glut.h>
3333
#endif
34-
34+
#if __APPLE__
35+
#include "metalapp.h"
36+
#endif
3537
#include "glsl.h"
3638
#include "oglapp.h"
3739

3840
bool g_verbose = false;
3941
bool g_gpulegacy = false;
4042
bool g_gpuinfo = false;
43+
#if __APPLE__
44+
bool g_useMetal = false;
45+
#endif
4146

4247
std::string g_filename;
4348

@@ -414,7 +419,12 @@ void UpdateOCIOGLState()
414419

415420
// Set the shader context.
416421
OCIO::GpuShaderDescRcPtr shaderDesc = OCIO::GpuShaderDesc::CreateShaderDesc();
417-
shaderDesc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_2);
422+
shaderDesc->setLanguage(
423+
#if __APPLE__
424+
g_useMetal ?
425+
OCIO::GPU_LANGUAGE_MSL_2_0 :
426+
#endif
427+
OCIO::GPU_LANGUAGE_GLSL_1_2);
418428
shaderDesc->setFunctionName("OCIODisplay");
419429
shaderDesc->setResourcePrefix("ocio_");
420430

@@ -613,6 +623,12 @@ void parseArguments(int argc, char **argv)
613623
{
614624
g_gpuinfo = true;
615625
}
626+
#if __APPLE__
627+
else if(0==strcmp(argv[i], "-metal"))
628+
{
629+
g_useMetal = true;
630+
}
631+
#endif
616632
else if(0==strcmp(argv[i], "-h"))
617633
{
618634
std::cout << std::endl;
@@ -624,6 +640,9 @@ void parseArguments(int argc, char **argv)
624640
std::cout << " -v : displays the color space information" << std::endl;
625641
std::cout << " -gpulegacy : use the legacy (i.e. baked) GPU color processing" << std::endl;
626642
std::cout << " -gpuinfo : output the OCIO shader program" << std::endl;
643+
#if __APPLE__
644+
std::cout << " -metal : use metal OCIO shader backend " << std::endl;
645+
#endif
627646
std::cout << std::endl;
628647
exit(0);
629648
}
@@ -640,7 +659,16 @@ int main(int argc, char **argv)
640659

641660
try
642661
{
643-
g_oglApp = std::make_shared<OCIO::ScreenApp>("ociodisplay", 512, 512);
662+
#if __APPLE__
663+
if(g_useMetal)
664+
{
665+
g_oglApp = std::make_shared<OCIO::MetalApp>("ociodisplay", 512, 512);
666+
}
667+
else
668+
#endif
669+
{
670+
g_oglApp = std::make_shared<OCIO::ScreenApp>("ociodisplay", 512, 512);
671+
}
644672
}
645673
catch (const OCIO::Exception & e)
646674
{

src/libutils/oglapphelpers/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ set(INCLUDES
1515
oglapp.h
1616
)
1717

18+
if(APPLE)
19+
20+
list(APPEND SOURCES
21+
msl.mm
22+
mtltexture.mm
23+
metalapp.mm
24+
)
25+
26+
list(APPEND INCLUDES
27+
msl.h
28+
mtltexture.h
29+
metalapp.h
30+
)
31+
32+
endif()
33+
1834
add_library(oglapphelpers STATIC ${SOURCES})
1935
set_target_properties(oglapphelpers PROPERTIES POSITION_INDEPENDENT_CODE ON)
2036
set_target_properties(oglapphelpers PROPERTIES OUTPUT_NAME OpenColorIOoglapphelpers)
@@ -82,6 +98,16 @@ else()
8298
)
8399
endif()
84100

101+
if(APPLE)
102+
target_link_libraries(oglapphelpers
103+
PRIVATE
104+
"-framework Carbon"
105+
"-framework IOKit"
106+
"-framework Metal"
107+
"-framework CoreVideo"
108+
)
109+
endif()
110+
85111
if(${OCIO_EGL_HEADLESS})
86112
target_include_directories(oglapphelpers
87113
PRIVATE

src/libutils/oglapphelpers/glsl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ std::string OpenGLBuilder::getGLSLVersionString()
447447
switch (m_shaderDesc->getLanguage())
448448
{
449449
case GPU_LANGUAGE_GLSL_1_2:
450+
case GPU_LANGUAGE_MSL_2_0:
450451
// That's the minimal version supported.
451452
return "#version 120";
452453
case GPU_LANGUAGE_GLSL_1_3:
@@ -460,15 +461,14 @@ std::string OpenGLBuilder::getGLSLVersionString()
460461
case GPU_LANGUAGE_CG:
461462
case GPU_LANGUAGE_HLSL_DX11:
462463
case LANGUAGE_OSL_1:
463-
case GPU_LANGUAGE_MSL_2_0:
464464
default:
465465
// These are all impossible in OpenGL contexts.
466466
// The shader will be unusable, so let's throw
467467
throw Exception("Invalid shader language for OpenGLBuilder");
468468
}
469469
}
470470

471-
unsigned OpenGLBuilder::buildProgram(const std::string & clientShaderProgram)
471+
unsigned OpenGLBuilder::buildProgram(const std::string & clientShaderProgram, bool standaloneShader)
472472
{
473473
const std::string shaderCacheID = m_shaderDesc->getCacheID();
474474
if(shaderCacheID!=m_shaderCacheID)
@@ -481,7 +481,7 @@ unsigned OpenGLBuilder::buildProgram(const std::string & clientShaderProgram)
481481

482482
std::ostringstream os;
483483
os << getGLSLVersionString() << std::endl
484-
<< m_shaderDesc->getShaderText() << std::endl
484+
<< (!standaloneShader ? m_shaderDesc->getShaderText() : "") << std::endl
485485
<< clientShaderProgram << std::endl;
486486

487487
if(m_verbose)

src/libutils/oglapphelpers/glsl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class OpenGLBuilder
7979

8080
// Build the complete shader program which includes the OCIO shader program
8181
// and the client shader program.
82-
unsigned buildProgram(const std::string & clientShaderProgram);
82+
unsigned buildProgram(const std::string & clientShaderProgram, bool standaloneShader);
8383
void useProgram();
8484
unsigned getProgramHandle();
8585

0 commit comments

Comments
 (0)