This covers implementation of the GPUTexture abstraction for the Metal backend, with additional utility functionality as required. Some components have been temporarily disabled pending dependencies on upcoming Metal backend components, and these will be addressed as the backend is fleshed out. One core challenge addressed in the Metal backend is the requirement for read/update routines for textures. MTLBlitCommandEncoders offer a limited range of the full functionality provided by OpenGLs texture update and read functions such that a series of compute kernels have been implemented to provide advanced functionality such as data format conversion and partial/swizzled component updates. This diff is provided in full, but if further division is required for purposes of code review, this can be done. Authored by Apple: Michael Parkin-White Ref T96261 Reviewed By: fclem Maniphest Tasks: T96261 Differential Revision: https://developer.blender.org/D14543
88 lines
2.0 KiB
C++
88 lines
2.0 KiB
C++
/* 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::gpu {
|
|
|
|
class Batch;
|
|
class DrawList;
|
|
class FrameBuffer;
|
|
class IndexBuf;
|
|
class QueryPool;
|
|
class Shader;
|
|
class UniformBuf;
|
|
class VertBuf;
|
|
class MTLContext;
|
|
|
|
class MTLBackend : public GPUBackend {
|
|
friend class MTLContext;
|
|
|
|
public:
|
|
/* Capabilities. */
|
|
static MTLCapabilities capabilities;
|
|
|
|
static MTLCapabilities &get_capabilities()
|
|
{
|
|
return MTLBackend::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 */
|
|
}
|
|
|
|
void compute_dispatch_indirect(StorageBuf *indirect_buf) 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;
|
|
StorageBuf *storagebuf_alloc(int size, GPUUsageType usage, 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 blender::gpu
|