From 849184452c465676e8c7d01a6b95112acdf2eb7c Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 29 Sep 2022 21:22:13 +0100 Subject: [PATCH] Add function to check if any guest texture mappings are unmapped --- .../gpu/interconnect/maxwell_3d/pipeline_state.cpp | 10 ++++++++-- app/src/main/cpp/skyline/gpu/texture/texture.cpp | 4 ++++ app/src/main/cpp/skyline/gpu/texture/texture.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp index a48190bb..b9b4c9e6 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp @@ -145,7 +145,10 @@ namespace skyline::gpu::interconnect::maxwell3d { auto mappings{ctx.channelCtx.asCtx->gmmu.TranslateRange(target.offset, guest.GetSize())}; guest.mappings.assign(mappings.begin(), mappings.end()); - view = ctx.executor.AcquireTextureManager().FindOrCreate(guest, ctx.executor.tag); + if (guest.MappingsValid()) + view = ctx.executor.AcquireTextureManager().FindOrCreate(guest, ctx.executor.tag); + else + view = {}; } /* Depth Render Target */ @@ -209,7 +212,10 @@ namespace skyline::gpu::interconnect::maxwell3d { auto mappings{ctx.channelCtx.asCtx->gmmu.TranslateRange(engine->ztOffset, guest.GetSize())}; guest.mappings.assign(mappings.begin(), mappings.end()); - view = ctx.executor.AcquireTextureManager().FindOrCreate(guest, ctx.executor.tag); + if (guest.MappingsValid()) + view = ctx.executor.AcquireTextureManager().FindOrCreate(guest, ctx.executor.tag); + else + view = {}; } /* Pipeline Stages */ diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.cpp b/app/src/main/cpp/skyline/gpu/texture/texture.cpp index 2c2c7554..17d623f6 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.cpp +++ b/app/src/main/cpp/skyline/gpu/texture/texture.cpp @@ -66,6 +66,10 @@ namespace skyline::gpu { return GetLayerStride() * (layerCount - baseArrayLayer); } + bool GuestTexture::MappingsValid() const { + return ranges::all_of(mappings, [](const auto &mapping) { return mapping.valid(); }); + } + TextureView::TextureView(std::shared_ptr texture, vk::ImageViewType type, vk::ImageSubresourceRange range, texture::Format format, vk::ComponentMapping mapping) : texture(std::move(texture)), type(type), format(format), mapping(mapping), range(range) {} Texture::TextureViewStorage::TextureViewStorage(vk::ImageViewType type, texture::Format format, vk::ComponentMapping mapping, vk::ImageSubresourceRange range, vk::raii::ImageView &&vkView) : type(type), format(format), mapping(mapping), range(range), vkView(std::move(vkView)) {} diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.h b/app/src/main/cpp/skyline/gpu/texture/texture.h index 1e6ab27e..fefb9040 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.h +++ b/app/src/main/cpp/skyline/gpu/texture/texture.h @@ -285,6 +285,8 @@ namespace skyline::gpu { u32 GetViewDepth() const; size_t GetSize(); + + bool MappingsValid() const; }; class TextureManager;