Blender  V3.3
GPU_context.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2016 by Mike Erwin. All rights reserved. */
3 
10 #pragma once
11 
12 #include "GPU_batch.h"
13 #include "GPU_common.h"
14 #include "GPU_platform.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /* GPU back-ends abstract the differences between different APIs. #GPU_context_create
21  * automatically initializes the back-end, and #GPU_context_discard frees it when there
22  * are no more contexts. */
23 bool GPU_backend_supported(void);
25 
27 typedef struct GPUContext GPUContext;
28 
29 GPUContext *GPU_context_create(void *ghost_window);
34 
40 
41 /* Begin and end frame are used to mark the singular boundary representing the lifetime of a whole
42  * frame. This also acts as a divisor for ensuring workload submission and flushing, especially for
43  * background rendering when there is no call to present.
44  * This is required by explicit-API's where there is no implicit workload flushing. */
47 
48 /* Legacy GPU (Intel HD4000 series) do not support sharing GPU objects between GPU
49  * contexts. EEVEE/Workbench can create different contexts for image/preview rendering, baking or
50  * compiling. When a legacy GPU is detected (`GPU_use_main_context_workaround()`) any worker
51  * threads should use the draw manager opengl context and make sure that they are the only one
52  * using it by locking the main context using these two functions. */
53 void GPU_context_main_lock(void);
54 void GPU_context_main_unlock(void);
55 
56 /* GPU Begin/end work blocks */
57 void GPU_render_begin(void);
58 void GPU_render_end(void);
59 
60 /* For operations which need to run exactly once per frame -- even if there are no render updates.
61  */
62 void GPU_render_step(void);
63 
64 #ifdef __cplusplus
65 }
66 #endif
struct GPUContext GPUContext
Definition: GPU_context.h:27
void GPU_context_main_lock(void)
Definition: gpu_context.cc:171
void GPU_render_begin(void)
Definition: gpu_context.cc:190
void GPU_context_begin_frame(GPUContext *ctx)
Definition: gpu_context.cc:147
GPUContext * GPU_context_active_get(void)
Definition: gpu_context.cc:142
void GPU_context_discard(GPUContext *)
Definition: gpu_context.cc:110
GPUContext * GPU_context_create(void *ghost_window)
Definition: gpu_context.cc:93
void GPU_context_end_frame(GPUContext *ctx)
Definition: gpu_context.cc:155
eGPUBackendType GPU_backend_get_type(void)
Definition: gpu_context.cc:274
void GPU_context_active_set(GPUContext *)
Definition: gpu_context.cc:127
void GPU_context_main_unlock(void)
Definition: gpu_context.cc:176
bool GPU_backend_supported(void)
Definition: gpu_context.cc:218
void GPU_render_end(void)
Definition: gpu_context.cc:196
void GPU_render_step(void)
Definition: gpu_context.cc:202
eGPUBackendType
Definition: GPU_platform.h:15