Blender V4.3
vk_backend.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "gpu_backend.hh"
12
13#ifdef WITH_RENDERDOC
14# include "renderdoc_api.hh"
15#endif
16
17#include "vk_common.hh"
18#include "vk_device.hh"
19#include "vk_shader_compiler.hh"
20
21namespace blender::gpu {
22
23class VKContext;
24class VKDescriptorSet;
25class VKDescriptorSetTracker;
26
27class VKBackend : public GPUBackend {
28 private:
29#ifdef WITH_RENDERDOC
30 renderdoc::api::Renderdoc renderdoc_api_;
31#endif
32
33 public:
35 /* Global instance to device handles. */
37
39 {
41 }
42
43 virtual ~VKBackend()
44 {
45 VKBackend::platform_exit();
46 }
47
55 static bool is_supported();
56
57 void delete_resources() override;
58
59 void samplers_update() override;
60 void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) override;
61 void compute_dispatch_indirect(StorageBuf *indirect_buf) override;
62
63 Context *context_alloc(void *ghost_window, void *ghost_context) override;
64
65 Batch *batch_alloc() override;
66 DrawList *drawlist_alloc(int list_length) override;
67 Fence *fence_alloc() override;
68 FrameBuffer *framebuffer_alloc(const char *name) override;
69 IndexBuf *indexbuf_alloc() override;
70 PixelBuffer *pixelbuf_alloc(size_t size) override;
71 QueryPool *querypool_alloc() override;
72 Shader *shader_alloc(const char *name) override;
73 Texture *texture_alloc(const char *name) override;
74 UniformBuf *uniformbuf_alloc(size_t size, const char *name) override;
75 StorageBuf *storagebuf_alloc(size_t size, GPUUsageType usage, const char *name) override;
76 VertBuf *vertbuf_alloc() override;
77
82
83 /* Render Frame Coordination --
84 * Used for performing per-frame actions globally */
85 void render_begin() override;
86 void render_end() override;
87 void render_step() override;
88
89 bool debug_capture_begin(const char *title);
90 void debug_capture_end();
91
92 static VKBackend &get()
93 {
94 return *static_cast<VKBackend *>(GPUBackend::get());
95 }
96
97 static void platform_init(const VKDevice &device);
98 static void capabilities_init(VKDevice &device);
99
100 private:
101 static void detect_workarounds(VKDevice &device);
102 static void platform_init();
103 static void platform_exit();
104
105 /* These classes are allowed to modify the global device. */
106 friend class VKContext;
107 friend class VKDescriptorSet;
109};
110
111} // namespace blender::gpu
static GPUBackend * get()
DrawList * drawlist_alloc(int list_length) override
Context * context_alloc(void *ghost_window, void *ghost_context) override
VKShaderCompiler shader_compiler
Definition vk_backend.hh:34
Batch * batch_alloc() override
StorageBuf * storagebuf_alloc(size_t size, GPUUsageType usage, const char *name) override
static void capabilities_init(VKDevice &device)
static VKBackend & get()
Definition vk_backend.hh:92
IndexBuf * indexbuf_alloc() override
static void platform_init(const VKDevice &device)
QueryPool * querypool_alloc() override
static bool is_supported()
void shader_cache_dir_clear_old() override
Definition vk_backend.hh:78
UniformBuf * uniformbuf_alloc(size_t size, const char *name) override
Texture * texture_alloc(const char *name) override
void samplers_update() override
PixelBuffer * pixelbuf_alloc(size_t size) override
void render_begin() override
Shader * shader_alloc(const char *name) override
void render_end() override
void render_step() override
FrameBuffer * framebuffer_alloc(const char *name) override
void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) override
void compute_dispatch_indirect(StorageBuf *indirect_buf) override
void delete_resources() override
bool debug_capture_begin(const char *title)
Definition vk_debug.cc:38
VertBuf * vertbuf_alloc() override
Fence * fence_alloc() override
static void detect_workarounds()