2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2013 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2014-10-07 15:46:19 -05:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
2014-10-07 15:46:19 -05:00
|
|
|
*/
|
|
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
#include "BKE_material.hh"
|
|
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_batch.hh"
|
2025-05-22 17:53:22 +02:00
|
|
|
#include "GPU_init_exit.hh" /* interface */
|
|
|
|
|
#include "GPU_pass.hh"
|
2015-07-02 19:30:08 +02:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "intern/gpu_private.hh"
|
2022-01-17 14:45:22 +01:00
|
|
|
#include "intern/gpu_shader_create_info_private.hh"
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "intern/gpu_shader_dependency_private.hh"
|
2014-10-07 15:46:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* although the order of initialization and shutdown should not matter
|
|
|
|
|
* (except for the extensions), I chose alphabetical and reverse alphabetical order
|
|
|
|
|
*/
|
|
|
|
|
static bool initialized = false;
|
|
|
|
|
|
2023-07-28 09:38:07 +10:00
|
|
|
void GPU_init()
|
2014-10-07 15:46:19 -05:00
|
|
|
{
|
2015-10-07 00:27:27 +11:00
|
|
|
/* can't avoid calling this multiple times, see wm_window_ghostwindow_add */
|
2019-04-22 09:32:37 +10:00
|
|
|
if (initialized) {
|
2014-10-07 15:46:19 -05:00
|
|
|
return;
|
2019-04-22 09:32:37 +10:00
|
|
|
}
|
2014-10-07 15:46:19 -05:00
|
|
|
|
|
|
|
|
initialized = true;
|
|
|
|
|
|
2025-04-07 15:26:25 +02:00
|
|
|
gpu_backend_init_resources();
|
|
|
|
|
|
2022-01-17 14:45:22 +01:00
|
|
|
gpu_shader_dependency_init();
|
|
|
|
|
gpu_shader_create_info_init();
|
|
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
GPU_pass_cache_init();
|
2015-02-16 21:19:12 +01:00
|
|
|
|
2017-02-08 00:38:07 +01:00
|
|
|
gpu_batch_init();
|
2014-10-07 15:46:19 -05:00
|
|
|
}
|
|
|
|
|
|
2023-07-28 09:38:07 +10:00
|
|
|
void GPU_exit()
|
2014-10-07 15:46:19 -05:00
|
|
|
{
|
2017-02-08 00:38:07 +01:00
|
|
|
gpu_batch_exit();
|
|
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
GPU_pass_cache_free();
|
|
|
|
|
|
|
|
|
|
BKE_material_defaults_free_gpu();
|
|
|
|
|
GPU_shader_free_builtin_shaders();
|
2014-10-07 15:46:19 -05:00
|
|
|
|
2025-05-12 19:54:03 +02:00
|
|
|
gpu_backend_delete_resources();
|
|
|
|
|
|
2022-01-17 14:45:22 +01:00
|
|
|
gpu_shader_dependency_exit();
|
|
|
|
|
gpu_shader_create_info_exit();
|
|
|
|
|
|
2014-10-07 15:46:19 -05:00
|
|
|
initialized = false;
|
|
|
|
|
}
|
2019-01-02 10:01:46 -02:00
|
|
|
|
2023-07-28 09:38:07 +10:00
|
|
|
bool GPU_is_init()
|
2019-01-02 10:01:46 -02:00
|
|
|
{
|
|
|
|
|
return initialized;
|
|
|
|
|
}
|