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_impl.h
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_impl.h')
-rw-r--r--intern/opencolorio/ocio_impl.h247
1 files changed, 90 insertions, 157 deletions
diff --git a/intern/opencolorio/ocio_impl.h b/intern/opencolorio/ocio_impl.h
index 3ffc0a4a475..0c759a35e15 100644
--- a/intern/opencolorio/ocio_impl.h
+++ b/intern/opencolorio/ocio_impl.h
@@ -76,36 +76,30 @@ class IOCIOImpl {
virtual OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
const char *srcName,
const char *dstName) = 0;
- virtual OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config,
- OCIO_ConstTransformRcPtr *transform) = 0;
-
- virtual void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img) = 0;
- virtual void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor,
- OCIO_PackedImageDesc *img) = 0;
- virtual void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
- virtual void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
- virtual void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
-
- virtual void processorRelease(OCIO_ConstProcessorRcPtr *p) = 0;
+ virtual void processorRelease(OCIO_ConstProcessorRcPtr *processor) = 0;
+
+ virtual OCIO_ConstCPUProcessorRcPtr *processorGetCPUProcessor(OCIO_ConstProcessorRcPtr *p) = 0;
+ virtual void cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
+ OCIO_PackedImageDesc *img) = 0;
+ virtual void cpuProcessorApply_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
+ OCIO_PackedImageDesc *img) = 0;
+ virtual void cpuProcessorApplyRGB(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel) = 0;
+ virtual void cpuProcessorApplyRGBA(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel) = 0;
+ virtual void cpuProcessorApplyRGBA_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
+ float *pixel) = 0;
+ virtual void cpuProcessorRelease(OCIO_ConstCPUProcessorRcPtr *cpu_processor) = 0;
virtual const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs) = 0;
- virtual OCIO_DisplayTransformRcPtr *createDisplayTransform(void) = 0;
- virtual void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt,
- const char *name) = 0;
- virtual void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
- virtual void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
- virtual void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt,
- OCIO_ConstTransformRcPtr *et) = 0;
- virtual void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt,
- OCIO_ConstTransformRcPtr *et) = 0;
- virtual void displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt,
- const char *looks) = 0;
- virtual void displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt,
- bool enabled) = 0;
- virtual void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt) = 0;
+ virtual OCIO_ConstProcessorRcPtr *createDisplayProcessor(OCIO_ConstConfigRcPtr *config,
+ const char *input,
+ const char *view,
+ const char *display,
+ const char *look,
+ const float scale,
+ const float exponent) = 0;
virtual OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data,
long width,
@@ -117,39 +111,31 @@ class IOCIOImpl {
virtual void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p) = 0;
- virtual OCIO_GroupTransformRcPtr *createGroupTransform(void) = 0;
- virtual void groupTransformSetDirection(OCIO_GroupTransformRcPtr *gt, const bool forward) = 0;
- virtual void groupTransformPushBack(OCIO_GroupTransformRcPtr *gt,
- OCIO_ConstTransformRcPtr *transform) = 0;
- virtual void groupTransformRelease(OCIO_GroupTransformRcPtr *gt) = 0;
-
- virtual OCIO_ColorSpaceTransformRcPtr *createColorSpaceTransform(void) = 0;
- virtual void colorSpaceTransformSetSrc(OCIO_ColorSpaceTransformRcPtr *ct, const char *name) = 0;
- virtual void colorSpaceTransformRelease(OCIO_ColorSpaceTransformRcPtr *ct) = 0;
-
- virtual OCIO_ExponentTransformRcPtr *createExponentTransform(void) = 0;
- virtual void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et,
- const float *exponent) = 0;
- virtual void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et) = 0;
-
- virtual OCIO_MatrixTransformRcPtr *createMatrixTransform(void) = 0;
- virtual void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
- const float *m44,
- const float *offset4) = 0;
- virtual void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt) = 0;
-
- virtual void matrixTransformScale(float *m44, float *offset4, const float *scale4) = 0;
-
- virtual bool supportGLSLDraw(void) = 0;
- virtual bool 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) = 0;
- virtual void finishGLSLDraw(struct OCIO_GLSLDrawState *state) = 0;
- virtual void freeGLState(struct OCIO_GLSLDrawState *state_r) = 0;
+ /* Optional GPU support. */
+ virtual bool supportGPUShader()
+ {
+ return false;
+ }
+ virtual bool 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 false;
+ }
+ virtual void gpuDisplayShaderUnbind(void)
+ {
+ }
+ virtual void gpuCacheFree(void)
+ {
+ }
virtual const char *getVersionString(void) = 0;
virtual int getVersionHex(void) = 0;
@@ -206,30 +192,28 @@ class FallbackImpl : public IOCIOImpl {
OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
const char *srcName,
const char *dstName);
- OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config,
- OCIO_ConstTransformRcPtr *transform);
+ void processorRelease(OCIO_ConstProcessorRcPtr *processor);
- void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
- void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
- void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
- void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
- void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
-
- void processorRelease(OCIO_ConstProcessorRcPtr *p);
+ OCIO_ConstCPUProcessorRcPtr *processorGetCPUProcessor(OCIO_ConstProcessorRcPtr *processor);
+ void cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor, OCIO_PackedImageDesc *img);
+ void cpuProcessorApply_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
+ OCIO_PackedImageDesc *img);
+ void cpuProcessorApplyRGB(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
+ void cpuProcessorApplyRGBA(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
+ void cpuProcessorApplyRGBA_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
+ void cpuProcessorRelease(OCIO_ConstCPUProcessorRcPtr *cpu_processor);
const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
- OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
- void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
- void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
- void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
- void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
- void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
- void displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt, const char *looks);
- void displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt, bool enabled);
- void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
+ OCIO_ConstProcessorRcPtr *createDisplayProcessor(OCIO_ConstConfigRcPtr *config,
+ const char *input,
+ const char *view,
+ const char *display,
+ const char *look,
+ const float scale,
+ const float exponent);
OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data,
long width,
@@ -241,38 +225,6 @@ class FallbackImpl : public IOCIOImpl {
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
- OCIO_GroupTransformRcPtr *createGroupTransform(void);
- void groupTransformSetDirection(OCIO_GroupTransformRcPtr *gt, const bool forward);
- void groupTransformPushBack(OCIO_GroupTransformRcPtr *gt, OCIO_ConstTransformRcPtr *transform);
- void groupTransformRelease(OCIO_GroupTransformRcPtr *gt);
-
- OCIO_ColorSpaceTransformRcPtr *createColorSpaceTransform(void);
- void colorSpaceTransformSetSrc(OCIO_ColorSpaceTransformRcPtr *ct, const char *name);
- void colorSpaceTransformRelease(OCIO_ColorSpaceTransformRcPtr *ct);
-
- OCIO_ExponentTransformRcPtr *createExponentTransform(void);
- void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
- void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
-
- OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
- void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
- const float *m44,
- const float *offset4);
- void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
-
- void matrixTransformScale(float *m44, float *offset4, const float *scale4);
-
- bool supportGLSLDraw(void);
- bool 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);
- void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
- void freeGLState(struct OCIO_GLSLDrawState *state_r);
-
const char *getVersionString(void);
int getVersionHex(void);
};
@@ -327,30 +279,28 @@ class OCIOImpl : public IOCIOImpl {
OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
const char *srcName,
const char *dstName);
- OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config,
- OCIO_ConstTransformRcPtr *transform);
-
- void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
- void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
- void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
- void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
- void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
+ void processorRelease(OCIO_ConstProcessorRcPtr *processor);
- void processorRelease(OCIO_ConstProcessorRcPtr *p);
+ OCIO_ConstCPUProcessorRcPtr *processorGetCPUProcessor(OCIO_ConstProcessorRcPtr *processor);
+ void cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor, OCIO_PackedImageDesc *img);
+ void cpuProcessorApply_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
+ OCIO_PackedImageDesc *img);
+ void cpuProcessorApplyRGB(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
+ void cpuProcessorApplyRGBA(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
+ void cpuProcessorApplyRGBA_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
+ void cpuProcessorRelease(OCIO_ConstCPUProcessorRcPtr *cpu_processor);
const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
- OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
- void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
- void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
- void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
- void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
- void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
- void displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt, const char *looks);
- void displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt, bool enabled);
- void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
+ OCIO_ConstProcessorRcPtr *createDisplayProcessor(OCIO_ConstConfigRcPtr *config,
+ const char *input,
+ const char *view,
+ const char *display,
+ const char *look,
+ const float scale,
+ const float exponent);
OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data,
long width,
@@ -362,37 +312,20 @@ class OCIOImpl : public IOCIOImpl {
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
- OCIO_GroupTransformRcPtr *createGroupTransform(void);
- void groupTransformSetDirection(OCIO_GroupTransformRcPtr *gt, const bool forward);
- void groupTransformPushBack(OCIO_GroupTransformRcPtr *gt, OCIO_ConstTransformRcPtr *transform);
- void groupTransformRelease(OCIO_GroupTransformRcPtr *gt);
-
- OCIO_ColorSpaceTransformRcPtr *createColorSpaceTransform(void);
- void colorSpaceTransformSetSrc(OCIO_ColorSpaceTransformRcPtr *ct, const char *name);
- void colorSpaceTransformRelease(OCIO_ColorSpaceTransformRcPtr *ct);
-
- OCIO_ExponentTransformRcPtr *createExponentTransform(void);
- void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
- void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
-
- OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
- void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
- const float *m44,
- const float *offset4);
- void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
-
- void matrixTransformScale(float *m44, float *offset4, const float *scale4);
-
- bool supportGLSLDraw(void);
- bool 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);
- void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
- void freeGLState(struct OCIO_GLSLDrawState *state_r);
+ bool supportGPUShader();
+ bool 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);
+ void gpuDisplayShaderUnbind(void);
+ void gpuCacheFree(void);
const char *getVersionString(void);
int getVersionHex(void);