Blender V5.0
gpu_backend.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#pragma once
12
13#include "BLI_color_types.hh"
14#include "BLI_string_ref.hh"
15#include "GPU_vertex_buffer.hh"
16
17namespace blender::gpu {
18
19class Context;
20
21class Batch;
22class Fence;
23class FrameBuffer;
24class IndexBuf;
25class PixelBuffer;
26class QueryPool;
27class Shader;
28class ShaderCompiler;
29class Texture;
30class UniformBuf;
31class StorageBuf;
32class VertBuf;
33
35 protected:
37
38 public:
39 virtual ~GPUBackend() = default;
40
41 /* Called after the main context creation and activation. */
42 virtual void init_resources() = 0;
43 /* Called before the main context deletion and deactivation. */
44 virtual void delete_resources() = 0;
45
46 static GPUBackend *get();
47
49 {
50 return compiler_;
51 }
52
53 virtual void samplers_update() = 0;
54 virtual void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) = 0;
55 virtual void compute_dispatch_indirect(StorageBuf *indirect_buf) = 0;
56
57 virtual Context *context_alloc(void *ghost_window, void *ghost_context) = 0;
58
59 virtual Batch *batch_alloc() = 0;
60 virtual Fence *fence_alloc() = 0;
61 virtual FrameBuffer *framebuffer_alloc(const char *name) = 0;
62 virtual IndexBuf *indexbuf_alloc() = 0;
63 virtual PixelBuffer *pixelbuf_alloc(size_t size) = 0;
64 virtual QueryPool *querypool_alloc() = 0;
65 virtual Shader *shader_alloc(const char *name) = 0;
66 virtual Texture *texture_alloc(const char *name) = 0;
67 virtual UniformBuf *uniformbuf_alloc(size_t size, const char *name) = 0;
68 virtual StorageBuf *storagebuf_alloc(size_t size, GPUUsageType usage, const char *name) = 0;
69 virtual VertBuf *vertbuf_alloc() = 0;
70 virtual void shader_cache_dir_clear_old() = 0;
71
72 /* Render Frame Coordination --
73 * Used for performing per-frame actions globally */
74 virtual void render_begin() = 0;
75 virtual void render_end() = 0;
76 virtual void render_step(bool force_resource_release = false) = 0;
77};
78
79namespace debug {
81
83{
84 if (name == "EEVEE") {
85 return ColorTheme4f(1.0, 0.5, 0.0, 1.0);
86 }
87 if (name == "External") {
88 return ColorTheme4f(0.0, 0.0, 1.0, 1.0);
89 }
90 if (name == "GpencilMode") {
91 return ColorTheme4f(1.0, 1.0, 0.0, 1.0);
92 }
93 if (name == "UV/Image") {
94 return ColorTheme4f(0.0, 1.0, 1.0, 1.0);
95 }
96 if (name == "Overlay") {
97 return ColorTheme4f(0.0, 1.0, 0.5, 1.0);
98 }
99 if (name == "Workbench") {
100 return ColorTheme4f(0.0, 0.7, 1.0, 1.0);
101 }
102 if (name == "Cycles") {
103 return ColorTheme4f(0.0, 0.5, 1.0, 1.0);
104 }
105 if (name == "BackBuffer.Blit") {
106 return ColorTheme4f(0.5, 0.7, 1.0, 1.0);
107 }
108 if (name == "Compositor") {
109 return ColorTheme4f(1.0, 0.5, 0.7, 1.0);
110 }
112}
113} // namespace debug
114
115} // namespace blender::gpu
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
virtual void init_resources()=0
virtual void render_end()=0
static GPUBackend * get()
virtual Batch * batch_alloc()=0
virtual void render_step(bool force_resource_release=false)=0
virtual void compute_dispatch_indirect(StorageBuf *indirect_buf)=0
virtual void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len)=0
ShaderCompiler * compiler_
virtual void delete_resources()=0
virtual void render_begin()=0
virtual void samplers_update()=0
ShaderCompiler * get_compiler()
virtual PixelBuffer * pixelbuf_alloc(size_t size)=0
virtual Context * context_alloc(void *ghost_window, void *ghost_context)=0
virtual QueryPool * querypool_alloc()=0
virtual Texture * texture_alloc(const char *name)=0
virtual FrameBuffer * framebuffer_alloc(const char *name)=0
virtual UniformBuf * uniformbuf_alloc(size_t size, const char *name)=0
virtual IndexBuf * indexbuf_alloc()=0
virtual StorageBuf * storagebuf_alloc(size_t size, GPUUsageType usage, const char *name)=0
virtual void shader_cache_dir_clear_old()=0
virtual ~GPUBackend()=default
virtual Fence * fence_alloc()=0
virtual VertBuf * vertbuf_alloc()=0
virtual Shader * shader_alloc(const char *name)=0
static ColorTheme4f get_debug_group_color(StringRefNull name)
static blender::ColorTheme4f GPU_DEBUG_GROUP_COLOR_DEFAULT
ColorTheme4< float > ColorTheme4f
const char * name