VERY experimental Nintendo Switch 2 emulator
C++
[vk] fix oversight with #3874 with invalid image ids (#4026)
lizzie116377f6d96d
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cppindex 9609965637..728554d6e6 100644--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp@@ -49,7 +49,6 @@ using VideoCore::Surface::PixelFormatFromDepthFormat;using VideoCore::Surface::PixelFormatFromRenderTargetFormat;constexpr size_t NUM_STAGES = Maxwell::MaxShaderStage;-constexpr size_t INLINE_IMAGE_ELEMENTS = 64;DescriptorLayoutBuilder MakeBuilder(const Device& device, std::span<const Shader::Info> infos) {DescriptorLayoutBuilder builder{device};@@ -314,8 +313,8 @@ void GraphicsPipeline::AddTransition(GraphicsPipeline* transition) {template <typename Spec>bool GraphicsPipeline::ConfigureImpl(bool is_indexed) {- boost::container::small_vector<VideoCommon::ImageViewInOut, INLINE_IMAGE_ELEMENTS> views;- boost::container::small_vector<VideoCommon::SamplerId, INLINE_IMAGE_ELEMENTS> samplers;+ boost::container::small_vector<VideoCommon::ImageViewInOut, 64> views;+ boost::container::small_vector<VideoCommon::SamplerId, 64> samplers;views.reserve(num_image_elements);samplers.reserve(num_textures);diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cppindex d99a650acc..e9c252fba6 100644--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp@@ -359,7 +359,7 @@ void RasterizerVulkan::DrawTexture() {query_cache.NotifySegment(true);query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, maxwell3d->regs.zpass_pixel_count_enable);const auto& draw_texture_state = maxwell3d->draw_manager.draw_texture_state;- const auto& sampler = texture_cache.GetSampler(draw_texture_state.src_sampler, true);+ const auto& sampler = texture_cache.GetSampler(draw_texture_state.src_sampler, false);const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture);const auto* framebuffer = texture_cache.GetFramebuffer();diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.hindex c0a0c3736b..2cfdb94359 100644--- a/src/video_core/texture_cache/texture_cache.h+++ b/src/video_core/texture_cache/texture_cache.h@@ -313,13 +313,14 @@ SamplerId TextureCache<P>::GetSamplerId(u32 index, bool compute) {LOG_DEBUG(HW_GPU, "Invalid sampler index={}", index);return NULL_SAMPLER_ID;}+ auto const map_index = index | (compute ? Common::SlotId::TAGGED_VALUE : 0);auto const [descriptor, is_new] = table.Read(*gpu_memory, index);if (is_new) {auto const id = FindSampler(descriptor, compute);- channel_state->sampler_ids.insert_or_assign(index | (compute ? Common::SlotId::TAGGED_VALUE : 0), id);+ channel_state->sampler_ids.insert_or_assign(map_index, id);return id;}- return channel_state->sampler_ids.find(index | (compute ? Common::SlotId::TAGGED_VALUE : 0))->second;+ return channel_state->sampler_ids.find(map_index)->second;}template <class P>@@ -542,6 +543,7 @@ ImageViewId TextureCache<P>::VisitImageView(u32 index, bool compute) {LOG_DEBUG(HW_GPU, "Invalid image view index={}", index);return NULL_IMAGE_VIEW_ID;}+ auto const map_index = index | (compute ? Common::SlotId::TAGGED_VALUE : 0);// Is new (on the tegra engine side)?auto const [descriptor, is_new] = table.Read(*gpu_memory, index);if (is_new) {@@ -551,14 +553,15 @@ ImageViewId TextureCache<P>::VisitImageView(u32 index, bool compute) {if (is_new_tc)pair->second = CreateImageView(descriptor);PrepareImageView(pair->second, false, false);- channel_state->image_view_ids.insert_or_assign(index | (compute ? Common::SlotId::TAGGED_VALUE : 0), pair->second);+ channel_state->image_view_ids.insert_or_assign(map_index, pair->second);return pair->second;}- channel_state->image_view_ids.insert_or_assign(index | (compute ? Common::SlotId::TAGGED_VALUE : 0), NULL_IMAGE_VIEW_ID);+ channel_state->image_view_ids.insert_or_assign(map_index, NULL_IMAGE_VIEW_ID);return NULL_IMAGE_VIEW_ID;}- auto const it = channel_state->image_view_ids.find(index | (compute ? Common::SlotId::TAGGED_VALUE : 0));- PrepareImageView(it->second, false, false);+ auto const it = channel_state->image_view_ids.find(map_index);+ if (it->second != NULL_IMAGE_VIEW_ID)+ PrepareImageView(it->second, false, false);return it->second;}