From 67dab8b8d835a543edf0750141c367d62e055d43 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Mon, 8 Apr 2024 18:30:04 +0200 Subject: [PATCH] metal: do not release null mtl textures --- .../renderer_metal/mtl_graphics_pipeline.cpp | 1 + src/video_core/renderer_metal/mtl_pipeline_cache.cpp | 2 +- src/video_core/renderer_metal/mtl_texture_cache.cpp | 10 ++++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/video_core/renderer_metal/mtl_graphics_pipeline.cpp b/src/video_core/renderer_metal/mtl_graphics_pipeline.cpp index 4399b75297..626b0221a6 100644 --- a/src/video_core/renderer_metal/mtl_graphics_pipeline.cpp +++ b/src/video_core/renderer_metal/mtl_graphics_pipeline.cpp @@ -15,6 +15,7 @@ #include "video_core/renderer_metal/mtl_command_recorder.h" #include "video_core/renderer_metal/mtl_device.h" #include "video_core/shader_notify.h" +#include "video_core/texture_cache/texture_cache.h" #include "video_core/texture_cache/texture_cache_base.h" namespace Metal { diff --git a/src/video_core/renderer_metal/mtl_pipeline_cache.cpp b/src/video_core/renderer_metal/mtl_pipeline_cache.cpp index f65332b26c..e9ac80b29f 100644 --- a/src/video_core/renderer_metal/mtl_pipeline_cache.cpp +++ b/src/video_core/renderer_metal/mtl_pipeline_cache.cpp @@ -266,7 +266,7 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( // HACK: dummy info std::array infos = {nullptr}; infos[0] = new Shader::Info{}; - infos[1] = new Shader::Info{}; + infos[4] = new Shader::Info{}; return std::make_unique(device, command_recorder, key, buffer_cache, texture_cache, &shader_notify, functions, infos); diff --git a/src/video_core/renderer_metal/mtl_texture_cache.cpp b/src/video_core/renderer_metal/mtl_texture_cache.cpp index ccb658ab73..9d87a23df2 100644 --- a/src/video_core/renderer_metal/mtl_texture_cache.cpp +++ b/src/video_core/renderer_metal/mtl_texture_cache.cpp @@ -103,9 +103,9 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI ImageId image_id_, Image& image) : VideoCommon::ImageViewBase{info, image.info, image_id_, image.gpu_addr} { using Shader::TextureType; - // TODO: For whatever reason, some images's internal objc objects is NULL - // TODO: metal-cpp provides no method to check for this - texture = image.GetHandle()->retain(); + if (image.GetHandle()) { + texture = image.GetHandle()->retain(); + } // TODO: create texture view } @@ -128,7 +128,9 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::NullImageV } ImageView::~ImageView() { - texture->release(); + if (texture) { + texture->release(); + } } Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& tsc) {