[Bf-blender-cvs] [46f8dba] master: Extend system-info with information about OIIO, OCIO and OSL

Sergey Sharybin noreply at git.blender.org
Sun Dec 8 10:03:21 CET 2013


Commit: 46f8dba4c783fe5d174bd47a70710f9d7f0aeb07
Author: Sergey Sharybin
Date:   Sun Dec 8 15:03:17 2013 +0600
http://developer.blender.org/rB46f8dba4c783fe5d174bd47a70710f9d7f0aeb07

Extend system-info with information about OIIO, OCIO and OSL

Summary:
Version of those libraries might be useful to know.

- OIIO and OCIO is exposed via bpy.app.oiio and bpy.app.ocio.
  There're "supported", "version" and "version_string" defined
  in those modules.

- OSL is available as _cycles.osl_version and _cycles.osl_version_string.

Reviewers: campbellbarton

Reviewed By: campbellbarton

CC: dingto

Differential Revision: http://developer.blender.org/D79

===================================================================

M	intern/cycles/blender/blender_python.cpp
M	intern/opencolorio/fallback_impl.cc
M	intern/opencolorio/ocio_capi.cc
M	intern/opencolorio/ocio_capi.h
M	intern/opencolorio/ocio_impl.cc
M	intern/opencolorio/ocio_impl.h
M	release/scripts/modules/sys_info.py
M	source/blender/imbuf/intern/oiio/openimageio_api.cpp
M	source/blender/imbuf/intern/oiio/openimageio_api.h
M	source/blender/python/SConscript
M	source/blender/python/intern/CMakeLists.txt
M	source/blender/python/intern/bpy_app.c
A	source/blender/python/intern/bpy_app_ocio.c
A	source/blender/python/intern/bpy_app_ocio.h
A	source/blender/python/intern/bpy_app_oiio.c
A	source/blender/python/intern/bpy_app_oiio.h

===================================================================

diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 8e6bcae..f10b185 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -475,11 +475,25 @@ void *CCL_python_module_init()
 	PyObject *mod = PyModule_Create(&ccl::module);
 
 #ifdef WITH_OSL
+	/* TODO(sergey): This gives us library we've been linking against.
+	 *               In theory with dynamic OSL library it might not be
+	 *               accurate, but there's nothing in OSL API which we
+	 *               might use th get version in runtime.
+	 */
+	int curversion = OSL_LIBRARY_VERSION_CODE;
 	PyModule_AddObject(mod, "with_osl", Py_True);
 	Py_INCREF(Py_True);
+	PyModule_AddObject(mod, "osl_version",
+	                   Py_BuildValue("(iii)",
+	                                  curversion / 10000, (curversion / 100) % 100, curversion % 100));
+	PyModule_AddObject(mod, "osl_version_string",
+	                   PyUnicode_FromFormat("%2d, %2d, %2d",
+	                                        curversion / 10000, (curversion / 100) % 100, curversion % 100));
 #else
 	PyModule_AddObject(mod, "with_osl", Py_False);
 	Py_INCREF(Py_False);
+	PyModule_AddStringCOnstant(mod, "osl_version", "unknown");
+	PyModule_AddStringCOnstant(mod, "osl_version_string", "unknown");
 #endif
 
 #ifdef WITH_NETWORK
diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc
index ca999ea..6383bbb 100644
--- a/intern/opencolorio/fallback_impl.cc
+++ b/intern/opencolorio/fallback_impl.cc
@@ -431,3 +431,13 @@ void FallbackImpl::finishGLSLDraw(OCIO_GLSLDrawState * /*state*/)
 void FallbackImpl::freeGLState(struct OCIO_GLSLDrawState * /*state_r*/)
 {
 }
+
+const char *FallbackImpl::getVersionString(void)
+{
+	return "fallback";
+}
+
+int FallbackImpl::getVersionHex(void)
+{
+	return 0;
+}
diff --git a/intern/opencolorio/ocio_capi.cc b/intern/opencolorio/ocio_capi.cc
index 30668df..47ee3af 100644
--- a/intern/opencolorio/ocio_capi.cc
+++ b/intern/opencolorio/ocio_capi.cc
@@ -338,3 +338,13 @@ void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state)
 {
 	impl->freeGLState(state);
 }
+
+const char *OCIO_getVersionString(void)
+{
+	return impl->getVersionString();
+}
+
+int OCIO_getVersionHex(void)
+{
+	return impl->getVersionHex();
+}
diff --git a/intern/opencolorio/ocio_capi.h b/intern/opencolorio/ocio_capi.h
index 5532ade..5abe104 100644
--- a/intern/opencolorio/ocio_capi.h
+++ b/intern/opencolorio/ocio_capi.h
@@ -193,6 +193,9 @@ int OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorR
 void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state);
 void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state);
 
+const char *OCIO_getVersionString(void);
+int OCIO_getVersionHex(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc
index 2cffe1a..663ca2d 100644
--- a/intern/opencolorio/ocio_impl.cc
+++ b/intern/opencolorio/ocio_impl.cc
@@ -609,3 +609,13 @@ void OCIOImpl::matrixTransformScale(float *m44, float *offset4, const float *sca
 {
 	MatrixTransform::Scale(m44, offset4, scale4f);
 }
+
+const char *OCIOImpl::getVersionString(void)
+{
+	return GetVersion();
+}
+
+int OCIOImpl::getVersionHex(void)
+{
+	return GetVersionHex();
+}
diff --git a/intern/opencolorio/ocio_impl.h b/intern/opencolorio/ocio_impl.h
index 8b666e8..4e7c1bc 100644
--- a/intern/opencolorio/ocio_impl.h
+++ b/intern/opencolorio/ocio_impl.h
@@ -110,6 +110,9 @@ public:
 	                           OCIO_CurveMappingSettings *curve_mapping_settings, bool predivide) = 0;
 	virtual void finishGLSLDraw(struct OCIO_GLSLDrawState *state) = 0;
 	virtual void freeGLState(struct OCIO_GLSLDrawState *state_r) = 0;
+
+	virtual const char *getVersionString(void) = 0;
+	virtual int getVersionHex(void) = 0;
 };
 
 class FallbackImpl : public IOCIOImpl {
@@ -194,6 +197,9 @@ public:
 	                   OCIO_CurveMappingSettings *curve_mapping_settings, bool predivide);
 	void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
 	void freeGLState(struct OCIO_GLSLDrawState *state_r);
+
+	const char *getVersionString(void);
+	int getVersionHex(void);
 };
 
 #ifdef WITH_OCIO
@@ -279,6 +285,9 @@ public:
 	                   OCIO_CurveMappingSettings *curve_mapping_settings, bool predivide);
 	void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
 	void freeGLState(struct OCIO_GLSLDrawState *state_r);
+
+	const char *getVersionString(void);
+	int getVersionHex(void);
 };
 #endif
 
diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py
index 83f2647..ef3e562 100644
--- a/release/scripts/modules/sys_info.py
+++ b/release/scripts/modules/sys_info.py
@@ -118,6 +118,36 @@ def write_sysinfo(op):
     else:
         output.write("Blender was built without FFmpeg support\n")
 
+    output.write("\nOther Libraries:\n")
+    output.write(lilies)
+    ocio = bpy.app.ocio
+    output.write("OpenColorIO: ")
+    if ocio.supported:
+        if ocio.version_string == "fallback":
+            output.write("Blender was built with OpenColorIO, " +
+                         "but it currently uses fallback color management.\n")
+        else:
+            output.write("%s\n" % (ocio.version_string))
+    else:
+        output.write("Blender was built without OpenColorIO support\n")
+
+    oiio = bpy.app.oiio
+    output.write("OpenImageIO: ")
+    if ocio.supported :
+        output.write("%s\n" % (oiio.version_string))
+    else:
+        output.write("Blender was built without OpenImageIO support\n")
+
+    output.write("OpenShadingLanguuage: ")
+    if bpy.app.build_options.cycles:
+        if bpy.app.build_options.cycles_osl:
+            from _cycles import osl_version_string
+            output.write("%s\n" % (osl_version_string))
+        else:
+            output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
+    else:
+        output.write("Blender was built without Cycles support\n")
+
     if bpy.app.background:
         output.write("\nOpenGL: missing, background mode\n")
     else:
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index fe74b8f..ec9c8fd 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -275,6 +275,11 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
 	}
 }
 
+int OIIO_getVersionHex(void)
+{
+	return openimageio_version();
+}
+
 } // export "C"
 
 
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.h b/source/blender/imbuf/intern/oiio/openimageio_api.h
index ad11f4b..df11225 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.h
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.h
@@ -39,12 +39,16 @@ extern "C" {
 
 #include <stdio.h>
 
+struct ImBuf;
+
 int		imb_is_a_photoshop			(const char *name);
 
 int		imb_save_photoshop			(struct ImBuf *ibuf, const char *name, int flags);
 
 struct ImBuf *imb_load_photoshop (const char *name, int flags, char *colorspace);
 
+int OIIO_getVersionHex(void);
+
 #ifdef __cplusplus
 }
 
diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript
index 0ac0285..3378c43 100644
--- a/source/blender/python/SConscript
+++ b/source/blender/python/SConscript
@@ -183,8 +183,13 @@ if env['WITH_BF_SMOKE']:
 if env['WITH_BF_COLLADA']:
     defs.append('WITH_COLLADA')
 
-if env['WITH_BF_OIIO']:
+if env['WITH_BF_OCIO']:
     defs.append('WITH_OCIO')
+    incs += ' ' + '#/intern/opencolorio'
+
+if env['WITH_BF_OIIO']:
+    defs.append('WITH_OPENIMAGEIO')
+    incs += ' ../../imbuf/intern/oiio'
 
 if env['WITH_BF_PLAYER']:
     defs.append('WITH_PLAYER')
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index ef5d26d..0605f40 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -35,6 +35,7 @@ set(INC
 	../../makesrna
 	../../windowmanager
 	../../../../intern/cycles/blender
+	../../../../intern/opencolorio
 	../../../../intern/guardedalloc
 )
 
@@ -49,6 +50,8 @@ set(SRC
 	bpy_app_ffmpeg.c
 	bpy_app_build_options.c
 	bpy_app_handlers.c
+	bpy_app_ocio.c
+	bpy_app_oiio.c
 	bpy_app_translations.c
 	bpy_driver.c
 	bpy_interface.c
@@ -73,6 +76,8 @@ set(SRC
 	bpy_app_ffmpeg.h
 	bpy_app_build_options.h
 	bpy_app_handlers.h
+	bpy_app_ocio.h
+	bpy_app_oiio.h
 	bpy_app_translations.h
 	bpy_driver.h
 	bpy_intern_string.h
@@ -242,6 +247,13 @@ if(WITH_OPENCOLORIO)
 	add_definitions(-DWITH_OCIO)
 endif()
 
+if(WITH_OPENIMAGEIO)
+	add_definitions(-DWITH_OPENIMAGEIO)
+	list(APPEND INC
+		../../imbuf/intern/oiio
+	)
+endif()
+
 if(WITH_PLAYER)
 	add_definitions(-DWITH_PLAYER)
 endif()
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 2176719..795015c 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -34,6 +34,8 @@
 #include "bpy_app.h"
 
 #include "bpy_app_ffmpeg.h"
+#include "bpy_app_ocio.h"
+#include "bpy_app_oiio.h"
 #include "bpy_app_build_options.h"
 
 #include "bpy_app_translations.h"
@@ -93,6 +95,8 @@ static PyStructSequence_Field app_info_fields[] = {
 
 	/* submodules */
 	{(char *)"ffmpeg", (char *)"FFmpeg library information backend"},
+	{(char *)"ocio", (char *)"OpenColorIO library information backend"},
+	{(char *)"oiio", (char *)"OpenImageIO library information backend"},
 	{(char *)"build_options", (char *)"A set containing most important enabled optional build features"},
 	{(char *)"handlers", (char *)"Application handler callbacks"},
 	{(char *)"translations", (char *)"Application and addons internationalization API"},
@@ -167,6 +171,8 @@ static PyObject *make_app_info(void)
 #endif
 
 	SetObjItem(BPY_app_ffmpeg_struct());
+	SetObjItem(BPY_app_ocio_struct());
+	SetObjItem(BPY_app_oiio_struct());
 	SetObjItem(BPY_app_build_options_struct());
 	SetObjItem(BPY_app_handlers_struct());
 	SetObjItem(BPY_app_translations_struct());
diff --git a/source/blender/python/intern/bpy_app_ocio.c b/source/blender/python/intern/bpy_app_ocio.c
new file mode 100644
index 00

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list