Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-01-31 21:35:00 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-02-12 21:06:35 +0300
commit1b4961b318f14064bc3c915da7206a74146af95d (patch)
treefd8168e60333efad3dd0433b5229e2f7f9d97131 /intern/opencolorio/ocio_capi.cc
parent6b40ee608c5a1dbe67870fab4b83cce4cc4b54f5 (diff)
OpenColorIO: upgrade to version 2.0.0
Ref T84819 Build System ============ This is an API breaking new version, and the updated code only builds with OpenColorIO 2.0 and later. Adding backwards compatibility was too complicated. * Tinyxml was replaced with Expat, adding a new dependency. * Yaml-cpp is now built as a dependency on Unix, as was already done on Windows. * Removed currently unused LCMS code. * Pystring remains built as part of OCIO itself, since it has no good build system. * Linux and macOS check for the OpenColorIO verison, and disable it if too old. Ref D10270 Processors and Transforms ========================= CPU processors now need to be created to do CPU processing. These are cached internally, but the cache lookup is not fast enough to execute per pixel or texture sample, so for performance these are now also exposed in the C API. The C API for transforms will no longer be needed afer all changes, so remove it to simplify the API and fallback implementation. Ref D10271 Display Transforms ================== Needs a bit more manual work constructing the transform. LegacyViewingPipeline could also have been used, but isn't really any simpler and since it's legacy we better not rely on it. We moved more logic into the opencolorio module, to simplify the API. There is no need to wrap a dozen functions just to be able to do this in C rather than C++. It's also tightly coupled to the GPU shader logic, and so should be in the same module. Ref D10271 GPU Display Shader ================== To avoid baking exposure and gamma into the GLSL shader and requiring slow recompiles when tweaking, we manually apply them in the shader. This leads to some logic duplicaton between the CPU and GPU display processor, but it seems unavoidable. Caching was also changed. Previously this was done both on the imbuf and opencolorio module levels. Now it's all done in the opencolorio module by simply matching color space names. We no longer use cacheIDs from OpenColorIO since computing them is expensive, and they are unlikely to match now that more is baked into the shader code. Shaders can now use multiple 2D textures, 3D textures and uniforms, rather than a single 3D texture. So allocating and binding those adds some code. Color space conversions for blending with overlays is now hardcoded in the shader. This was using harcoded numbers anyway, if this every becomes a general OpenColorIO transform it can be changed, but for now there is no point to add code complexity. Ref D10273 CIE XYZ ======= We need standard CIE XYZ values for rendering effects like blackbody emission. The relation to the scene linear role is based on OpenColorIO configuration. In OpenColorIO 2.0 configs roles can no longer have the same name as color spaces, which means our XYZ role and colorspace in the configuration give an error. Instead use the new standard aces_interchange role, which relates scene linear to a known scene referred color space. Compatibility with the old XYZ role is preserved, if the configuration file has no conflicting names. Also includes a non-functional change to the configuraton file to use an XYZ-to-ACES matrix instead of REC709-to-ACES, makes debugging a little easier since the matrix is the same one we have in the code now and that is also found easily in the ACES specs. Ref D10274
Diffstat (limited to 'intern/opencolorio/ocio_capi.cc')
-rw-r--r--intern/opencolorio/ocio_capi.cc205
1 files changed, 56 insertions, 149 deletions
diff --git a/intern/opencolorio/ocio_capi.cc b/intern/opencolorio/ocio_capi.cc
index 84c36de364c..a7416f82b91 100644
--- a/intern/opencolorio/ocio_capi.cc
+++ b/intern/opencolorio/ocio_capi.cc
@@ -194,40 +194,45 @@ OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr
return impl->configGetProcessorWithNames(config, srcName, dstName);
}
-OCIO_ConstProcessorRcPtr *OCIO_configGetProcessor(OCIO_ConstConfigRcPtr *config,
- OCIO_ConstTransformRcPtr *transform)
+void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *processor)
{
- return impl->configGetProcessor(config, transform);
+ impl->processorRelease(processor);
}
-void OCIO_processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
+OCIO_ConstCPUProcessorRcPtr *OCIO_processorGetCPUProcessor(OCIO_ConstProcessorRcPtr *processor)
{
- impl->processorApply(processor, img);
+ return impl->processorGetCPUProcessor(processor);
}
-void OCIO_processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
+void OCIO_cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor, OCIO_PackedImageDesc *img)
{
- impl->processorApply_predivide(processor, img);
+ impl->cpuProcessorApply(cpu_processor, img);
}
-void OCIO_processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
+void OCIO_cpuProcessorApply_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
+ OCIO_PackedImageDesc *img)
{
- impl->processorApplyRGB(processor, pixel);
+ impl->cpuProcessorApply_predivide(cpu_processor, img);
}
-void OCIO_processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
+void OCIO_cpuProcessorApplyRGB(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel)
{
- impl->processorApplyRGBA(processor, pixel);
+ impl->cpuProcessorApplyRGB(cpu_processor, pixel);
}
-void OCIO_processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
+void OCIO_cpuProcessorApplyRGBA(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel)
{
- impl->processorApplyRGBA_predivide(processor, pixel);
+ impl->cpuProcessorApplyRGBA(cpu_processor, pixel);
}
-void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *p)
+void OCIO_cpuProcessorApplyRGBA_predivide(OCIO_ConstCPUProcessorRcPtr *processor, float *pixel)
{
- impl->processorRelease(p);
+ impl->cpuProcessorApplyRGBA_predivide(processor, pixel);
+}
+
+void OCIO_cpuProcessorRelease(OCIO_ConstCPUProcessorRcPtr *cpu_processor)
+{
+ impl->cpuProcessorRelease(cpu_processor);
}
const char *OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
@@ -245,49 +250,15 @@ const char *OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs)
return impl->colorSpaceGetFamily(cs);
}
-OCIO_DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
-{
- return impl->createDisplayTransform();
-}
-
-void OCIO_displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name)
-{
- impl->displayTransformSetInputColorSpaceName(dt, name);
-}
-
-void OCIO_displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name)
-{
- impl->displayTransformSetDisplay(dt, name);
-}
-
-void OCIO_displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name)
-{
- impl->displayTransformSetView(dt, name);
-}
-
-void OCIO_displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
-{
- impl->displayTransformSetDisplayCC(dt, t);
-}
-
-void OCIO_displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
+OCIO_ConstProcessorRcPtr *OCIO_createDisplayProcessor(OCIO_ConstConfigRcPtr *config,
+ const char *input,
+ const char *view,
+ const char *display,
+ const char *look,
+ const float scale,
+ const float exponent)
{
- impl->displayTransformSetLinearCC(dt, t);
-}
-
-void OCIO_displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt, const char *looks)
-{
- impl->displayTransformSetLooksOverride(dt, looks);
-}
-
-void OCIO_displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt, bool enabled)
-{
- impl->displayTransformSetLooksOverrideEnabled(dt, enabled);
-}
-
-void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
-{
- impl->displayTransformRelease(dt);
+ return impl->createDisplayProcessor(config, input, view, display, look, scale, exponent);
}
OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data,
@@ -307,108 +278,44 @@ void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *id)
impl->OCIO_PackedImageDescRelease(id);
}
-OCIO_GroupTransformRcPtr *OCIO_createGroupTransform(void)
-{
- return impl->createGroupTransform();
-}
-
-void OCIO_groupTransformSetDirection(OCIO_GroupTransformRcPtr *gt, const bool forward)
-{
- impl->groupTransformSetDirection(gt, forward);
-}
-
-void OCIO_groupTransformPushBack(OCIO_GroupTransformRcPtr *gt, OCIO_ConstTransformRcPtr *tr)
-{
- impl->groupTransformPushBack(gt, tr);
-}
-
-void OCIO_groupTransformRelease(OCIO_GroupTransformRcPtr *gt)
-{
- impl->groupTransformRelease(gt);
-}
-
-OCIO_ColorSpaceTransformRcPtr *OCIO_createColorSpaceTransform(void)
-{
- return impl->createColorSpaceTransform();
-}
-
-void OCIO_colorSpaceTransformSetSrc(OCIO_ColorSpaceTransformRcPtr *ct, const char *name)
-{
- impl->colorSpaceTransformSetSrc(ct, name);
-}
-
-void OCIO_colorSpaceTransformRelease(OCIO_ColorSpaceTransformRcPtr *ct)
-{
- impl->colorSpaceTransformRelease(ct);
-}
-
-OCIO_ExponentTransformRcPtr *OCIO_createExponentTransform(void)
-{
- return impl->createExponentTransform();
-}
-
-void OCIO_exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent)
-{
- impl->exponentTransformSetValue(et, exponent);
-}
-
-void OCIO_exponentTransformRelease(OCIO_ExponentTransformRcPtr *et)
-{
- impl->exponentTransformRelease(et);
-}
-
-OCIO_MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
-{
- return impl->createMatrixTransform();
-}
-
-void OCIO_matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
- const float *m44,
- const float *offset4)
-{
- impl->matrixTransformSetValue(mt, m44, offset4);
-}
-
-void OCIO_matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt)
-{
- impl->matrixTransformRelease(mt);
-}
-
-void OCIO_matrixTransformScale(float *m44, float *offset4, const float *scale4f)
-{
- impl->matrixTransformScale(m44, offset4, scale4f);
-}
-
-int OCIO_supportGLSLDraw(void)
+bool OCIO_supportGPUShader()
{
- return (int)impl->supportGLSLDraw();
+ return impl->supportGPUShader();
}
-int OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r,
- OCIO_ConstProcessorRcPtr *ocio_processor_scene_to_ui,
- OCIO_ConstProcessorRcPtr *ocio_processor_ui_to_display,
- OCIO_CurveMappingSettings *curve_mapping_settings,
- float dither,
- bool predivide,
- bool overlay)
+bool OCIO_gpuDisplayShaderBind(OCIO_ConstConfigRcPtr *config,
+ const char *input,
+ const char *view,
+ const char *display,
+ const char *look,
+ OCIO_CurveMappingSettings *curve_mapping_settings,
+ const float scale,
+ const float exponent,
+ const float dither,
+ const bool use_predivide,
+ const bool use_overlay)
{
- return (int)impl->setupGLSLDraw(state_r,
- ocio_processor_scene_to_ui,
- ocio_processor_ui_to_display,
- curve_mapping_settings,
- dither,
- predivide,
- overlay);
+ return impl->gpuDisplayShaderBind(config,
+ input,
+ view,
+ display,
+ look,
+ curve_mapping_settings,
+ scale,
+ exponent,
+ dither,
+ use_predivide,
+ use_overlay);
}
-void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state)
+void OCIO_gpuDisplayShaderUnbind(void)
{
- impl->finishGLSLDraw(state);
+ impl->gpuDisplayShaderUnbind();
}
-void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state)
+void OCIO_gpuCacheFree(void)
{
- impl->freeGLState(state);
+ impl->gpuCacheFree();
}
const char *OCIO_getVersionString(void)