Commit 0d2de6f0 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix precision issue in blit math

Bug: chromium:1154759 Change-Id: If31ef7ebecdfa2a0cba91e917870ea0bdfd9b9db Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2570464 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 19a302fc
...@@ -913,9 +913,9 @@ angle::Result FramebufferVk::blit(const gl::Context *context, ...@@ -913,9 +913,9 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
destArea = destArea.removeReversal(); destArea = destArea.removeReversal();
// Calculate the stretch factor prior to any clipping, as it needs to remain constant. // Calculate the stretch factor prior to any clipping, as it needs to remain constant.
const float stretch[2] = { const double stretch[2] = {
std::abs(sourceArea.width / static_cast<float>(destArea.width)), std::abs(sourceArea.width / static_cast<double>(destArea.width)),
std::abs(sourceArea.height / static_cast<float>(destArea.height)), std::abs(sourceArea.height / static_cast<double>(destArea.height)),
}; };
// Potentially make adjustments for pre-rotatation. To handle various cases (e.g. clipping) // Potentially make adjustments for pre-rotatation. To handle various cases (e.g. clipping)
...@@ -962,11 +962,12 @@ angle::Result FramebufferVk::blit(const gl::Context *context, ...@@ -962,11 +962,12 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
else else
{ {
// Shift dest area's x0,y0,x1,y1 by as much as the source area's got shifted (taking // Shift dest area's x0,y0,x1,y1 by as much as the source area's got shifted (taking
// stretching into account) // stretching into account). Note that double is used as float doesn't have enough
float x0Shift = std::round((clippedSourceArea.x - absSourceArea.x) / stretch[0]); // precision near the end of int range.
float y0Shift = std::round((clippedSourceArea.y - absSourceArea.y) / stretch[1]); double x0Shift = std::round((clippedSourceArea.x - absSourceArea.x) / stretch[0]);
float x1Shift = std::round((absSourceArea.x1() - clippedSourceArea.x1()) / stretch[0]); double y0Shift = std::round((clippedSourceArea.y - absSourceArea.y) / stretch[1]);
float y1Shift = std::round((absSourceArea.y1() - clippedSourceArea.y1()) / stretch[1]); double x1Shift = std::round((absSourceArea.x1() - clippedSourceArea.x1()) / stretch[0]);
double y1Shift = std::round((absSourceArea.y1() - clippedSourceArea.y1()) / stretch[1]);
// If the source area was reversed in any direction, the shift should be applied in the // If the source area was reversed in any direction, the shift should be applied in the
// opposite direction as well. // opposite direction as well.
...@@ -1068,8 +1069,8 @@ angle::Result FramebufferVk::blit(const gl::Context *context, ...@@ -1068,8 +1069,8 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
commonParams.destOffset[1] = destArea.y; commonParams.destOffset[1] = destArea.y;
commonParams.rotatedOffsetFactor[0] = std::abs(sourceArea.width); commonParams.rotatedOffsetFactor[0] = std::abs(sourceArea.width);
commonParams.rotatedOffsetFactor[1] = std::abs(sourceArea.height); commonParams.rotatedOffsetFactor[1] = std::abs(sourceArea.height);
commonParams.stretch[0] = stretch[0]; commonParams.stretch[0] = static_cast<float>(stretch[0]);
commonParams.stretch[1] = stretch[1]; commonParams.stretch[1] = static_cast<float>(stretch[1]);
commonParams.srcExtents[0] = srcFramebufferDimensions.width; commonParams.srcExtents[0] = srcFramebufferDimensions.width;
commonParams.srcExtents[1] = srcFramebufferDimensions.height; commonParams.srcExtents[1] = srcFramebufferDimensions.height;
commonParams.blitArea = blitArea; commonParams.blitArea = blitArea;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment