forked from bartvdbraak/blender
Cleanup: renaming of GPU contexts for clarity
* opengl_context -> system_gpu_context. This is the operating system OpenGL, Metal or Vulkan context provided by GHOST. * gpu_context -> blender_gpu_context. This is the GPUContext provided by the Blender GPU module, which wraps the GHOST context and adds some state. * Various functions create/destroy/enable/disable both contexts, these have just gpu_context in the name now. Pull Request: https://projects.blender.org/blender/blender/pulls/108723
This commit is contained in:
parent
a20162392e
commit
a2bd080cf3
@ -162,7 +162,7 @@ extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
|
||||
* \param height: The height the window.
|
||||
* \param state: The state of the window when opened.
|
||||
* \param is_dialog: Stay on top of parent window, no icon in taskbar, can't be minimized.
|
||||
* \param glSettings: Misc OpenGL options.
|
||||
* \param gpuSettings: Misc GPU options.
|
||||
* \return A handle to the new window ( == NULL if creation failed).
|
||||
*/
|
||||
extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
|
||||
@ -174,17 +174,17 @@ extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
bool is_dialog,
|
||||
GHOST_GLSettings glSettings);
|
||||
GHOST_GPUSettings gpuSettings);
|
||||
|
||||
/**
|
||||
* Create a new off-screen context.
|
||||
* Never explicitly delete the context, use #disposeContext() instead.
|
||||
* \param systemhandle: The handle to the system.
|
||||
* \param glSettings: Misc OpenGL options.
|
||||
* \param gpuSettings: Misc GPU options.
|
||||
* \return A handle to the new context ( == NULL if creation failed).
|
||||
*/
|
||||
extern GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_GLSettings glSettings);
|
||||
extern GHOST_ContextHandle GHOST_CreateGPUContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_GPUSettings gpuSettings);
|
||||
|
||||
/**
|
||||
* Dispose of a context.
|
||||
@ -192,8 +192,8 @@ extern GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemha
|
||||
* \param contexthandle: Handle to the context to be disposed.
|
||||
* \return Indication of success.
|
||||
*/
|
||||
extern GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_ContextHandle contexthandle);
|
||||
extern GHOST_TSuccess GHOST_DisposeGPUContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_ContextHandle contexthandle);
|
||||
|
||||
/**
|
||||
* Returns the window user data.
|
||||
@ -730,24 +730,24 @@ extern GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle);
|
||||
* \param contexthandle: The handle to the context.
|
||||
* \return A success indicator.
|
||||
*/
|
||||
extern GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthandle);
|
||||
extern GHOST_TSuccess GHOST_ActivateGPUContext(GHOST_ContextHandle contexthandle);
|
||||
|
||||
/**
|
||||
* Release the drawing context bound to this thread.
|
||||
* \param contexthandle: The handle to the context.
|
||||
* \return A success indicator.
|
||||
*/
|
||||
extern GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle);
|
||||
extern GHOST_TSuccess GHOST_ReleaseGPUContext(GHOST_ContextHandle contexthandle);
|
||||
|
||||
/**
|
||||
* Get the OpenGL frame-buffer handle that serves as a default frame-buffer.
|
||||
* Get the GPU frame-buffer handle that serves as a default frame-buffer.
|
||||
*/
|
||||
extern unsigned int GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle contexthandle);
|
||||
extern unsigned int GHOST_GetContextDefaultGPUFramebuffer(GHOST_ContextHandle contexthandle);
|
||||
|
||||
/**
|
||||
* Get the OpenGL frame-buffer handle that serves as a default frame-buffer.
|
||||
* Get the GPU frame-buffer handle that serves as a default frame-buffer.
|
||||
*/
|
||||
extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle);
|
||||
extern unsigned int GHOST_GetDefaultGPUFramebuffer(GHOST_WindowHandle windowhandle);
|
||||
|
||||
/**
|
||||
* Use multi-touch gestures if supported.
|
||||
@ -1072,7 +1072,7 @@ int GHOST_XrSessionIsRunning(const GHOST_XrContextHandle xr_context);
|
||||
|
||||
/**
|
||||
* Check if \a xr_context has a session that requires an upside-down frame-buffer (compared to
|
||||
* OpenGL). If true, the render result should be flipped vertically for correct output.
|
||||
* GPU). If true, the render result should be flipped vertically for correct output.
|
||||
* \note Only to be called after session start, may otherwise result in a false negative.
|
||||
*/
|
||||
int GHOST_XrSessionNeedsUpsideDownDrawing(const GHOST_XrContextHandle xr_context);
|
||||
|
@ -230,7 +230,7 @@ class GHOST_ISystem {
|
||||
* \param width: The width the window.
|
||||
* \param height: The height the window.
|
||||
* \param state: The state of the window when opened.
|
||||
* \param glSettings: Misc OpenGL settings.
|
||||
* \param gpuSettings: Misc GPU settings.
|
||||
* \param exclusive: Use to show the window on top and ignore others (used full-screen).
|
||||
* \param is_dialog: Stay on top of parent window, no icon in taskbar, can't be minimized.
|
||||
* \param parentWindow: Parent (embedder) window
|
||||
@ -242,7 +242,7 @@ class GHOST_ISystem {
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive = false,
|
||||
const bool is_dialog = false,
|
||||
const GHOST_IWindow *parentWindow = NULL) = 0;
|
||||
@ -259,7 +259,7 @@ class GHOST_ISystem {
|
||||
* Never explicitly delete the context, use #disposeContext() instead.
|
||||
* \return The new context (or 0 if creation failed).
|
||||
*/
|
||||
virtual GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings) = 0;
|
||||
virtual GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings) = 0;
|
||||
|
||||
/**
|
||||
* Dispose of a context.
|
||||
|
@ -64,9 +64,9 @@ typedef struct {
|
||||
} GHOST_CursorBitmapRef;
|
||||
|
||||
typedef enum {
|
||||
GHOST_glStereoVisual = (1 << 0),
|
||||
GHOST_glDebugContext = (1 << 1),
|
||||
} GHOST_GLFlags;
|
||||
GHOST_gpuStereoVisual = (1 << 0),
|
||||
GHOST_gpuDebugContext = (1 << 1),
|
||||
} GHOST_GPUFlags;
|
||||
|
||||
typedef enum GHOST_DialogOptions {
|
||||
GHOST_DialogWarning = (1 << 0),
|
||||
@ -681,7 +681,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
int flags;
|
||||
GHOST_TDrawingContextType context_type;
|
||||
} GHOST_GLSettings;
|
||||
} GHOST_GPUSettings;
|
||||
|
||||
typedef enum {
|
||||
/** Axis that cursor grab will wrap. */
|
||||
|
@ -135,16 +135,16 @@ void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
|
||||
system->getAllDisplayDimensions(*width, *height);
|
||||
}
|
||||
|
||||
GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_GLSettings glSettings)
|
||||
GHOST_ContextHandle GHOST_CreateGPUContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_GPUSettings gpuSettings)
|
||||
{
|
||||
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
|
||||
|
||||
return (GHOST_ContextHandle)system->createOffscreenContext(glSettings);
|
||||
return (GHOST_ContextHandle)system->createOffscreenContext(gpuSettings);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_ContextHandle contexthandle)
|
||||
GHOST_TSuccess GHOST_DisposeGPUContext(GHOST_SystemHandle systemhandle,
|
||||
GHOST_ContextHandle contexthandle)
|
||||
{
|
||||
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
|
||||
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
|
||||
@ -161,7 +161,7 @@ GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
bool is_dialog,
|
||||
GHOST_GLSettings glSettings)
|
||||
GHOST_GPUSettings gpuSettings)
|
||||
{
|
||||
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
|
||||
|
||||
@ -171,7 +171,7 @@ GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
|
||||
width,
|
||||
height,
|
||||
state,
|
||||
glSettings,
|
||||
gpuSettings,
|
||||
false,
|
||||
is_dialog,
|
||||
(GHOST_IWindow *)parent_windowhandle);
|
||||
@ -716,7 +716,7 @@ GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandl
|
||||
return window->activateDrawingContext();
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthandle)
|
||||
GHOST_TSuccess GHOST_ActivateGPUContext(GHOST_ContextHandle contexthandle)
|
||||
{
|
||||
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
|
||||
if (context) {
|
||||
@ -726,21 +726,21 @@ GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthandle)
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle)
|
||||
GHOST_TSuccess GHOST_ReleaseGPUContext(GHOST_ContextHandle contexthandle)
|
||||
{
|
||||
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
|
||||
|
||||
return context->releaseDrawingContext();
|
||||
}
|
||||
|
||||
uint GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle contexthandle)
|
||||
uint GHOST_GetContextDefaultGPUFramebuffer(GHOST_ContextHandle contexthandle)
|
||||
{
|
||||
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
|
||||
|
||||
return context->getDefaultFramebuffer();
|
||||
}
|
||||
|
||||
uint GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle)
|
||||
uint GHOST_GetDefaultGPUFramebuffer(GHOST_WindowHandle windowhandle)
|
||||
{
|
||||
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
|
||||
|
||||
|
@ -397,12 +397,12 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window,
|
||||
const GHOST_DisplaySetting &settings,
|
||||
const bool stereoVisual)
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
|
||||
if (stereoVisual) {
|
||||
glSettings.flags |= GHOST_glStereoVisual;
|
||||
gpuSettings.flags |= GHOST_gpuStereoVisual;
|
||||
}
|
||||
glSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
|
||||
gpuSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
|
||||
/* NOTE: don't use #getCurrentDisplaySetting() because on X11 we may
|
||||
* be zoomed in and the desktop may be bigger than the viewport. */
|
||||
GHOST_ASSERT(m_displayManager,
|
||||
@ -414,7 +414,7 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window,
|
||||
settings.xPixels,
|
||||
settings.yPixels,
|
||||
GHOST_kWindowStateNormal,
|
||||
glSettings,
|
||||
gpuSettings,
|
||||
true /* exclusive */);
|
||||
return (*window == nullptr) ? GHOST_kFailure : GHOST_kSuccess;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class GHOST_System : public GHOST_ISystem {
|
||||
* Never explicitly delete the context, use #disposeContext() instead.
|
||||
* \return The new context (or 0 if creation failed).
|
||||
*/
|
||||
virtual GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings) = 0;
|
||||
virtual GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings) = 0;
|
||||
|
||||
/**
|
||||
* Returns whether a window is valid.
|
||||
|
@ -77,7 +77,7 @@ class GHOST_SystemCocoa : public GHOST_System {
|
||||
* \param width: The width the window.
|
||||
* \param height: The height the window.
|
||||
* \param state: The state of the window when opened.
|
||||
* \param glSettings: Misc OpenGL settings.
|
||||
* \param gpuSettings: Misc GPU settings.
|
||||
* \param exclusive: Use to show the window on top and ignore others (used full-screen).
|
||||
* \param parentWindow: Parent (embedder) window.
|
||||
* \return The new window (or 0 if creation failed).
|
||||
@ -88,7 +88,7 @@ class GHOST_SystemCocoa : public GHOST_System {
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive = false,
|
||||
const bool is_dialog = false,
|
||||
const GHOST_IWindow *parentWindow = NULL);
|
||||
@ -98,7 +98,7 @@ class GHOST_SystemCocoa : public GHOST_System {
|
||||
* Never explicitly delete the context, use #disposeContext() instead.
|
||||
* \return The new context (or 0 if creation failed).
|
||||
*/
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings);
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings);
|
||||
|
||||
/**
|
||||
* Dispose of a context.
|
||||
|
@ -696,7 +696,7 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const char *title,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive,
|
||||
const bool is_dialog,
|
||||
const GHOST_IWindow *parentWindow)
|
||||
@ -725,9 +725,9 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const char *title,
|
||||
width,
|
||||
height,
|
||||
state,
|
||||
glSettings.context_type,
|
||||
glSettings.flags & GHOST_glStereoVisual,
|
||||
glSettings.flags & GHOST_glDebugContext,
|
||||
gpuSettings.context_type,
|
||||
gpuSettings.flags & GHOST_gpuStereoVisual,
|
||||
gpuSettings.flags & GHOST_gpuDebugContext,
|
||||
is_dialog,
|
||||
(GHOST_WindowCocoa *)parentWindow);
|
||||
|
||||
@ -755,11 +755,11 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const char *title,
|
||||
* Never explicitly delete the context, use #disposeContext() instead.
|
||||
* \return The new context (or 0 if creation failed).
|
||||
*/
|
||||
GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext(GHOST_GLSettings glSettings)
|
||||
GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext(GHOST_GPUSettings gpuSettings)
|
||||
{
|
||||
#ifdef WITH_VULKAN_BACKEND
|
||||
if (glSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0;
|
||||
if (gpuSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
const bool debug_context = (gpuSettings.flags & GHOST_gpuDebugContext) != 0;
|
||||
GHOST_Context *context = new GHOST_ContextVK(false, NULL, 1, 2, debug_context);
|
||||
if (!context->initializeDrawingContext()) {
|
||||
delete context;
|
||||
@ -769,7 +769,7 @@ GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext(GHOST_GLSettings glSet
|
||||
}
|
||||
#endif
|
||||
|
||||
GHOST_Context *context = new GHOST_ContextCGL(false, NULL, NULL, NULL, glSettings.context_type);
|
||||
GHOST_Context *context = new GHOST_ContextCGL(false, NULL, NULL, NULL, gpuSettings.context_type);
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
|
@ -79,7 +79,7 @@ class GHOST_SystemHeadless : public GHOST_System {
|
||||
void getAllDisplayDimensions(uint32_t & /*width*/, uint32_t & /*height*/) const override
|
||||
{ /* nop */
|
||||
}
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GLSettings /*glSettings*/) override
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GPUSettings /*gpuSettings*/) override
|
||||
{
|
||||
#ifdef __linux__
|
||||
GHOST_Context *context;
|
||||
@ -150,7 +150,7 @@ class GHOST_SystemHeadless : public GHOST_System {
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool /*exclusive*/,
|
||||
const bool /*is_dialog*/,
|
||||
const GHOST_IWindow *parentWindow) override
|
||||
@ -162,8 +162,8 @@ class GHOST_SystemHeadless : public GHOST_System {
|
||||
height,
|
||||
state,
|
||||
parentWindow,
|
||||
glSettings.context_type,
|
||||
((glSettings.flags & GHOST_glStereoVisual) != 0));
|
||||
gpuSettings.context_type,
|
||||
((gpuSettings.flags & GHOST_gpuStereoVisual) != 0));
|
||||
}
|
||||
|
||||
GHOST_IWindow *getWindowUnderCursor(int32_t /*x*/, int32_t /*y*/) override
|
||||
|
@ -42,7 +42,7 @@ GHOST_IWindow *GHOST_SystemSDL::createWindow(const char *title,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive,
|
||||
const bool /* is_dialog */,
|
||||
const GHOST_IWindow *parentWindow)
|
||||
@ -56,8 +56,8 @@ GHOST_IWindow *GHOST_SystemSDL::createWindow(const char *title,
|
||||
width,
|
||||
height,
|
||||
state,
|
||||
glSettings.context_type,
|
||||
((glSettings.flags & GHOST_glStereoVisual) != 0),
|
||||
gpuSettings.context_type,
|
||||
((gpuSettings.flags & GHOST_gpuStereoVisual) != 0),
|
||||
exclusive,
|
||||
parentWindow);
|
||||
|
||||
@ -125,7 +125,7 @@ uint8_t GHOST_SystemSDL::getNumDisplays() const
|
||||
return SDL_GetNumVideoDisplays();
|
||||
}
|
||||
|
||||
GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GLSettings /*glSettings*/)
|
||||
GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GPUSettings /*gpuSettings*/)
|
||||
{
|
||||
GHOST_Context *context = new GHOST_ContextSDL(false,
|
||||
nullptr,
|
||||
|
@ -60,7 +60,7 @@ class GHOST_SystemSDL : public GHOST_System {
|
||||
|
||||
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override;
|
||||
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings) override;
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings) override;
|
||||
|
||||
GHOST_TSuccess disposeContext(GHOST_IContext *context) override;
|
||||
|
||||
@ -73,7 +73,7 @@ class GHOST_SystemSDL : public GHOST_System {
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive = false,
|
||||
const bool is_dialog = false,
|
||||
const GHOST_IWindow *parentWindow = nullptr) override;
|
||||
|
@ -6279,7 +6279,7 @@ static GHOST_Context *createOffscreenContext_impl(GHOST_SystemWayland *system,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings glSettings)
|
||||
GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GPUSettings gpuSettings)
|
||||
{
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
std::lock_guard lock_server_guard{*server_mutex};
|
||||
@ -6289,9 +6289,9 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings glS
|
||||
wl_surface *wl_surface = wl_compositor_create_surface(wl_compositor());
|
||||
|
||||
#ifdef WITH_VULKAN_BACKEND
|
||||
const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0;
|
||||
const bool debug_context = (gpuSettings.flags & GHOST_gpuDebugContext) != 0;
|
||||
|
||||
if (glSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
if (gpuSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
GHOST_Context *context = new GHOST_ContextVK(false,
|
||||
GHOST_kVulkanPlatformWayland,
|
||||
0,
|
||||
@ -6310,7 +6310,7 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings glS
|
||||
return context;
|
||||
}
|
||||
#else
|
||||
(void)glSettings;
|
||||
(void)gpuSettings;
|
||||
#endif
|
||||
|
||||
wl_egl_window *egl_window = wl_surface ? wl_egl_window_create(wl_surface, 1, 1) : nullptr;
|
||||
@ -6359,7 +6359,7 @@ GHOST_IWindow *GHOST_SystemWayland::createWindow(const char *title,
|
||||
const uint32_t width,
|
||||
const uint32_t height,
|
||||
const GHOST_TWindowState state,
|
||||
const GHOST_GLSettings glSettings,
|
||||
const GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive,
|
||||
const bool is_dialog,
|
||||
const GHOST_IWindow *parentWindow)
|
||||
@ -6374,9 +6374,9 @@ GHOST_IWindow *GHOST_SystemWayland::createWindow(const char *title,
|
||||
height,
|
||||
state,
|
||||
parentWindow,
|
||||
glSettings.context_type,
|
||||
gpuSettings.context_type,
|
||||
is_dialog,
|
||||
((glSettings.flags & GHOST_glStereoVisual) != 0),
|
||||
((gpuSettings.flags & GHOST_gpuStereoVisual) != 0),
|
||||
exclusive);
|
||||
|
||||
if (window) {
|
||||
|
@ -157,7 +157,7 @@ class GHOST_SystemWayland : public GHOST_System {
|
||||
|
||||
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override;
|
||||
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings) override;
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings) override;
|
||||
|
||||
GHOST_TSuccess disposeContext(GHOST_IContext *context) override;
|
||||
|
||||
@ -167,7 +167,7 @@ class GHOST_SystemWayland : public GHOST_System {
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive,
|
||||
const bool is_dialog,
|
||||
const GHOST_IWindow *parentWindow) override;
|
||||
|
@ -224,7 +224,7 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(const char *title,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool /*exclusive*/,
|
||||
const bool is_dialog,
|
||||
const GHOST_IWindow *parentWindow)
|
||||
@ -237,11 +237,11 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(const char *title,
|
||||
width,
|
||||
height,
|
||||
state,
|
||||
glSettings.context_type,
|
||||
((glSettings.flags & GHOST_glStereoVisual) != 0),
|
||||
gpuSettings.context_type,
|
||||
((gpuSettings.flags & GHOST_gpuStereoVisual) != 0),
|
||||
false,
|
||||
(GHOST_WindowWin32 *)parentWindow,
|
||||
((glSettings.flags & GHOST_glDebugContext) != 0),
|
||||
((gpuSettings.flags & GHOST_gpuDebugContext) != 0),
|
||||
is_dialog);
|
||||
|
||||
if (window->getValid()) {
|
||||
@ -263,15 +263,15 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(const char *title,
|
||||
* Never explicitly delete the window, use #disposeContext() instead.
|
||||
* \return The new context (or 0 if creation failed).
|
||||
*/
|
||||
GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GLSettings glSettings)
|
||||
GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GPUSettings gpuSettings)
|
||||
{
|
||||
const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0;
|
||||
const bool debug_context = (gpuSettings.flags & GHOST_gpuDebugContext) != 0;
|
||||
|
||||
GHOST_Context *context = nullptr;
|
||||
|
||||
#ifdef WITH_VULKAN_BACKEND
|
||||
/* Vulkan does not need a window. */
|
||||
if (glSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
if (gpuSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
context = new GHOST_ContextVK(false, (HWND)0, 1, 2, debug_context);
|
||||
|
||||
if (!context->initializeDrawingContext()) {
|
||||
|
@ -103,7 +103,7 @@ class GHOST_SystemWin32 : public GHOST_System {
|
||||
* \param width: The width the window.
|
||||
* \param height: The height the window.
|
||||
* \param state: The state of the window when opened.
|
||||
* \param glSettings: Misc OpenGL settings.
|
||||
* \param gpuSettings: Misc GPU settings.
|
||||
* \param exclusive: Use to show the window on top and ignore others (used full-screen).
|
||||
* \param parentWindow: Parent window.
|
||||
* \return The new window (or 0 if creation failed).
|
||||
@ -114,7 +114,7 @@ class GHOST_SystemWin32 : public GHOST_System {
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive = false,
|
||||
const bool is_dialog = false,
|
||||
const GHOST_IWindow *parentWindow = 0);
|
||||
@ -124,7 +124,7 @@ class GHOST_SystemWin32 : public GHOST_System {
|
||||
* Never explicitly delete the window, use #disposeContext() instead.
|
||||
* \return The new context (or 0 if creation failed).
|
||||
*/
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings);
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings);
|
||||
|
||||
/**
|
||||
* Dispose of a context.
|
||||
|
@ -304,7 +304,7 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive,
|
||||
const bool is_dialog,
|
||||
const GHOST_IWindow *parentWindow)
|
||||
@ -324,11 +324,11 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title,
|
||||
height,
|
||||
state,
|
||||
(GHOST_WindowX11 *)parentWindow,
|
||||
glSettings.context_type,
|
||||
gpuSettings.context_type,
|
||||
is_dialog,
|
||||
((glSettings.flags & GHOST_glStereoVisual) != 0),
|
||||
((gpuSettings.flags & GHOST_gpuStereoVisual) != 0),
|
||||
exclusive,
|
||||
(glSettings.flags & GHOST_glDebugContext) != 0);
|
||||
(gpuSettings.flags & GHOST_gpuDebugContext) != 0);
|
||||
|
||||
if (window) {
|
||||
/* Both are now handle in GHOST_WindowX11.cc
|
||||
@ -399,7 +399,7 @@ static GHOST_Context *create_glx_context(Display *display,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSettings)
|
||||
GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GPUSettings gpuSettings)
|
||||
{
|
||||
/* During development:
|
||||
* try 4.x compatibility profile
|
||||
@ -411,11 +411,11 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
||||
* try 3.3 core profile
|
||||
* no fall-backs. */
|
||||
|
||||
const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0;
|
||||
const bool debug_context = (gpuSettings.flags & GHOST_gpuDebugContext) != 0;
|
||||
GHOST_Context *context = nullptr;
|
||||
|
||||
#ifdef WITH_VULKAN_BACKEND
|
||||
if (glSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
if (gpuSettings.context_type == GHOST_kDrawingContextTypeVulkan) {
|
||||
context = new GHOST_ContextVK(
|
||||
false, GHOST_kVulkanPlatformX11, 0, m_display, NULL, NULL, 1, 2, debug_context);
|
||||
|
||||
|
@ -124,7 +124,7 @@ class GHOST_SystemX11 : public GHOST_System {
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_GLSettings glSettings,
|
||||
GHOST_GPUSettings gpuSettings,
|
||||
const bool exclusive = false,
|
||||
const bool is_dialog = false,
|
||||
const GHOST_IWindow *parentWindow = nullptr) override;
|
||||
@ -134,7 +134,7 @@ class GHOST_SystemX11 : public GHOST_System {
|
||||
* Never explicitly delete the context, use #disposeContext() instead.
|
||||
* \return The new context (or 0 if creation failed).
|
||||
*/
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings) override;
|
||||
GHOST_IContext *createOffscreenContext(GHOST_GPUSettings gpuSettings) override;
|
||||
|
||||
/**
|
||||
* Dispose of a context.
|
||||
|
@ -412,7 +412,7 @@ bool processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
char *title1 = "gears - main window";
|
||||
char *title2 = "gears - secondary window";
|
||||
GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(processEvent, NULL);
|
||||
@ -433,7 +433,7 @@ int main(int argc, char **argv)
|
||||
GHOST_kWindowStateNormal,
|
||||
false,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
glSettings);
|
||||
gpuSettings);
|
||||
if (!sMainWindow) {
|
||||
printf("could not create main window\n");
|
||||
exit(-1);
|
||||
@ -450,7 +450,7 @@ int main(int argc, char **argv)
|
||||
GHOST_kWindowStateNormal,
|
||||
false,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
glSettings);
|
||||
gpuSettings);
|
||||
if (!sSecondaryWindow) {
|
||||
printf("could not create secondary window\n");
|
||||
exit(-1);
|
||||
|
@ -406,13 +406,13 @@ Application::Application(GHOST_ISystem *system)
|
||||
m_exitRequested(false),
|
||||
stereo(false)
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
glSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
gpuSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
|
||||
fApp = this;
|
||||
|
||||
// Create the main window
|
||||
m_mainWindow = system->createWindow(
|
||||
"gears - main window", 10, 64, 320, 200, GHOST_kWindowStateNormal, glSettings);
|
||||
"gears - main window", 10, 64, 320, 200, GHOST_kWindowStateNormal, gpuSettings);
|
||||
|
||||
if (!m_mainWindow) {
|
||||
std::cout << "could not create main window\n";
|
||||
@ -421,7 +421,7 @@ Application::Application(GHOST_ISystem *system)
|
||||
|
||||
// Create a secondary window
|
||||
m_secondaryWindow = system->createWindow(
|
||||
"gears - secondary window", 340, 64, 320, 200, GHOST_kWindowStateNormal, glSettings);
|
||||
"gears - secondary window", 340, 64, 320, 200, GHOST_kWindowStateNormal, gpuSettings);
|
||||
if (!m_secondaryWindow) {
|
||||
std::cout << "could not create secondary window\n";
|
||||
exit(-1);
|
||||
|
@ -306,7 +306,7 @@ MainWindow *mainwindow_new(MultiTestApp *app)
|
||||
{
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(app);
|
||||
GHOST_WindowHandle win;
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
|
||||
win = GHOST_CreateWindow(sys,
|
||||
NULL,
|
||||
@ -318,7 +318,7 @@ MainWindow *mainwindow_new(MultiTestApp *app)
|
||||
GHOST_kWindowStateNormal,
|
||||
false,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
glSettings);
|
||||
gpuSettings);
|
||||
|
||||
if (win) {
|
||||
MainWindow *mw = MEM_callocN(sizeof(*mw), "mainwindow_new");
|
||||
@ -557,7 +557,7 @@ static void loggerwindow_handle(void *priv, GHOST_EventHandle evt)
|
||||
|
||||
LoggerWindow *loggerwindow_new(MultiTestApp *app)
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(app);
|
||||
uint32_t screensize[2];
|
||||
GHOST_WindowHandle win;
|
||||
@ -573,7 +573,7 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app)
|
||||
GHOST_kWindowStateNormal,
|
||||
false,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
glSettings);
|
||||
gpuSettings);
|
||||
|
||||
if (win) {
|
||||
LoggerWindow *lw = MEM_callocN(sizeof(*lw), "loggerwindow_new");
|
||||
@ -761,7 +761,7 @@ static void extrawindow_handle(void *priv, GHOST_EventHandle evt)
|
||||
|
||||
ExtraWindow *extrawindow_new(MultiTestApp *app)
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(app);
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
@ -775,7 +775,7 @@ ExtraWindow *extrawindow_new(MultiTestApp *app)
|
||||
GHOST_kWindowStateNormal,
|
||||
false,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
glSettings);
|
||||
gpuSettings);
|
||||
|
||||
if (win) {
|
||||
ExtraWindow *ew = MEM_callocN(sizeof(*ew), "mainwindow_new");
|
||||
|
@ -162,15 +162,15 @@ void DRW_uniform_attrs_pool_free(struct GHash *table);
|
||||
void DRW_render_context_enable(struct Render *render);
|
||||
void DRW_render_context_disable(struct Render *render);
|
||||
|
||||
void DRW_opengl_context_create(void);
|
||||
void DRW_opengl_context_destroy(void);
|
||||
void DRW_opengl_context_enable(void);
|
||||
void DRW_opengl_context_disable(void);
|
||||
void DRW_gpu_context_create(void);
|
||||
void DRW_gpu_context_destroy(void);
|
||||
void DRW_gpu_context_enable(void);
|
||||
void DRW_gpu_context_disable(void);
|
||||
|
||||
#ifdef WITH_XR_OPENXR
|
||||
/* XXX: see comment on #DRW_xr_opengl_context_get() */
|
||||
void *DRW_xr_opengl_context_get(void);
|
||||
void *DRW_xr_gpu_context_get(void);
|
||||
/* XXX: see comment on #DRW_system_gpu_context_get() */
|
||||
void *DRW_system_gpu_context_get(void);
|
||||
void *DRW_xr_blender_gpu_context_get(void);
|
||||
void DRW_xr_drawing_begin(void);
|
||||
void DRW_xr_drawing_end(void);
|
||||
#endif
|
||||
@ -183,19 +183,16 @@ void DRW_cache_free_old_subdiv(void);
|
||||
void DRW_subdiv_free(void);
|
||||
|
||||
/* Never use this. Only for closing blender. */
|
||||
void DRW_opengl_context_enable_ex(bool restore);
|
||||
void DRW_opengl_context_disable_ex(bool restore);
|
||||
void DRW_gpu_context_enable_ex(bool restore);
|
||||
void DRW_gpu_context_disable_ex(bool restore);
|
||||
|
||||
void DRW_opengl_render_context_enable(void *re_gl_context);
|
||||
void DRW_opengl_render_context_disable(void *re_gl_context);
|
||||
/**
|
||||
* Needs to be called AFTER #DRW_opengl_render_context_enable().
|
||||
*/
|
||||
void DRW_gpu_render_context_enable(void *re_gpu_context);
|
||||
/**
|
||||
* Needs to be called BEFORE #DRW_opengl_render_context_disable().
|
||||
*/
|
||||
void DRW_gpu_render_context_disable(void *re_gpu_context);
|
||||
/* Render pipeline GPU context control.
|
||||
* Enable system context first, then enable blender context,
|
||||
* then disable blender context, then disable system context. */
|
||||
void DRW_system_gpu_render_context_enable(void *re_system_gpu_context);
|
||||
void DRW_system_gpu_render_context_disable(void *re_system_gpu_context);
|
||||
void DRW_blender_gpu_render_context_enable(void *re_gpu_context);
|
||||
void DRW_blender_gpu_render_context_disable(void *re_gpu_context);
|
||||
|
||||
void DRW_deferred_shader_remove(struct GPUMaterial *mat);
|
||||
void DRW_deferred_shader_optimize_remove(struct GPUMaterial *mat);
|
||||
@ -210,8 +207,8 @@ void DRW_drawdata_free(struct ID *id);
|
||||
struct DRWData *DRW_viewport_data_create(void);
|
||||
void DRW_viewport_data_free(struct DRWData *drw_data);
|
||||
|
||||
bool DRW_opengl_context_release(void);
|
||||
void DRW_opengl_context_activate(bool drw_state);
|
||||
bool DRW_gpu_context_release(void);
|
||||
void DRW_gpu_context_activate(bool drw_state);
|
||||
|
||||
/**
|
||||
* We may want to move this into a more general location.
|
||||
|
@ -62,13 +62,13 @@
|
||||
(IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_Y)
|
||||
|
||||
/* TODO: should be replace by a more elegant alternative. */
|
||||
extern void DRW_opengl_context_enable(void);
|
||||
extern void DRW_opengl_context_disable(void);
|
||||
extern void DRW_gpu_context_enable(void);
|
||||
extern void DRW_gpu_context_disable(void);
|
||||
|
||||
extern void DRW_opengl_render_context_enable(void *re_gl_context);
|
||||
extern void DRW_opengl_render_context_disable(void *re_gl_context);
|
||||
extern void DRW_gpu_render_context_enable(void *re_gpu_context);
|
||||
extern void DRW_gpu_render_context_disable(void *re_gpu_context);
|
||||
extern void DRW_system_gpu_render_context_enable(void *re_system_gpu_context);
|
||||
extern void DRW_system_gpu_render_context_disable(void *re_system_gpu_context);
|
||||
extern void DRW_blender_gpu_render_context_enable(void *re_blender_gpu_context);
|
||||
extern void DRW_blender_gpu_render_context_disable(void *re_blender_gpu_context);
|
||||
|
||||
typedef struct EEVEE_LightBake {
|
||||
Depsgraph *depsgraph;
|
||||
@ -157,7 +157,7 @@ typedef struct EEVEE_LightBake {
|
||||
int frame;
|
||||
|
||||
/** If running in parallel (in a separate thread), use this context. */
|
||||
void *gl_context, *gpu_context;
|
||||
void *system_gpu_context, *blender_gpu_context;
|
||||
|
||||
ThreadMutex *mutex;
|
||||
} EEVEE_LightBake;
|
||||
@ -601,20 +601,20 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake)
|
||||
{
|
||||
if (GPU_use_main_context_workaround() && !BLI_thread_is_main()) {
|
||||
GPU_context_main_lock();
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
GPU_render_begin();
|
||||
return;
|
||||
}
|
||||
|
||||
if (lbake->gl_context) {
|
||||
DRW_opengl_render_context_enable(lbake->gl_context);
|
||||
if (lbake->gpu_context == NULL) {
|
||||
lbake->gpu_context = GPU_context_create(NULL, lbake->gl_context);
|
||||
if (lbake->system_gpu_context) {
|
||||
DRW_system_gpu_render_context_enable(lbake->system_gpu_context);
|
||||
if (lbake->blender_gpu_context == NULL) {
|
||||
lbake->blender_gpu_context = GPU_context_create(NULL, lbake->system_gpu_context);
|
||||
}
|
||||
DRW_gpu_render_context_enable(lbake->gpu_context);
|
||||
DRW_blender_gpu_render_context_enable(lbake->blender_gpu_context);
|
||||
}
|
||||
else {
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
}
|
||||
GPU_render_begin();
|
||||
}
|
||||
@ -623,19 +623,19 @@ static void eevee_lightbake_context_disable(EEVEE_LightBake *lbake)
|
||||
{
|
||||
|
||||
if (GPU_use_main_context_workaround() && !BLI_thread_is_main()) {
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
GPU_render_end();
|
||||
GPU_context_main_unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (lbake->gl_context) {
|
||||
DRW_gpu_render_context_disable(lbake->gpu_context);
|
||||
if (lbake->system_gpu_context) {
|
||||
DRW_blender_gpu_render_context_disable(lbake->blender_gpu_context);
|
||||
GPU_render_end();
|
||||
DRW_opengl_render_context_disable(lbake->gl_context);
|
||||
DRW_system_gpu_render_context_disable(lbake->system_gpu_context);
|
||||
}
|
||||
else {
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
GPU_render_end();
|
||||
}
|
||||
}
|
||||
@ -788,13 +788,13 @@ wmJob *EEVEE_lightbake_job_create(wmWindowManager *wm,
|
||||
lbake->scene = scene;
|
||||
lbake->bmain = bmain;
|
||||
lbake->view_layer_input = view_layer;
|
||||
lbake->gl_context = old_lbake->gl_context;
|
||||
lbake->system_gpu_context = old_lbake->system_gpu_context;
|
||||
lbake->own_resources = true;
|
||||
lbake->delay = delay;
|
||||
lbake->frame = frame;
|
||||
|
||||
if (lbake->gl_context == NULL && !GPU_use_main_context_workaround()) {
|
||||
lbake->gl_context = WM_opengl_context_create();
|
||||
if (lbake->system_gpu_context == NULL && !GPU_use_main_context_workaround()) {
|
||||
lbake->system_gpu_context = WM_system_gpu_context_create();
|
||||
wm_window_reset_drawable();
|
||||
}
|
||||
|
||||
@ -835,7 +835,7 @@ void *EEVEE_lightbake_job_data_alloc(
|
||||
lbake->frame = frame;
|
||||
|
||||
if (run_as_job && !GPU_use_main_context_workaround()) {
|
||||
lbake->gl_context = WM_opengl_context_create();
|
||||
lbake->system_gpu_context = WM_system_gpu_context_create();
|
||||
wm_window_reset_drawable();
|
||||
}
|
||||
|
||||
@ -865,12 +865,12 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake)
|
||||
BLI_mutex_lock(lbake->mutex);
|
||||
}
|
||||
|
||||
if (lbake->gl_context) {
|
||||
DRW_opengl_render_context_enable(lbake->gl_context);
|
||||
DRW_gpu_render_context_enable(lbake->gpu_context);
|
||||
if (lbake->system_gpu_context) {
|
||||
DRW_system_gpu_render_context_enable(lbake->system_gpu_context);
|
||||
DRW_blender_gpu_render_context_enable(lbake->blender_gpu_context);
|
||||
}
|
||||
else if (!lbake->resource_only) {
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
}
|
||||
|
||||
/* XXX: Free the resources contained in the view-layer data
|
||||
@ -887,24 +887,24 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake)
|
||||
GPU_FRAMEBUFFER_FREE_SAFE(lbake->rt_fb[i]);
|
||||
}
|
||||
|
||||
if (lbake->gpu_context) {
|
||||
DRW_gpu_render_context_disable(lbake->gpu_context);
|
||||
DRW_gpu_render_context_enable(lbake->gpu_context);
|
||||
GPU_context_discard(lbake->gpu_context);
|
||||
if (lbake->blender_gpu_context) {
|
||||
DRW_blender_gpu_render_context_disable(lbake->blender_gpu_context);
|
||||
DRW_blender_gpu_render_context_enable(lbake->blender_gpu_context);
|
||||
GPU_context_discard(lbake->blender_gpu_context);
|
||||
}
|
||||
|
||||
if (lbake->gl_context && lbake->own_resources) {
|
||||
if (lbake->system_gpu_context && lbake->own_resources) {
|
||||
/* Delete the baking context. */
|
||||
DRW_opengl_render_context_disable(lbake->gl_context);
|
||||
WM_opengl_context_dispose(lbake->gl_context);
|
||||
lbake->gpu_context = NULL;
|
||||
lbake->gl_context = NULL;
|
||||
DRW_system_gpu_render_context_disable(lbake->system_gpu_context);
|
||||
WM_system_gpu_context_dispose(lbake->system_gpu_context);
|
||||
lbake->blender_gpu_context = NULL;
|
||||
lbake->system_gpu_context = NULL;
|
||||
}
|
||||
else if (lbake->gl_context) {
|
||||
DRW_opengl_render_context_disable(lbake->gl_context);
|
||||
else if (lbake->system_gpu_context) {
|
||||
DRW_system_gpu_render_context_disable(lbake->system_gpu_context);
|
||||
}
|
||||
else if (!lbake->resource_only) {
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
}
|
||||
|
||||
if (!lbake->resource_only) {
|
||||
@ -1490,10 +1490,10 @@ void EEVEE_lightbake_job(void *custom_data, bool *stop, bool *do_update, float *
|
||||
lcache->flag |= LIGHTCACHE_BAKED;
|
||||
lcache->flag &= ~LIGHTCACHE_BAKING;
|
||||
|
||||
/* Assume that if lbake->gl_context is NULL
|
||||
/* Assume that if lbake->system_gpu_context is NULL
|
||||
* we are not running in this in a job, so update
|
||||
* the scene light-cache pointer before deleting it. */
|
||||
if (lbake->gl_context == NULL) {
|
||||
if (lbake->system_gpu_context == NULL) {
|
||||
BLI_assert(BLI_thread_is_main());
|
||||
EEVEE_lightbake_update(lbake);
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
|
||||
|
||||
/* If light-cache auto-update is enable we tag the relevant part
|
||||
* of the cache to update and fire up a baking job. */
|
||||
if (!DRW_state_is_image_render() && !DRW_state_is_opengl_render() &&
|
||||
if (!DRW_state_is_image_render() && !DRW_state_is_viewport_image_render() &&
|
||||
(pinfo->do_grid_update || pinfo->do_cube_update))
|
||||
{
|
||||
BLI_assert(draw_ctx->evil_C);
|
||||
|
@ -94,7 +94,7 @@ void EEVEE_lookdev_init(EEVEE_Data *vedata)
|
||||
/* Viewport / Spheres size. */
|
||||
const rcti *rect;
|
||||
rcti fallback_rect;
|
||||
if (DRW_state_is_opengl_render()) {
|
||||
if (DRW_state_is_viewport_image_render()) {
|
||||
const float *vp_size = DRW_viewport_size_get();
|
||||
fallback_rect.xmax = vp_size[0];
|
||||
fallback_rect.ymax = vp_size[1];
|
||||
|
@ -431,7 +431,7 @@ void EEVEE_renderpasses_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
|
||||
bool is_valid = (render_pass & EEVEE_RENDERPASSES_ALL) != 0;
|
||||
bool needs_color_transfer = (render_pass & EEVEE_RENDERPASSES_COLOR_PASS) != 0 &&
|
||||
DRW_state_is_opengl_render();
|
||||
DRW_state_is_viewport_image_render();
|
||||
UNUSED_VARS(needs_color_transfer);
|
||||
|
||||
if ((render_pass & EEVEE_RENDER_PASS_BLOOM) != 0 &&
|
||||
|
@ -245,7 +245,7 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
|
||||
* Reset for each "redraw". When rendering using OpenGL render,
|
||||
* we accumulate the redraw inside the drawing loop in eevee_draw_scene().
|
||||
*/
|
||||
if (DRW_state_is_opengl_render()) {
|
||||
if (DRW_state_is_viewport_image_render()) {
|
||||
effects->taa_render_sample = 1;
|
||||
}
|
||||
effects->bypass_drawing = false;
|
||||
|
@ -30,7 +30,7 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata)
|
||||
float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
int background_type;
|
||||
|
||||
if (DRW_state_is_opengl_render() && !DRW_state_draw_background()) {
|
||||
if (DRW_state_is_viewport_image_render() && !DRW_state_draw_background()) {
|
||||
background_type = BG_SOLID;
|
||||
color_override[3] = 1.0f;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class Background {
|
||||
float4 color_override(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
int background_type;
|
||||
|
||||
if (DRW_state_is_opengl_render() && !DRW_state_draw_background()) {
|
||||
if (DRW_state_is_viewport_image_render() && !DRW_state_draw_background()) {
|
||||
background_type = BG_SOLID;
|
||||
color_override[3] = 1.0f;
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ static void workbench_draw_scene(void *ved)
|
||||
WORKBENCH_Data *vedata = ved;
|
||||
WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
|
||||
|
||||
if (DRW_state_is_opengl_render()) {
|
||||
if (DRW_state_is_viewport_image_render()) {
|
||||
while (wpd->taa_sample < max_ii(1, wpd->taa_sample_len)) {
|
||||
workbench_update_world_ubo(wpd);
|
||||
|
||||
|
@ -944,7 +944,7 @@ bool DRW_state_is_scene_render(void);
|
||||
/**
|
||||
* Whether we are rendering simple opengl render
|
||||
*/
|
||||
bool DRW_state_is_opengl_render(void);
|
||||
bool DRW_state_is_viewport_image_render(void);
|
||||
bool DRW_state_is_playback(void);
|
||||
/**
|
||||
* Is the user navigating the region.
|
||||
|
@ -61,7 +61,7 @@ BLI_INLINE void DRW_ibo_request(GPUBatch *batch, GPUIndexBuf **ibo)
|
||||
BLI_INLINE bool DRW_ibo_requested(GPUIndexBuf *ibo)
|
||||
{
|
||||
/* TODO: do not rely on data uploaded. This prevents multi-threading.
|
||||
* (need access to a OpenGL context). */
|
||||
* (need access to a GPU context). */
|
||||
return (ibo != NULL && !GPU_indexbuf_is_init(ibo));
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ static struct {
|
||||
|
||||
static void drw_state_prepare_clean_for_draw(DRWManager *dst)
|
||||
{
|
||||
memset(dst, 0x0, offsetof(DRWManager, gl_context));
|
||||
memset(dst, 0x0, offsetof(DRWManager, system_gpu_context));
|
||||
}
|
||||
|
||||
/* This function is used to reset draw manager to a state
|
||||
@ -126,7 +126,7 @@ static void drw_state_prepare_clean_for_draw(DRWManager *dst)
|
||||
#ifdef DEBUG
|
||||
static void drw_state_ensure_not_reused(DRWManager *dst)
|
||||
{
|
||||
memset(dst, 0xff, offsetof(DRWManager, gl_context));
|
||||
memset(dst, 0xff, offsetof(DRWManager, system_gpu_context));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1341,7 +1341,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
|
||||
/* XXX Really nasty locking. But else this could
|
||||
* be executed by the material previews thread
|
||||
* while rendering a viewport. */
|
||||
BLI_ticket_mutex_lock(DST.gl_context_mutex);
|
||||
BLI_ticket_mutex_lock(DST.system_gpu_context_mutex);
|
||||
|
||||
/* Reset before using it. */
|
||||
drw_state_prepare_clean_for_draw(&DST);
|
||||
@ -1378,7 +1378,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
|
||||
|
||||
drw_manager_exit(&DST);
|
||||
|
||||
BLI_ticket_mutex_unlock(DST.gl_context_mutex);
|
||||
BLI_ticket_mutex_unlock(DST.system_gpu_context_mutex);
|
||||
}
|
||||
|
||||
/* update a viewport which belongs to a GPUOffscreen */
|
||||
@ -1905,7 +1905,7 @@ static void DRW_render_gpencil_to_image(RenderEngine *engine,
|
||||
void DRW_render_gpencil(RenderEngine *engine, Depsgraph *depsgraph)
|
||||
{
|
||||
/* This function should only be called if there are grease pencil objects,
|
||||
* especially important to avoid failing in background renders without OpenGL context. */
|
||||
* especially important to avoid failing in background renders without GPU context. */
|
||||
BLI_assert(DRW_render_check_grease_pencil(depsgraph));
|
||||
|
||||
Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
||||
@ -2964,7 +2964,7 @@ bool DRW_state_is_scene_render(void)
|
||||
return DST.options.is_scene_render;
|
||||
}
|
||||
|
||||
bool DRW_state_is_opengl_render(void)
|
||||
bool DRW_state_is_viewport_image_render(void)
|
||||
{
|
||||
return DST.options.is_image_render && !DST.options.is_scene_render;
|
||||
}
|
||||
@ -3119,14 +3119,14 @@ void DRW_engines_free(void)
|
||||
{
|
||||
drw_registered_engines_free();
|
||||
|
||||
if (DST.gl_context == NULL) {
|
||||
if (DST.system_gpu_context == NULL) {
|
||||
/* Nothing has been setup. Nothing to clear.
|
||||
* Otherwise, DRW_opengl_context_enable can
|
||||
* Otherwise, DRW_gpu_context_enable can
|
||||
* create a context in background mode. (see #62355) */
|
||||
return;
|
||||
}
|
||||
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
|
||||
DRW_TEXTURE_FREE_SAFE(g_select_buffer.texture_depth);
|
||||
GPU_FRAMEBUFFER_FREE_SAFE(g_select_buffer.framebuffer_depth_only);
|
||||
@ -3152,59 +3152,59 @@ void DRW_engines_free(void)
|
||||
GPU_draw_list_discard(DST.draw_list);
|
||||
}
|
||||
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
}
|
||||
|
||||
void DRW_render_context_enable(Render *render)
|
||||
{
|
||||
if (G.background && DST.gl_context == NULL) {
|
||||
WM_init_opengl();
|
||||
if (G.background && DST.system_gpu_context == NULL) {
|
||||
WM_init_gpu();
|
||||
}
|
||||
|
||||
GPU_render_begin();
|
||||
|
||||
if (GPU_use_main_context_workaround()) {
|
||||
GPU_context_main_lock();
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
return;
|
||||
}
|
||||
|
||||
void *re_gl_context = RE_gl_context_get(render);
|
||||
void *re_system_gpu_context = RE_system_gpu_context_get(render);
|
||||
|
||||
/* Changing Context */
|
||||
if (re_gl_context != NULL) {
|
||||
DRW_opengl_render_context_enable(re_gl_context);
|
||||
if (re_system_gpu_context != NULL) {
|
||||
DRW_system_gpu_render_context_enable(re_system_gpu_context);
|
||||
/* We need to query gpu context after a gl context has been bound. */
|
||||
void *re_gpu_context = NULL;
|
||||
re_gpu_context = RE_gpu_context_get(render);
|
||||
DRW_gpu_render_context_enable(re_gpu_context);
|
||||
void *re_blender_gpu_context = NULL;
|
||||
re_blender_gpu_context = RE_blender_gpu_context_get(render);
|
||||
DRW_blender_gpu_render_context_enable(re_blender_gpu_context);
|
||||
}
|
||||
else {
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
}
|
||||
}
|
||||
|
||||
void DRW_render_context_disable(Render *render)
|
||||
{
|
||||
if (GPU_use_main_context_workaround()) {
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
GPU_render_end();
|
||||
GPU_context_main_unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
void *re_gl_context = RE_gl_context_get(render);
|
||||
void *re_system_gpu_context = RE_system_gpu_context_get(render);
|
||||
|
||||
if (re_gl_context != NULL) {
|
||||
void *re_gpu_context = NULL;
|
||||
re_gpu_context = RE_gpu_context_get(render);
|
||||
if (re_system_gpu_context != NULL) {
|
||||
void *re_blender_gpu_context = NULL;
|
||||
re_blender_gpu_context = RE_blender_gpu_context_get(render);
|
||||
/* GPU rendering may occur during context disable. */
|
||||
DRW_gpu_render_context_disable(re_gpu_context);
|
||||
DRW_blender_gpu_render_context_disable(re_blender_gpu_context);
|
||||
GPU_render_end();
|
||||
DRW_opengl_render_context_disable(re_gl_context);
|
||||
DRW_system_gpu_render_context_disable(re_system_gpu_context);
|
||||
}
|
||||
else {
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
GPU_render_end();
|
||||
}
|
||||
}
|
||||
@ -3212,51 +3212,51 @@ void DRW_render_context_disable(Render *render)
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Init/Exit (DRW_opengl_ctx)
|
||||
/** \name Init/Exit (DRW_gpu_ctx)
|
||||
* \{ */
|
||||
|
||||
void DRW_opengl_context_create(void)
|
||||
void DRW_gpu_context_create(void)
|
||||
{
|
||||
BLI_assert(DST.gl_context == NULL); /* Ensure it's called once */
|
||||
BLI_assert(DST.system_gpu_context == NULL); /* Ensure it's called once */
|
||||
|
||||
DST.gl_context_mutex = BLI_ticket_mutex_alloc();
|
||||
DST.system_gpu_context_mutex = BLI_ticket_mutex_alloc();
|
||||
/* This changes the active context. */
|
||||
DST.gl_context = WM_opengl_context_create();
|
||||
WM_opengl_context_activate(DST.gl_context);
|
||||
/* Be sure to create gpu_context too. */
|
||||
DST.gpu_context = GPU_context_create(0, DST.gl_context);
|
||||
DST.system_gpu_context = WM_system_gpu_context_create();
|
||||
WM_system_gpu_context_activate(DST.system_gpu_context);
|
||||
/* Be sure to create blender_gpu_context too. */
|
||||
DST.blender_gpu_context = GPU_context_create(0, DST.system_gpu_context);
|
||||
/* So we activate the window's one afterwards. */
|
||||
wm_window_reset_drawable();
|
||||
}
|
||||
|
||||
void DRW_opengl_context_destroy(void)
|
||||
void DRW_gpu_context_destroy(void)
|
||||
{
|
||||
BLI_assert(BLI_thread_is_main());
|
||||
if (DST.gl_context != NULL) {
|
||||
WM_opengl_context_activate(DST.gl_context);
|
||||
GPU_context_active_set(DST.gpu_context);
|
||||
GPU_context_discard(DST.gpu_context);
|
||||
WM_opengl_context_dispose(DST.gl_context);
|
||||
BLI_ticket_mutex_free(DST.gl_context_mutex);
|
||||
if (DST.system_gpu_context != NULL) {
|
||||
WM_system_gpu_context_activate(DST.system_gpu_context);
|
||||
GPU_context_active_set(DST.blender_gpu_context);
|
||||
GPU_context_discard(DST.blender_gpu_context);
|
||||
WM_system_gpu_context_dispose(DST.system_gpu_context);
|
||||
BLI_ticket_mutex_free(DST.system_gpu_context_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
void DRW_opengl_context_enable_ex(bool UNUSED(restore))
|
||||
void DRW_gpu_context_enable_ex(bool UNUSED(restore))
|
||||
{
|
||||
if (DST.gl_context != NULL) {
|
||||
if (DST.system_gpu_context != NULL) {
|
||||
/* IMPORTANT: We don't support immediate mode in render mode!
|
||||
* This shall remain in effect until immediate mode supports
|
||||
* multiple threads. */
|
||||
BLI_ticket_mutex_lock(DST.gl_context_mutex);
|
||||
BLI_ticket_mutex_lock(DST.system_gpu_context_mutex);
|
||||
GPU_render_begin();
|
||||
WM_opengl_context_activate(DST.gl_context);
|
||||
GPU_context_active_set(DST.gpu_context);
|
||||
WM_system_gpu_context_activate(DST.system_gpu_context);
|
||||
GPU_context_active_set(DST.blender_gpu_context);
|
||||
}
|
||||
}
|
||||
|
||||
void DRW_opengl_context_disable_ex(bool restore)
|
||||
void DRW_gpu_context_disable_ex(bool restore)
|
||||
{
|
||||
if (DST.gl_context != NULL) {
|
||||
if (DST.system_gpu_context != NULL) {
|
||||
#ifdef __APPLE__
|
||||
/* Need to flush before disabling draw context, otherwise it does not
|
||||
* always finish drawing and viewport can be empty or partially drawn */
|
||||
@ -3269,7 +3269,7 @@ void DRW_opengl_context_disable_ex(bool restore)
|
||||
wm_window_reset_drawable();
|
||||
}
|
||||
else {
|
||||
WM_opengl_context_release(DST.gl_context);
|
||||
WM_system_gpu_context_release(DST.system_gpu_context);
|
||||
GPU_context_active_set(NULL);
|
||||
}
|
||||
|
||||
@ -3277,51 +3277,51 @@ void DRW_opengl_context_disable_ex(bool restore)
|
||||
* called outside of an existing render loop. */
|
||||
GPU_render_end();
|
||||
|
||||
BLI_ticket_mutex_unlock(DST.gl_context_mutex);
|
||||
BLI_ticket_mutex_unlock(DST.system_gpu_context_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
void DRW_opengl_context_enable(void)
|
||||
void DRW_gpu_context_enable(void)
|
||||
{
|
||||
/* TODO: should be replace by a more elegant alternative. */
|
||||
|
||||
if (G.background && DST.gl_context == NULL) {
|
||||
WM_init_opengl();
|
||||
if (G.background && DST.system_gpu_context == NULL) {
|
||||
WM_init_gpu();
|
||||
}
|
||||
DRW_opengl_context_enable_ex(true);
|
||||
DRW_gpu_context_enable_ex(true);
|
||||
}
|
||||
|
||||
void DRW_opengl_context_disable(void)
|
||||
void DRW_gpu_context_disable(void)
|
||||
{
|
||||
DRW_opengl_context_disable_ex(true);
|
||||
DRW_gpu_context_disable_ex(true);
|
||||
}
|
||||
|
||||
void DRW_opengl_render_context_enable(void *re_gl_context)
|
||||
void DRW_system_gpu_render_context_enable(void *re_system_gpu_context)
|
||||
{
|
||||
/* If thread is main you should use DRW_opengl_context_enable(). */
|
||||
/* If thread is main you should use DRW_gpu_context_enable(). */
|
||||
BLI_assert(!BLI_thread_is_main());
|
||||
|
||||
/* TODO: get rid of the blocking. Only here because of the static global DST. */
|
||||
BLI_ticket_mutex_lock(DST.gl_context_mutex);
|
||||
WM_opengl_context_activate(re_gl_context);
|
||||
BLI_ticket_mutex_lock(DST.system_gpu_context_mutex);
|
||||
WM_system_gpu_context_activate(re_system_gpu_context);
|
||||
}
|
||||
|
||||
void DRW_opengl_render_context_disable(void *re_gl_context)
|
||||
void DRW_system_gpu_render_context_disable(void *re_system_gpu_context)
|
||||
{
|
||||
WM_opengl_context_release(re_gl_context);
|
||||
WM_system_gpu_context_release(re_system_gpu_context);
|
||||
/* TODO: get rid of the blocking. */
|
||||
BLI_ticket_mutex_unlock(DST.gl_context_mutex);
|
||||
BLI_ticket_mutex_unlock(DST.system_gpu_context_mutex);
|
||||
}
|
||||
|
||||
void DRW_gpu_render_context_enable(void *re_gpu_context)
|
||||
void DRW_blender_gpu_render_context_enable(void *re_gpu_context)
|
||||
{
|
||||
/* If thread is main you should use DRW_opengl_context_enable(). */
|
||||
/* If thread is main you should use DRW_gpu_context_enable(). */
|
||||
BLI_assert(!BLI_thread_is_main());
|
||||
|
||||
GPU_context_active_set(re_gpu_context);
|
||||
}
|
||||
|
||||
void DRW_gpu_render_context_disable(void *UNUSED(re_gpu_context))
|
||||
void DRW_blender_gpu_render_context_disable(void *UNUSED(re_gpu_context))
|
||||
{
|
||||
GPU_flush();
|
||||
GPU_context_active_set(NULL);
|
||||
@ -3331,39 +3331,39 @@ void DRW_gpu_render_context_disable(void *UNUSED(re_gpu_context))
|
||||
|
||||
#ifdef WITH_XR_OPENXR
|
||||
|
||||
void *DRW_xr_opengl_context_get(void)
|
||||
void *DRW_system_gpu_context_get(void)
|
||||
{
|
||||
/* XXX: There should really be no such getter, but for VR we currently can't easily avoid it.
|
||||
* OpenXR needs some low level info for the OpenGL context that will be used for submitting the
|
||||
* OpenXR needs some low level info for the GPU context that will be used for submitting the
|
||||
* final frame-buffer. VR could in theory create its own context, but that would mean we have to
|
||||
* switch to it just to submit the final frame, which has notable performance impact.
|
||||
*
|
||||
* We could "inject" a context through DRW_opengl_render_context_enable(), but that would have to
|
||||
* work from the main thread, which is tricky to get working too. The preferable solution would
|
||||
* be using a separate thread for VR drawing where a single context can stay active. */
|
||||
* We could "inject" a context through DRW_system_gpu_render_context_enable(), but that would
|
||||
* have to work from the main thread, which is tricky to get working too. The preferable solution
|
||||
* would be using a separate thread for VR drawing where a single context can stay active. */
|
||||
|
||||
return DST.gl_context;
|
||||
return DST.system_gpu_context;
|
||||
}
|
||||
|
||||
void *DRW_xr_gpu_context_get(void)
|
||||
void *DRW_xr_blender_gpu_context_get(void)
|
||||
{
|
||||
/* XXX: See comment on #DRW_xr_opengl_context_get(). */
|
||||
/* XXX: See comment on #DRW_system_gpu_context_get(). */
|
||||
|
||||
return DST.gpu_context;
|
||||
return DST.blender_gpu_context;
|
||||
}
|
||||
|
||||
void DRW_xr_drawing_begin(void)
|
||||
{
|
||||
/* XXX: See comment on #DRW_xr_opengl_context_get(). */
|
||||
/* XXX: See comment on #DRW_system_gpu_context_get(). */
|
||||
|
||||
BLI_ticket_mutex_lock(DST.gl_context_mutex);
|
||||
BLI_ticket_mutex_lock(DST.system_gpu_context_mutex);
|
||||
}
|
||||
|
||||
void DRW_xr_drawing_end(void)
|
||||
{
|
||||
/* XXX: See comment on #DRW_xr_opengl_context_get(). */
|
||||
/* XXX: See comment on #DRW_system_gpu_context_get(). */
|
||||
|
||||
BLI_ticket_mutex_unlock(DST.gl_context_mutex);
|
||||
BLI_ticket_mutex_unlock(DST.system_gpu_context_mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -3388,58 +3388,59 @@ void DRW_draw_state_init_gtests(eGPUShaderConfig sh_cfg)
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Draw manager context release/activation
|
||||
*
|
||||
* These functions are used in cases when an OpenGL context creation is needed during the draw.
|
||||
* This happens, for example, when an external engine needs to create its own OpenGL context from
|
||||
* These functions are used in cases when an GPU context creation is needed during the draw.
|
||||
* This happens, for example, when an external engine needs to create its own GPU context from
|
||||
* the engine initialization.
|
||||
*
|
||||
* Example of context creation:
|
||||
*
|
||||
* const bool drw_state = DRW_opengl_context_release();
|
||||
* gl_context = WM_opengl_context_create();
|
||||
* DRW_opengl_context_activate(drw_state);
|
||||
* const bool drw_state = DRW_gpu_context_release();
|
||||
* system_gpu_context = WM_system_gpu_context_create();
|
||||
* DRW_gpu_context_activate(drw_state);
|
||||
*
|
||||
* Example of context destruction:
|
||||
*
|
||||
* const bool drw_state = DRW_opengl_context_release();
|
||||
* WM_opengl_context_activate(gl_context);
|
||||
* WM_opengl_context_dispose(gl_context);
|
||||
* DRW_opengl_context_activate(drw_state);
|
||||
* const bool drw_state = DRW_gpu_context_release();
|
||||
* WM_system_gpu_context_activate(system_gpu_context);
|
||||
* WM_system_gpu_context_dispose(system_gpu_context);
|
||||
* DRW_gpu_context_activate(drw_state);
|
||||
*
|
||||
*
|
||||
* NOTE: Will only perform context modification when on main thread. This way these functions can
|
||||
* be used in an engine without check on whether it is a draw manager which manages OpenGL context
|
||||
* on the current thread. The downside of this is that if the engine performs OpenGL creation from
|
||||
* a non-main thread, that thread is supposed to not have OpenGL context ever bound by Blender.
|
||||
* be used in an engine without check on whether it is a draw manager which manages GPU context
|
||||
* on the current thread. The downside of this is that if the engine performs GPU creation from
|
||||
* a non-main thread, that thread is supposed to not have GPU context ever bound by Blender.
|
||||
*
|
||||
* \{ */
|
||||
|
||||
bool DRW_opengl_context_release(void)
|
||||
bool DRW_gpu_context_release(void)
|
||||
{
|
||||
if (!BLI_thread_is_main()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GPU_context_active_get() != DST.gpu_context) {
|
||||
if (GPU_context_active_get() != DST.blender_gpu_context) {
|
||||
/* Context release is requested from the outside of the draw manager main draw loop, indicate
|
||||
* this to the `DRW_opengl_context_activate()` so that it restores drawable of the window. */
|
||||
* this to the `DRW_gpu_context_activate()` so that it restores drawable of the window.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
GPU_context_active_set(NULL);
|
||||
WM_opengl_context_release(DST.gl_context);
|
||||
WM_system_gpu_context_release(DST.system_gpu_context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DRW_opengl_context_activate(bool drw_state)
|
||||
void DRW_gpu_context_activate(bool drw_state)
|
||||
{
|
||||
if (!BLI_thread_is_main()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (drw_state) {
|
||||
WM_opengl_context_activate(DST.gl_context);
|
||||
GPU_context_active_set(DST.gpu_context);
|
||||
WM_system_gpu_context_activate(DST.system_gpu_context);
|
||||
GPU_context_active_set(DST.blender_gpu_context);
|
||||
}
|
||||
else {
|
||||
wm_window_reset_drawable();
|
||||
|
@ -666,13 +666,13 @@ typedef struct DRWManager {
|
||||
|
||||
/* ---------- Nothing after this point is cleared after use ----------- */
|
||||
|
||||
/* gl_context serves as the offset for clearing only
|
||||
/* system_gpu_context serves as the offset for clearing only
|
||||
* the top portion of the struct so DO NOT MOVE IT! */
|
||||
/** Unique ghost context used by the draw manager. */
|
||||
void *gl_context;
|
||||
GPUContext *gpu_context;
|
||||
void *system_gpu_context;
|
||||
GPUContext *blender_gpu_context;
|
||||
/** Mutex to lock the drw manager and avoid concurrent context usage. */
|
||||
TicketMutex *gl_context_mutex;
|
||||
TicketMutex *system_gpu_context_mutex;
|
||||
|
||||
GPUDrawList *draw_list;
|
||||
|
||||
|
@ -59,8 +59,8 @@ typedef struct DRWShaderCompiler {
|
||||
/** Optimization queue. */
|
||||
ListBase optimize_queue; /* GPUMaterial */
|
||||
|
||||
void *gl_context;
|
||||
GPUContext *gpu_context;
|
||||
void *system_gpu_context;
|
||||
GPUContext *blender_gpu_context;
|
||||
bool own_context;
|
||||
} DRWShaderCompiler;
|
||||
|
||||
@ -74,20 +74,20 @@ static void drw_deferred_shader_compilation_exec(
|
||||
{
|
||||
GPU_render_begin();
|
||||
DRWShaderCompiler *comp = (DRWShaderCompiler *)custom_data;
|
||||
void *gl_context = comp->gl_context;
|
||||
GPUContext *gpu_context = comp->gpu_context;
|
||||
void *system_gpu_context = comp->system_gpu_context;
|
||||
GPUContext *blender_gpu_context = comp->blender_gpu_context;
|
||||
|
||||
BLI_assert(gl_context != NULL);
|
||||
BLI_assert(gpu_context != NULL);
|
||||
BLI_assert(system_gpu_context != NULL);
|
||||
BLI_assert(blender_gpu_context != NULL);
|
||||
|
||||
const bool use_main_context_workaround = GPU_use_main_context_workaround();
|
||||
if (use_main_context_workaround) {
|
||||
BLI_assert(gl_context == DST.gl_context);
|
||||
BLI_assert(system_gpu_context == DST.system_gpu_context);
|
||||
GPU_context_main_lock();
|
||||
}
|
||||
|
||||
WM_opengl_context_activate(gl_context);
|
||||
GPU_context_active_set(gpu_context);
|
||||
WM_system_gpu_context_activate(system_gpu_context);
|
||||
GPU_context_active_set(blender_gpu_context);
|
||||
|
||||
while (true) {
|
||||
if (*stop != 0) {
|
||||
@ -145,7 +145,7 @@ static void drw_deferred_shader_compilation_exec(
|
||||
}
|
||||
|
||||
GPU_context_active_set(NULL);
|
||||
WM_opengl_context_release(gl_context);
|
||||
WM_system_gpu_context_release(system_gpu_context);
|
||||
if (use_main_context_workaround) {
|
||||
GPU_context_main_unlock();
|
||||
}
|
||||
@ -163,10 +163,10 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
|
||||
|
||||
if (comp->own_context) {
|
||||
/* Only destroy if the job owns the context. */
|
||||
WM_opengl_context_activate(comp->gl_context);
|
||||
GPU_context_active_set(comp->gpu_context);
|
||||
GPU_context_discard(comp->gpu_context);
|
||||
WM_opengl_context_dispose(comp->gl_context);
|
||||
WM_system_gpu_context_activate(comp->system_gpu_context);
|
||||
GPU_context_active_set(comp->blender_gpu_context);
|
||||
GPU_context_discard(comp->blender_gpu_context);
|
||||
WM_system_gpu_context_dispose(comp->system_gpu_context);
|
||||
|
||||
wm_window_reset_drawable();
|
||||
}
|
||||
@ -204,9 +204,9 @@ static void drw_deferred_queue_append(GPUMaterial *mat, bool is_optimization_job
|
||||
BLI_movelisttolist(&comp->optimize_queue, &old_comp->optimize_queue);
|
||||
BLI_spin_unlock(&old_comp->list_lock);
|
||||
/* Do not recreate context, just pass ownership. */
|
||||
if (old_comp->gl_context) {
|
||||
comp->gl_context = old_comp->gl_context;
|
||||
comp->gpu_context = old_comp->gpu_context;
|
||||
if (old_comp->system_gpu_context) {
|
||||
comp->system_gpu_context = old_comp->system_gpu_context;
|
||||
comp->blender_gpu_context = old_comp->blender_gpu_context;
|
||||
old_comp->own_context = false;
|
||||
comp->own_context = job_own_context;
|
||||
}
|
||||
@ -226,18 +226,18 @@ static void drw_deferred_queue_append(GPUMaterial *mat, bool is_optimization_job
|
||||
}
|
||||
|
||||
/* Create only one context. */
|
||||
if (comp->gl_context == NULL) {
|
||||
if (comp->system_gpu_context == NULL) {
|
||||
if (use_main_context) {
|
||||
comp->gl_context = DST.gl_context;
|
||||
comp->gpu_context = DST.gpu_context;
|
||||
comp->system_gpu_context = DST.system_gpu_context;
|
||||
comp->blender_gpu_context = DST.blender_gpu_context;
|
||||
}
|
||||
else {
|
||||
comp->gl_context = WM_opengl_context_create();
|
||||
comp->gpu_context = GPU_context_create(NULL, comp->gl_context);
|
||||
comp->system_gpu_context = WM_system_gpu_context_create();
|
||||
comp->blender_gpu_context = GPU_context_create(NULL, comp->system_gpu_context);
|
||||
GPU_context_active_set(NULL);
|
||||
|
||||
WM_opengl_context_activate(DST.gl_context);
|
||||
GPU_context_active_set(DST.gpu_context);
|
||||
WM_system_gpu_context_activate(DST.system_gpu_context);
|
||||
GPU_context_active_set(DST.blender_gpu_context);
|
||||
}
|
||||
comp->own_context = job_own_context;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ uint *DRW_select_buffer_read(
|
||||
if (BLI_rcti_isect(&r, &rect_clamp, &rect_clamp)) {
|
||||
SELECTID_Context *select_ctx = DRW_select_engine_context_get();
|
||||
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
/* Update the drawing. */
|
||||
DRW_draw_select_id(depsgraph, region, v3d, rect);
|
||||
|
||||
@ -84,7 +84,7 @@ uint *DRW_select_buffer_read(
|
||||
}
|
||||
|
||||
GPU_framebuffer_restore();
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
}
|
||||
|
||||
if (r_buf_len) {
|
||||
|
@ -1088,7 +1088,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
RE_current_scene_update_cb(re, rj, current_scene_update);
|
||||
RE_stats_draw_cb(re, rj, image_renderinfo_cb);
|
||||
RE_progress_cb(re, rj, render_progress_update);
|
||||
RE_gl_context_create(re);
|
||||
RE_system_gpu_context_create(re);
|
||||
|
||||
rj->re = re;
|
||||
G.is_break = false;
|
||||
|
@ -302,7 +302,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
|
||||
uchar *gp_rect;
|
||||
uchar *render_rect = ibuf_result->byte_buffer.data;
|
||||
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
GPU_offscreen_bind(oglrender->ofs, true);
|
||||
|
||||
GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
@ -324,7 +324,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
|
||||
blend_color_mix_byte(&render_rect[i], &render_rect[i], &gp_rect[i]);
|
||||
}
|
||||
GPU_offscreen_unbind(oglrender->ofs, true);
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
|
||||
MEM_freeN(gp_rect);
|
||||
}
|
||||
@ -744,14 +744,14 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
|
||||
BKE_render_resolution(&scene->r, false, &sizex, &sizey);
|
||||
|
||||
/* corrects render size with actual size, not every card supports non-power-of-two dimensions */
|
||||
DRW_opengl_context_enable(); /* Off-screen creation needs to be done in DRW context. */
|
||||
DRW_gpu_context_enable(); /* Off-screen creation needs to be done in DRW context. */
|
||||
ofs = GPU_offscreen_create(sizex,
|
||||
sizey,
|
||||
true,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_HOST_READ,
|
||||
err_out);
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
|
||||
if (!ofs) {
|
||||
BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer, %s", err_out);
|
||||
@ -925,9 +925,9 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
|
||||
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
GPU_offscreen_free(oglrender->ofs);
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
|
||||
if (oglrender->is_sequencer) {
|
||||
MEM_freeN(oglrender->seq_data.ibufs_arr);
|
||||
|
@ -243,7 +243,7 @@ static void compo_initjob(void *cjv)
|
||||
}
|
||||
|
||||
cj->re = RE_NewSceneRender(scene);
|
||||
RE_gl_context_create(cj->re);
|
||||
RE_system_gpu_context_create(cj->re);
|
||||
}
|
||||
|
||||
/* Called before redraw notifiers, it moves finished previews over. */
|
||||
@ -302,7 +302,7 @@ static void compo_startjob(void *cjv,
|
||||
}
|
||||
}
|
||||
|
||||
RE_gl_context_destroy(cj->re);
|
||||
RE_system_gpu_context_destroy(cj->re);
|
||||
|
||||
ntree->runtime->test_break = nullptr;
|
||||
ntree->runtime->stats_draw = nullptr;
|
||||
|
@ -1899,7 +1899,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
|
||||
}
|
||||
|
||||
const bool own_ofs = (ofs == nullptr);
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
|
||||
if (own_ofs) {
|
||||
/* bind */
|
||||
@ -1910,7 +1910,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_HOST_READ,
|
||||
err_out);
|
||||
if (ofs == nullptr) {
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -2006,7 +2006,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
|
||||
GPU_offscreen_free(ofs);
|
||||
}
|
||||
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
|
||||
if (old_fb) {
|
||||
GPU_framebuffer_bind(old_fb);
|
||||
|
@ -666,7 +666,7 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
||||
UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
|
||||
|
||||
/* All of the queries need to be perform on the drawing context. */
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
|
||||
G.f |= G_FLAG_PICKSEL;
|
||||
|
||||
@ -746,7 +746,7 @@ int view3d_opengl_select_ex(ViewContext *vc,
|
||||
GPU_depth_test(GPU_DEPTH_NONE);
|
||||
}
|
||||
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
|
||||
UI_Theme_Restore(&theme_state);
|
||||
|
||||
|
@ -60,7 +60,7 @@ void GPU_viewport_colorspace_set(GPUViewport *viewport,
|
||||
float dither);
|
||||
|
||||
/**
|
||||
* Should be called from DRW after DRW_opengl_context_enable.
|
||||
* Should be called from DRW after DRW_gpu_context_enable.
|
||||
*/
|
||||
void GPU_viewport_bind_from_offscreen(GPUViewport *viewport,
|
||||
struct GPUOffScreen *ofs,
|
||||
|
@ -43,21 +43,21 @@ void ShaderBuilder::init()
|
||||
{
|
||||
CLG_init();
|
||||
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
switch (GPU_backend_type_selection_get()) {
|
||||
case GPU_BACKEND_OPENGL:
|
||||
glSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
|
||||
gpuSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
|
||||
break;
|
||||
|
||||
#ifdef WITH_METAL_BACKEND
|
||||
case GPU_BACKEND_METAL:
|
||||
glSettings.context_type = GHOST_kDrawingContextTypeMetal;
|
||||
gpuSettings.context_type = GHOST_kDrawingContextTypeMetal;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_VULKAN_BACKEND
|
||||
case GPU_BACKEND_VULKAN:
|
||||
glSettings.context_type = GHOST_kDrawingContextTypeVulkan;
|
||||
gpuSettings.context_type = GHOST_kDrawingContextTypeVulkan;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -67,8 +67,8 @@ void ShaderBuilder::init()
|
||||
}
|
||||
|
||||
ghost_system_ = GHOST_CreateSystemBackground();
|
||||
ghost_context_ = GHOST_CreateOpenGLContext(ghost_system_, glSettings);
|
||||
GHOST_ActivateOpenGLContext(ghost_context_);
|
||||
ghost_context_ = GHOST_CreateGPUContext(ghost_system_, gpuSettings);
|
||||
GHOST_ActivateGPUContext(ghost_context_);
|
||||
|
||||
gpu_context_ = GPU_context_create(nullptr, ghost_context_);
|
||||
GPU_init();
|
||||
@ -80,7 +80,7 @@ void ShaderBuilder::exit()
|
||||
|
||||
GPU_context_discard(gpu_context_);
|
||||
|
||||
GHOST_DisposeOpenGLContext(ghost_system_, ghost_context_);
|
||||
GHOST_DisposeGPUContext(ghost_system_, ghost_context_);
|
||||
GHOST_DisposeSystem(ghost_system_);
|
||||
|
||||
CLG_exit();
|
||||
|
@ -194,7 +194,7 @@ void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
|
||||
rect_size[0] = BLI_rcti_size_x(rect) + 1;
|
||||
rect_size[1] = BLI_rcti_size_y(rect) + 1;
|
||||
|
||||
DRW_opengl_context_enable();
|
||||
DRW_gpu_context_enable();
|
||||
|
||||
if (!equals_v2v2_int(viewport->size, rect_size)) {
|
||||
copy_v2_v2_int(viewport->size, rect_size);
|
||||
@ -562,7 +562,7 @@ void GPU_viewport_unbind_from_offscreen(GPUViewport *viewport,
|
||||
void GPU_viewport_unbind(GPUViewport *UNUSED(viewport))
|
||||
{
|
||||
GPU_framebuffer_restore();
|
||||
DRW_opengl_context_disable();
|
||||
DRW_gpu_context_disable();
|
||||
}
|
||||
|
||||
int GPU_viewport_active_view_get(GPUViewport *viewport)
|
||||
|
@ -51,7 +51,7 @@ GLContext::GLContext(void *ghost_window, GLSharedOrphanLists &shared_orphan_list
|
||||
ghost_window_ = ghost_window;
|
||||
|
||||
if (ghost_window) {
|
||||
GLuint default_fbo = GHOST_GetDefaultOpenGLFramebuffer((GHOST_WindowHandle)ghost_window);
|
||||
GLuint default_fbo = GHOST_GetDefaultGPUFramebuffer((GHOST_WindowHandle)ghost_window);
|
||||
GHOST_RectangleHandle bounds = GHOST_GetClientBounds((GHOST_WindowHandle)ghost_window);
|
||||
int w = GHOST_GetWidthRectangle(bounds);
|
||||
int h = GHOST_GetHeightRectangle(bounds);
|
||||
|
@ -24,12 +24,12 @@ void GPUTest::SetUp()
|
||||
|
||||
CLG_init();
|
||||
GPU_backend_type_selection_set(gpu_backend_type);
|
||||
GHOST_GLSettings glSettings = {};
|
||||
glSettings.context_type = draw_context_type;
|
||||
glSettings.flags = GHOST_glDebugContext;
|
||||
GHOST_GPUSettings gpuSettings = {};
|
||||
gpuSettings.context_type = draw_context_type;
|
||||
gpuSettings.flags = GHOST_gpuDebugContext;
|
||||
ghost_system = GHOST_CreateSystem();
|
||||
ghost_context = GHOST_CreateOpenGLContext(ghost_system, glSettings);
|
||||
GHOST_ActivateOpenGLContext(ghost_context);
|
||||
ghost_context = GHOST_CreateGPUContext(ghost_system, gpuSettings);
|
||||
GHOST_ActivateGPUContext(ghost_context);
|
||||
context = GPU_context_create(nullptr, ghost_context);
|
||||
GPU_init();
|
||||
|
||||
@ -46,7 +46,7 @@ void GPUTest::TearDown()
|
||||
|
||||
GPU_exit();
|
||||
GPU_context_discard(context);
|
||||
GHOST_DisposeOpenGLContext(ghost_system, ghost_context);
|
||||
GHOST_DisposeGPUContext(ghost_system, ghost_context);
|
||||
GHOST_DisposeSystem(ghost_system);
|
||||
CLG_exit();
|
||||
|
||||
|
@ -162,10 +162,10 @@ typedef struct RenderEngine {
|
||||
void *update_render_passes_data;
|
||||
|
||||
/* GPU context. */
|
||||
void *wm_gpu_context; /* WindowManager GPU context -> GHOSTContext. */
|
||||
ThreadMutex gpu_context_mutex;
|
||||
void *wm_blender_gpu_context; /* WindowManager GPU context -> GHOSTContext. */
|
||||
ThreadMutex blender_gpu_context_mutex;
|
||||
bool use_drw_render_context;
|
||||
struct GPUContext *gpu_context;
|
||||
struct GPUContext *blender_gpu_context;
|
||||
/* Whether to restore DRWState after RenderEngine display pass. */
|
||||
bool gpu_restore_context;
|
||||
} RenderEngine;
|
||||
@ -272,8 +272,6 @@ void RE_engines_init_experimental(void);
|
||||
void RE_engines_exit(void);
|
||||
void RE_engines_register(RenderEngineType *render_type);
|
||||
|
||||
bool RE_engine_is_opengl(RenderEngineType *render_type);
|
||||
|
||||
/**
|
||||
* Return true if the RenderEngineType has native support for direct loading of Alembic data. For
|
||||
* Cycles, this also checks that the experimental feature set is enabled.
|
||||
|
@ -426,10 +426,10 @@ void RE_current_scene_update_cb(struct Render *re,
|
||||
void *handle,
|
||||
void (*f)(void *handle, struct Scene *scene));
|
||||
|
||||
void RE_gl_context_create(Render *re);
|
||||
void RE_gl_context_destroy(Render *re);
|
||||
void *RE_gl_context_get(Render *re);
|
||||
void *RE_gpu_context_get(Render *re);
|
||||
void RE_system_gpu_context_create(Render *re);
|
||||
void RE_system_gpu_context_destroy(Render *re);
|
||||
void *RE_system_gpu_context_get(Render *re);
|
||||
void *RE_blender_gpu_context_get(Render *re);
|
||||
|
||||
/**
|
||||
* \param x: ranges from -1 to 1.
|
||||
|
@ -115,13 +115,6 @@ bool RE_engine_is_external(const Render *re)
|
||||
return (re->engine && re->engine->type && re->engine->type->render);
|
||||
}
|
||||
|
||||
bool RE_engine_is_opengl(RenderEngineType *render_type)
|
||||
{
|
||||
/* TODO: refine? Can we have OpenGL render engine without OpenGL render pipeline? */
|
||||
return (render_type->draw_engine != nullptr) &&
|
||||
DRW_engine_render_support(render_type->draw_engine);
|
||||
}
|
||||
|
||||
bool RE_engine_supports_alembic_procedural(const RenderEngineType *render_type, Scene *scene)
|
||||
{
|
||||
if ((render_type->flag & RE_USE_ALEMBIC_PROCEDURAL) == 0) {
|
||||
@ -143,7 +136,7 @@ RenderEngine *RE_engine_create(RenderEngineType *type)
|
||||
engine->type = type;
|
||||
|
||||
BLI_mutex_init(&engine->update_render_passes_mutex);
|
||||
BLI_mutex_init(&engine->gpu_context_mutex);
|
||||
BLI_mutex_init(&engine->blender_gpu_context_mutex);
|
||||
|
||||
return engine;
|
||||
}
|
||||
@ -176,7 +169,7 @@ void RE_engine_free(RenderEngine *engine)
|
||||
|
||||
engine_depsgraph_free(engine);
|
||||
|
||||
BLI_mutex_end(&engine->gpu_context_mutex);
|
||||
BLI_mutex_end(&engine->blender_gpu_context_mutex);
|
||||
BLI_mutex_end(&engine->update_render_passes_mutex);
|
||||
|
||||
MEM_freeN(engine);
|
||||
@ -1271,7 +1264,7 @@ void RE_engine_tile_highlight_clear_all(RenderEngine *engine)
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name OpenGL context manipulation.
|
||||
/** \name GPU context manipulation.
|
||||
*
|
||||
* GPU context for engine to create and update GPU resources in its own thread,
|
||||
* without blocking the main thread. Used by Cycles' display driver to create
|
||||
@ -1282,7 +1275,7 @@ void RE_engine_tile_highlight_clear_all(RenderEngine *engine)
|
||||
bool RE_engine_gpu_context_create(RenderEngine *engine)
|
||||
{
|
||||
/* If the there already is a draw manager render context available, reuse it. */
|
||||
engine->use_drw_render_context = (engine->re && RE_gl_context_get(engine->re));
|
||||
engine->use_drw_render_context = (engine->re && RE_system_gpu_context_get(engine->re));
|
||||
if (engine->use_drw_render_context) {
|
||||
return true;
|
||||
}
|
||||
@ -1291,49 +1284,49 @@ bool RE_engine_gpu_context_create(RenderEngine *engine)
|
||||
* the main thread here to safely create a context. */
|
||||
BLI_assert(BLI_thread_is_main());
|
||||
|
||||
const bool drw_state = DRW_opengl_context_release();
|
||||
engine->wm_gpu_context = WM_opengl_context_create();
|
||||
const bool drw_state = DRW_gpu_context_release();
|
||||
engine->wm_blender_gpu_context = WM_system_gpu_context_create();
|
||||
|
||||
if (engine->wm_gpu_context) {
|
||||
/* Activate new OpenGL Context for GPUContext creation. */
|
||||
WM_opengl_context_activate(engine->wm_gpu_context);
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
/* Activate new GPU Context for GPUContext creation. */
|
||||
WM_system_gpu_context_activate(engine->wm_blender_gpu_context);
|
||||
/* Requires GPUContext for usage of GPU Module for displaying results. */
|
||||
engine->gpu_context = GPU_context_create(nullptr, engine->wm_gpu_context);
|
||||
engine->blender_gpu_context = GPU_context_create(nullptr, engine->wm_blender_gpu_context);
|
||||
GPU_context_active_set(nullptr);
|
||||
/* Deactivate newly created OpenGL Context, as it is not needed until
|
||||
/* Deactivate newly created GPU Context, as it is not needed until
|
||||
* `RE_engine_gpu_context_enable` is called. */
|
||||
WM_opengl_context_release(engine->wm_gpu_context);
|
||||
WM_system_gpu_context_release(engine->wm_blender_gpu_context);
|
||||
}
|
||||
else {
|
||||
engine->gpu_context = nullptr;
|
||||
engine->blender_gpu_context = nullptr;
|
||||
}
|
||||
|
||||
DRW_opengl_context_activate(drw_state);
|
||||
DRW_gpu_context_activate(drw_state);
|
||||
|
||||
return engine->wm_gpu_context != nullptr;
|
||||
return engine->wm_blender_gpu_context != nullptr;
|
||||
}
|
||||
|
||||
void RE_engine_gpu_context_destroy(RenderEngine *engine)
|
||||
{
|
||||
if (!engine->wm_gpu_context) {
|
||||
if (!engine->wm_blender_gpu_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool drw_state = DRW_opengl_context_release();
|
||||
const bool drw_state = DRW_gpu_context_release();
|
||||
|
||||
WM_opengl_context_activate(engine->wm_gpu_context);
|
||||
if (engine->gpu_context) {
|
||||
WM_system_gpu_context_activate(engine->wm_blender_gpu_context);
|
||||
if (engine->blender_gpu_context) {
|
||||
GPUContext *restore_context = GPU_context_active_get();
|
||||
GPU_context_active_set(engine->gpu_context);
|
||||
GPU_context_discard(engine->gpu_context);
|
||||
if (restore_context != engine->gpu_context) {
|
||||
GPU_context_active_set(engine->blender_gpu_context);
|
||||
GPU_context_discard(engine->blender_gpu_context);
|
||||
if (restore_context != engine->blender_gpu_context) {
|
||||
GPU_context_active_set(restore_context);
|
||||
}
|
||||
engine->gpu_context = nullptr;
|
||||
engine->blender_gpu_context = nullptr;
|
||||
}
|
||||
WM_opengl_context_dispose(engine->wm_gpu_context);
|
||||
WM_system_gpu_context_dispose(engine->wm_blender_gpu_context);
|
||||
|
||||
DRW_opengl_context_activate(drw_state);
|
||||
DRW_gpu_context_activate(drw_state);
|
||||
}
|
||||
|
||||
bool RE_engine_gpu_context_enable(RenderEngine *engine)
|
||||
@ -1343,16 +1336,16 @@ bool RE_engine_gpu_context_enable(RenderEngine *engine)
|
||||
DRW_render_context_enable(engine->re);
|
||||
return true;
|
||||
}
|
||||
if (engine->wm_gpu_context) {
|
||||
BLI_mutex_lock(&engine->gpu_context_mutex);
|
||||
/* If a previous OpenGL/GPUContext was active (DST.gpu_context), we should later restore this
|
||||
* when disabling the RenderEngine context. */
|
||||
engine->gpu_restore_context = DRW_opengl_context_release();
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
BLI_mutex_lock(&engine->blender_gpu_context_mutex);
|
||||
/* If a previous GPU/GPUContext was active (DST.blender_gpu_context), we should later
|
||||
* restore this when disabling the RenderEngine context. */
|
||||
engine->gpu_restore_context = DRW_gpu_context_release();
|
||||
|
||||
/* Activate RenderEngine OpenGL and GPU Context. */
|
||||
WM_opengl_context_activate(engine->wm_gpu_context);
|
||||
if (engine->gpu_context) {
|
||||
GPU_context_active_set(engine->gpu_context);
|
||||
/* Activate RenderEngine System and Blender GPU Context. */
|
||||
WM_system_gpu_context_activate(engine->wm_blender_gpu_context);
|
||||
if (engine->blender_gpu_context) {
|
||||
GPU_context_active_set(engine->blender_gpu_context);
|
||||
GPU_render_begin();
|
||||
}
|
||||
return true;
|
||||
@ -1366,15 +1359,15 @@ void RE_engine_gpu_context_disable(RenderEngine *engine)
|
||||
DRW_render_context_disable(engine->re);
|
||||
}
|
||||
else {
|
||||
if (engine->wm_gpu_context) {
|
||||
if (engine->gpu_context) {
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
if (engine->blender_gpu_context) {
|
||||
GPU_render_end();
|
||||
GPU_context_active_set(nullptr);
|
||||
}
|
||||
WM_opengl_context_release(engine->wm_gpu_context);
|
||||
WM_system_gpu_context_release(engine->wm_blender_gpu_context);
|
||||
/* Restore DRW state context if previously active. */
|
||||
DRW_opengl_context_activate(engine->gpu_restore_context);
|
||||
BLI_mutex_unlock(&engine->gpu_context_mutex);
|
||||
DRW_gpu_context_activate(engine->gpu_restore_context);
|
||||
BLI_mutex_unlock(&engine->blender_gpu_context_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1385,8 +1378,8 @@ void RE_engine_gpu_context_lock(RenderEngine *engine)
|
||||
/* Locking already handled by the draw manager. */
|
||||
}
|
||||
else {
|
||||
if (engine->wm_gpu_context) {
|
||||
BLI_mutex_lock(&engine->gpu_context_mutex);
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
BLI_mutex_lock(&engine->blender_gpu_context_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1397,8 +1390,8 @@ void RE_engine_gpu_context_unlock(RenderEngine *engine)
|
||||
/* Locking already handled by the draw manager. */
|
||||
}
|
||||
else {
|
||||
if (engine->wm_gpu_context) {
|
||||
BLI_mutex_unlock(&engine->gpu_context_mutex);
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
BLI_mutex_unlock(&engine->blender_gpu_context_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -877,44 +877,44 @@ void RE_test_break_cb(Render *re, void *handle, bool (*f)(void *handle))
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name OpenGL Context
|
||||
/** \name GPU Context
|
||||
* \{ */
|
||||
|
||||
void RE_gl_context_create(Render *re)
|
||||
void RE_system_gpu_context_create(Render *re)
|
||||
{
|
||||
/* Needs to be created in the main OpenGL thread. */
|
||||
re->gl_context = WM_opengl_context_create();
|
||||
/* Needs to be created in the main thread. */
|
||||
re->system_gpu_context = WM_system_gpu_context_create();
|
||||
/* So we activate the window's one afterwards. */
|
||||
wm_window_reset_drawable();
|
||||
}
|
||||
|
||||
void RE_gl_context_destroy(Render *re)
|
||||
void RE_system_gpu_context_destroy(Render *re)
|
||||
{
|
||||
/* Needs to be called from the thread which used the OpenGL context for rendering. */
|
||||
if (re->gl_context) {
|
||||
if (re->gpu_context) {
|
||||
WM_opengl_context_activate(re->gl_context);
|
||||
GPU_context_active_set(static_cast<GPUContext *>(re->gpu_context));
|
||||
GPU_context_discard(static_cast<GPUContext *>(re->gpu_context));
|
||||
re->gpu_context = nullptr;
|
||||
/* Needs to be called from the thread which used the GPU context for rendering. */
|
||||
if (re->system_gpu_context) {
|
||||
if (re->blender_gpu_context) {
|
||||
WM_system_gpu_context_activate(re->system_gpu_context);
|
||||
GPU_context_active_set(static_cast<GPUContext *>(re->blender_gpu_context));
|
||||
GPU_context_discard(static_cast<GPUContext *>(re->blender_gpu_context));
|
||||
re->blender_gpu_context = nullptr;
|
||||
}
|
||||
|
||||
WM_opengl_context_dispose(re->gl_context);
|
||||
re->gl_context = nullptr;
|
||||
WM_system_gpu_context_dispose(re->system_gpu_context);
|
||||
re->system_gpu_context = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void *RE_gl_context_get(Render *re)
|
||||
void *RE_system_gpu_context_get(Render *re)
|
||||
{
|
||||
return re->gl_context;
|
||||
return re->system_gpu_context;
|
||||
}
|
||||
|
||||
void *RE_gpu_context_get(Render *re)
|
||||
void *RE_blender_gpu_context_get(Render *re)
|
||||
{
|
||||
if (re->gpu_context == nullptr) {
|
||||
re->gpu_context = GPU_context_create(nullptr, re->gl_context);
|
||||
if (re->blender_gpu_context == nullptr) {
|
||||
re->blender_gpu_context = GPU_context_create(nullptr, re->system_gpu_context);
|
||||
}
|
||||
return re->gpu_context;
|
||||
return re->blender_gpu_context;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@ -1752,7 +1752,7 @@ static void render_pipeline_free(Render *re)
|
||||
re->pipeline_scene_eval = nullptr;
|
||||
}
|
||||
/* Destroy the opengl context in the correct thread. */
|
||||
RE_gl_context_destroy(re);
|
||||
RE_system_gpu_context_destroy(re);
|
||||
|
||||
/* In the case the engine did not mark tiles as finished (un-highlight, which could happen in the
|
||||
* case of cancelled render) ensure the storage is empty. */
|
||||
|
@ -124,8 +124,8 @@ struct Render {
|
||||
char viewname[MAX_NAME];
|
||||
|
||||
/* TODO: replace by a whole draw manager. */
|
||||
void *gl_context;
|
||||
void *gpu_context;
|
||||
void *system_gpu_context;
|
||||
void *blender_gpu_context;
|
||||
};
|
||||
|
||||
/* **************** defines ********************* */
|
||||
|
@ -144,7 +144,7 @@ void WM_init_splash_on_startup(struct bContext *C);
|
||||
*/
|
||||
void WM_init_splash(struct bContext *C);
|
||||
|
||||
void WM_init_opengl(void);
|
||||
void WM_init_gpu(void);
|
||||
|
||||
/**
|
||||
* Return an identifier for the underlying GHOST implementation.
|
||||
@ -313,10 +313,10 @@ void WM_window_ensure_active_view_layer(struct wmWindow *win) ATTR_NONNULL(1);
|
||||
|
||||
bool WM_window_is_temp_screen(const struct wmWindow *win) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
void *WM_opengl_context_create(void);
|
||||
void WM_opengl_context_dispose(void *context);
|
||||
void WM_opengl_context_activate(void *context);
|
||||
void WM_opengl_context_release(void *context);
|
||||
void *WM_system_gpu_context_create(void);
|
||||
void WM_system_gpu_context_dispose(void *context);
|
||||
void WM_system_gpu_context_activate(void *context);
|
||||
void WM_system_gpu_context_release(void *context);
|
||||
|
||||
/* #WM_window_open alignment */
|
||||
typedef enum eWindowAlignment {
|
||||
|
@ -1199,11 +1199,11 @@ static void wm_draw_surface(bContext *C, wmSurface *surface)
|
||||
wm_window_clear_drawable(CTX_wm_manager(C));
|
||||
wm_surface_make_drawable(surface);
|
||||
|
||||
GPU_context_begin_frame(surface->gpu_ctx);
|
||||
GPU_context_begin_frame(surface->blender_gpu_context);
|
||||
|
||||
surface->draw(C);
|
||||
|
||||
GPU_context_end_frame(surface->gpu_ctx);
|
||||
GPU_context_end_frame(surface->blender_gpu_context);
|
||||
|
||||
/* Avoid interference with window drawable */
|
||||
wm_surface_clear_drawable();
|
||||
|
@ -159,12 +159,12 @@ void WM_init_state_start_with_console_set(bool value)
|
||||
* so that it does not break anything that can run in headless mode (as in
|
||||
* without display server attached).
|
||||
*/
|
||||
static bool opengl_is_init = false;
|
||||
static bool gpu_is_init = false;
|
||||
|
||||
void WM_init_opengl(void)
|
||||
void WM_init_gpu(void)
|
||||
{
|
||||
/* Must be called only once. */
|
||||
BLI_assert(opengl_is_init == false);
|
||||
BLI_assert(gpu_is_init == false);
|
||||
|
||||
if (G.background) {
|
||||
/* Ghost is still not initialized elsewhere in background mode. */
|
||||
@ -176,13 +176,13 @@ void WM_init_opengl(void)
|
||||
}
|
||||
|
||||
/* Needs to be first to have an OpenGL context bound. */
|
||||
DRW_opengl_context_create();
|
||||
DRW_gpu_context_create();
|
||||
|
||||
GPU_init();
|
||||
|
||||
GPU_pass_cache_init();
|
||||
|
||||
opengl_is_init = true;
|
||||
gpu_is_init = true;
|
||||
}
|
||||
|
||||
static void sound_jack_sync_callback(Main *bmain, int mode, double time)
|
||||
@ -317,7 +317,7 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
/* Sets 3D mouse dead-zone. */
|
||||
WM_ndof_deadzone_set(U.ndof_deadzone);
|
||||
#endif
|
||||
WM_init_opengl();
|
||||
WM_init_gpu();
|
||||
|
||||
if (!WM_platform_support_perform_checks()) {
|
||||
/* No attempt to avoid memory leaks here. */
|
||||
@ -603,7 +603,7 @@ void WM_exit_ex(bContext *C, const bool do_python, const bool do_user_exit_actio
|
||||
|
||||
BKE_subdiv_exit();
|
||||
|
||||
if (opengl_is_init) {
|
||||
if (gpu_is_init) {
|
||||
BKE_image_free_unused_gpu_textures();
|
||||
}
|
||||
|
||||
@ -617,7 +617,7 @@ void WM_exit_ex(bContext *C, const bool do_python, const bool do_user_exit_actio
|
||||
|
||||
/* Free the GPU subdivision data after the database to ensure that subdivision structs used by
|
||||
* the modifiers were garbage collected. */
|
||||
if (opengl_is_init) {
|
||||
if (gpu_is_init) {
|
||||
DRW_subdiv_free();
|
||||
}
|
||||
|
||||
@ -664,13 +664,13 @@ void WM_exit_ex(bContext *C, const bool do_python, const bool do_user_exit_actio
|
||||
|
||||
/* Delete GPU resources and context. The UI also uses GPU resources and so
|
||||
* is also deleted with the context active. */
|
||||
if (opengl_is_init) {
|
||||
DRW_opengl_context_enable_ex(false);
|
||||
if (gpu_is_init) {
|
||||
DRW_gpu_context_enable_ex(false);
|
||||
UI_exit();
|
||||
GPU_pass_cache_free();
|
||||
GPU_exit();
|
||||
DRW_opengl_context_disable_ex(false);
|
||||
DRW_opengl_context_destroy();
|
||||
DRW_gpu_context_disable_ex(false);
|
||||
DRW_gpu_context_destroy();
|
||||
}
|
||||
else {
|
||||
UI_exit();
|
||||
|
@ -191,7 +191,7 @@ typedef enum eWS_Qual {
|
||||
static struct WindowStateGlobal {
|
||||
GHOST_SystemHandle ghost_system;
|
||||
void *ghost_window;
|
||||
GPUContext *gpu_context;
|
||||
GPUContext *blender_gpu_context;
|
||||
|
||||
/* events */
|
||||
eWS_Qual qual;
|
||||
@ -1350,9 +1350,9 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
|
||||
static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey)
|
||||
{
|
||||
GHOST_GLSettings glsettings = {0};
|
||||
GHOST_GPUSettings gpusettings = {0};
|
||||
const eGPUBackendType gpu_backend = GPU_backend_type_selection_get();
|
||||
glsettings.context_type = wm_ghost_drawing_context_type(gpu_backend);
|
||||
gpusettings.context_type = wm_ghost_drawing_context_type(gpu_backend);
|
||||
uint32_t scr_w, scr_h;
|
||||
|
||||
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &scr_w, &scr_h);
|
||||
@ -1369,7 +1369,7 @@ static void playanim_window_open(const char *title, int posx, int posy, int size
|
||||
/* Could optionally start full-screen. */
|
||||
GHOST_kWindowStateNormal,
|
||||
false,
|
||||
glsettings);
|
||||
gpusettings);
|
||||
}
|
||||
|
||||
static void playanim_window_zoom(PlayState *ps, const float zoom_offset)
|
||||
@ -1569,7 +1569,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
// GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
|
||||
|
||||
/* initialize OpenGL immediate mode */
|
||||
g_WS.gpu_context = GPU_context_create(g_WS.ghost_window, NULL);
|
||||
g_WS.blender_gpu_context = GPU_context_create(g_WS.ghost_window, NULL);
|
||||
GPU_init();
|
||||
|
||||
/* initialize the font */
|
||||
@ -1832,11 +1832,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
|
||||
BLF_exit();
|
||||
|
||||
if (g_WS.gpu_context) {
|
||||
GPU_context_active_set(g_WS.gpu_context);
|
||||
if (g_WS.blender_gpu_context) {
|
||||
GPU_context_active_set(g_WS.blender_gpu_context);
|
||||
GPU_exit();
|
||||
GPU_context_discard(g_WS.gpu_context);
|
||||
g_WS.gpu_context = NULL;
|
||||
GPU_context_discard(g_WS.blender_gpu_context);
|
||||
g_WS.blender_gpu_context = NULL;
|
||||
}
|
||||
|
||||
GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window);
|
||||
|
@ -54,7 +54,7 @@ void wm_surfaces_do_depsgraph(bContext *C)
|
||||
void wm_surface_clear_drawable(void)
|
||||
{
|
||||
if (g_drawable) {
|
||||
WM_opengl_context_release(g_drawable->ghost_ctx);
|
||||
WM_system_gpu_context_release(g_drawable->system_gpu_context);
|
||||
GPU_context_active_set(NULL);
|
||||
|
||||
if (g_drawable->deactivate) {
|
||||
@ -74,10 +74,10 @@ void wm_surface_set_drawable(wmSurface *surface, bool activate)
|
||||
if (surface->activate) {
|
||||
surface->activate();
|
||||
}
|
||||
WM_opengl_context_activate(surface->ghost_ctx);
|
||||
WM_system_gpu_context_activate(surface->system_gpu_context);
|
||||
}
|
||||
|
||||
GPU_context_active_set(surface->gpu_ctx);
|
||||
GPU_context_active_set(surface->blender_gpu_context);
|
||||
}
|
||||
|
||||
void wm_surface_make_drawable(wmSurface *surface)
|
||||
|
@ -216,7 +216,7 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
|
||||
wm->winactive = NULL;
|
||||
}
|
||||
|
||||
/* We need this window's opengl context active to discard it. */
|
||||
/* We need this window's GPU context active to discard it. */
|
||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||
GPU_context_active_set(win->gpuctx);
|
||||
|
||||
@ -670,17 +670,17 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
|
||||
bool is_dialog)
|
||||
{
|
||||
/* A new window is created when page-flip mode is required for a window. */
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
|
||||
glSettings.flags |= GHOST_glStereoVisual;
|
||||
gpuSettings.flags |= GHOST_gpuStereoVisual;
|
||||
}
|
||||
|
||||
if (G.debug & G_DEBUG_GPU) {
|
||||
glSettings.flags |= GHOST_glDebugContext;
|
||||
gpuSettings.flags |= GHOST_gpuDebugContext;
|
||||
}
|
||||
|
||||
eGPUBackendType gpu_backend = GPU_backend_type_selection_get();
|
||||
glSettings.context_type = wm_ghost_drawing_context_type(gpu_backend);
|
||||
gpuSettings.context_type = wm_ghost_drawing_context_type(gpu_backend);
|
||||
|
||||
int scr_w, scr_h;
|
||||
wm_get_desktopsize(&scr_w, &scr_h);
|
||||
@ -699,7 +699,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
|
||||
win->sizey,
|
||||
(GHOST_TWindowState)win->windowstate,
|
||||
is_dialog,
|
||||
glSettings);
|
||||
gpuSettings);
|
||||
|
||||
if (ghostwin) {
|
||||
win->gpuctx = GPU_context_create(ghostwin, NULL);
|
||||
@ -2632,10 +2632,10 @@ void wm_window_IME_end(wmWindow *win)
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Direct OpenGL Context Management
|
||||
/** \name Direct GPU Context Management
|
||||
* \{ */
|
||||
|
||||
void *WM_opengl_context_create(void)
|
||||
void *WM_system_gpu_context_create(void)
|
||||
{
|
||||
/* On Windows there is a problem creating contexts that share resources (almost any object,
|
||||
* including legacy display lists, but also textures) with a context which is current in another
|
||||
@ -2649,31 +2649,31 @@ void *WM_opengl_context_create(void)
|
||||
BLI_assert(BLI_thread_is_main());
|
||||
BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get());
|
||||
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
GHOST_GPUSettings gpuSettings = {0};
|
||||
const eGPUBackendType gpu_backend = GPU_backend_type_selection_get();
|
||||
glSettings.context_type = wm_ghost_drawing_context_type(gpu_backend);
|
||||
gpuSettings.context_type = wm_ghost_drawing_context_type(gpu_backend);
|
||||
if (G.debug & G_DEBUG_GPU) {
|
||||
glSettings.flags |= GHOST_glDebugContext;
|
||||
gpuSettings.flags |= GHOST_gpuDebugContext;
|
||||
}
|
||||
return GHOST_CreateOpenGLContext(g_system, glSettings);
|
||||
return GHOST_CreateGPUContext(g_system, gpuSettings);
|
||||
}
|
||||
|
||||
void WM_opengl_context_dispose(void *context)
|
||||
void WM_system_gpu_context_dispose(void *context)
|
||||
{
|
||||
BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get());
|
||||
GHOST_DisposeOpenGLContext(g_system, (GHOST_ContextHandle)context);
|
||||
GHOST_DisposeGPUContext(g_system, (GHOST_ContextHandle)context);
|
||||
}
|
||||
|
||||
void WM_opengl_context_activate(void *context)
|
||||
void WM_system_gpu_context_activate(void *context)
|
||||
{
|
||||
BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get());
|
||||
GHOST_ActivateOpenGLContext((GHOST_ContextHandle)context);
|
||||
GHOST_ActivateGPUContext((GHOST_ContextHandle)context);
|
||||
}
|
||||
|
||||
void WM_opengl_context_release(void *context)
|
||||
void WM_system_gpu_context_release(void *context)
|
||||
{
|
||||
BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get());
|
||||
GHOST_ReleaseOpenGLContext((GHOST_ContextHandle)context);
|
||||
GHOST_ReleaseGPUContext((GHOST_ContextHandle)context);
|
||||
}
|
||||
|
||||
void WM_ghost_show_message_box(const char *title,
|
||||
|
@ -21,8 +21,8 @@ extern "C" {
|
||||
typedef struct wmSurface {
|
||||
struct wmSurface *next, *prev;
|
||||
|
||||
GHOST_ContextHandle ghost_ctx;
|
||||
struct GPUContext *gpu_ctx;
|
||||
GHOST_ContextHandle system_gpu_context;
|
||||
struct GPUContext *blender_gpu_context;
|
||||
|
||||
void *customdata;
|
||||
|
||||
|
@ -86,7 +86,7 @@ void wm_window_process_events(const bContext *C);
|
||||
void wm_window_clear_drawable(wmWindowManager *wm);
|
||||
void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win);
|
||||
/**
|
||||
* Reset active the current window opengl drawing context.
|
||||
* Reset active the current window gpu drawing context.
|
||||
*/
|
||||
void wm_window_reset_drawable(void);
|
||||
|
||||
|
@ -1469,8 +1469,8 @@ static wmSurface *wm_xr_session_surface_create(void)
|
||||
surface->activate = DRW_xr_drawing_begin;
|
||||
surface->deactivate = DRW_xr_drawing_end;
|
||||
|
||||
surface->ghost_ctx = DRW_xr_opengl_context_get();
|
||||
surface->gpu_ctx = DRW_xr_gpu_context_get();
|
||||
surface->system_gpu_context = DRW_system_gpu_context_get();
|
||||
surface->blender_gpu_context = DRW_xr_blender_gpu_context_get();
|
||||
|
||||
data->controller_art->regionid = RGN_TYPE_XR;
|
||||
surface->customdata = data;
|
||||
@ -1490,7 +1490,7 @@ void *wm_xr_session_gpu_binding_context_create(void)
|
||||
* and running. */
|
||||
WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL);
|
||||
|
||||
return surface->ghost_ctx;
|
||||
return surface->system_gpu_context;
|
||||
}
|
||||
|
||||
void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle UNUSED(context))
|
||||
|
Loading…
Reference in New Issue
Block a user