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"
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
namespace blender::gpu {
|
|
|
|
|
|
|
|
|
|
void GPUTest::SetUp()
|
|
|
|
|
{
|
2023-03-23 16:37:52 +01:00
|
|
|
prev_g_debug_ = G.debug;
|
2023-12-12 10:14:13 +01:00
|
|
|
G.debug |= g_debug_flags_;
|
2023-03-23 16:37:52 +01:00
|
|
|
|
|
|
|
|
CLG_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;
|
2020-09-08 11:31:47 +02:00
|
|
|
ghost_system = GHOST_CreateSystem();
|
2024-09-30 11:21:28 +02:00
|
|
|
GPU_backend_ghost_system_set(ghost_system);
|
2023-06-08 15:46:53 +02:00
|
|
|
ghost_context = GHOST_CreateGPUContext(ghost_system, gpuSettings);
|
|
|
|
|
GHOST_ActivateGPUContext(ghost_context);
|
2022-09-22 17:27:51 +02:00
|
|
|
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();
|
2023-02-21 15:03:12 +01: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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GPUTest::TearDown()
|
|
|
|
|
{
|
2023-03-23 16:37:52 +01:00
|
|
|
GPU_debug_capture_end();
|
2023-02-21 15:03:12 +01: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();
|
|
|
|
|
GPU_context_discard(context);
|
2023-06-08 15:46:53 +02:00
|
|
|
GHOST_DisposeGPUContext(ghost_system, ghost_context);
|
2020-09-08 11:31:47 +02:00
|
|
|
GHOST_DisposeSystem(ghost_system);
|
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
|