[Bf-blender-cvs] [20bcc99] experimental-build: Decklink test build
Benoit Bolsee
noreply at git.blender.org
Sat Jan 9 11:33:13 CET 2016
Commit: 20bcc993e477400a6bac987c9d55da67c11c4646
Author: Benoit Bolsee
Date: Sat Jan 9 11:31:46 2016 +0100
Branches: experimental-build
https://developer.blender.org/rB20bcc993e477400a6bac987c9d55da67c11c4646
Decklink test build
===================================================================
M CMakeLists.txt
M build_files/cmake/macros.cmake
A doc/python_api/examples/bge.texture.2.py
M doc/python_api/rst/bge.logic.rst
M doc/python_api/rst/bge.render.rst
M doc/python_api/rst/bge.texture.rst
M doc/python_api/rst/bge_types/bge.types.BL_Shader.rst
M intern/CMakeLists.txt
M intern/atomic/atomic_ops.h
A intern/decklink/CMakeLists.txt
A intern/decklink/DeckLinkAPI.cpp
A intern/decklink/DeckLinkAPI.h
A intern/decklink/linux/DeckLinkAPI.h
A intern/decklink/linux/DeckLinkAPIConfiguration.h
A intern/decklink/linux/DeckLinkAPIConfiguration_v10_2.h
A intern/decklink/linux/DeckLinkAPIDeckControl.h
A intern/decklink/linux/DeckLinkAPIDiscovery.h
A intern/decklink/linux/DeckLinkAPIDispatch.cpp
A intern/decklink/linux/DeckLinkAPIDispatch_v7_6.cpp
A intern/decklink/linux/DeckLinkAPIDispatch_v8_0.cpp
A intern/decklink/linux/DeckLinkAPIModes.h
A intern/decklink/linux/DeckLinkAPITypes.h
A intern/decklink/linux/DeckLinkAPIVersion.h
A intern/decklink/linux/DeckLinkAPI_v10_2.h
A intern/decklink/linux/DeckLinkAPI_v7_1.h
A intern/decklink/linux/DeckLinkAPI_v7_3.h
A intern/decklink/linux/DeckLinkAPI_v7_6.h
A intern/decklink/linux/DeckLinkAPI_v7_9.h
A intern/decklink/linux/DeckLinkAPI_v8_0.h
A intern/decklink/linux/DeckLinkAPI_v8_1.h
A intern/decklink/linux/DeckLinkAPI_v9_2.h
A intern/decklink/linux/DeckLinkAPI_v9_9.h
A intern/decklink/linux/LinuxCOM.h
A intern/decklink/win/DeckLinkAPI_h.h
A intern/decklink/win/DeckLinkAPI_i.c
M intern/ghost/CMakeLists.txt
M intern/ghost/GHOST_ISystem.h
M intern/ghost/GHOST_Types.h
M intern/ghost/intern/GHOST_ContextGLX.cpp
M intern/ghost/intern/GHOST_ContextGLX.h
M intern/ghost/intern/GHOST_ContextWGL.cpp
M intern/ghost/intern/GHOST_ContextWGL.h
M intern/ghost/intern/GHOST_System.cpp
M intern/ghost/intern/GHOST_System.h
M intern/ghost/intern/GHOST_SystemWin32.cpp
M intern/ghost/intern/GHOST_SystemX11.cpp
M intern/ghost/intern/GHOST_WindowWin32.cpp
M intern/ghost/intern/GHOST_WindowWin32.h
M intern/ghost/intern/GHOST_WindowX11.cpp
M intern/ghost/intern/GHOST_WindowX11.h
A intern/gpudirect/CMakeLists.txt
A intern/gpudirect/dvpapi.cpp
A intern/gpudirect/dvpapi.h
M intern/moto/include/MT_Matrix4x4.h
M source/blender/gpu/GPU_texture.h
M source/blender/gpu/intern/gpu_framebuffer.c
M source/blender/gpu/intern/gpu_texture.c
M source/blender/python/generic/bgl.c
M source/blenderplayer/CMakeLists.txt
M source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
M source/gameengine/GamePlayer/ghost/GPG_Application.cpp
M source/gameengine/GamePlayer/ghost/GPG_Application.h
M source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
M source/gameengine/Ketsji/BL_Shader.cpp
M source/gameengine/Ketsji/BL_Shader.h
M source/gameengine/Ketsji/KX_Dome.cpp
M source/gameengine/Ketsji/KX_KetsjiEngine.cpp
M source/gameengine/Ketsji/KX_KetsjiEngine.h
M source/gameengine/Ketsji/KX_PythonInit.cpp
M source/gameengine/Ketsji/KX_Scene.cpp
M source/gameengine/Ketsji/KX_Scene.h
M source/gameengine/Rasterizer/CMakeLists.txt
A source/gameengine/Rasterizer/RAS_IOffScreen.h
M source/gameengine/Rasterizer/RAS_IRasterizer.h
A source/gameengine/Rasterizer/RAS_ISync.h
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
A source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp
A source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
A source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp
A source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h
M source/gameengine/VideoTexture/CMakeLists.txt
M source/gameengine/VideoTexture/Common.h
A source/gameengine/VideoTexture/DeckLink.cpp
A source/gameengine/VideoTexture/DeckLink.h
M source/gameengine/VideoTexture/Exception.cpp
M source/gameengine/VideoTexture/Exception.h
M source/gameengine/VideoTexture/FilterBase.h
M source/gameengine/VideoTexture/FilterSource.h
M source/gameengine/VideoTexture/ImageBase.cpp
M source/gameengine/VideoTexture/ImageBase.h
M source/gameengine/VideoTexture/ImageMix.cpp
M source/gameengine/VideoTexture/ImageRender.cpp
M source/gameengine/VideoTexture/ImageRender.h
M source/gameengine/VideoTexture/ImageViewport.cpp
M source/gameengine/VideoTexture/ImageViewport.h
M source/gameengine/VideoTexture/Texture.cpp
M source/gameengine/VideoTexture/VideoBase.cpp
M source/gameengine/VideoTexture/VideoBase.h
A source/gameengine/VideoTexture/VideoDeckLink.cpp
A source/gameengine/VideoTexture/VideoDeckLink.h
M source/gameengine/VideoTexture/VideoFFmpeg.cpp
M source/gameengine/VideoTexture/blendVideoTex.cpp
===================================================================
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d9d515..7ebad3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -231,6 +231,7 @@ option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported
mark_as_advanced(WITH_SYSTEM_BULLET)
option(WITH_GAMEENGINE "Enable Game Engine" ${_init_GAMEENGINE})
option(WITH_PLAYER "Build Player" OFF)
+option(WITH_DECKLINK "Support BlackMagicDesign DeckLink cards in the BGE" OFF)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
# Compositor
@@ -275,6 +276,7 @@ endif()
if(WITH_X11)
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON)
+ option(WITH_X11_ALPHA "Enable X11 transparent background" ON)
endif()
if(UNIX AND NOT APPLE)
@@ -711,6 +713,7 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS)
set(WITH_X11 OFF)
set(WITH_X11_XINPUT OFF)
set(WITH_X11_XF86VMODE OFF)
+ set(WITH_X11_ALPHA OFF)
set(WITH_GHOST_XDND OFF)
set(WITH_INPUT_IME OFF)
endif()
@@ -855,6 +858,16 @@ if(WITH_X11)
endif()
endif()
+ if(WITH_X11_ALPHA)
+ find_library(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH})
+ mark_as_advanced(X11_Xrender_LIB)
+ if (X11_Xrender_LIB)
+ list(APPEND PLATFORM_LINKLIBS ${X11_Xrender_LIB})
+ else()
+ set(WITH_X11_ALPHA OFF)
+ endif()
+ endif()
+
endif()
@@ -2988,6 +3001,7 @@ if(FIRST_RUN)
info_cfg_text("System Options:")
info_cfg_option(WITH_INSTALL_PORTABLE)
+ info_cfg_option(WITH_X11_ALPHA)
info_cfg_option(WITH_X11_XF86VMODE)
info_cfg_option(WITH_X11_XINPUT)
info_cfg_option(WITH_MEM_JEMALLOC)
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index cacc741..8fad0bd 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -311,7 +311,6 @@ function(SETUP_LIBDIRS)
if(WITH_MEM_JEMALLOC)
link_directories(${JEMALLOC_LIBPATH})
endif()
-
if(WIN32 AND NOT UNIX)
link_directories(${PTHREADS_LIBPATH})
endif()
@@ -705,6 +704,14 @@ function(SETUP_BLENDER_SORTED_LIBS)
list_insert_after(BLENDER_SORTED_LIBS "ge_logic_ngnetwork" "extern_bullet")
endif()
+ if(WITH_DECKLINK)
+ list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink)
+ endif()
+
+ if(WIN32)
+ list(APPEND BLENDER_SORTED_LIBS bf_intern_gpudirect)
+ endif()
+
if(WITH_OPENSUBDIV)
list(APPEND BLENDER_SORTED_LIBS bf_intern_opensubdiv)
endif()
diff --git a/doc/python_api/examples/bge.texture.2.py b/doc/python_api/examples/bge.texture.2.py
new file mode 100644
index 0000000..0abbfe1
--- /dev/null
+++ b/doc/python_api/examples/bge.texture.2.py
@@ -0,0 +1,154 @@
+"""
+Video Capture with DeckLink
++++++++++++++++++++++++++++
+Video frames captured with DeckLink cards have pixel formats that are not directly usable by OpenGL,
+they must be processed by a shader. Two shaders are presented here, for the 'r210' and 'v210' pixel
+formats:
+"""
+import bge
+from bge import logic
+from bge import texture as vt
+
+fragment_shaders = {
+'r210': """
+#version 130
+uniform usampler2D tex;
+// stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)
+uniform float stereo;
+// eye = 0.0 for the left eye, 0.5 for the right eye
+uniform float eye;
+
+void main(void)
+{
+ vec4 color;
+ unsigned int r;
+ float tx, ty;
+ tx = gl_TexCoord[0].x;
+ ty = eye+gl_TexCoord[0].y*stereo;
+ r = texture(tex, vec2(tx, ty)).r;
+ color.b = float((((r >> 24U)&0xFFU)+((r>>8U)&0x300U))-64U)*0.001136364;
+ color.g = float((((r >> 18U)&0x3FU)+((r>>2U)&0x3C0U))-64U)*0.001136364;
+ color.r = float((((r >> 12U)&0x0FU)+((r<<4U)&0x3F0U))-64U)*0.001136364;
+ // Set alpha to 0.7 for partial transparency when GL_BLEND is enabled
+ color.a = 0.7;
+ gl_FragColor = color;
+}
+""",
+
+'v210':"""
+#version 130
+uniform usampler2D tex;
+// stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)
+uniform float stereo;
+// eye = 0.0 for the left eye, 0.5 for the right eye
+uniform float eye;
+
+void main(void)
+{
+ vec4 color;
+ float tx, ty;
+ float width, sx, dx, Y, U, V, bx;
+ unsigned int w0, w1, w2, w3;
+ int px;
+
+ tx = gl_TexCoord[0].x;
+ ty = eye+gl_TexCoord[0].y*stereo;
+ // size of the texture (=real size * 2/3)
+ width = float(textureSize(tex, 0).x);
+ // to sample macro pixels (6 pixels in 4 words)
+ sx = tx*width*0.25+0.05;
+ // index of display pixel in the macro pixel 0..5
+ px = int(floor(fract(sx)*6.0));
+ // increment as we sample the macro pixel
+ dx = 1.0/width;
+ // base x coord of macro pixel
+ bx = (floor(sx)+0.01)*dx*4.0;
+ // load the 4 words components of the macro pixel
+ w0 = texture(tex, vec2(bx, ty)).r;
+ w1 = texture(tex, vec2(bx+dx, ty)).r;
+ w2 = texture(tex, vec2(bx+dx*2.0, ty)).r;
+ w3 = texture(tex, vec2(bx+dx*3.0, ty)).r;
+ switch (px) {
+ case 0:
+ case 1:
+ U = float( w0 &0x3FFU);
+ V = float((w0>>20U)&0x3FFU);
+ break;
+ case 2:
+ case 3:
+ U = float((w1>>10U)&0x3FFU);
+ V = float( w2 &0x3FFU);
+ break;
+ default:
+ U = float((w2>>20U)&0x3FFU);
+ V = float((w3>>10U)&0x3FFU);
+ break;
+ }
+ switch (px) {
+ case 0:
+ Y = float((w0>>10U)&0x3FFU);
+ break;
+ case 1:
+ Y = float( w1 &0x3FFU);
+ break;
+ case 2:
+ Y = float((w1>>20U)&0x3FFU);
+ break;
+ case 3:
+ Y = float((w2>>10U)&0x3FFU);
+ break;
+ case 4:
+ Y = float( w3 &0x3FFU);
+ break;
+ default:
+ Y = float((w3>>20U)&0x3FFU);
+ break;
+ }
+ Y = (Y-64.0)*0.001141553;
+ U = (U-64.0)*0.001116071-0.5;
+ V = (V-64.0)*0.001116071-0.5;
+ color.r = Y + 1.5748 * V;
+ color.g = Y - 0.1873 * U - 0.4681 * V;
+ color.b = Y + 1.8556 * U;
+ color.a = 0.7;
+ gl_FragColor = color;
+}
+"""
+}
+
+#
+# Helper function to attach a pixel shader to the material that receives the video frame.
+#
+def add_shader(obj, pixel, matId, is_3D):
+ if pixel in fragment_shaders:
+ frag = fragment_shaders[pixel]
+ mat = obj.meshes[0].materials[matId]
+ shader = mat.getShader()
+ if shader != None and not shader.isValid():
+ shader.setSource("", frag, 1)
+ shader.setUniform1i("tex", 0)
+ shader.setUniformEyef("eye")
+ shader.setUniform1f("stereo", 0.5 if is_3D else 1.0);
+
+#
+# To be called once to initialize the object
+#
+def init(cont):
+ obj = cont.owner
+ if not "video" in obj:
+ matId = vt.materialID(obj, 'IMvideo.png')
+ add_shader(obj, 'r210', matId, True)
+ tex = vt.Texture(obj, matId)
+ tex.source = vt.VideoDeckLink("HD1080p24/r210/3D", 0)
+ tex.source.play()
+ obj["video"] = tex
+
+#
+# To be called on every frame
+#
+def play(cont):
+ obj = cont.owner
+ try:
+ obj["video"].refresh(True)
+ except:
+ pass
diff --git a/doc/python_api/rst/bge.logic.rst b/doc/python_api/rst/bge.logic.rst
index 3f35901..0967610 100644
--- a/doc/python_api/rst/bge.logic.rst
+++ b/doc/python_api/rst/bge.logic.rst
@@ -378,6 +378,27 @@ General functions
Render next frame (if Python has control)
+.. function:: setRender(render)
+
+ Sets the global flag that controls the render of the scene.
+ If True, the render is done after the logic frame.
+ If False, the render is skipped and another logic frame starts immediately.
+
+ .. note::
+ GPU VSync no longer limits the number of frame per second when render is off,
+ but the 'Use Frame Rate' option still regulates the fps. To run as many frames
+ as possible, untick this option (Render Properties, System panel)
+
+ :arg render: the render flag
+ :type render: bool
+
+.. function:: getRender()
+
+ Get the current value of the global render flag
+
+ :return: The flag value
+ :rtype: bool
+
**********************
Time related functions
**********************
diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst
index 3b565e2..0c6f9a9 100644
--- a/doc/python_api/rst/bge.render.rst
+++ b/doc/python_api/rst/bge.render.rst
@@ -90,6 +90,43 @@ Constants
Right eye being used during stereoscopic rendering.
+.. data:: RAS_OFS_RENDER_BUFFER
+
+ The pixel buffer for offscreen render is a RenderBuffer. Argument to :func:`offScreenCreate`
+
+.. data:: RAS_OFS_RENDER_TEXTURE
+
+ The pixel buffer for offscreen render is a Texture. Argument to :func:`offScreenCreate`
+
+*****
+Types
+*****
+
+.. class:: RASOffScreen
+
+ An off-screen render buffer object.
+
+ Use :func:`offScreenCreate` to create it.
+ Currently it can only be used in the :class:`bge.texture.ImageRender` constructor to render on a FBO rather than the
+ default viewport.
+
+ .. attribute:: width
+
+ The width in pixel of the FBO
+
+ :type: integer
+
+ .. attribute:: height
+
+ The height in pixel of the FBO
+
+ :type: integer
+
+ .. attribute:: color
+
+ The underlying OpenGL bind code of the texture object that holds the rendered image, 0 if the FBO is using RenderBuffer. The choice between RenderBuffer and Texture is determined by the target argument of :func:`offScreenCreate`.
+
+ :type: integer
*********
Functions
@@ -362,3 +399,18 @@ Functions
Get the current vsync value
:rtype: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE
+
+.. function:: offScreenCreate(width,height[,samples=0][,target=bge.render.RAS_OFS_RENDER_BUFFER])
+
+ Create a Off-screen render buffer object.
+
+ :arg width: the width of the buffer in pixels
+ :type width: integer
+ :arg height: the height of the buffer in pixels
+ :type height: integer
+ :arg samples: the number of multisample for anti-aliasing (MSAA), 0 to disable MSAA
+ :type samples: integer
+ :arg target: the pixel storage: :data:`RAS_OFS_RENDER_BUFFER` to render on RenderBuffers (the default), :data:`RAS_OFS_RENDER_TEXTURE` to render on texture. The later is interesting if you want to access the texture directly (see :attr:`RASOffScreen.color`). Otherwise the default is preferable as it's more widely supported by GPUs and more efficient. If
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list