2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2020-09-08 11:31:47 +02:00
|
|
|
|
|
|
|
|
#include "testing/testing.h"
|
|
|
|
|
|
2021-05-10 07:59:10 +02:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
|
2023-08-11 08:18:30 +02:00
|
|
|
#include "BLI_math_color.h"
|
2025-04-14 12:37:49 +02:00
|
|
|
#include "BLI_threads.h"
|
2023-08-11 08:18:30 +02:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_context.hh"
|
|
|
|
|
#include "GPU_debug.hh"
|
|
|
|
|
#include "GPU_init_exit.hh"
|
2025-01-26 20:08:03 +01:00
|
|
|
|
2020-09-08 11:31:47 +02:00
|
|
|
#include "gpu_testing.hh"
|
|
|
|
|
|
|
|
|
|
#include "GHOST_C-api.h"
|
2025-04-29 18:14:53 +02:00
|
|
|
#include "GHOST_Path-api.hh"
|
2020-09-08 11:31:47 +02:00
|
|
|
|
|
|
|
|
namespace blender::gpu {
|
|
|
|
|
|
2025-04-29 14:02:38 +02:00
|
|
|
GHOST_SystemHandle GPUTest::ghost_system_;
|
|
|
|
|
GHOST_ContextHandle GPUTest::ghost_context_;
|
|
|
|
|
GPUContext *GPUTest::context_;
|
|
|
|
|
|
|
|
|
|
int32_t GPUTest::prev_g_debug_;
|
|
|
|
|
|
|
|
|
|
void GPUTest::SetUpTestSuite(GHOST_TDrawingContextType draw_context_type,
|
|
|
|
|
eGPUBackendType gpu_backend_type,
|
|
|
|
|
int32_t g_debug_flags)
|
2020-09-08 11:31:47 +02:00
|
|
|
{
|
2023-03-23 16:37:52 +01:00
|
|
|
prev_g_debug_ = G.debug;
|
2025-04-29 14:02:38 +02:00
|
|
|
G.debug |= g_debug_flags;
|
2023-03-23 16:37:52 +01:00
|
|
|
|
|
|
|
|
CLG_init();
|
2025-04-14 12:37:49 +02:00
|
|
|
BLI_threadapi_init();
|
2022-11-15 13:12:05 +01:00
|
|
|
GPU_backend_type_selection_set(gpu_backend_type);
|
2023-06-08 15:46:53 +02:00
|
|
|
GHOST_GPUSettings gpuSettings = {};
|
|
|
|
|
gpuSettings.context_type = draw_context_type;
|
|
|
|
|
gpuSettings.flags = GHOST_gpuDebugContext;
|
2025-04-29 14:02:38 +02:00
|
|
|
ghost_system_ = GHOST_CreateSystemBackground();
|
|
|
|
|
GPU_backend_ghost_system_set(ghost_system_);
|
|
|
|
|
ghost_context_ = GHOST_CreateGPUContext(ghost_system_, gpuSettings);
|
|
|
|
|
GHOST_ActivateGPUContext(ghost_context_);
|
|
|
|
|
context_ = GPU_context_create(nullptr, ghost_context_);
|
2020-09-08 11:31:47 +02:00
|
|
|
GPU_init();
|
2023-03-23 16:37:52 +01:00
|
|
|
|
2023-05-08 15:32:15 +02:00
|
|
|
BLI_init_srgb_conversion();
|
|
|
|
|
|
2023-09-06 14:39:38 +02:00
|
|
|
GPU_render_begin();
|
2025-04-29 14:02:38 +02:00
|
|
|
GPU_context_begin_frame(context_);
|
2024-02-23 10:57:37 +01:00
|
|
|
GPU_debug_capture_begin(nullptr);
|
2020-09-08 11:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-29 14:02:38 +02:00
|
|
|
void GPUTest::TearDownTestSuite()
|
2020-09-08 11:31:47 +02:00
|
|
|
{
|
2023-03-23 16:37:52 +01:00
|
|
|
GPU_debug_capture_end();
|
2025-04-29 14:02:38 +02:00
|
|
|
GPU_context_end_frame(context_);
|
2023-09-06 14:39:38 +02:00
|
|
|
GPU_render_end();
|
2023-03-23 16:37:52 +01:00
|
|
|
|
2020-09-08 11:31:47 +02:00
|
|
|
GPU_exit();
|
2025-04-29 14:02:38 +02:00
|
|
|
GPU_context_discard(context_);
|
|
|
|
|
GHOST_DisposeGPUContext(ghost_system_, ghost_context_);
|
|
|
|
|
GHOST_DisposeSystem(ghost_system_);
|
2025-04-29 18:14:53 +02:00
|
|
|
GHOST_DisposeSystemPaths();
|
2021-05-10 07:59:10 +02:00
|
|
|
CLG_exit();
|
2023-03-23 16:37:52 +01:00
|
|
|
|
|
|
|
|
G.debug = prev_g_debug_;
|
2020-09-08 11:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-02 09:48:41 +10:00
|
|
|
} // namespace blender::gpu
|