Commit 7e2a9820 by Ian Elliott Committed by Commit Bot

Vulkan: Make explicitly-[non-]rotated get methods

Split FramebufferVk::getCompleteRenderArea() into 2, [non-]rotated, explicitly-named methods. Simplify the uses of these methods, and fix some rotation cases. Also explicitly-name FramebufferVk::getScissoredRenderArea(). Bug: b/151111296 Change-Id: I1754ec2796fd8625b916a2dba2e723e70ecba419 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2305389Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent bdc79361
...@@ -960,7 +960,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context, ...@@ -960,7 +960,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
// TODO(jmadill): Use dirty bit. http://anglebug.com/3014 // TODO(jmadill): Use dirty bit. http://anglebug.com/3014
if (!mRenderPassCommandBuffer) if (!mRenderPassCommandBuffer)
{ {
gl::Rectangle scissoredRenderArea = mDrawFramebuffer->getScissoredRenderArea(this); gl::Rectangle scissoredRenderArea = mDrawFramebuffer->getRotatedScissoredRenderArea(this);
ANGLE_TRY(startRenderPass(scissoredRenderArea, nullptr)); ANGLE_TRY(startRenderPass(scissoredRenderArea, nullptr));
} }
...@@ -2626,7 +2626,7 @@ void ContextVk::updateDepthRange(float nearPlane, float farPlane) ...@@ -2626,7 +2626,7 @@ void ContextVk::updateDepthRange(float nearPlane, float farPlane)
angle::Result ContextVk::updateScissor(const gl::State &glState) angle::Result ContextVk::updateScissor(const gl::State &glState)
{ {
FramebufferVk *framebufferVk = vk::GetImpl(glState.getDrawFramebuffer()); FramebufferVk *framebufferVk = vk::GetImpl(glState.getDrawFramebuffer());
gl::Rectangle renderArea = framebufferVk->getCompleteRenderArea(); gl::Rectangle renderArea = framebufferVk->getNonRotatedCompleteRenderArea();
// Clip the render area to the viewport. // Clip the render area to the viewport.
gl::Rectangle viewportClippedRenderArea; gl::Rectangle viewportClippedRenderArea;
...@@ -2651,7 +2651,7 @@ angle::Result ContextVk::updateScissor(const gl::State &glState) ...@@ -2651,7 +2651,7 @@ angle::Result ContextVk::updateScissor(const gl::State &glState)
// is too small, we need to start a new one. The latter can happen if a scissored clear starts // is too small, we need to start a new one. The latter can happen if a scissored clear starts
// a render pass, the scissor is disabled and a draw call is issued to affect the whole // a render pass, the scissor is disabled and a draw call is issued to affect the whole
// framebuffer. // framebuffer.
gl::Rectangle scissoredRenderArea = framebufferVk->getScissoredRenderArea(this); gl::Rectangle scissoredRenderArea = framebufferVk->getRotatedScissoredRenderArea(this);
if (!mRenderPassCommands->empty()) if (!mRenderPassCommands->empty())
{ {
if (!mRenderPassCommands->getRenderArea().encloses(scissoredRenderArea)) if (!mRenderPassCommands->getRenderArea().encloses(scissoredRenderArea))
......
...@@ -277,7 +277,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -277,7 +277,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
{ {
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
const gl::Rectangle scissoredRenderArea = getScissoredRenderArea(contextVk); const gl::Rectangle scissoredRenderArea = getRotatedScissoredRenderArea(contextVk);
// Discard clear altogether if scissor has 0 width or height. // Discard clear altogether if scissor has 0 width or height.
if (scissoredRenderArea.width == 0 || scissoredRenderArea.height == 0) if (scissoredRenderArea.width == 0 || scissoredRenderArea.height == 0)
...@@ -318,14 +318,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -318,14 +318,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
// The front-end should ensure we don't attempt to clear stencil if all bits are masked. // The front-end should ensure we don't attempt to clear stencil if all bits are masked.
ASSERT(!clearStencil || stencilMask != 0); ASSERT(!clearStencil || stencilMask != 0);
gl::Rectangle completeRenderArea = getCompleteRenderArea(); bool scissoredClear = scissoredRenderArea != getRotatedCompleteRenderArea(contextVk);
if (contextVk->isRotatedAspectRatioForDrawFBO())
{
// The surface is rotated 90/270 degrees. This changes the aspect ratio of the surface.
std::swap(completeRenderArea.x, completeRenderArea.y);
std::swap(completeRenderArea.width, completeRenderArea.height);
}
bool scissoredClear = scissoredRenderArea != completeRenderArea;
// Special case for rendering feedback loops: clears are always valid in GL since they don't // Special case for rendering feedback loops: clears are always valid in GL since they don't
// sample from any textures. // sample from any textures.
...@@ -553,7 +546,14 @@ angle::Result FramebufferVk::readPixels(const gl::Context *context, ...@@ -553,7 +546,14 @@ angle::Result FramebufferVk::readPixels(const gl::Context *context,
} }
// Flush any deferred clears. // Flush any deferred clears.
ANGLE_TRY(flushDeferredClears(contextVk, fbRect)); gl::Rectangle rotatedFbRect = fbRect;
if (contextVk->isRotatedAspectRatioForReadFBO())
{
// The surface is rotated 90/270 degrees. This changes the aspect ratio of the surface.
// Since fbRect.{x|y} are both 0, there's no need to swap them.
std::swap(rotatedFbRect.width, rotatedFbRect.height);
}
ANGLE_TRY(flushDeferredClears(contextVk, rotatedFbRect));
GLuint outputSkipBytes = 0; GLuint outputSkipBytes = 0;
PackPixelsParams params; PackPixelsParams params;
...@@ -723,7 +723,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context, ...@@ -723,7 +723,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
// We can sometimes end up in a blit with some clear commands saved. Ensure all clear commands // We can sometimes end up in a blit with some clear commands saved. Ensure all clear commands
// are issued before we issue the blit command. // are issued before we issue the blit command.
ANGLE_TRY(flushDeferredClears(contextVk, getCompleteRenderArea())); ANGLE_TRY(flushDeferredClears(contextVk, getRotatedCompleteRenderArea(contextVk)));
const gl::State &glState = contextVk->getState(); const gl::State &glState = contextVk->getState();
const gl::Framebuffer *srcFramebuffer = glState.getReadFramebuffer(); const gl::Framebuffer *srcFramebuffer = glState.getReadFramebuffer();
...@@ -895,7 +895,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context, ...@@ -895,7 +895,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
// about the source area anymore. The offset translation is done based on the original source // about the source area anymore. The offset translation is done based on the original source
// and destination rectangles. The stretch factor is already calculated as well. // and destination rectangles. The stretch factor is already calculated as well.
gl::Rectangle blitArea; gl::Rectangle blitArea;
if (!gl::ClipRectangle(getScissoredRenderArea(contextVk), srcClippedDestArea, &blitArea)) if (!gl::ClipRectangle(getRotatedScissoredRenderArea(contextVk), srcClippedDestArea, &blitArea))
{ {
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -1399,7 +1399,10 @@ angle::Result FramebufferVk::syncState(const gl::Context *context, ...@@ -1399,7 +1399,10 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
// Only defer clears for whole draw framebuffer ops. If the scissor test is on and the scissor // Only defer clears for whole draw framebuffer ops. If the scissor test is on and the scissor
// rect doesn't match the draw rect, forget it. // rect doesn't match the draw rect, forget it.
gl::Rectangle renderArea = getCompleteRenderArea(); //
// NOTE: Neither renderArea nor scissoredRenderArea are rotated, since scissoredRenderArea did
// not come from FramebufferVk::getRotatedScissoredRenderArea().
gl::Rectangle renderArea = getNonRotatedCompleteRenderArea();
gl::Rectangle scissoredRenderArea = ClipRectToScissor(context->getState(), renderArea, false); gl::Rectangle scissoredRenderArea = ClipRectToScissor(context->getState(), renderArea, false);
bool deferClears = binding == GL_DRAW_FRAMEBUFFER && renderArea == scissoredRenderArea; bool deferClears = binding == GL_DRAW_FRAMEBUFFER && renderArea == scissoredRenderArea;
...@@ -1466,7 +1469,16 @@ angle::Result FramebufferVk::syncState(const gl::Context *context, ...@@ -1466,7 +1469,16 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
// channels. // channels.
if (binding == GL_READ_FRAMEBUFFER && !mDeferredClears.empty()) if (binding == GL_READ_FRAMEBUFFER && !mDeferredClears.empty())
{ {
ANGLE_TRY(flushDeferredClears(contextVk, scissoredRenderArea)); // Rotate scissoredRenderArea based on the read FBO's rotation (different than
// FramebufferVk::getRotatedScissoredRenderArea(), which is based on the draw FBO's
// rotation). Since the rectangle is scissored, it must be fully rotated, and not just
// have the width and height swapped.
bool invertViewport = contextVk->isViewportFlipEnabledForReadFBO();
gl::Rectangle rotatedScissoredRenderArea;
RotateRectangle(contextVk->getRotationReadFramebuffer(), invertViewport, renderArea.width,
renderArea.height, scissoredRenderArea, &rotatedScissoredRenderArea);
ANGLE_TRY(flushDeferredClears(contextVk, rotatedScissoredRenderArea));
} }
// No-op redundant changes to prevent closing the RenderPass. // No-op redundant changes to prevent closing the RenderPass.
...@@ -1964,15 +1976,39 @@ gl::Extents FramebufferVk::getReadImageExtents() const ...@@ -1964,15 +1976,39 @@ gl::Extents FramebufferVk::getReadImageExtents() const
return readRenderTarget->getExtents(); return readRenderTarget->getExtents();
} }
gl::Rectangle FramebufferVk::getCompleteRenderArea() const // Return the framebuffer's non-rotated render area. This is a gl::Rectangle that is based on the
// dimensions of the framebuffer, IS NOT rotated, and IS NOT y-flipped
gl::Rectangle FramebufferVk::getNonRotatedCompleteRenderArea() const
{ {
const gl::Box &dimensions = mState.getDimensions(); const gl::Box &dimensions = mState.getDimensions();
return gl::Rectangle(0, 0, dimensions.width, dimensions.height); return gl::Rectangle(0, 0, dimensions.width, dimensions.height);
} }
gl::Rectangle FramebufferVk::getScissoredRenderArea(ContextVk *contextVk) const // Return the framebuffer's rotated render area. This is a gl::Rectangle that is based on the
// dimensions of the framebuffer, IS ROTATED for the draw FBO, and IS NOT y-flipped
//
// Note: Since the rectangle is not scissored (i.e. x and y are guaranteed to be zero), only the
// width and height must be swapped if the rotation is 90 or 270 degrees.
gl::Rectangle FramebufferVk::getRotatedCompleteRenderArea(ContextVk *contextVk) const
{
gl::Rectangle renderArea = getNonRotatedCompleteRenderArea();
if (contextVk->isRotatedAspectRatioForDrawFBO())
{
// The surface is rotated 90/270 degrees. This changes the aspect ratio of the surface.
std::swap(renderArea.width, renderArea.height);
}
return renderArea;
}
// Return the framebuffer's scissored and rotated render area. This is a gl::Rectangle that is
// based on the dimensions of the framebuffer, is clipped to the scissor, IS ROTATED and IS
// Y-FLIPPED for the draw FBO.
//
// Note: Since the rectangle is scissored, it must be fully rotated, and not just have the width
// and height swapped.
gl::Rectangle FramebufferVk::getRotatedScissoredRenderArea(ContextVk *contextVk) const
{ {
const gl::Rectangle renderArea = getCompleteRenderArea(); const gl::Rectangle renderArea = getNonRotatedCompleteRenderArea();
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO(); bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
gl::Rectangle scissoredArea = ClipRectToScissor(contextVk->getState(), renderArea, false); gl::Rectangle scissoredArea = ClipRectToScissor(contextVk->getState(), renderArea, false);
gl::Rectangle rotatedScissoredArea; gl::Rectangle rotatedScissoredArea;
......
...@@ -105,8 +105,9 @@ class FramebufferVk : public FramebufferImpl ...@@ -105,8 +105,9 @@ class FramebufferVk : public FramebufferImpl
void *pixels); void *pixels);
gl::Extents getReadImageExtents() const; gl::Extents getReadImageExtents() const;
gl::Rectangle getCompleteRenderArea() const; gl::Rectangle getNonRotatedCompleteRenderArea() const;
gl::Rectangle getScissoredRenderArea(ContextVk *contextVk) const; gl::Rectangle getRotatedCompleteRenderArea(ContextVk *contextVk) const;
gl::Rectangle getRotatedScissoredRenderArea(ContextVk *contextVk) const;
const gl::DrawBufferMask &getEmulatedAlphaAttachmentMask() const; const gl::DrawBufferMask &getEmulatedAlphaAttachmentMask() const;
RenderTargetVk *getColorDrawRenderTarget(size_t colorIndex) const; RenderTargetVk *getColorDrawRenderTarget(size_t colorIndex) const;
......
...@@ -1100,13 +1100,8 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk, ...@@ -1100,13 +1100,8 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
} }
VkViewport viewport; VkViewport viewport;
gl::Rectangle completeRenderArea = framebuffer->getCompleteRenderArea(); gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO(); bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
if (contextVk->isRotatedAspectRatioForDrawFBO())
{
// The surface is rotated 90/270 degrees. This changes the aspect ratio of the surface.
std::swap(completeRenderArea.width, completeRenderArea.height);
}
gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, invertViewport, completeRenderArea.height, gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, invertViewport, completeRenderArea.height,
&viewport); &viewport);
pipelineDesc.setViewport(viewport); pipelineDesc.setViewport(viewport);
...@@ -1322,12 +1317,7 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk, ...@@ -1322,12 +1317,7 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk,
} }
VkViewport viewport; VkViewport viewport;
gl::Rectangle completeRenderArea = framebuffer->getCompleteRenderArea(); gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
if (contextVk->isRotatedAspectRatioForDrawFBO())
{
// The surface is rotated 90/270 degrees. This changes the aspect ratio of the surface.
std::swap(completeRenderArea.width, completeRenderArea.height);
}
gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, false, completeRenderArea.height, &viewport); gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, false, completeRenderArea.height, &viewport);
pipelineDesc.setViewport(viewport); pipelineDesc.setViewport(viewport);
......
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