From 6d3c637052ef59e92390ce6361bec2dc32f78e80 Mon Sep 17 00:00:00 2001 From: Shahbaz Youssefi Date: Sat, 18 Jun 2022 00:13:56 -0400 Subject: [PATCH] Vulkan: Fix 180 and 270 degree rotated resolve Bug: angleproject:7197 Bug: b/235877059 Change-Id: I4d4ee622f49bb3218449414a1f0dd91fa4e4f541 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3708997 Auto-Submit: Shahbaz Youssefi Commit-Queue: Shahbaz Youssefi Reviewed-by: Amirali Abdolrashidi Reviewed-by: Ian Elliott Commit-Queue: Amirali Abdolrashidi --- .../Vulkan_internal_shader_programs.json | 2 +- .../renderer/vulkan/FramebufferVk.cpp | 2 +- src/libANGLE/renderer/vulkan/UtilsVk.cpp | 44 +++++-------------- .../vulkan/shaders/src/BlitResolve.frag | 1 - .../angle_end2end_tests_expectations.txt | 5 --- 5 files changed, 13 insertions(+), 41 deletions(-) diff --git a/scripts/code_generation_hashes/Vulkan_internal_shader_programs.json b/scripts/code_generation_hashes/Vulkan_internal_shader_programs.json index 5253df92c..bcb55b04c 100644 --- a/scripts/code_generation_hashes/Vulkan_internal_shader_programs.json +++ b/scripts/code_generation_hashes/Vulkan_internal_shader_programs.json @@ -266,7 +266,7 @@ "src/libANGLE/renderer/vulkan/shaders/gen/OverlayDraw.vert.00000000.inc": "7c6873b4adbfd7ca626a2e2801a96a47", "src/libANGLE/renderer/vulkan/shaders/src/BlitResolve.frag": - "0b16d3ad95d7dbc2ce7175462152e4f9", + "029da84d0083a96ad9a441d8c181b006", "src/libANGLE/renderer/vulkan/shaders/src/BlitResolve.frag.json": "353929c45304fe9c327b50a53c5f1918", "src/libANGLE/renderer/vulkan/shaders/src/BlitResolveStencilNoExport.comp": diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp index 7011978d3..7422952df 100644 --- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp +++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp @@ -1146,7 +1146,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context, commonParams.srcExtents[0] = srcFramebufferDimensions.width; commonParams.srcExtents[1] = srcFramebufferDimensions.height; commonParams.blitArea = blitArea; - commonParams.linear = filter == GL_LINEAR; + commonParams.linear = filter == GL_LINEAR && !isResolve; commonParams.flipX = flipX; commonParams.flipY = flipY; commonParams.rotation = rotation; diff --git a/src/libANGLE/renderer/vulkan/UtilsVk.cpp b/src/libANGLE/renderer/vulkan/UtilsVk.cpp index 425250234..2cc3c96d9 100644 --- a/src/libANGLE/renderer/vulkan/UtilsVk.cpp +++ b/src/libANGLE/renderer/vulkan/UtilsVk.cpp @@ -2427,40 +2427,30 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk, switch (params.rotation) { case SurfaceRotation::Identity: - break; case SurfaceRotation::Rotated90Degrees: - shaderParams.rotateXY = 1; break; case SurfaceRotation::Rotated180Degrees: - if (isResolve) - { - shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0]; - shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1]; - } - else - { - shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0]; - shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1]; - } - break; case SurfaceRotation::Rotated270Degrees: if (isResolve) { - shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0]; - shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1]; + // Align the offset with minus 1, or the sample position near the edge will be + // wrong. + shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0] - 1; + shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1] - 1; } else { shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0]; shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1]; } - shaderParams.rotateXY = 1; break; default: UNREACHABLE(); break; } + shaderParams.rotateXY = IsRotatedAspectRatio(params.rotation); + bool blitColor = srcColorView != nullptr; bool blitDepth = srcDepthView != nullptr; bool blitStencil = srcStencilView != nullptr; @@ -2687,42 +2677,30 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk, switch (params.rotation) { case SurfaceRotation::Identity: - break; case SurfaceRotation::Rotated90Degrees: - shaderParams.rotateXY = 1; break; case SurfaceRotation::Rotated180Degrees: + case SurfaceRotation::Rotated270Degrees: if (isResolve) { // Align the offset with minus 1, or the sample position near the edge will be // wrong. - shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0] - 1; - shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1]; - } - else - { - shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0] - 1; - shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1]; - } - break; - case SurfaceRotation::Rotated270Degrees: - if (isResolve) - { shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0] - 1; shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1] - 1; } else { - shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0] - 1; - shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1] - 1; + shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0]; + shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1]; } - shaderParams.rotateXY = 1; break; default: UNREACHABLE(); break; } + shaderParams.rotateXY = IsRotatedAspectRatio(params.rotation); + // Linear sampling is only valid with color blitting. ASSERT(!params.linear); diff --git a/src/libANGLE/renderer/vulkan/shaders/src/BlitResolve.frag b/src/libANGLE/renderer/vulkan/shaders/src/BlitResolve.frag index f154a3dd2..b19ca2f15 100644 --- a/src/libANGLE/renderer/vulkan/shaders/src/BlitResolve.frag +++ b/src/libANGLE/renderer/vulkan/shaders/src/BlitResolve.frag @@ -170,7 +170,6 @@ void main() // // Note that T is params.stretch and O is params.offset. - // X CoordType srcImageCoords = CoordType(gl_FragCoord.xy); // X #if !IsResolve srcImageCoords *= params.stretch; // TX diff --git a/src/tests/angle_end2end_tests_expectations.txt b/src/tests/angle_end2end_tests_expectations.txt index 941cecaab..85ebf822c 100644 --- a/src/tests/angle_end2end_tests_expectations.txt +++ b/src/tests/angle_end2end_tests_expectations.txt @@ -48,17 +48,12 @@ 6926 VULKAN : Texture2DTestES3.TextureRGBUpdateWithPBO/ES3_Vulkan* = SKIP 6730 VULKAN : GLSLTest_ES3.GLVertexIDIntegerTextureDrawElementsU8Line/* = SKIP 6730 VULKAN : GLSLTest_ES3.GLVertexIDIntegerTextureDrawElementsU8LineIds/* = SKIP -7197 VULKAN : BlitFramebufferTest.ResolveWithRotation/ES3_Vulkan_EmulatedPrerotation180 = SKIP -7197 VULKAN : BlitFramebufferTest.ResolveWithRotation/ES3_Vulkan_EmulatedPrerotation270 = SKIP -7197 VULKAN : BlitFramebufferTest.BlitMultisampleStencilToDefault/ES3_Vulkan_EmulatedPrerotation180 = SKIP 7198 VULKAN : BlitFramebufferTest.BlitMultisampleStencilToDefault/ES3_Vulkan_EmulatedPrerotation90 = SKIP 7198 VULKAN : BlitFramebufferTest.BlitMultisampleStencilToDefault/ES3_Vulkan_EmulatedPrerotation270 = SKIP 7291 VULKAN : BlitFramebufferTest.Blit3D/* = SKIP 7291 VULKAN : BlitFramebufferTest.Blit3DTo2DArray/* = SKIP 7291 VULKAN : BlitFramebufferTest.Blit2DArrayTo3D/* = SKIP 235523746 VULKAN : VulkanPerformanceCounterTest.CreateDestroyTextureDoesNotIncreaseDescriptporSetCache/* = SKIP -235877059 VULKAN : MultisampleTestES3.ResolveToFBO/ES3_Vulkan_EmulatedPrerotation180 = SKIP -235877059 VULKAN : MultisampleTestES3.ResolveToFBO/ES3_Vulkan_EmulatedPrerotation270 = SKIP // Windows 3786 WIN NVIDIA D3D11 : BufferDataOverflowTest.VertexBufferIntegerOverflow/* = SKIP