Backend initialization needs to be delayed until after the OpenGL context is created. This worked fine in foreground mode because the OpenGL context already exists for the window at the point GPU_backend_init_once was called, but not for background mode. Create the backend just in time in GPU_context_create as before, and automatically free it when the last context id discarded. But check if any GPU backend is supported before creating the OpenGL context. Ref D15463, D15465
36 lines
730 B
C++
36 lines
730 B
C++
/* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#include "testing/testing.h"
|
|
|
|
#include "CLG_log.h"
|
|
|
|
#include "GPU_context.h"
|
|
#include "GPU_init_exit.h"
|
|
#include "gpu_testing.hh"
|
|
|
|
#include "GHOST_C-api.h"
|
|
|
|
namespace blender::gpu {
|
|
|
|
void GPUTest::SetUp()
|
|
{
|
|
GHOST_GLSettings glSettings = {0};
|
|
CLG_init();
|
|
ghost_system = GHOST_CreateSystem();
|
|
ghost_context = GHOST_CreateOpenGLContext(ghost_system, glSettings);
|
|
GHOST_ActivateOpenGLContext(ghost_context);
|
|
context = GPU_context_create(nullptr);
|
|
GPU_init();
|
|
}
|
|
|
|
void GPUTest::TearDown()
|
|
{
|
|
GPU_exit();
|
|
GPU_context_discard(context);
|
|
GHOST_DisposeOpenGLContext(ghost_system, ghost_context);
|
|
GHOST_DisposeSystem(ghost_system);
|
|
CLG_exit();
|
|
}
|
|
|
|
} // namespace blender::gpu
|