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

WIP: add high-precision GPU trilinear interpolation for 3D LUTs #1794

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions include/OpenColorIO/OpenColorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,13 @@ enum OptimizationFlags : unsigned long
*/
OPTIMIZATION_NO_DYNAMIC_PROPERTIES = 0x10000000,

/**
* For GPU processor, use native trilinear interpolation for 3D LUTs. This is faster,
* but on many GPUs also lower precision. With low-resolution LUTs, LUTs with large
* extents, or LUTs applied in a linear color space this can sometimes cause color banding.
*/
OPTIMIZATION_NATIVE_GPU_TRILINEAR = 0x20000000,

/// Apply all possible optimizations.
OPTIMIZATION_ALL = 0xFFFFFFFF,

Expand All @@ -645,6 +652,7 @@ enum OptimizationFlags : unsigned long
OPTIMIZATION_COMP_LUT1D |
OPTIMIZATION_LUT_INV_FAST |
OPTIMIZATION_FAST_LOG_EXP_POW |
OPTIMIZATION_NATIVE_GPU_TRILINEAR |
OPTIMIZATION_COMP_SEPARABLE_PREFIX),

OPTIMIZATION_GOOD = OPTIMIZATION_VERY_GOOD | OPTIMIZATION_COMP_LUT3D,
Expand Down
5 changes: 4 additions & 1 deletion src/OpenColorIO/GPUProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ void GPUProcessor::Impl::finalize(const OpRcPtrVec & rawOps, OptimizationFlags o
// Is NoOp ?
m_isNoOp = m_ops.isNoOp();

// Store optimization flags for use when generating shader code.
m_oFlags = oFlags;

// Does the color processing introduce crosstalk between the pixel channels?
m_hasChannelCrosstalk = m_ops.hasChannelCrosstalk();

Expand All @@ -104,7 +107,7 @@ void GPUProcessor::Impl::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCrea
// Create the shader program information.
for(const auto & op : m_ops)
{
op->extractGpuShaderInfo(shaderCreator);
op->extractGpuShaderInfo(shaderCreator, m_oFlags);
}

WriteShaderHeader(shaderCreator);
Expand Down
1 change: 1 addition & 0 deletions src/OpenColorIO/GPUProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class GPUProcessor::Impl
OpRcPtrVec m_ops;
bool m_isNoOp = false;
bool m_hasChannelCrosstalk = true;
OptimizationFlags m_oFlags = OPTIMIZATION_DEFAULT;
std::string m_cacheID;
mutable Mutex m_mutex;
};
Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/Op.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class Op
virtual bool supportedByLegacyShader() const { return true; }

// Create & add the gpu shader information needed by the op. Op has to be finalized.
virtual void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const = 0;
virtual void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags oFlags = OPTIMIZATION_DEFAULT) const = 0;

virtual bool isDynamic() const;
virtual bool hasDynamicProperty(DynamicPropertyType type) const;
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/cdl/CDLOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CDLOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstCDLOpDataRcPtr cdlData() const { return DynamicPtrCast<const CDLOpData>(data()); }
Expand Down Expand Up @@ -133,7 +133,7 @@ ConstOpCPURcPtr CDLOp::getCPUOp(bool fastLogExpPow) const
return GetCDLCPURenderer(data, fastLogExpPow);
}

void CDLOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void CDLOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstCDLOpDataRcPtr data = cdlData();
GetCDLGPUShaderProgram(shaderCreator, data);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/exponent/ExponentOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class ExponentOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstExponentOpDataRcPtr expData() const { return DynamicPtrCast<const ExponentOpData>(data()); }
Expand Down Expand Up @@ -251,7 +251,7 @@ ConstOpCPURcPtr ExponentOp::getCPUOp(bool /*fastLogExpPow*/) const
return std::make_shared<ExponentOpCPU>(expData());
}

void ExponentOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void ExponentOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
GpuShaderText ss(shaderCreator->getLanguage());
ss.indent();
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/exposurecontrast/ExposureContrastOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ExposureContrastOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstExposureContrastOpDataRcPtr ecData() const
Expand Down Expand Up @@ -135,7 +135,7 @@ ConstOpCPURcPtr ExposureContrastOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetExposureContrastCPURenderer(ecOpData);
}

void ExposureContrastOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void ExposureContrastOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstExposureContrastOpDataRcPtr ecOpData = ecData();
GetExposureContrastGPUShaderProgram(shaderCreator, ecOpData);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/fixedfunction/FixedFunctionOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FixedFunctionOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstFixedFunctionOpDataRcPtr fnData() const { return DynamicPtrCast<const FixedFunctionOpData>(data()); }
Expand Down Expand Up @@ -125,7 +125,7 @@ ConstOpCPURcPtr FixedFunctionOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetFixedFunctionCPURenderer(data);
}

void FixedFunctionOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void FixedFunctionOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstFixedFunctionOpDataRcPtr fnOpData = fnData();
GetFixedFunctionGPUShaderProgram(shaderCreator, fnOpData);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/gamma/GammaOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GammaOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstGammaOpDataRcPtr gammaData() const { return DynamicPtrCast<const GammaOpData>(data()); }
Expand Down Expand Up @@ -123,7 +123,7 @@ ConstOpCPURcPtr GammaOp::getCPUOp(bool fastLogExpPow) const
return GetGammaRenderer(data, fastLogExpPow);
}

void GammaOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void GammaOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstGammaOpDataRcPtr data = gammaData();
GetGammaGPUShaderProgram(shaderCreator, data);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/gradingprimary/GradingPrimaryOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GradingPrimaryOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstGradingPrimaryOpDataRcPtr primaryData() const
Expand Down Expand Up @@ -190,7 +190,7 @@ ConstOpCPURcPtr GradingPrimaryOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetGradingPrimaryCPURenderer(data);
}

void GradingPrimaryOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void GradingPrimaryOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstGradingPrimaryOpDataRcPtr data = primaryData();
GetGradingPrimaryGPUShaderProgram(shaderCreator, data);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/gradingrgbcurve/GradingRGBCurveOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GradingRGBCurveOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstGradingRGBCurveOpDataRcPtr rgbCurveData() const
Expand Down Expand Up @@ -190,7 +190,7 @@ ConstOpCPURcPtr GradingRGBCurveOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetGradingRGBCurveCPURenderer(data);
}

void GradingRGBCurveOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void GradingRGBCurveOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstGradingRGBCurveOpDataRcPtr data = rgbCurveData();
GetGradingRGBCurveGPUShaderProgram(shaderCreator, data);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/gradingtone/GradingToneOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GradingToneOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstGradingToneOpDataRcPtr toneData() const
Expand Down Expand Up @@ -184,7 +184,7 @@ ConstOpCPURcPtr GradingToneOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetGradingToneCPURenderer(data);
}

void GradingToneOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void GradingToneOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstGradingToneOpDataRcPtr data = toneData();
GetGradingToneGPUShaderProgram(shaderCreator, data);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/log/LogOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LogOp: public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstLogOpDataRcPtr logData() const { return DynamicPtrCast<const LogOpData>(data()); }
Expand Down Expand Up @@ -110,7 +110,7 @@ ConstOpCPURcPtr LogOp::getCPUOp(bool fastLogExpPow) const
return GetLogRenderer(data, fastLogExpPow);
}

void LogOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void LogOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstLogOpDataRcPtr data = logData();
GetLogGPUShaderProgram(shaderCreator, data);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/lut1d/Lut1DOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Lut1DOp : public Op
ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

bool supportedByLegacyShader() const override { return false; }
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

ConstLut1DOpDataRcPtr lut1DData() const { return DynamicPtrCast<const Lut1DOpData>(data()); }
Lut1DOpDataRcPtr lut1DData() { return DynamicPtrCast<Lut1DOpData>(data()); }
Expand Down Expand Up @@ -154,7 +154,7 @@ ConstOpCPURcPtr Lut1DOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetLut1DRenderer(data, BIT_DEPTH_F32, BIT_DEPTH_F32);
}

void Lut1DOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void Lut1DOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstLut1DOpDataRcPtr lutData = lut1DData();
if (lutData->getDirection() == TRANSFORM_DIR_INVERSE)
Expand Down
6 changes: 3 additions & 3 deletions src/OpenColorIO/ops/lut3d/Lut3DOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Lut3DOp : public Op
ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

bool supportedByLegacyShader() const override { return false; }
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags oFlags) const override;

protected:
ConstLut3DOpDataRcPtr lut3DData() const
Expand Down Expand Up @@ -200,7 +200,7 @@ ConstOpCPURcPtr Lut3DOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetLut3DRenderer(data);
}

void Lut3DOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void Lut3DOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags oFlags) const
{
ConstLut3DOpDataRcPtr lutData = lut3DData();
if (lutData->getDirection() == TRANSFORM_DIR_INVERSE)
Expand All @@ -216,7 +216,7 @@ void Lut3DOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
lutData = tmp;
}

GetLut3DGPUShaderProgram(shaderCreator, lutData);
GetLut3DGPUShaderProgram(shaderCreator, lutData, oFlags);
}
}

Expand Down
86 changes: 71 additions & 15 deletions src/OpenColorIO/ops/lut3d/Lut3DOpGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace OCIO_NAMESPACE
{

void GetLut3DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, ConstLut3DOpDataRcPtr & lutData)
void GetLut3DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, ConstLut3DOpDataRcPtr & lutData, OptimizationFlags oFlags)
{

if (shaderCreator->getLanguage() == LANGUAGE_OSL_1)
Expand All @@ -32,9 +32,11 @@ void GetLut3DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, ConstLut3DO
std::string name(resName.str());
StringUtils::ReplaceInPlace(name, "__", "_");

const bool use_high_precision = !HasFlag(oFlags, OPTIMIZATION_NATIVE_GPU_TRILINEAR);
Interpolation samplerInterpolation = lutData->getConcreteInterpolation();
// Enforce GL_NEAREST with shader-generated tetrahedral interpolation.
if (samplerInterpolation == INTERP_TETRAHEDRAL)
// Enforce GL_NEAREST with shader-generated tetrahedral interpolation
// or hand-rolled trilinear interpolation.
if (samplerInterpolation == INTERP_TETRAHEDRAL || use_high_precision)
{
samplerInterpolation = INTERP_NEAREST;
}
Expand Down Expand Up @@ -225,18 +227,72 @@ void GetLut3DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, ConstLut3DO
else
{
// Trilinear interpolation
// Use texture3d and GL_LINEAR and the GPU's built-in trilinear algorithm.
// Note that the fractional components are quantized to 8-bits on some
// hardware, which introduces significant error with small grid sizes.

ss.newLine() << ss.float3Decl(name + "_coords")
<< " = (" << shaderCreator->getPixelName() << ".zyx * "
<< ss.float3Const(dim - 1) << " + "
<< ss.float3Const(0.5f) + ") / "
<< ss.float3Const(dim) << ";";

ss.newLine() << shaderCreator->getPixelName() << ".rgb = "
<< ss.sampleTex3D(name, name + "_coords") << ".rgb;";
if (use_high_precision)
{
// Use GL_NEAREST and do interpolation by hand to avoid the precision
// issues of native trilinear interpolation on many popular GPUs.

ss.newLine() << ss.float3Decl("coords") << " = "
<< shaderCreator->getPixelName() << ".rgb * "
<< ss.float3Const(dim - 1) << "; ";

// baseInd is on [0,dim-1]
ss.newLine() << ss.float3Decl("baseInd") << " = floor(coords);";

// frac is on [0,1]
ss.newLine() << ss.float3Decl("frac") << " = coords - baseInd;";

// Scale/offset baseInd onto [0,1] as usual for doing texture lookups.
// We use zyx to flip the order since blue varies most rapidly
// in the grid array ordering.
ss.newLine() << "baseInd = ( baseInd.zyx + " << ss.float3Const(0.5f) << " ) / " << ss.float3Const(dim) << ";";

// Fetch the 8 corners of the 3D texture cell.
ss.newLine() << ss.float3Decl("nextInd") << " = baseInd;";
ss.newLine() << ss.float3Decl("v1") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";
ss.newLine() << "nextInd = baseInd + " << ss.float3Const(incr, 0.0f, 0.0f) << ";";
ss.newLine() << ss.float3Decl("v2") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";
ss.newLine() << "nextInd = baseInd + " << ss.float3Const(0.0f, incr, 0.0f) << ";";
ss.newLine() << ss.float3Decl("v3") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";
ss.newLine() << "nextInd = baseInd + " << ss.float3Const(incr, incr, 0.0f) << ";";
ss.newLine() << ss.float3Decl("v4") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";
ss.newLine() << "nextInd = baseInd + " << ss.float3Const(0.0f, 0.0f, incr) << ";";
ss.newLine() << ss.float3Decl("v5") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";
ss.newLine() << "nextInd = baseInd + " << ss.float3Const(incr, 0.0f, incr) << ";";
ss.newLine() << ss.float3Decl("v6") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";
ss.newLine() << "nextInd = baseInd + " << ss.float3Const(0.0f, incr, incr) << ";";
ss.newLine() << ss.float3Decl("v7") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";
ss.newLine() << "nextInd = baseInd + " << ss.float3Const(incr, incr, incr) << ";";
ss.newLine() << ss.float3Decl("v8") << " = " << ss.sampleTex3D(name, "nextInd") << ".rgb;";

// Lerp on Z.
ss.newLine() << ss.float3Decl("v1_2") << " = " << ss.lerp("v1", "v2", "frac.z") << ";";
ss.newLine() << ss.float3Decl("v3_4") << " = " << ss.lerp("v3", "v4", "frac.z") << ";";
ss.newLine() << ss.float3Decl("v5_6") << " = " << ss.lerp("v5", "v6", "frac.z") << ";";
ss.newLine() << ss.float3Decl("v7_8") << " = " << ss.lerp("v7", "v8", "frac.z") << ";";

// Lerp on Y.
ss.newLine() << ss.float3Decl("v1_2_3_4") << " = " << ss.lerp("v1_2", "v3_4", "frac.y") << ";";
ss.newLine() << ss.float3Decl("v5_6_7_8") << " = " << ss.lerp("v5_6", "v7_8", "frac.y") << ";";

// Lerp on X.
ss.newLine() << shaderCreator->getPixelName() << ".rgb = " << ss.lerp("v1_2_3_4", "v5_6_7_8", "frac.x") << ";";
}
else
{
// Use texture3d and GL_LINEAR and the GPU's built-in trilinear algorithm.
// Note that the fractional components are quantized to 8-bits on some
// hardware, which introduces significant error with small grid sizes.

ss.newLine() << ss.float3Decl(name + "_coords")
<< " = (" << shaderCreator->getPixelName() << ".zyx * "
<< ss.float3Const(dim - 1) << " + "
<< ss.float3Const(0.5f) + ") / "
<< ss.float3Const(dim) << ";";

ss.newLine() << shaderCreator->getPixelName() << ".rgb = "
<< ss.sampleTex3D(name, name + "_coords") << ".rgb;";
}
}

shaderCreator->addToFunctionShaderCode(ss.string().c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/ops/lut3d/Lut3DOpGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace OCIO_NAMESPACE
{

void GetLut3DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, ConstLut3DOpDataRcPtr & lutData);
void GetLut3DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, ConstLut3DOpDataRcPtr & lutData, OptimizationFlags oFlags);

} // namespace OCIO_NAMESPACE

Expand Down
4 changes: 2 additions & 2 deletions src/OpenColorIO/ops/matrix/MatrixOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MatrixOffsetOp : public Op

ConstOpCPURcPtr getCPUOp(bool fastLogExpPow) const override;

void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const override;
void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const override;

protected:
ConstMatrixOpDataRcPtr matrixData() const { return DynamicPtrCast<const MatrixOpData>(data()); }
Expand Down Expand Up @@ -187,7 +187,7 @@ ConstOpCPURcPtr MatrixOffsetOp::getCPUOp(bool /*fastLogExpPow*/) const
return GetMatrixRenderer(data);
}

void MatrixOffsetOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
void MatrixOffsetOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator, OptimizationFlags /*oFlags*/) const
{
ConstMatrixOpDataRcPtr data = matrixData();
if (data->getDirection() == TRANSFORM_DIR_INVERSE)
Expand Down
Loading