blob: 78f638d23f516e13234760f0ddce2e42a685afd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup gpu
*/
#pragma once
#include "BLI_vector.hh"
#include "gpu_backend.hh"
#include "mtl_capabilities.hh"
namespace blender {
namespace gpu {
class Batch;
class DrawList;
class FrameBuffer;
class IndexBuf;
class QueryPool;
class Shader;
class Texture;
class UniformBuf;
class VertBuf;
class MTLContext;
class MTLBackend : public GPUBackend {
friend class MTLContext;
public:
/* Capabilities. */
static MTLCapabilities capabilities;
inline ~MTLBackend()
{
MTLBackend::platform_exit();
}
static bool metal_is_supported();
inline static MTLBackend *get()
{
return static_cast<MTLBackend *>(GPUBackend::get());
}
void samplers_update() override;
inline void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) override
{
/* Placeholder */
}
/* MTL Allocators need to be implemented in separate .mm files, due to allocation of Objective-C
* objects. */
Context *context_alloc(void *ghost_window) override;
Batch *batch_alloc() override;
DrawList *drawlist_alloc(int list_length) override;
FrameBuffer *framebuffer_alloc(const char *name) override;
IndexBuf *indexbuf_alloc() override;
QueryPool *querypool_alloc() override;
Shader *shader_alloc(const char *name) override;
Texture *texture_alloc(const char *name) override;
UniformBuf *uniformbuf_alloc(int size, const char *name) override;
VertBuf *vertbuf_alloc() override;
/* Render Frame Coordination. */
void render_begin() override;
void render_end() override;
void render_step() override;
bool is_inside_render_boundary();
private:
static void platform_init(MTLContext *ctx);
static void platform_exit();
static void capabilities_init(MTLContext *ctx);
};
} // namespace gpu
} // namespace blender
|