diff options
Diffstat (limited to 'source/blender/gpu/metal/mtl_backend.mm')
-rw-r--r-- | source/blender/gpu/metal/mtl_backend.mm | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/source/blender/gpu/metal/mtl_backend.mm b/source/blender/gpu/metal/mtl_backend.mm index 83cf3af0804..240951c1ebd 100644 --- a/source/blender/gpu/metal/mtl_backend.mm +++ b/source/blender/gpu/metal/mtl_backend.mm @@ -8,10 +8,16 @@ #include "gpu_backend.hh" #include "mtl_backend.hh" +#include "mtl_batch.hh" #include "mtl_context.hh" +#include "mtl_drawlist.hh" #include "mtl_framebuffer.hh" +#include "mtl_immediate.hh" +#include "mtl_index_buffer.hh" #include "mtl_query.hh" +#include "mtl_shader.hh" #include "mtl_uniform_buffer.hh" +#include "mtl_vertex_buffer.hh" #include "gpu_capabilities_private.hh" #include "gpu_platform_private.hh" @@ -34,21 +40,19 @@ void MTLBackend::samplers_update(){ /* Placeholder -- Handled in MTLContext. */ }; -Context *MTLBackend::context_alloc(void *ghost_window) +Context *MTLBackend::context_alloc(void *ghost_window, void *ghost_context) { - return new MTLContext(ghost_window); + return new MTLContext(ghost_window, ghost_context); }; Batch *MTLBackend::batch_alloc() { - /* TODO(Metal): Implement MTLBatch. */ - return nullptr; + return new MTLBatch(); }; DrawList *MTLBackend::drawlist_alloc(int list_length) { - /* TODO(Metal): Implement MTLDrawList. */ - return nullptr; + return new MTLDrawList(list_length); }; FrameBuffer *MTLBackend::framebuffer_alloc(const char *name) @@ -60,8 +64,7 @@ FrameBuffer *MTLBackend::framebuffer_alloc(const char *name) IndexBuf *MTLBackend::indexbuf_alloc() { - /* TODO(Metal): Implement MTLIndexBuf. */ - return nullptr; + return new MTLIndexBuf(); }; QueryPool *MTLBackend::querypool_alloc() @@ -71,8 +74,8 @@ QueryPool *MTLBackend::querypool_alloc() Shader *MTLBackend::shader_alloc(const char *name) { - /* TODO(Metal): Implement MTLShader. */ - return nullptr; + MTLContext *mtl_context = MTLContext::get(); + return new MTLShader(mtl_context, name); }; Texture *MTLBackend::texture_alloc(const char *name) @@ -93,8 +96,7 @@ StorageBuf *MTLBackend::storagebuf_alloc(int size, GPUUsageType usage, const cha VertBuf *MTLBackend::vertbuf_alloc() { - /* TODO(Metal): Implement MTLVertBuf. */ - return nullptr; + return new MTLVertBuf(); } void MTLBackend::render_begin() @@ -168,7 +170,7 @@ void MTLBackend::platform_init(MTLContext *ctx) eGPUSupportLevel support_level = GPU_SUPPORT_LEVEL_SUPPORTED; BLI_assert(ctx); - id<MTLDevice> mtl_device = nil; /*ctx->device; TODO(Metal): Implement MTLContext. */ + id<MTLDevice> mtl_device = ctx->device; BLI_assert(device); NSString *gpu_name = [mtl_device name]; @@ -187,7 +189,7 @@ void MTLBackend::platform_init(MTLContext *ctx) os = GPU_OS_UNIX; #endif - BLI_assert(os == GPU_OS_MAC && "Platform must be macOS"); + BLI_assert_msg(os == GPU_OS_MAC, "Platform must be macOS"); /* Determine Vendor from name. */ if (strstr(vendor, "ATI") || strstr(vendor, "AMD")) { @@ -334,7 +336,7 @@ bool MTLBackend::metal_is_supported() void MTLBackend::capabilities_init(MTLContext *ctx) { BLI_assert(ctx); - id<MTLDevice> device = nil; /*ctx->device TODO(Metal): Implement MTLContext. */ + id<MTLDevice> device = ctx->device; BLI_assert(device); /* Initialize Capabilities. */ @@ -381,6 +383,8 @@ void MTLBackend::capabilities_init(MTLContext *ctx) GCaps.shader_image_load_store_support = ([device supportsFamily:MTLGPUFamilyApple3] || MTLBackend::capabilities.supports_family_mac1 || MTLBackend::capabilities.supports_family_mac2); + /* TODO(Metal): Add support? */ + GCaps.shader_draw_parameters_support = false; GCaps.compute_shader_support = false; /* TODO(Metal): Add compute support. */ GCaps.shader_storage_buffer_objects_support = false; /* TODO(Metal): implement Storage Buffer support. */ @@ -414,6 +418,7 @@ void MTLBackend::capabilities_init(MTLContext *ctx) GCaps.depth_blitting_workaround = false; GCaps.use_main_context_workaround = false; GCaps.broken_amd_driver = false; + GCaps.clear_viewport_workaround = true; /* Metal related workarounds. */ /* Minimum per-vertex stride is 4 bytes in Metal. |