forked from ShuriZma/suyu
1
0
Fork 0

metal: use metal cpp

This commit is contained in:
Samuliak 2024-04-06 20:28:54 +02:00
parent cc0cde9c3f
commit 897e0dfdc0
20 changed files with 189 additions and 225 deletions

View File

@ -320,4 +320,3 @@ if (ARCHITECTURE_arm64 AND NOT TARGET sse2neon)
add_library(sse2neon INTERFACE) add_library(sse2neon INTERFACE)
target_include_directories(sse2neon INTERFACE sse2neon) target_include_directories(sse2neon INTERFACE sse2neon)
endif() endif()

View File

@ -184,6 +184,11 @@ else()
endif() endif()
endif() endif()
if (APPLE)
# TODO: use target_link_libraries
include_directories(${CMAKE_SOURCE_DIR}/externals/metal-cpp)
endif()
add_subdirectory(common) add_subdirectory(common)
add_subdirectory(core) add_subdirectory(core)
add_subdirectory(audio_core) add_subdirectory(audio_core)

View File

@ -374,16 +374,17 @@ if (APPLE)
) )
list(APPEND sources list(APPEND sources
renderer_metal/mtl_buffer_cache.mm renderer_metal/metal_cpp_impl.cpp
renderer_metal/mtl_buffer_cache.cpp
renderer_metal/mtl_buffer_cache_base.cpp renderer_metal/mtl_buffer_cache_base.cpp
renderer_metal/mtl_command_recorder.mm renderer_metal/mtl_command_recorder.cpp
renderer_metal/mtl_device.mm renderer_metal/mtl_device.cpp
renderer_metal/mtl_rasterizer.mm renderer_metal/mtl_rasterizer.cpp
renderer_metal/mtl_staging_buffer_pool.mm renderer_metal/mtl_staging_buffer_pool.cpp
renderer_metal/mtl_swap_chain.mm renderer_metal/mtl_swap_chain.cpp
renderer_metal/mtl_texture_cache.mm renderer_metal/mtl_texture_cache.cpp
renderer_metal/mtl_texture_cache_base.cpp renderer_metal/mtl_texture_cache_base.cpp
renderer_metal/renderer_metal.mm renderer_metal/renderer_metal.cpp
) )
endif() endif()
@ -404,10 +405,6 @@ add_dependencies(video_core host_shaders)
target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE}) target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE})
target_link_libraries(video_core PRIVATE sirit Vulkan::Headers Vulkan::UtilityHeaders GPUOpen::VulkanMemoryAllocator) target_link_libraries(video_core PRIVATE sirit Vulkan::Headers Vulkan::UtilityHeaders GPUOpen::VulkanMemoryAllocator)
if (APPLE)
target_include_directories(video_core PRIVATE ${CMAKE_SOURCE_DIR}/externals/metal-cpp)
endif()
if (ENABLE_NSIGHT_AFTERMATH) if (ENABLE_NSIGHT_AFTERMATH)
if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK}) if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK})
message(FATAL_ERROR "Environment variable NSIGHT_AFTERMATH_SDK has to be provided") message(FATAL_ERROR "Environment variable NSIGHT_AFTERMATH_SDK has to be provided")

View File

@ -0,0 +1,6 @@
#define NS_PRIVATE_IMPLEMENTATION
#define CA_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
#include <Foundation/Foundation.hpp>
#include <Metal/Metal.hpp>
#include <QuartzCore/QuartzCore.hpp>

View File

@ -15,37 +15,36 @@ namespace Metal {
namespace { namespace {
MTLBuffer_t CreatePrivateBuffer(const Device& device, size_t size) { MTL::Buffer* CreatePrivateBuffer(const Device& device, size_t size) {
return [device.GetDevice() newBufferWithLength:size options:MTLResourceStorageModePrivate]; return device.GetDevice()->newBuffer(size, MTL::ResourceStorageModePrivate);
} }
} // Anonymous namespace } // Anonymous namespace
BoundBuffer::BoundBuffer(MTLBuffer_t buffer_, size_t offset_, size_t size_) BoundBuffer::BoundBuffer(MTL::Buffer* buffer_, size_t offset_, size_t size_)
: buffer{[buffer_ retain]}, offset{offset_}, size{size_} {} : buffer{buffer_->retain()}, offset{offset_}, size{size_} {}
BoundBuffer::~BoundBuffer() { BoundBuffer::~BoundBuffer() {
if (buffer) { if (buffer) {
[buffer release]; buffer->release();
} }
} }
BufferView::BufferView(MTLBuffer_t buffer_, size_t offset_, size_t size_, BufferView::BufferView(MTL::Buffer* buffer_, size_t offset_, size_t size_,
VideoCore::Surface::PixelFormat format_) VideoCore::Surface::PixelFormat format_)
: buffer{[buffer_ retain]}, offset{offset_}, size{size_}, format{format_} {} : buffer{buffer_->retain()}, offset{offset_}, size{size_}, format{format_} {}
BufferView::~BufferView() { BufferView::~BufferView() {
[buffer release]; buffer->release();
} }
Buffer::Buffer(BufferCacheRuntime& runtime, VideoCommon::NullBufferParams null_params) Buffer::Buffer(BufferCacheRuntime& runtime, VideoCommon::NullBufferParams null_params)
: VideoCommon::BufferBase(null_params), buffer{runtime.CreateNullBuffer()}, : VideoCommon::BufferBase(null_params), buffer{runtime.CreateNullBuffer()}, is_null{true},
is_null{true}, view(buffer, 0, BufferCacheRuntime::NULL_BUFFER_SIZE) {} view(buffer, 0, BufferCacheRuntime::NULL_BUFFER_SIZE) {}
Buffer::Buffer(BufferCacheRuntime& runtime, DAddr cpu_addr_, u64 size_bytes_) Buffer::Buffer(BufferCacheRuntime& runtime, DAddr cpu_addr_, u64 size_bytes_)
: VideoCommon::BufferBase(cpu_addr_, size_bytes_), : VideoCommon::BufferBase(cpu_addr_, size_bytes_),
buffer{CreatePrivateBuffer(runtime.device, size_bytes_)}, buffer{CreatePrivateBuffer(runtime.device, size_bytes_)}, view(buffer, 0, size_bytes_) {}
view(buffer, 0, size_bytes_) {}
BufferView Buffer::View(u32 offset, u32 size, VideoCore::Surface::PixelFormat format) { BufferView Buffer::View(u32 offset, u32 size, VideoCore::Surface::PixelFormat format) {
return BufferView(buffer, offset, size, format); return BufferView(buffer, offset, size, format);
@ -78,18 +77,18 @@ void BufferCacheRuntime::TickFrame(Common::SlotVector<Buffer>& slot_buffers) noe
void BufferCacheRuntime::Finish() {} void BufferCacheRuntime::Finish() {}
void BufferCacheRuntime::CopyBuffer(MTLBuffer_t dst_buffer, MTLBuffer_t src_buffer, void BufferCacheRuntime::CopyBuffer(MTL::Buffer* dst_buffer, MTL::Buffer* src_buffer,
std::span<const VideoCommon::BufferCopy> copies, bool barrier, std::span<const VideoCommon::BufferCopy> copies, bool barrier,
bool can_reorder_upload) { bool can_reorder_upload) {
// TODO: copy buffer // TODO: copy buffer
} }
void BufferCacheRuntime::ClearBuffer(MTLBuffer_t dest_buffer, u32 offset, size_t size, u32 value) { void BufferCacheRuntime::ClearBuffer(MTL::Buffer* dest_buffer, u32 offset, size_t size, u32 value) {
// TODO: clear buffer // TODO: clear buffer
} }
void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format,
u32 base_vertex, u32 num_indices, MTLBuffer_t buffer, u32 base_vertex, u32 num_indices, MTL::Buffer* buffer,
u32 offset, [[maybe_unused]] u32 size) { u32 offset, [[maybe_unused]] u32 size) {
// TODO: convert parameters to Metal enums // TODO: convert parameters to Metal enums
bound_index_buffer = {BoundBuffer(buffer, offset, size)}; bound_index_buffer = {BoundBuffer(buffer, offset, size)};
@ -99,7 +98,7 @@ void BufferCacheRuntime::BindQuadIndexBuffer(PrimitiveTopology topology, u32 fir
// TODO: bind quad index buffer // TODO: bind quad index buffer
} }
void BufferCacheRuntime::BindVertexBuffer(u32 index, MTLBuffer_t buffer, u32 offset, u32 size, void BufferCacheRuntime::BindVertexBuffer(u32 index, MTL::Buffer* buffer, u32 offset, u32 size,
u32 stride) { u32 stride) {
// TODO: use stride // TODO: use stride
bound_vertex_buffers[MAX_METAL_BUFFERS - index - 1] = {BoundBuffer(buffer, offset, size)}; bound_vertex_buffers[MAX_METAL_BUFFERS - index - 1] = {BoundBuffer(buffer, offset, size)};
@ -115,9 +114,8 @@ void BufferCacheRuntime::ReserveNullBuffer() {
} }
} }
MTLBuffer_t BufferCacheRuntime::CreateNullBuffer() { MTL::Buffer* BufferCacheRuntime::CreateNullBuffer() {
return [device.GetDevice() newBufferWithLength:NULL_BUFFER_SIZE return CreatePrivateBuffer(device, NULL_BUFFER_SIZE);
options:MTLResourceStorageModePrivate];
} }
} // namespace Vulkan } // namespace Metal

View File

@ -19,21 +19,21 @@ class BufferCacheRuntime;
struct BoundBuffer { struct BoundBuffer {
BoundBuffer() = default; BoundBuffer() = default;
BoundBuffer(MTLBuffer_t buffer_, size_t offset_, size_t size_); BoundBuffer(MTL::Buffer* buffer_, size_t offset_, size_t size_);
~BoundBuffer(); ~BoundBuffer();
MTLBuffer_t buffer = nil; MTL::Buffer* buffer = nil;
size_t offset{}; size_t offset{};
size_t size{}; size_t size{};
}; };
struct BufferView { struct BufferView {
BufferView(MTLBuffer_t buffer_, size_t offset_, size_t size_, BufferView(MTL::Buffer* buffer_, size_t offset_, size_t size_,
VideoCore::Surface::PixelFormat format_ = VideoCore::Surface::PixelFormat::Invalid); VideoCore::Surface::PixelFormat format_ = VideoCore::Surface::PixelFormat::Invalid);
~BufferView(); ~BufferView();
MTLBuffer_t buffer = nil; MTL::Buffer* buffer = nil;
size_t offset{}; size_t offset{};
size_t size{}; size_t size{};
VideoCore::Surface::PixelFormat format{}; VideoCore::Surface::PixelFormat format{};
@ -50,16 +50,16 @@ public:
// TODO: track usage // TODO: track usage
} }
[[nodiscard]] MTLBuffer_t Handle() const noexcept { [[nodiscard]] MTL::Buffer* Handle() const noexcept {
return buffer; return buffer;
} }
operator MTLBuffer_t() const noexcept { operator MTL::Buffer*() const noexcept {
return buffer; return buffer;
} }
private: private:
MTLBuffer_t buffer = nil; MTL::Buffer* buffer = nil;
bool is_null{}; bool is_null{};
BufferView view; BufferView view;
@ -108,25 +108,25 @@ public:
void PreCopyBarrier() {} void PreCopyBarrier() {}
void CopyBuffer(MTLBuffer_t src_buffer, MTLBuffer_t dst_buffer, void CopyBuffer(MTL::Buffer* src_buffer, MTL::Buffer* dst_buffer,
std::span<const VideoCommon::BufferCopy> copies, bool barrier, std::span<const VideoCommon::BufferCopy> copies, bool barrier,
bool can_reorder_upload = false); bool can_reorder_upload = false);
void PostCopyBarrier() {} void PostCopyBarrier() {}
void ClearBuffer(MTLBuffer_t dest_buffer, u32 offset, size_t size, u32 value); void ClearBuffer(MTL::Buffer* dest_buffer, u32 offset, size_t size, u32 value);
void BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, u32 num_indices, void BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, u32 num_indices,
u32 base_vertex, MTLBuffer_t buffer, u32 offset, u32 size); u32 base_vertex, MTL::Buffer* buffer, u32 offset, u32 size);
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count); void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
void BindVertexBuffer(u32 index, MTLBuffer_t buffer, u32 offset, u32 size, u32 stride); void BindVertexBuffer(u32 index, MTL::Buffer* buffer, u32 offset, u32 size, u32 stride);
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings); void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
// TODO: implement // TODO: implement
void BindTransformFeedbackBuffer(u32 index, MTLBuffer_t buffer, u32 offset, u32 size) {} void BindTransformFeedbackBuffer(u32 index, MTL::Buffer* buffer, u32 offset, u32 size) {}
// TODO: implement // TODO: implement
void BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings) {} void BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings) {}
@ -138,11 +138,11 @@ public:
return ref.mapped_span; return ref.mapped_span;
} }
void BindUniformBuffer(MTLBuffer_t buffer, u32 offset, u32 size) { void BindUniformBuffer(MTL::Buffer* buffer, u32 offset, u32 size) {
BindBuffer(buffer, offset, size); BindBuffer(buffer, offset, size);
} }
void BindStorageBuffer(MTLBuffer_t buffer, u32 offset, u32 size, void BindStorageBuffer(MTL::Buffer* buffer, u32 offset, u32 size,
[[maybe_unused]] bool is_written) { [[maybe_unused]] bool is_written) {
BindBuffer(buffer, offset, size); BindBuffer(buffer, offset, size);
} }
@ -152,21 +152,21 @@ public:
VideoCore::Surface::PixelFormat format) {} VideoCore::Surface::PixelFormat format) {}
private: private:
void BindBuffer(MTLBuffer_t buffer, u32 offset, u32 size) { void BindBuffer(MTL::Buffer* buffer, u32 offset, u32 size) {
// FIXME: what should be the index? // FIXME: what should be the index?
bound_buffers[0] = BoundBuffer(buffer, offset, size); bound_buffers[0] = BoundBuffer(buffer, offset, size);
} }
void ReserveNullBuffer(); void ReserveNullBuffer();
MTLBuffer_t CreateNullBuffer(); MTL::Buffer* CreateNullBuffer();
const Device& device; const Device& device;
CommandRecorder& command_recorder; CommandRecorder& command_recorder;
StagingBufferPool& staging_pool; StagingBufferPool& staging_pool;
// Common buffers // Common buffers
MTLBuffer_t null_buffer = nil; MTL::Buffer* null_buffer = nil;
MTLBuffer_t quad_index_buffer = nil; MTL::Buffer* quad_index_buffer = nil;
// TODO: probably move this into a separate class // TODO: probably move this into a separate class
// Bound state // Bound state

View File

@ -12,10 +12,10 @@ CommandRecorder::CommandRecorder(const Device& device_) : device(device_) {}
CommandRecorder::~CommandRecorder() = default; CommandRecorder::~CommandRecorder() = default;
void CommandRecorder::BeginRenderPass(MTLRenderPassDescriptor* render_pass_descriptor) { void CommandRecorder::BeginRenderPass(MTL::RenderPassDescriptor* render_pass_descriptor) {
RequireCommandBuffer(); RequireCommandBuffer();
EndEncoding(); EndEncoding();
encoder = [command_buffer renderCommandEncoderWithDescriptor:render_pass_descriptor]; encoder = command_buffer->renderCommandEncoder(render_pass_descriptor);
encoder_type = EncoderType::Render; encoder_type = EncoderType::Render;
} }
@ -23,7 +23,7 @@ void CommandRecorder::RequireComputeEncoder() {
RequireCommandBuffer(); RequireCommandBuffer();
if (!encoder || encoder_type != EncoderType::Compute) { if (!encoder || encoder_type != EncoderType::Compute) {
EndEncoding(); EndEncoding();
encoder = [command_buffer computeCommandEncoder]; encoder = command_buffer->computeCommandEncoder();
encoder_type = EncoderType::Compute; encoder_type = EncoderType::Compute;
} }
} }
@ -32,28 +32,28 @@ void CommandRecorder::RequireBlitEncoder() {
RequireCommandBuffer(); RequireCommandBuffer();
if (!encoder || encoder_type != EncoderType::Blit) { if (!encoder || encoder_type != EncoderType::Blit) {
EndEncoding(); EndEncoding();
encoder = [command_buffer blitCommandEncoder]; encoder = command_buffer->blitCommandEncoder();
encoder_type = EncoderType::Blit; encoder_type = EncoderType::Blit;
} }
} }
void CommandRecorder::EndEncoding() { void CommandRecorder::EndEncoding() {
if (encoder) { if (encoder) {
[encoder endEncoding]; encoder->endEncoding();
//[encoder release]; //[encoder release];
encoder = nil; encoder = nil;
} }
} }
void CommandRecorder::Present(CAMetalDrawable_t drawable) { void CommandRecorder::Present(CA::MetalDrawable* drawable) {
EndEncoding(); EndEncoding();
[command_buffer presentDrawable:drawable]; command_buffer->presentDrawable(drawable);
} }
void CommandRecorder::Submit() { void CommandRecorder::Submit() {
if (command_buffer) { if (command_buffer) {
EndEncoding(); EndEncoding();
[command_buffer commit]; command_buffer->commit();
//[command_buffer release]; //[command_buffer release];
command_buffer = nil; command_buffer = nil;
} }
@ -61,7 +61,7 @@ void CommandRecorder::Submit() {
void CommandRecorder::RequireCommandBuffer() { void CommandRecorder::RequireCommandBuffer() {
if (!command_buffer) { if (!command_buffer) {
command_buffer = [device.GetCommandQueue() commandBuffer]; command_buffer = device.GetCommandQueue()->commandBuffer();
} }
} }

View File

@ -3,8 +3,8 @@
#pragma once #pragma once
#include "objc_bridge.h" #include <Metal/Metal.hpp>
#include "video_core/renderer_metal/objc_bridge.h" #include <QuartzCore/QuartzCore.hpp>
namespace Metal { namespace Metal {
@ -17,7 +17,7 @@ public:
CommandRecorder(const Device& device_); CommandRecorder(const Device& device_);
~CommandRecorder(); ~CommandRecorder();
void BeginRenderPass(MTLRenderPassDescriptor* render_pass_descriptor); void BeginRenderPass(MTL::RenderPassDescriptor* render_pass_descriptor);
void CheckIfRenderPassIsActive() { void CheckIfRenderPassIsActive() {
if (!encoder || encoder_type != EncoderType::Render) { if (!encoder || encoder_type != EncoderType::Render) {
@ -32,15 +32,15 @@ public:
void EndEncoding(); void EndEncoding();
void Present(CAMetalDrawable_t drawable); void Present(CA::MetalDrawable* drawable);
void Submit(); void Submit();
MTLCommandBuffer_t GetCommandBuffer() { MTL::CommandBuffer* GetCommandBuffer() {
return command_buffer; return command_buffer;
} }
MTLCommandEncoder_t GetCommandEncoder() { MTL::CommandEncoder* GetCommandEncoder() {
return encoder; return encoder;
} }
@ -49,8 +49,8 @@ private:
// HACK: Command buffers and encoders currently aren't released every frame due to Xcode // HACK: Command buffers and encoders currently aren't released every frame due to Xcode
// crashing in Debug mode. This leads to memory leaks // crashing in Debug mode. This leads to memory leaks
MTLCommandBuffer_t command_buffer = nil; MTL::CommandBuffer* command_buffer = nil;
MTLCommandEncoder_t encoder = nil; MTL::CommandEncoder* encoder = nil;
EncoderType encoder_type; EncoderType encoder_type;

View File

@ -6,19 +6,19 @@
namespace Metal { namespace Metal {
Device::Device() { Device::Device() {
device = MTLCreateSystemDefaultDevice(); device = MTL::CreateSystemDefaultDevice();
if (!device) { if (!device) {
throw std::runtime_error("Failed to create Metal device"); throw std::runtime_error("Failed to create Metal device");
} }
command_queue = [device newCommandQueue]; command_queue = device->newCommandQueue();
if (!command_queue) { if (!command_queue) {
throw std::runtime_error("Failed to create Metal command queue"); throw std::runtime_error("Failed to create Metal command queue");
} }
} }
Device::~Device() { Device::~Device() {
[command_queue release]; command_queue->release();
[device release]; device->release();
} }
} // namespace Metal } // namespace Metal

View File

@ -3,7 +3,9 @@
#pragma once #pragma once
#include "video_core/renderer_metal/objc_bridge.h" #include <Foundation/Foundation.hpp>
#include <Metal/Metal.hpp>
#include <QuartzCore/QuartzCore.hpp>
namespace Metal { namespace Metal {
@ -12,17 +14,17 @@ public:
explicit Device(); explicit Device();
~Device(); ~Device();
MTLDevice_t GetDevice() const { MTL::Device* GetDevice() const {
return device; return device;
} }
MTLCommandQueue_t GetCommandQueue() const { MTL::CommandQueue* GetCommandQueue() const {
return command_queue; return command_queue;
} }
private: private:
MTLDevice_t device; MTL::Device* device;
MTLCommandQueue_t command_queue; MTL::CommandQueue* command_queue;
}; };
} // namespace Metal } // namespace Metal

View File

@ -18,18 +18,18 @@
namespace Metal { namespace Metal {
StagingBufferRef::StagingBufferRef(MTLBuffer_t buffer_, size_t offset_, std::span<u8> mapped_span_) StagingBufferRef::StagingBufferRef(MTL::Buffer* buffer_, size_t offset_, std::span<u8> mapped_span_)
: buffer{[buffer_ retain]}, offset{offset_}, mapped_span{mapped_span_} {} : buffer{buffer_->retain()}, offset{offset_}, mapped_span{mapped_span_} {}
StagingBufferRef::~StagingBufferRef() { StagingBufferRef::~StagingBufferRef() {
[buffer release]; buffer->release();
} }
StagingBuffer::StagingBuffer(MTLBuffer_t buffer_, std::span<u8> mapped_span_) StagingBuffer::StagingBuffer(MTL::Buffer* buffer_, std::span<u8> mapped_span_)
: buffer{[buffer_ retain]}, mapped_span{mapped_span_} {} : buffer{buffer_->retain()}, mapped_span{mapped_span_} {}
StagingBuffer::~StagingBuffer() { StagingBuffer::~StagingBuffer() {
[buffer release]; buffer->release();
} }
StagingBufferRef StagingBuffer::Ref() const noexcept { StagingBufferRef StagingBuffer::Ref() const noexcept {
@ -42,8 +42,8 @@ constexpr size_t REGION_SIZE = STREAM_BUFFER_SIZE / StagingBufferPool::NUM_SYNCS
StagingBufferPool::StagingBufferPool(const Device& device_, CommandRecorder& command_recorder_) StagingBufferPool::StagingBufferPool(const Device& device_, CommandRecorder& command_recorder_)
: device{device_}, command_recorder{command_recorder_} { : device{device_}, command_recorder{command_recorder_} {
stream_buffer = [device.GetDevice() newBufferWithLength:STREAM_BUFFER_SIZE stream_buffer =
options:MTLResourceStorageModeShared]; device.GetDevice()->newBuffer(STREAM_BUFFER_SIZE, MTL::ResourceStorageModeShared);
} }
StagingBufferPool::~StagingBufferPool() = default; StagingBufferPool::~StagingBufferPool() = default;
@ -83,10 +83,9 @@ StagingBufferRef StagingBufferPool::GetStagingBuffer(size_t size, MemoryUsage us
StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage usage, StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage usage,
bool deferred) { bool deferred) {
const u32 log2 = Common::Log2Ceil64(size); const u32 log2 = Common::Log2Ceil64(size);
MTLBuffer_t buffer = [device.GetDevice() newBufferWithLength:size MTL::Buffer* buffer = device.GetDevice()->newBuffer(size, MTL::ResourceStorageModeShared);
options:MTLResourceStorageModeShared];
// TODO: check if the mapped span is correct // TODO: check if the mapped span is correct
std::span<u8> mapped_span(static_cast<u8*>([buffer contents]), size); std::span<u8> mapped_span(static_cast<u8*>(buffer->contents()), size);
auto& entry = GetCache(usage)[log2].entries.emplace_back(buffer, mapped_span); auto& entry = GetCache(usage)[log2].entries.emplace_back(buffer, mapped_span);
return entry.Ref(); return entry.Ref();

View File

@ -7,10 +7,9 @@
#include <span> #include <span>
#include <vector> #include <vector>
#include "common/common_types.h" #include <Metal/Metal.hpp>
#include "objc_bridge.h" #include "common/common_types.h"
#include "video_core/renderer_metal/objc_bridge.h"
namespace Metal { namespace Metal {
@ -24,19 +23,19 @@ enum class MemoryUsage {
}; };
struct StagingBufferRef { struct StagingBufferRef {
StagingBufferRef(MTLBuffer_t buffer_, size_t offset_, std::span<u8> mapped_span_); StagingBufferRef(MTL::Buffer* buffer_, size_t offset_, std::span<u8> mapped_span_);
~StagingBufferRef(); ~StagingBufferRef();
MTLBuffer_t buffer; MTL::Buffer* buffer;
size_t offset; size_t offset;
std::span<u8> mapped_span; std::span<u8> mapped_span;
}; };
struct StagingBuffer { struct StagingBuffer {
StagingBuffer(MTLBuffer_t buffer_, std::span<u8> mapped_span_); StagingBuffer(MTL::Buffer* buffer_, std::span<u8> mapped_span_);
~StagingBuffer(); ~StagingBuffer();
MTLBuffer_t buffer; MTL::Buffer* buffer;
std::span<u8> mapped_span; std::span<u8> mapped_span;
StagingBufferRef Ref() const noexcept; StagingBufferRef Ref() const noexcept;
@ -52,7 +51,7 @@ public:
StagingBufferRef Request(size_t size, MemoryUsage usage, bool deferred = false); StagingBufferRef Request(size_t size, MemoryUsage usage, bool deferred = false);
void FreeDeferred(StagingBufferRef& ref); void FreeDeferred(StagingBufferRef& ref);
[[nodiscard]] MTLBuffer_t GetSTreamBufferHandle() const noexcept { [[nodiscard]] MTL::Buffer* GetSTreamBufferHandle() const noexcept {
return stream_buffer; return stream_buffer;
} }
@ -83,7 +82,7 @@ private:
const Device& device; const Device& device;
CommandRecorder& command_recorder; CommandRecorder& command_recorder;
MTLBuffer_t stream_buffer{}; MTL::Buffer* stream_buffer{};
size_t iterator = 0; size_t iterator = 0;
size_t used_iterator = 0; size_t used_iterator = 0;

View File

@ -8,28 +8,28 @@
namespace Metal { namespace Metal {
SwapChain::SwapChain(const Device& device_, CommandRecorder& command_recorder_, SwapChain::SwapChain(const Device& device_, CommandRecorder& command_recorder_,
const CAMetalLayer* layer_) CA::MetalLayer* layer_)
: device(device_), command_recorder(command_recorder_), layer([layer_ retain]) { : device(device_), command_recorder(command_recorder_), layer(layer_->retain()) {
// Give the layer our device // Give the layer our device
layer.device = device.GetDevice(); layer->setDevice(device.GetDevice());
} }
SwapChain::~SwapChain() { SwapChain::~SwapChain() {
[layer release]; layer->release();
} }
void SwapChain::AcquireNextDrawable() { void SwapChain::AcquireNextDrawable() {
// Get the next drawable // Get the next drawable
drawable = [[layer nextDrawable] retain]; drawable = layer->nextDrawable()->retain();
} }
void SwapChain::Present() { void SwapChain::Present() {
command_recorder.Present(drawable); command_recorder.Present(drawable);
[drawable release]; drawable->release();
} }
MTLTexture_t SwapChain::GetDrawableTexture() { MTL::Texture* SwapChain::GetDrawableTexture() {
return drawable.texture; return drawable->texture();
} }
} // namespace Metal } // namespace Metal

View File

@ -3,7 +3,8 @@
#pragma once #pragma once
#include "video_core/renderer_metal/objc_bridge.h" #include <Metal/Metal.hpp>
#include <QuartzCore/QuartzCore.hpp>
namespace Metal { namespace Metal {
@ -12,8 +13,7 @@ class CommandRecorder;
class SwapChain { class SwapChain {
public: public:
SwapChain(const Device& device_, CommandRecorder& command_recorder_, SwapChain(const Device& device_, CommandRecorder& command_recorder_, CA::MetalLayer* layer_);
const CAMetalLayer* layer_);
~SwapChain(); ~SwapChain();
void AcquireNextDrawable(); void AcquireNextDrawable();
@ -21,14 +21,14 @@ public:
void Present(); void Present();
// Can only be called between AcquireNextDrawable and Present // Can only be called between AcquireNextDrawable and Present
MTLTexture_t GetDrawableTexture(); MTL::Texture* GetDrawableTexture();
private: private:
const Device& device; const Device& device;
CommandRecorder& command_recorder; CommandRecorder& command_recorder;
const CAMetalLayer* layer; CA::MetalLayer* layer;
CAMetalDrawable_t drawable = nil; CA::MetalDrawable* drawable = nil;
}; };
} // namespace Metal } // namespace Metal

View File

@ -3,9 +3,9 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <boost/container/small_vector.hpp>
#include <span> #include <span>
#include <vector> #include <vector>
#include <boost/container/small_vector.hpp>
#include "common/bit_cast.h" #include "common/bit_cast.h"
#include "common/bit_util.h" #include "common/bit_util.h"
@ -37,8 +37,7 @@ using VideoCore::Surface::SurfaceType;
TextureCacheRuntime::TextureCacheRuntime(const Device& device_, CommandRecorder& command_recorder_, TextureCacheRuntime::TextureCacheRuntime(const Device& device_, CommandRecorder& command_recorder_,
StagingBufferPool& staging_buffer_pool_) StagingBufferPool& staging_buffer_pool_)
: device{device_}, command_recorder{command_recorder_}, : device{device_}, command_recorder{command_recorder_},
staging_buffer_pool{staging_buffer_pool_}, staging_buffer_pool{staging_buffer_pool_}, resolution{Settings::values.resolution_info} {}
resolution{Settings::values.resolution_info} {}
void TextureCacheRuntime::TickFrame() {} void TextureCacheRuntime::TickFrame() {}
@ -54,30 +53,28 @@ void TextureCacheRuntime::FreeDeferredStagingBuffer(StagingBufferRef& ref) {
staging_buffer_pool.FreeDeferred(ref); staging_buffer_pool.FreeDeferred(ref);
} }
Image::Image(TextureCacheRuntime& runtime, const ImageInfo& info, Image::Image(TextureCacheRuntime& runtime, const ImageInfo& info, GPUVAddr gpu_addr_,
GPUVAddr gpu_addr_, VAddr cpu_addr_) VAddr cpu_addr_)
: VideoCommon::ImageBase(info, gpu_addr_, cpu_addr_) { : VideoCommon::ImageBase(info, gpu_addr_, cpu_addr_) {
MTLTextureDescriptor *texture_descriptor = MTL::TextureDescriptor* texture_descriptor = MTL::TextureDescriptor::alloc()->init();
[[MTLTextureDescriptor alloc] init];
// TODO: don't hardcode the format // TODO: don't hardcode the format
texture_descriptor.pixelFormat = MTLPixelFormatRGBA8Unorm; texture_descriptor->setPixelFormat(MTL::PixelFormatRGBA8Unorm);
texture_descriptor.width = info.size.width; texture_descriptor->setWidth(info.size.width);
texture_descriptor.height = info.size.height; texture_descriptor->setHeight(info.size.height);
texture = texture = runtime.device.GetDevice()->newTexture(texture_descriptor);
[runtime.device.GetDevice() newTextureWithDescriptor:texture_descriptor];
} }
Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBase{params} {} Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBase{params} {}
Image::~Image() { Image::~Image() {
if (texture) { if (texture) {
[texture release]; texture->release();
} }
} }
// TODO: implement these // TODO: implement these
void Image::UploadMemory(MTLBuffer_t buffer, size_t offset, void Image::UploadMemory(MTL::Buffer* buffer, size_t offset,
std::span<const VideoCommon::BufferImageCopy> copies) { std::span<const VideoCommon::BufferImageCopy> copies) {
; ;
} }
@ -87,38 +84,33 @@ void Image::UploadMemory(const StagingBufferRef& map,
; ;
} }
void Image::DownloadMemory(MTLBuffer_t buffer, size_t offset, void Image::DownloadMemory(MTL::Buffer* buffer, size_t offset,
std::span<const VideoCommon::BufferImageCopy> copies) { std::span<const VideoCommon::BufferImageCopy> copies) {
; ;
} }
// TODO: uncomment void Image::DownloadMemory(std::span<MTL::Buffer*> buffers, std::span<size_t> offsets,
/*
void Image::DownloadMemory(std::span<MTLBuffer_t> buffers, std::span<size_t> offsets,
std::span<const VideoCommon::BufferImageCopy> copies) { std::span<const VideoCommon::BufferImageCopy> copies) {
; ;
} }
*/
void Image::DownloadMemory(const StagingBufferRef& map, void Image::DownloadMemory(const StagingBufferRef& map,
std::span<const VideoCommon::BufferImageCopy> copies) { std::span<const VideoCommon::BufferImageCopy> copies) {
; ;
} }
ImageView::ImageView(TextureCacheRuntime& runtime, ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info,
const VideoCommon::ImageViewInfo& info, ImageId image_id_, ImageId image_id_, Image& image)
Image& image)
: VideoCommon::ImageViewBase{info, image.info, image_id_, image.gpu_addr} { : VideoCommon::ImageViewBase{info, image.info, image_id_, image.gpu_addr} {
using Shader::TextureType; using Shader::TextureType;
texture = [image.GetHandle() retain]; texture = image.GetHandle()->retain();
// TODO: create texture view // TODO: create texture view
} }
ImageView::ImageView(TextureCacheRuntime& runtime, ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info,
const VideoCommon::ImageViewInfo& info, ImageId image_id_, ImageId image_id_, Image& image, const SlotVector<Image>& slot_imgs)
Image& image, const SlotVector<Image>& slot_imgs)
: ImageView(runtime, info, image_id_, image) { : ImageView(runtime, info, image_id_, image) {
// TODO: save slot images // TODO: save slot images
} }
@ -134,33 +126,31 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::NullImageV
// TODO: implement // TODO: implement
} }
ImageView::~ImageView() { [texture release]; } ImageView::~ImageView() {
texture->release();
}
Sampler::Sampler(TextureCacheRuntime& runtime, Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& tsc) {
const Tegra::Texture::TSCEntry& tsc) { MTL::SamplerDescriptor* sampler_descriptor = MTL::SamplerDescriptor::alloc()->init();
MTLSamplerDescriptor* sampler_descriptor =
[[MTLSamplerDescriptor alloc] init];
// TODO: configure the descriptor // TODO: configure the descriptor
sampler_state = [runtime.device.GetDevice() sampler_state = runtime.device.GetDevice()->newSamplerState(sampler_descriptor);
newSamplerStateWithDescriptor:sampler_descriptor];
} }
Framebuffer::Framebuffer(TextureCacheRuntime& runtime, Framebuffer::Framebuffer(TextureCacheRuntime& runtime, std::span<ImageView*, NUM_RT> color_buffers,
std::span<ImageView*, NUM_RT> color_buffers, ImageView* depth_buffer, const VideoCommon::RenderTargets& key) {
ImageView* depth_buffer, CreateRenderPassDescriptor(runtime, color_buffers, depth_buffer, key.is_rescaled,
const VideoCommon::RenderTargets& key) { key.size.width, key.size.height);
CreateRenderPassDescriptor(runtime, color_buffers, depth_buffer,
key.is_rescaled, key.size.width, key.size.height);
} }
Framebuffer::~Framebuffer() = default; Framebuffer::~Framebuffer() = default;
void Framebuffer::CreateRenderPassDescriptor( void Framebuffer::CreateRenderPassDescriptor(TextureCacheRuntime& runtime,
TextureCacheRuntime& runtime, std::span<ImageView*, NUM_RT> color_buffers, std::span<ImageView*, NUM_RT> color_buffers,
ImageView* depth_buffer, bool is_rescaled, size_t width, size_t height) { ImageView* depth_buffer, bool is_rescaled,
render_pass = [MTLRenderPassDescriptor renderPassDescriptor]; size_t width, size_t height) {
render_pass = MTL::RenderPassDescriptor::alloc()->init();
for (size_t index = 0; index < NUM_RT; ++index) { for (size_t index = 0; index < NUM_RT; ++index) {
const ImageView* const color_buffer = color_buffers[index]; const ImageView* const color_buffer = color_buffers[index];
@ -168,18 +158,19 @@ void Framebuffer::CreateRenderPassDescriptor(
continue; continue;
} }
// TODO: don't use index as attachment index // TODO: don't use index as attachment index
render_pass.colorAttachments[index].clearColor = auto color_attachment = render_pass->colorAttachments()->object(index);
MTLClearColorMake(0.5, 1.0, 0.0, 1.0); color_attachment->setClearColor(MTL::ClearColor::Make(0.5, 1.0, 0.0, 1.0));
render_pass.colorAttachments[index].loadAction = MTLLoadActionClear; color_attachment->setLoadAction(MTL::LoadActionClear);
render_pass.colorAttachments[index].storeAction = MTLStoreActionStore; color_attachment->setStoreAction(MTL::StoreActionStore);
render_pass.colorAttachments[index].texture = color_buffer->GetHandle(); color_attachment->setTexture(color_buffer->GetHandle());
} }
if (depth_buffer) { if (depth_buffer) {
render_pass.depthAttachment.clearDepth = 1.0; auto depth_attachment = render_pass->depthAttachment();
render_pass.depthAttachment.loadAction = MTLLoadActionClear; depth_attachment->setClearDepth(1.0);
render_pass.depthAttachment.storeAction = MTLStoreActionStore; depth_attachment->setLoadAction(MTL::LoadActionClear);
render_pass.depthAttachment.texture = depth_buffer->GetHandle(); depth_attachment->setStoreAction(MTL::StoreActionStore);
depth_attachment->setTexture(depth_buffer->GetHandle());
} }
} }
} // namespace Vulkan } // namespace Metal

View File

@ -5,12 +5,13 @@
#include <span> #include <span>
#include <Metal/Metal.hpp>
#include "mtl_staging_buffer_pool.h" #include "mtl_staging_buffer_pool.h"
#include "video_core/texture_cache/texture_cache_base.h" #include "video_core/texture_cache/texture_cache_base.h"
#include "shader_recompiler/shader_info.h" #include "shader_recompiler/shader_info.h"
#include "video_core/renderer_metal/mtl_staging_buffer_pool.h" #include "video_core/renderer_metal/mtl_staging_buffer_pool.h"
#include "video_core/renderer_metal/objc_bridge.h"
#include "video_core/texture_cache/image_view_base.h" #include "video_core/texture_cache/image_view_base.h"
namespace Settings { namespace Settings {
@ -127,21 +128,17 @@ public:
Image(Image&&) = default; Image(Image&&) = default;
Image& operator=(Image&&) = default; Image& operator=(Image&&) = default;
void UploadMemory(MTLBuffer_t buffer, size_t offset, void UploadMemory(MTL::Buffer* buffer, size_t offset,
std::span<const VideoCommon::BufferImageCopy> copies); std::span<const VideoCommon::BufferImageCopy> copies);
void UploadMemory(const StagingBufferRef& map, void UploadMemory(const StagingBufferRef& map,
std::span<const VideoCommon::BufferImageCopy> copies); std::span<const VideoCommon::BufferImageCopy> copies);
void DownloadMemory(MTLBuffer_t buffer, size_t offset, void DownloadMemory(MTL::Buffer* buffer, size_t offset,
std::span<const VideoCommon::BufferImageCopy> copies); std::span<const VideoCommon::BufferImageCopy> copies);
// For some reason, this function cannot be defined in the .mm file since it would report void DownloadMemory(std::span<MTL::Buffer*> buffers, std::span<size_t> offsets,
// undefined symbols std::span<const VideoCommon::BufferImageCopy> copies);
void DownloadMemory(std::span<MTLBuffer_t> buffers, std::span<size_t> offsets,
std::span<const VideoCommon::BufferImageCopy> copies) {
// TODO: implement
}
void DownloadMemory(const StagingBufferRef& map, void DownloadMemory(const StagingBufferRef& map,
std::span<const VideoCommon::BufferImageCopy> copies); std::span<const VideoCommon::BufferImageCopy> copies);
@ -160,12 +157,12 @@ public:
return true; return true;
} }
MTLTexture_t GetHandle() const noexcept { MTL::Texture* GetHandle() const noexcept {
return texture; return texture;
} }
private: private:
MTLTexture_t texture = nil; MTL::Texture* texture = nil;
bool initialized = false; bool initialized = false;
bool rescaled = false; bool rescaled = false;
@ -188,12 +185,12 @@ public:
ImageView(ImageView&&) = default; ImageView(ImageView&&) = default;
ImageView& operator=(ImageView&&) = default; ImageView& operator=(ImageView&&) = default;
MTLTexture_t GetHandle() const noexcept { MTL::Texture* GetHandle() const noexcept {
return texture; return texture;
} }
private: private:
MTLTexture_t texture; MTL::Texture* texture;
}; };
class ImageAlloc : public VideoCommon::ImageAllocBase {}; class ImageAlloc : public VideoCommon::ImageAllocBase {};
@ -202,12 +199,12 @@ class Sampler {
public: public:
explicit Sampler(TextureCacheRuntime&, const Tegra::Texture::TSCEntry&); explicit Sampler(TextureCacheRuntime&, const Tegra::Texture::TSCEntry&);
MTLSamplerState_t GetHandle() const noexcept { MTL::SamplerState* GetHandle() const noexcept {
return sampler_state; return sampler_state;
} }
private: private:
MTLSamplerState_t sampler_state; MTL::SamplerState* sampler_state;
}; };
class Framebuffer { class Framebuffer {
@ -227,12 +224,12 @@ public:
ImageView* depth_buffer, bool is_rescaled, size_t width, ImageView* depth_buffer, bool is_rescaled, size_t width,
size_t height); size_t height);
MTLRenderPassDescriptor* GetHandle() const noexcept { MTL::RenderPassDescriptor* GetHandle() const noexcept {
return render_pass; return render_pass;
} }
private: private:
MTLRenderPassDescriptor* render_pass{}; MTL::RenderPassDescriptor* render_pass{};
}; };
struct TextureCacheParams { struct TextureCacheParams {
@ -249,7 +246,7 @@ struct TextureCacheParams {
using Sampler = Metal::Sampler; using Sampler = Metal::Sampler;
using Framebuffer = Metal::Framebuffer; using Framebuffer = Metal::Framebuffer;
using AsyncBuffer = Metal::StagingBufferRef; using AsyncBuffer = Metal::StagingBufferRef;
using BufferType = MTLBuffer_t; using BufferType = MTL::Buffer*;
}; };
using TextureCache = VideoCommon::TextureCache<TextureCacheParams>; using TextureCache = VideoCommon::TextureCache<TextureCacheParams>;

View File

@ -1,29 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#ifdef __OBJC__
#import <Metal/Metal.h>
#import <QuartzCore/QuartzCore.h>
typedef id<MTLDevice> MTLDevice_t;
typedef id<MTLCommandQueue> MTLCommandQueue_t;
typedef id<MTLCommandBuffer> MTLCommandBuffer_t;
typedef id<MTLCommandEncoder> MTLCommandEncoder_t;
typedef id<MTLBuffer> MTLBuffer_t;
typedef id<MTLTexture> MTLTexture_t;
typedef id<MTLSamplerState> MTLSamplerState_t;
typedef id<CAMetalDrawable> CAMetalDrawable_t;
#else
typedef void* MTLDevice_t;
typedef void* MTLCommandQueue_t;
typedef void* MTLCommandBuffer_t;
typedef void* MTLCommandEncoder_t;
typedef void* MTLBuffer_t;
typedef void* MTLTexture_t;
typedef void* MTLSamplerState_t;
typedef void MTLRenderPassDescriptor;
typedef void CAMetalLayer;
typedef void* CAMetalDrawable_t;
#define nil NULL
#endif

View File

@ -4,19 +4,18 @@
#include "core/frontend/emu_window.h" #include "core/frontend/emu_window.h"
#include "core/frontend/graphics_context.h" #include "core/frontend/graphics_context.h"
#include "video_core/capture.h" #include "video_core/capture.h"
#include "video_core/renderer_metal/renderer_metal.h"
#include "video_core/renderer_metal/mtl_device.h" #include "video_core/renderer_metal/mtl_device.h"
#include "video_core/renderer_metal/renderer_metal.h"
namespace Metal { namespace Metal {
RendererMetal::RendererMetal(Core::Frontend::EmuWindow& emu_window, RendererMetal::RendererMetal(Core::Frontend::EmuWindow& emu_window,
Tegra::MaxwellDeviceMemoryManager& device_memory_, Tegra::GPU& gpu_, Tegra::MaxwellDeviceMemoryManager& device_memory_, Tegra::GPU& gpu_,
std::unique_ptr<Core::Frontend::GraphicsContext> context_) std::unique_ptr<Core::Frontend::GraphicsContext> context_)
: RendererBase(emu_window, std::move(context_)), device_memory{device_memory_}, : RendererBase(emu_window, std::move(context_)), device_memory{device_memory_}, gpu{gpu_},
gpu{gpu_}, device{}, device{}, command_recorder(device),
command_recorder(device),
swap_chain(device, command_recorder, swap_chain(device, command_recorder,
static_cast<const CAMetalLayer*>(render_window.GetWindowInfo().render_surface)), static_cast<CA::MetalLayer*>(render_window.GetWindowInfo().render_surface)),
rasterizer(gpu_, device_memory, device, command_recorder, swap_chain) {} rasterizer(gpu_, device_memory, device, command_recorder, swap_chain) {}
RendererMetal::~RendererMetal() = default; RendererMetal::~RendererMetal() = default;
@ -30,11 +29,13 @@ void RendererMetal::Composite(std::span<const Tegra::FramebufferConfig> framebuf
swap_chain.AcquireNextDrawable(); swap_chain.AcquireNextDrawable();
// TODO: copy the framebuffer to the drawable texture instead of this dummy render pass // TODO: copy the framebuffer to the drawable texture instead of this dummy render pass
MTLRenderPassDescriptor* render_pass_descriptor = [MTLRenderPassDescriptor renderPassDescriptor]; MTL::RenderPassDescriptor* render_pass_descriptor = MTL::RenderPassDescriptor::alloc()->init();
render_pass_descriptor.colorAttachments[0].clearColor = MTLClearColorMake(1.0, 0.5, 0.0, 1.0); render_pass_descriptor->colorAttachments()->object(0)->setClearColor(
render_pass_descriptor.colorAttachments[0].loadAction = MTLLoadActionClear; MTL::ClearColor::Make(1.0, 0.5, 0.0, 1.0));
render_pass_descriptor.colorAttachments[0].storeAction = MTLStoreActionStore; render_pass_descriptor->colorAttachments()->object(0)->setLoadAction(MTL::LoadActionClear);
render_pass_descriptor.colorAttachments[0].texture = swap_chain.GetDrawableTexture(); render_pass_descriptor->colorAttachments()->object(0)->setStoreAction(MTL::StoreActionStore);
render_pass_descriptor->colorAttachments()->object(0)->setTexture(
swap_chain.GetDrawableTexture());
command_recorder.BeginRenderPass(render_pass_descriptor); command_recorder.BeginRenderPass(render_pass_descriptor);

View File

@ -6,7 +6,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "objc_bridge.h"
#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/host1x/gpu_device_memory_manager.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
#include "video_core/renderer_metal/mtl_command_recorder.h" #include "video_core/renderer_metal/mtl_command_recorder.h"