diff options
| -rw-r--r-- | src/common/polyfill_thread.h | 20 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | 4 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | 3 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/spirv_emit_context.h | 1 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 15 |
5 files changed, 29 insertions, 14 deletions
diff --git a/src/common/polyfill_thread.h b/src/common/polyfill_thread.h index b5ef055db..41cbb9ed5 100644 --- a/src/common/polyfill_thread.h +++ b/src/common/polyfill_thread.h | |||
| @@ -19,8 +19,8 @@ | |||
| 19 | namespace Common { | 19 | namespace Common { |
| 20 | 20 | ||
| 21 | template <typename Condvar, typename Lock, typename Pred> | 21 | template <typename Condvar, typename Lock, typename Pred> |
| 22 | void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) { | 22 | void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred&& pred) { |
| 23 | cv.wait(lock, token, std::move(pred)); | 23 | cv.wait(lk, token, std::move(pred)); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | template <typename Rep, typename Period> | 26 | template <typename Rep, typename Period> |
| @@ -332,13 +332,17 @@ private: | |||
| 332 | namespace Common { | 332 | namespace Common { |
| 333 | 333 | ||
| 334 | template <typename Condvar, typename Lock, typename Pred> | 334 | template <typename Condvar, typename Lock, typename Pred> |
| 335 | void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred pred) { | 335 | void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred pred) { |
| 336 | if (token.stop_requested()) { | 336 | if (token.stop_requested()) { |
| 337 | return; | 337 | return; |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | std::stop_callback callback(token, [&] { cv.notify_all(); }); | 340 | std::stop_callback callback(token, [&] { |
| 341 | cv.wait(lock, [&] { return pred() || token.stop_requested(); }); | 341 | { std::scoped_lock lk2{*lk.mutex()}; } |
| 342 | cv.notify_all(); | ||
| 343 | }); | ||
| 344 | |||
| 345 | cv.wait(lk, [&] { return pred() || token.stop_requested(); }); | ||
| 342 | } | 346 | } |
| 343 | 347 | ||
| 344 | template <typename Rep, typename Period> | 348 | template <typename Rep, typename Period> |
| @@ -353,8 +357,10 @@ bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep, | |||
| 353 | 357 | ||
| 354 | std::stop_callback cb(token, [&] { | 358 | std::stop_callback cb(token, [&] { |
| 355 | // Wake up the waiting thread. | 359 | // Wake up the waiting thread. |
| 356 | std::unique_lock lk{m}; | 360 | { |
| 357 | stop_requested = true; | 361 | std::scoped_lock lk{m}; |
| 362 | stop_requested = true; | ||
| 363 | } | ||
| 358 | cv.notify_one(); | 364 | cv.notify_one(); |
| 359 | }); | 365 | }); |
| 360 | 366 | ||
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 34240b36f..8decdf399 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -204,9 +204,7 @@ Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& ind | |||
| 204 | if (def.count > 1) { | 204 | if (def.count > 1) { |
| 205 | throw NotImplementedException("Indirect texture sample"); | 205 | throw NotImplementedException("Indirect texture sample"); |
| 206 | } | 206 | } |
| 207 | const Id sampler_id{def.id}; | 207 | return ctx.OpLoad(ctx.image_buffer_type, def.id); |
| 208 | const Id id{ctx.OpLoad(ctx.sampled_texture_buffer_type, sampler_id)}; | ||
| 209 | return ctx.OpImage(ctx.image_buffer_type, id); | ||
| 210 | } else { | 208 | } else { |
| 211 | const TextureDefinition& def{ctx.textures.at(info.descriptor_index)}; | 209 | const TextureDefinition& def{ctx.textures.at(info.descriptor_index)}; |
| 212 | if (def.count > 1) { | 210 | if (def.count > 1) { |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 238fb40e3..72f69b7aa 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -1247,9 +1247,8 @@ void EmitContext::DefineTextureBuffers(const Info& info, u32& binding) { | |||
| 1247 | } | 1247 | } |
| 1248 | const spv::ImageFormat format{spv::ImageFormat::Unknown}; | 1248 | const spv::ImageFormat format{spv::ImageFormat::Unknown}; |
| 1249 | image_buffer_type = TypeImage(F32[1], spv::Dim::Buffer, 0U, false, false, 1, format); | 1249 | image_buffer_type = TypeImage(F32[1], spv::Dim::Buffer, 0U, false, false, 1, format); |
| 1250 | sampled_texture_buffer_type = TypeSampledImage(image_buffer_type); | ||
| 1251 | 1250 | ||
| 1252 | const Id type{TypePointer(spv::StorageClass::UniformConstant, sampled_texture_buffer_type)}; | 1251 | const Id type{TypePointer(spv::StorageClass::UniformConstant, image_buffer_type)}; |
| 1253 | texture_buffers.reserve(info.texture_buffer_descriptors.size()); | 1252 | texture_buffers.reserve(info.texture_buffer_descriptors.size()); |
| 1254 | for (const TextureBufferDescriptor& desc : info.texture_buffer_descriptors) { | 1253 | for (const TextureBufferDescriptor& desc : info.texture_buffer_descriptors) { |
| 1255 | if (desc.count != 1) { | 1254 | if (desc.count != 1) { |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index e63330f11..7c49fd504 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h | |||
| @@ -206,7 +206,6 @@ public: | |||
| 206 | Id output_u32{}; | 206 | Id output_u32{}; |
| 207 | 207 | ||
| 208 | Id image_buffer_type{}; | 208 | Id image_buffer_type{}; |
| 209 | Id sampled_texture_buffer_type{}; | ||
| 210 | Id image_u32{}; | 209 | Id image_u32{}; |
| 211 | 210 | ||
| 212 | std::array<UniformDefinitions, Info::MAX_CBUFS> cbufs{}; | 211 | std::array<UniformDefinitions, Info::MAX_CBUFS> cbufs{}; |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 4457b366f..1bdb0def5 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -719,6 +719,7 @@ typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_ad | |||
| 719 | return nullptr; | 719 | return nullptr; |
| 720 | } | 720 | } |
| 721 | const auto& image_map_ids = it->second; | 721 | const auto& image_map_ids = it->second; |
| 722 | boost::container::small_vector<const ImageBase*, 4> valid_images; | ||
| 722 | for (const ImageMapId map_id : image_map_ids) { | 723 | for (const ImageMapId map_id : image_map_ids) { |
| 723 | const ImageMapView& map = slot_map_views[map_id]; | 724 | const ImageMapView& map = slot_map_views[map_id]; |
| 724 | const ImageBase& image = slot_images[map.image_id]; | 725 | const ImageBase& image = slot_images[map.image_id]; |
| @@ -728,8 +729,20 @@ typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_ad | |||
| 728 | if (image.image_view_ids.empty()) { | 729 | if (image.image_view_ids.empty()) { |
| 729 | continue; | 730 | continue; |
| 730 | } | 731 | } |
| 731 | return &slot_image_views[image.image_view_ids.at(0)]; | 732 | valid_images.push_back(&image); |
| 732 | } | 733 | } |
| 734 | |||
| 735 | if (valid_images.size() == 1) [[likely]] { | ||
| 736 | return &slot_image_views[valid_images[0]->image_view_ids.at(0)]; | ||
| 737 | } | ||
| 738 | |||
| 739 | if (valid_images.size() > 0) [[unlikely]] { | ||
| 740 | std::ranges::sort(valid_images, [](const auto* a, const auto* b) { | ||
| 741 | return a->modification_tick > b->modification_tick; | ||
| 742 | }); | ||
| 743 | return &slot_image_views[valid_images[0]->image_view_ids.at(0)]; | ||
| 744 | } | ||
| 745 | |||
| 733 | return nullptr; | 746 | return nullptr; |
| 734 | } | 747 | } |
| 735 | 748 | ||