Blender V5.0
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
8
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;
26
27class VKBackend : public GPUBackend {
28 private:
29#ifdef WITH_RENDERDOC
30 renderdoc::api::Renderdoc renderdoc_api_;
31#endif
32
33 public:
34 /* Global instance to device handles. */
36
38 {
40 }
41
42 virtual ~VKBackend()
43 {
44 VKBackend::platform_exit();
45 }
46
54 static bool is_supported();
55
56 void init_resources() override;
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 Fence *fence_alloc() override;
67 FrameBuffer *framebuffer_alloc(const char *name) override;
68 IndexBuf *indexbuf_alloc() override;
69 PixelBuffer *pixelbuf_alloc(size_t size) override;
70 QueryPool *querypool_alloc() override;
71 Shader *shader_alloc(const char *name) override;
72 Texture *texture_alloc(const char *name) override;
73 UniformBuf *uniformbuf_alloc(size_t size, const char *name) override;
74 StorageBuf *storagebuf_alloc(size_t size, GPUUsageType usage, const char *name) override;
75 VertBuf *vertbuf_alloc() override;
76
81
82 /* Render Frame Coordination --
83 * Used for performing per-frame actions globally */
84 void render_begin() override;
85 void render_end() override;
86 void render_step(bool /*force_resource_release*/) override;
87
88 bool debug_capture_begin(const char *title);
89 void debug_capture_end();
90
91 static VKBackend &get()
92 {
93 return *static_cast<VKBackend *>(GPUBackend::get());
94 }
95
96 static void platform_init(const VKDevice &device);
97 static void capabilities_init(VKDevice &device);
98
99 private:
100 static void detect_workarounds(VKDevice &device);
101 static void platform_init();
102 static void platform_exit();
103
104 /* These classes are allowed to modify the global device. */
105 friend class VKContext;
106 friend class VKDescriptorSet;
108};
109
110} // namespace blender::gpu
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
static GPUBackend * get()
void render_step(bool) override
Context * context_alloc(void *ghost_window, void *ghost_context) override
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:91
IndexBuf * indexbuf_alloc() override
static void platform_init(const VKDevice &device)
QueryPool * querypool_alloc() override
friend class VKDescriptorSetTracker
static bool is_supported()
void shader_cache_dir_clear_old() override
Definition vk_backend.hh:77
UniformBuf * uniformbuf_alloc(size_t size, const char *name) override
friend class VKDescriptorSet
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
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:99
void init_resources() override
VertBuf * vertbuf_alloc() override
Fence * fence_alloc() override
static void detect_workarounds()
const char * name