[Bf-blender-cvs] [62fe7e9a9d0] master: GPU: support default framebuffer with ID not equal to 0
Commit: 62fe7e9a9d0e211bc2ad4cdfedb2489c5f899133 Author: Tomoaki Kawada Date: Sat Jun 1 17:54:07 2019 +0200 Branches: master https://developer.blender.org/rB62fe7e9a9d0e211bc2ad4cdfedb2489c5f899133 GPU: support default framebuffer with ID not equal to 0 === M intern/ghost/GHOST_C-api.h M intern/ghost/GHOST_IWindow.h M intern/ghost/intern/GHOST_C-api.cpp M intern/ghost/intern/GHOST_Context.h M intern/ghost/intern/GHOST_Window.cpp M intern/ghost/intern/GHOST_Window.h M source/blender/draw/engines/eevee/eevee_lightcache.c M source/blender/draw/intern/draw_manager.c M source/blender/gpu/GPU_context.h M source/blender/gpu/intern/gpu_context.cpp M source/blender/gpu/intern/gpu_context_private.h M source/blender/gpu/intern/gpu_extensions.c M source/blender/gpu/intern/gpu_framebuffer.c M source/blender/render/intern/source/pipeline.c M source/blender/windowmanager/intern/wm_playanim.c M source/blender/windowmanager/intern/wm_window.c === diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 3238be8fd87..ea9d6925e23 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -721,6 +721,11 @@ extern GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthan */ extern GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle); +/** + * Get the OpenGL framebuffer handle that serves as a default framebuffer. + */ +extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windwHandle); + /** * Set which tablet API to use. Only affects Windows, other platforms have a single API. * \param systemhandle The handle to the system diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h index 8042244c536..52894a7c38d 100644 --- a/intern/ghost/GHOST_IWindow.h +++ b/intern/ghost/GHOST_IWindow.h @@ -217,6 +217,12 @@ class GHOST_IWindow { */ virtual GHOST_TSuccess activateDrawingContext() = 0; + /** + * Gets the OpenGL framebuffer associated with the window's contents. + * \return The name of an OpenGL framebuffer object. + */ + virtual unsigned int getDefaultFramebuffer() = 0; + /** * Invalidates the contents of this window. * \return Indication of success. diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 38ddf9819f9..ef653c114e8 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -633,6 +633,13 @@ GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle) return context->releaseDrawingContext(); } +unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle) +{ + GHOST_IWindow *window = (GHOST_IWindow *)windowhandle; + + return window->getDefaultFramebuffer(); +} + GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle) { GHOST_IWindow *window = (GHOST_IWindow *)windowhandle; diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h index 7937fd1f7c7..bbf6d6a510d 100644 --- a/intern/ghost/intern/GHOST_Context.h +++ b/intern/ghost/intern/GHOST_Context.h @@ -119,6 +119,15 @@ class GHOST_Context : public GHOST_IContext { return m_stereoVisual; } + /** + * Gets the OpenGL framebuffer associated with the OpenGL context + * \return The ID of an OpenGL framebuffer object. + */ + virtual unsigned int getDefaultFramebuffer() + { +return 0; + } + protected: void initContextGLEW(); diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp index 5649386063d..76f2d2347db 100644 --- a/intern/ghost/intern/GHOST_Window.cpp +++ b/intern/ghost/intern/GHOST_Window.cpp @@ -109,6 +109,11 @@ GHOST_TSuccess GHOST_Window::getSwapInterval(int &intervalOut) return m_context->getSwapInterval(intervalOut); } +unsigned int GHOST_Window::getDefaultFramebuffer() +{ + return (m_context) ? m_context->getDefaultFramebuffer() : 0; +} + GHOST_TSuccess GHOST_Window::activateDrawingContext() { return m_context->activateDrawingContext(); diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index acd0c93ff87..50a563453f6 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -261,6 +261,12 @@ class GHOST_Window : public GHOST_IWindow { */ GHOST_TSuccess updateDrawingContext(); + /** + * Gets the OpenGL framebuffer associated with the window's contents. + * \return The ID of an OpenGL framebuffer object. + */ + virtual unsigned int getDefaultFramebuffer(); + /** * Returns the window user data. * \return The window user data. diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/e
[Bf-blender-cvs] [99de160340c] master: macOS: fix viewport lagging, by using CAMetalLayer instead of NSOpenGLView
Commit: 99de160340c7ae08ac5abed12a541017e4846d87 Author: Tomoaki Kawada Date: Fri May 24 18:38:20 2019 +0200 Branches: master https://developer.blender.org/rB99de160340c7ae08ac5abed12a541017e4846d87 macOS: fix viewport lagging, by using CAMetalLayer instead of NSOpenGLView On GPUs that support it, we now present OpenGL contents via CAMetalLayer. This fixes frame skipping issues found in T60043. If the system does not have a Metal capable GPU, NSOpenGLView will continue to be used. Patch by Tomoaki Kawada, with some changes by Brecht Van Lommel. Differential Revision: https://developer.blender.org/D4619 === M build_files/cmake/platform/platform_apple.cmake M intern/ghost/intern/GHOST_ContextCGL.h M intern/ghost/intern/GHOST_ContextCGL.mm M intern/ghost/intern/GHOST_SystemCocoa.mm M intern/ghost/intern/GHOST_WindowCocoa.h M intern/ghost/intern/GHOST_WindowCocoa.mm M intern/ghost/intern/GHOST_WindowViewCocoa.h === diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 3366d49868d..d7c4370cde7 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -181,7 +181,7 @@ endif() set(PLATFORM_CFLAGS "-pipe -funsigned-char") set(PLATFORM_LINKFLAGS - "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio" + "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework Metal -framework QuartzCore" ) list(APPEND PLATFORM_LINKLIBS c++) diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h index b808effc795..37c1ac34299 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.h +++ b/intern/ghost/intern/GHOST_ContextCGL.h @@ -26,15 +26,23 @@ #include "GHOST_Context.h" -@class NSOpenGLView; +@class CAMetalLayer; +@class MTLCommandQueue; +@class MTLRenderPipelineState; +@class MTLTexture; @class NSOpenGLContext; +@class NSOpenGLView; +@class NSView; class GHOST_ContextCGL : public GHOST_Context { public: /** * Constructor. */ - GHOST_ContextCGL(bool stereoVisual, NSOpenGLView *openGLView); + GHOST_ContextCGL(bool stereoVisual, + NSView *metalView, + CAMetalLayer *metalLayer, + NSOpenGLView *openglView); /** * Destructor. @@ -59,6 +67,8 @@ class GHOST_ContextCGL : public GHOST_Context { */ GHOST_TSuccess releaseDrawingContext(); + unsigned int getDefaultFramebuffer(); + /** * Call immediately after new to initialize. If this fails then immediately delete the object. * \return Indication as to whether initialization has succeeded. @@ -94,12 +104,24 @@ class GHOST_ContextCGL : public GHOST_Context { GHOST_TSuccess updateDrawingContext(); private: - /** The openGL view */ + /** Metal state */ + NSView *m_metalView; + CAMetalLayer *m_metalLayer; + MTLCommandQueue *m_metalCmdQueue; + MTLRenderPipelineState *m_metalRenderPipeline; + + /** OpenGL state, for GPUs that don't support Metal */ NSOpenGLView *m_openGLView; /** The OpenGL drawing context */ NSOpenGLContext *m_openGLContext; + /** The virtualized default framebuffer */ + unsigned int m_defaultFramebuffer; + + /** The virtualized default framebuffer's texture */ + MTLTexture *m_defaultFramebufferMetalTexture; + bool m_coreProfile; const bool m_debug; @@ -107,6 +129,13 @@ class GHOST_ContextCGL : public GHOST_Context { /** The first created OpenGL context (for sharing display lists) */ static NSOpenGLContext *s_sharedOpenGLContext; static int s_sharedCount; + + /* Metal functions */ + void metalInit(); + void metalFree(); + void metalInitFramebuffer(); + void metalUpdateFramebuffer(); + void metalSwapBuffers(); }; #endif // __GHOST_CONTEXTCGL_H__ diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm index 5fe40cb04a0..12c340ffe97 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.mm +++ b/intern/ghost/intern/GHOST_ContextCGL.mm @@ -26,25 +26,61 @@ #include "GHOST_ContextCGL.h" #include +#include +#include #include #include +static void ghost_fatal_error_dialog(const char *msg) +{ + @autoreleasepool { +NSString *message = [NSString stringWithFormat:@"Error opening window:\n%s", msg]; + +NSAlert *alert = [[NSAlert alloc] init]; +[alert addButtonWithTitle:@"Quit"]; +[alert setMessageText:@"Blender"]; +[alert setInfor
[Bf-blender-cvs] [9e3246ce6e9] master: Fix T63794: duplicating an armature clears B-Bones' custom handle references.
Commit: 9e3246ce6e9767148e4394dc7acbec04a7d69163 Author: Tomoaki Kawada Date: Sun Apr 28 16:19:45 2019 +0300 Branches: master https://developer.blender.org/rB9e3246ce6e9767148e4394dc7acbec04a7d69163 Fix T63794: duplicating an armature clears B-Bones' custom handle references. This patch fixes T63794 by updating duplicated bones' custom handle references to point to the new armature's bones. The problem occurs because B-Bones of a duplicated armature keep pointing to the old armature's bones. The references are cleared upon entering Edit Mode because there are no matching `EditBone` for such bones, and `find_ebone_link` just returns `NULL` in such cases. Reviewers: mont29, angavrilov Maniphest Tasks: T63794 Differential Revision: https://developer.blender.org/D4726 === M source/blender/blenkernel/intern/armature.c === diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 97238020f29..7f374c1d66e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -169,6 +169,28 @@ static void copy_bonechildren(Bone *bone_dst, } } +static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst, GHash **bone_hash) +{ + Bone *bone_dst_child; + + /* Lazily create the name -> bone hashtable. */ + if ((bone_dst->bbone_prev || bone_dst->bbone_next) && *bone_hash == NULL) { +*bone_hash = BKE_armature_bone_from_name_map(arm_dst); + } + + if (bone_dst->bbone_prev) { +bone_dst->bbone_prev = BLI_ghash_lookup(*bone_hash, bone_dst->bbone_prev->name); + } + if (bone_dst->bbone_next) { +bone_dst->bbone_next = BLI_ghash_lookup(*bone_hash, bone_dst->bbone_next->name); + } + + for (bone_dst_child = bone_dst->childbase.first; bone_dst_child; + bone_dst_child = bone_dst_child->next) { +copy_bonechildren_custom_handles(bone_dst_child, arm_dst, bone_hash); + } +} + /** * Only copy internal data of Armature ID from source * to already allocated/initialized destination. @@ -202,6 +224,17 @@ void BKE_armature_copy_data(Main *UNUSED(bmain), arm_dst->act_bone = bone_dst_act; + /* Fix custom handle references. */ + GHash *bone_hash = NULL; /* lazily created */ + + for (bone_dst = arm_dst->bonebase.first; bone_dst; bone_dst = bone_dst->next) { +copy_bonechildren_custom_handles(bone_dst, arm_dst, &bone_hash); + } + + if (bone_hash) { +BLI_ghash_free(bone_hash, NULL, NULL); + } + arm_dst->edbo = NULL; arm_dst->act_edbone = NULL; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs