Skip to content

Commit

Permalink
Adsk Contrib - Issues #1968 (mirrored builtins) and #1992 (LUT-free b…
Browse files Browse the repository at this point in the history
…uiltins Pt.1)

For issue #1992 - "Make LUT-free implementations of certain built-in transforms"
- Adding fixed-functions PQ_TO_LINEAR and LINEAR_TO_PQ. These will be used to handle following built-in transforms if the LUT support is turned off:
-- CURVE - ST-2084_to_LINEAR
-- CURVE - LINEAR_to_ST-2084
-- DISPLAY - CIE-XYZ-D65_to_REC.2100-PQ
-- DISPLAY - CIE-XYZ-D65_to_ST2084-P3-D65
- Implemented CPU renderers for scalar, SSE2 (with fastPower) and SSE2 (with Intel SVML) intrinsics targets for the new fixed-function.
- Implemented GPU shader generator for the new fixed-function
- Remaining fixed-functions will be implemented in an upcoming PR.

For issue #1968 - "Make display EOTFs in built-in transforms mirrored and unclamped to preserve sub-black and super-white"
- Existing LUT-based HLG curve is now unclamped at both ends and mirrored around origin.
- Both the existing LUT-based and the new LUT-free implementations of the PQ curve are now unclamped at both ends and mirrored around origin.

Aux Changes
- GetFixedFunctionCPURenderer() now takes a new bool parameter fastLogExpPow.
- Added a stand-in OCIO_LUT_SUPPORT preprocessor macro in preparation for ocio-lite where the lut support can be turned off.
- Added util functions to Config_tests.cpp to help creating configs with arbitrary version.
- Added ability to test fixed-function cpu renderers with and without fastLogExpPow.
- Added capability to specify custom extended ranges in the GPU unit tests. Default value is [-1.0,2.0] same as the previously hard-coded range.
- Fixed a bug in the GPU unit tests where the computed domain values would overshoot.

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
  • Loading branch information
cozdas committed Aug 27, 2024
1 parent ae79fdf commit 2ce223f
Show file tree
Hide file tree
Showing 19 changed files with 653 additions and 59 deletions.
7 changes: 7 additions & 0 deletions docs/api/python/frozen/pyopencolorio_fixedfunctionstyle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

FIXED_FUNCTION_ACES_GAMUT_COMP_13 : ACES 1.3 Parametric Gamut Compression (expects ACEScg values)

FIXED_FUNCTION_PQ_TO_LINEAR : SMPTE ST 2084:2014 EOTF Linearization Equation

.. py:method:: name() -> str
:property:

Expand Down Expand Up @@ -104,6 +106,11 @@
:value: <FixedFunctionStyle.FIXED_FUNCTION_XYZ_TO_xyY: 7>


.. py:attribute:: FixedFunctionStyle.FIXED_FUNCTION_PQ_TO_LINEAR
:module: PyOpenColorIO
:value: <FixedFunctionStyle.FIXED_FUNCTION_PQ_TO_LINEAR: 13>


.. py:property:: FixedFunctionStyle.value
:module: PyOpenColorIO

3 changes: 2 additions & 1 deletion include/OpenColorIO/OpenColorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ enum FixedFunctionStyle
FIXED_FUNCTION_XYZ_TO_LUV, ///< CIE XYZ to 1976 CIELUV colour space (D65 white)
FIXED_FUNCTION_ACES_GAMUTMAP_02, ///< ACES 0.2 Gamut clamping algorithm -- NOT IMPLEMENTED YET
FIXED_FUNCTION_ACES_GAMUTMAP_07, ///< ACES 0.7 Gamut clamping algorithm -- NOT IMPLEMENTED YET
FIXED_FUNCTION_ACES_GAMUT_COMP_13 ///< ACES 1.3 Parametric Gamut Compression (expects ACEScg values)
FIXED_FUNCTION_ACES_GAMUT_COMP_13, ///< ACES 1.3 Parametric Gamut Compression (expects ACEScg values)
FIXED_FUNCTION_PQ_TO_LINEAR, ///< SMPTE ST-2084 EOTF linearization, scaled with 100 nits at 1.0, and with negative values mirrored
};

/// Enumeration of the :cpp:class:`ExposureContrastTransform` transform algorithms.
Expand Down
12 changes: 11 additions & 1 deletion src/OpenColorIO/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5300,17 +5300,27 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons
}
else if (ConstFixedFunctionTransformRcPtr ff = DynamicPtrCast<const FixedFunctionTransform>(transform))
{
auto ffstyle = ff->getStyle();
if (m_majorVersion < 2)
{
throw Exception("Only config version 2 (or higher) can have "
"FixedFunctionTransform.");
}

if (m_majorVersion == 2 && m_minorVersion < 1 && ff->getStyle() == FIXED_FUNCTION_ACES_GAMUT_COMP_13)
if (m_majorVersion == 2 && m_minorVersion < 1 && ffstyle == FIXED_FUNCTION_ACES_GAMUT_COMP_13)
{
throw Exception("Only config version 2.1 (or higher) can have "
"FixedFunctionTransform style 'ACES_GAMUT_COMP_13'.");
}

if (m_majorVersion == 2 && m_minorVersion < 4 )
{
if(ffstyle == FIXED_FUNCTION_PQ_TO_LINEAR)
{
throw Exception("Only config version 2.4 (or higher) can have "
"FixedFunctionTransform style 'PQ_TO_LINEAR'.");
}
}
}
else if (DynamicPtrCast<const GradingPrimaryTransform>(transform))
{
Expand Down
2 changes: 2 additions & 0 deletions src/OpenColorIO/ParseUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ const char * FixedFunctionStyleToString(FixedFunctionStyle style)
case FIXED_FUNCTION_XYZ_TO_xyY: return "XYZ_TO_xyY";
case FIXED_FUNCTION_XYZ_TO_uvY: return "XYZ_TO_uvY";
case FIXED_FUNCTION_XYZ_TO_LUV: return "XYZ_TO_LUV";
case FIXED_FUNCTION_PQ_TO_LINEAR: return "PQ_TO_LINEAR";
case FIXED_FUNCTION_ACES_GAMUTMAP_02:
case FIXED_FUNCTION_ACES_GAMUTMAP_07:
throw Exception("Unimplemented fixed function types: "
Expand Down Expand Up @@ -391,6 +392,7 @@ FixedFunctionStyle FixedFunctionStyleFromString(const char * style)
else if(str == "xyz_to_xyy") return FIXED_FUNCTION_XYZ_TO_xyY;
else if(str == "xyz_to_uvy") return FIXED_FUNCTION_XYZ_TO_uvY;
else if(str == "xyz_to_luv") return FIXED_FUNCTION_XYZ_TO_LUV;
else if(str == "pq_to_linear") return FIXED_FUNCTION_PQ_TO_LINEAR;

// Default style is meaningless.
std::stringstream ss;
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 @@ -119,10 +119,10 @@ std::string FixedFunctionOp::getCacheID() const
return cacheIDStream.str();
}

ConstOpCPURcPtr FixedFunctionOp::getCPUOp(bool /*fastLogExpPow*/) const
ConstOpCPURcPtr FixedFunctionOp::getCPUOp(bool fastLogExpPow) const
{
ConstFixedFunctionOpDataRcPtr data = fnData();
return GetFixedFunctionCPURenderer(data);
return GetFixedFunctionCPURenderer(data, fastLogExpPow);
}

void FixedFunctionOp::extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const
Expand Down
Loading

0 comments on commit 2ce223f

Please sign in to comment.