Commit a91dcb62 by Ian Elliott Committed by Commit Bot

Fix FramebufferVk::getScissoredRenderArea() for pre-rotation

This fixes cases where pre-rotation wasn't occuring for small scissors used with glClear(). There are around 1000 tests that do this. Test: angle_deqp_gles2_tests --gtest_filter=dEQP.GLES2/functional_fragment_ops_depth_stencil_* Bug: angleproject:4431 Bug: b/157933235 Bug: b/157933198 Change-Id: I469d51975e3bc3a7bfc9521a3817c919e809f7dd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2228211Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent 77851053
......@@ -207,6 +207,50 @@ void SetFloatUniformMatrixFast(unsigned int arrayElementOffset,
}
} // anonymous namespace
void RotateRectangle(const SurfaceRotation rotation,
const bool flipY,
const int framebufferWidth,
const int framebufferHeight,
const gl::Rectangle &incoming,
gl::Rectangle *outgoing)
{
// GLES's y-axis points up; Vulkan's points down.
switch (rotation)
{
case SurfaceRotation::Identity:
// Do not rotate gl_Position (surface matches the device's orientation):
outgoing->x = incoming.x;
outgoing->y = flipY ? framebufferHeight - incoming.y - incoming.height : incoming.y;
outgoing->width = incoming.width;
outgoing->height = incoming.height;
break;
case SurfaceRotation::Rotated90Degrees:
// Rotate gl_Position 90 degrees:
outgoing->x = incoming.y;
outgoing->y = flipY ? incoming.x : framebufferWidth - incoming.x - incoming.width;
outgoing->width = incoming.height;
outgoing->height = incoming.width;
break;
case SurfaceRotation::Rotated180Degrees:
// Rotate gl_Position 180 degrees:
outgoing->x = framebufferWidth - incoming.x - incoming.width;
outgoing->y = flipY ? incoming.y : framebufferHeight - incoming.y - incoming.height;
outgoing->width = incoming.width;
outgoing->height = incoming.height;
break;
case SurfaceRotation::Rotated270Degrees:
// Rotate gl_Position 270 degrees:
outgoing->x = framebufferHeight - incoming.y - incoming.height;
outgoing->y = flipY ? framebufferWidth - incoming.x - incoming.width : incoming.x;
outgoing->width = incoming.height;
outgoing->height = incoming.width;
break;
default:
UNREACHABLE();
break;
}
}
PackPixelsParams::PackPixelsParams()
: destFormat(nullptr),
outputPitch(0),
......
......@@ -60,6 +60,13 @@ enum class SurfaceRotation
EnumCount = InvalidEnum,
};
void RotateRectangle(const SurfaceRotation rotation,
const bool flipY,
const int framebufferWidth,
const int framebufferHeight,
const gl::Rectangle &incoming,
gl::Rectangle *outgoing);
using MipGenerationFunction = void (*)(size_t sourceWidth,
size_t sourceHeight,
size_t sourceDepth,
......
......@@ -268,50 +268,6 @@ SurfaceRotation DetermineSurfaceRotation(gl::Framebuffer *framebuffer,
}
}
void RotateRectangle(const SurfaceRotation rotation,
const bool flipY,
const int framebufferWidth,
const int framebufferHeight,
const gl::Rectangle &incoming,
gl::Rectangle *outgoing)
{
// GLES's y-axis points up; Vulkan's points down.
switch (rotation)
{
case SurfaceRotation::Identity:
// Do not rotate gl_Position (surface matches the device's orientation):
outgoing->x = incoming.x;
outgoing->y = flipY ? framebufferHeight - incoming.y - incoming.height : incoming.y;
outgoing->width = incoming.width;
outgoing->height = incoming.height;
break;
case SurfaceRotation::Rotated90Degrees:
// Rotate gl_Position 90 degrees:
outgoing->x = incoming.y;
outgoing->y = flipY ? incoming.x : framebufferWidth - incoming.x - incoming.width;
outgoing->width = incoming.height;
outgoing->height = incoming.width;
break;
case SurfaceRotation::Rotated180Degrees:
// Rotate gl_Position 180 degrees:
outgoing->x = framebufferWidth - incoming.x - incoming.width;
outgoing->y = flipY ? incoming.y : framebufferHeight - incoming.y - incoming.height;
outgoing->width = incoming.width;
outgoing->height = incoming.height;
break;
case SurfaceRotation::Rotated270Degrees:
// Rotate gl_Position 270 degrees:
outgoing->x = framebufferHeight - incoming.y - incoming.height;
outgoing->y = flipY ? framebufferWidth - incoming.x - incoming.width : incoming.x;
outgoing->width = incoming.height;
outgoing->height = incoming.width;
break;
default:
UNREACHABLE();
break;
}
}
// Should not generate a copy with modern C++.
EventName GetTraceEventName(const char *title, uint32_t counter)
{
......@@ -4161,16 +4117,7 @@ angle::Result ContextVk::flushAndBeginRenderPass(
vk::CommandBuffer *outsideRenderPassCommandBuffer;
ANGLE_TRY(endRenderPassAndGetCommandBuffer(&outsideRenderPassCommandBuffer));
gl::Rectangle rotatedRenderArea = renderArea;
if (isRotatedAspectRatioForDrawFBO())
{
// The surface is rotated 90/270 degrees. This changes the aspect ratio of
// the surface. Swap the x and y axis of the renderArea.
std::swap(rotatedRenderArea.x, rotatedRenderArea.y);
std::swap(rotatedRenderArea.width, rotatedRenderArea.height);
}
mRenderPassCommands->beginRenderPass(framebuffer, rotatedRenderArea, renderPassDesc,
mRenderPassCommands->beginRenderPass(framebuffer, renderArea, renderPassDesc,
renderPassAttachmentOps, clearValues, commandBufferOut);
return angle::Result::Continue;
}
......
......@@ -1726,7 +1726,11 @@ gl::Rectangle FramebufferVk::getScissoredRenderArea(ContextVk *contextVk) const
{
const gl::Rectangle renderArea = getCompleteRenderArea();
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
return ClipRectToScissor(contextVk->getState(), renderArea, invertViewport);
gl::Rectangle scissoredArea = ClipRectToScissor(contextVk->getState(), renderArea, false);
gl::Rectangle rotatedScissoredArea;
RotateRectangle(contextVk->getRotationDrawFramebuffer(), invertViewport, renderArea.width,
renderArea.height, scissoredArea, &rotatedScissoredArea);
return rotatedScissoredArea;
}
RenderTargetVk *FramebufferVk::getFirstRenderTarget() const
......
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