From 6a02e7140f93b51fb2fe866f1450928aa64da4cb Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 19 Oct 2021 19:46:36 +0200 Subject: [PATCH] early-access version 2148 --- README.md | 2 +- .../backend/spirv/emit_spirv_image.cpp | 21 ++++++++++++++----- .../renderer_vulkan/vk_rasterizer.cpp | 3 ++- .../renderer_vulkan/vk_state_tracker.h | 7 +++++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8ced4ed84..fd1b3119f 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2147. +This is the source code for early-access 2148. ## Legal Notice diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 3588f052b..1d5364309 100755 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp @@ -355,11 +355,22 @@ Id EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& Id EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id dref, Id bias_lc, const IR::Value& offset) { const auto info{inst->Flags()}; - const ImageOperands operands(ctx, info.has_bias != 0, false, info.has_lod_clamp != 0, bias_lc, - offset); - return Emit(&EmitContext::OpImageSparseSampleDrefImplicitLod, - &EmitContext::OpImageSampleDrefImplicitLod, ctx, inst, ctx.F32[1], - Texture(ctx, info, index), coords, dref, operands.MaskOptional(), operands.Span()); + if (ctx.stage == Stage::Fragment) { + const ImageOperands operands(ctx, info.has_bias != 0, false, info.has_lod_clamp != 0, + bias_lc, offset); + return Emit(&EmitContext::OpImageSparseSampleDrefImplicitLod, + &EmitContext::OpImageSampleDrefImplicitLod, ctx, inst, ctx.F32[1], + Texture(ctx, info, index), coords, dref, operands.MaskOptional(), + operands.Span()); + } else { + // Implicit lods in compute behave on hardware as if sampling from LOD 0. + // This check is to ensure all drivers behave this way. + const Id lod{ctx.Const(0.0f)}; + const ImageOperands operands(ctx, false, true, false, lod, offset); + return Emit(&EmitContext::OpImageSparseSampleDrefExplicitLod, + &EmitContext::OpImageSampleDrefExplicitLod, ctx, inst, ctx.F32[1], + Texture(ctx, info, index), coords, dref, operands.Mask(), operands.Span()); + } } Id EmitImageSampleDrefExplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 04ecc034d..b6496e8f5 100755 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -592,7 +592,8 @@ void RasterizerVulkan::EndTransformFeedback() { } void RasterizerVulkan::UpdateViewportsState(Tegra::Engines::Maxwell3D::Regs& regs) { - if (!state_tracker.TouchViewports()) { + if (!state_tracker.TouchViewports() && + !state_tracker.ChangedYNegate(regs.screen_y_control.y_negate)) { return; } const std::array viewports{ diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index 2f2d6b31f..801d05afa 100755 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h @@ -137,6 +137,12 @@ public: return has_changed; } + bool ChangedYNegate(u32 new_y_negate) { + const bool has_changed = current_y_negate != new_y_negate; + current_y_negate = new_y_negate; + return has_changed; + } + private: static constexpr auto INVALID_TOPOLOGY = static_cast(~0u); @@ -149,6 +155,7 @@ private: Tegra::Engines::Maxwell3D::DirtyState::Flags& flags; Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags; Maxwell::PrimitiveTopology current_topology = INVALID_TOPOLOGY; + u32 current_y_negate{}; }; } // namespace Vulkan