From 5ace31b471b2e05c23904d8841df7eb52f273d95 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Sat, 5 Oct 2024 18:45:57 +0200 Subject: [PATCH] bind uniform buffers --- src/video_core/renderer_metal/mtl_buffer_cache.cpp | 3 ++- src/video_core/renderer_metal/mtl_buffer_cache.h | 3 ++- src/video_core/renderer_metal/mtl_rasterizer.cpp | 4 ++-- src/video_core/renderer_metal/mtl_staging_buffer_pool.cpp | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/video_core/renderer_metal/mtl_buffer_cache.cpp b/src/video_core/renderer_metal/mtl_buffer_cache.cpp index acddd34f05..7fce777fee 100644 --- a/src/video_core/renderer_metal/mtl_buffer_cache.cpp +++ b/src/video_core/renderer_metal/mtl_buffer_cache.cpp @@ -27,6 +27,7 @@ BufferView::BufferView(MTL::Buffer* buffer_, size_t offset_, size_t size_, : buffer{buffer_->retain()}, offset{offset_}, size{size_}, format{format_} {} BufferView::~BufferView() { + // TODO: uncomment // buffer->release(); } @@ -121,7 +122,7 @@ void BufferCacheRuntime::ReserveNullBuffer() { } MTL::Buffer* BufferCacheRuntime::CreateNullBuffer() { - return CreatePrivateBuffer(device, NULL_BUFFER_SIZE); + return CreatePrivateBuffer(device, NULL_BUFFER_SIZE * 2); } } // namespace Metal diff --git a/src/video_core/renderer_metal/mtl_buffer_cache.h b/src/video_core/renderer_metal/mtl_buffer_cache.h index 1af11d3cec..4cbb8eedec 100644 --- a/src/video_core/renderer_metal/mtl_buffer_cache.h +++ b/src/video_core/renderer_metal/mtl_buffer_cache.h @@ -36,7 +36,7 @@ public: [[nodiscard]] BufferView View(u32 offset, u32 size, VideoCore::Surface::PixelFormat format); void MarkUsage(u64 offset, u64 size) noexcept { - // TODO: track usage + // TODO: track usage? } [[nodiscard]] MTL::Buffer* Handle() const noexcept { @@ -122,6 +122,7 @@ public: void BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings) {} std::span BindMappedUniformBuffer(size_t stage, u32 binding_index, u32 size) { + // TODO: just set bytes in case the size is <= 4KB? const StagingBufferRef ref = staging_pool.Request(size, MemoryUsage::Upload); BindBuffer(stage, binding_index, ref.buffer, static_cast(ref.offset), size); diff --git a/src/video_core/renderer_metal/mtl_rasterizer.cpp b/src/video_core/renderer_metal/mtl_rasterizer.cpp index e2e95f7f13..4ef1debd74 100644 --- a/src/video_core/renderer_metal/mtl_rasterizer.cpp +++ b/src/video_core/renderer_metal/mtl_rasterizer.cpp @@ -124,11 +124,11 @@ void RasterizerMetal::Query(GPUVAddr gpu_addr, VideoCommon::QueryType type, void RasterizerMetal::BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size) { - LOG_DEBUG(Render_Metal, "called"); + buffer_cache.BindGraphicsUniformBuffer(stage, index, gpu_addr, size); } void RasterizerMetal::DisableGraphicsUniformBuffer(size_t stage, u32 index) { - LOG_DEBUG(Render_Metal, "called"); + buffer_cache.DisableGraphicsUniformBuffer(stage, index); } void RasterizerMetal::FlushAll() { diff --git a/src/video_core/renderer_metal/mtl_staging_buffer_pool.cpp b/src/video_core/renderer_metal/mtl_staging_buffer_pool.cpp index 37733fdf4c..dae8096397 100644 --- a/src/video_core/renderer_metal/mtl_staging_buffer_pool.cpp +++ b/src/video_core/renderer_metal/mtl_staging_buffer_pool.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include #include #include @@ -30,7 +29,8 @@ StagingBuffer::StagingBuffer(MTL::Buffer* buffer_, std::span mapped_span_) : buffer{buffer_->retain()}, mapped_span{mapped_span_} {} StagingBuffer::~StagingBuffer() { - buffer->release(); + // TODO: uncomment + //buffer->release(); } StagingBufferRef StagingBuffer::Ref() const noexcept {