diff options
author | FernandoS27 <fsahmkow27@gmail.com> | 2021-10-19 19:41:57 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-11-16 22:11:31 +0100 |
commit | 826a350e2b6aadb4f123189c28f065b0e7926264 (patch) | |
tree | 313ea78b62cee597b3c6f36ff2ca2bd37f29319d /src/video_core/renderer_vulkan/vk_rasterizer.cpp | |
parent | Texture cache: fix Intel with rescaler. (diff) | |
download | yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar.gz yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar.bz2 yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar.lz yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar.xz yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar.zst yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index a9334e101..ff75d14a1 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -211,6 +211,8 @@ void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) { EndTransformFeedback(); } +#pragma optimize("", off) + void RasterizerVulkan::Clear() { MICROPROFILE_SCOPE(Vulkan_Clearing); @@ -260,7 +262,37 @@ void RasterizerVulkan::Clear() { const u32 color_attachment = regs.clear_buffers.RT; if (use_color && framebuffer->HasAspectColorBit(color_attachment)) { VkClearValue clear_value; - std::memcpy(clear_value.color.float32, regs.clear_color, sizeof(regs.clear_color)); + bool is_integer = false; + bool is_signed = false; + size_t int_size = 8; + for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; ++i) { + const auto& this_rt = regs.rt[i]; + if (this_rt.Address() == 0) { + continue; + } + if (this_rt.format == Tegra::RenderTargetFormat::NONE) { + continue; + } + const auto format = + VideoCore::Surface::PixelFormatFromRenderTargetFormat(this_rt.format); + is_integer = IsPixelFormatInteger(format); + is_signed = IsPixelFormatSignedInteger(format); + int_size = PixelComponentSizeBitsInteger(format); + break; + } + if (!is_integer) { + std::memcpy(clear_value.color.float32, regs.clear_color, sizeof(regs.clear_color)); + } else if (!is_signed) { + for (size_t i = 0; i < 4; i++) { + clear_value.color.uint32[i] = + static_cast<u32>(static_cast<u64>(int_size << 1U) * regs.clear_color[i]); + } + } else { + for (size_t i = 0; i < 4; i++) { + clear_value.color.int32[i] = static_cast<s32>( + (static_cast<s32>(int_size - 1) << 1) * (regs.clear_color[i] - 0.5f)); + } + } scheduler.Record([color_attachment, clear_value, clear_rect](vk::CommandBuffer cmdbuf) { const VkClearAttachment attachment{ |