Blender V5.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
8
9#pragma once
10
11#include <cstdio>
12
13#include "gpu_backend.hh"
14
15#ifdef WITH_RENDERDOC
16# include "renderdoc_api.hh"
17#endif
18
19#include "vk_common.hh"
20#include "vk_device.hh"
21#include "vk_shader_compiler.hh"
22
23namespace blender::gpu {
24
25class VKContext;
26class VKDescriptorSet;
28
29class VKBackend : public GPUBackend {
30 private:
31#ifdef WITH_RENDERDOC
32 renderdoc::api::Renderdoc renderdoc_api_;
33#endif
34
35 public:
36 /* Global instance to device handles. */
38
40 {
42 }
43
44 virtual ~VKBackend()
45 {
46 VKBackend::platform_exit();
47 }
48
56 static bool is_supported();
57
63 static void supported_devices_print(FILE *fp);
64
65 void init_resources() override;
66 void delete_resources() override;
67
68 void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) override;
69 void compute_dispatch_indirect(StorageBuf *indirect_buf) override;
70
71 Context *context_alloc(GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context) override;
72
73 Batch *batch_alloc() override;
74 Fence *fence_alloc() override;
75 WorkInFlight *work_in_flight_alloc(unsigned int max_in_flight) override;
76 FrameBuffer *framebuffer_alloc(const char *name) override;
77 IndexBuf *indexbuf_alloc() override;
78 PixelBuffer *pixelbuf_alloc(size_t size) override;
79 QueryPool *querypool_alloc() override;
80 Shader *shader_alloc(const char *name) override;
81 Texture *texture_alloc(const char *name) override;
83 UniformBuf *uniformbuf_alloc(size_t size, const char *name) override;
84 StorageBuf *storagebuf_alloc(size_t size, GPUUsageType usage, const char *name) override;
85 VertBuf *vertbuf_alloc() override;
86 TopLevelAS *tlas_alloc(const char *name) override;
87 BottomLevelAS *blas_alloc(const char *name) override;
88
93
94 /* Render Frame Coordination --
95 * Used for performing per-frame actions globally */
96 void render_begin() override;
97 void render_end() override;
98 void render_step(bool /*force_resource_release*/) override;
99
100 bool debug_capture_begin(const char *title);
101 void debug_capture_end();
102
103 static VKBackend &get()
104 {
105 return *static_cast<VKBackend *>(GPUBackend::get());
106 }
107
108 static void platform_init(const VKDevice &device);
109 static void capabilities_init(VKDevice &device);
110
111 private:
112 static void detect_workarounds(VKDevice &device);
113 static void platform_init();
114 static void platform_exit();
115
116 /* These classes are allowed to modify the global device. */
117 friend class VKContext;
118 friend class VKDescriptorSet;
120};
121
122} // namespace blender::gpu
static GPUBackend * get()
void render_step(bool) override
TexturePool * texturepool_alloc() override
TopLevelAS * tlas_alloc(const char *name) 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()
IndexBuf * indexbuf_alloc() override
BottomLevelAS * blas_alloc(const char *name) 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:89
UniformBuf * uniformbuf_alloc(size_t size, const char *name) override
friend class VKDescriptorSet
Texture * texture_alloc(const char *name) 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:101
void init_resources() override
VertBuf * vertbuf_alloc() override
Context * context_alloc(GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context) override
WorkInFlight * work_in_flight_alloc(unsigned int max_in_flight) override
Fence * fence_alloc() override
static void supported_devices_print(FILE *fp)
static void detect_workarounds()