Commit 1a135adc by Luc Ferron Committed by Commit Bot

Vulkan: Fix how the viewport is calculated with Y flip

- This fixes all ViewportTest.* and MipmapTest.* - Tests left to fix in end2end: - BlitFramebuffer* - MaxTextureSizeTest.* - PointSpritesTest.* Every other test in angle_end2end_tests are working. Bug: angleproject:2673 Change-Id: I162083bc847c15fa5490ab524ad4c22747d232ea Reviewed-on: https://chromium-review.googlesource.com/1126333 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c2136b67
......@@ -435,9 +435,13 @@ void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits
updateScissor(glState);
break;
case gl::State::DIRTY_BIT_VIEWPORT:
mPipelineDesc->updateViewport(glState.getViewport(), glState.getNearPlane(),
glState.getFarPlane(), isViewportFlipEnabled());
{
FramebufferVk *framebufferVk = vk::GetImpl(glState.getDrawFramebuffer());
mPipelineDesc->updateViewport(framebufferVk, glState.getViewport(),
glState.getNearPlane(), glState.getFarPlane(),
isViewportFlipEnabled());
break;
}
case gl::State::DIRTY_BIT_DEPTH_RANGE:
mPipelineDesc->updateDepthRange(glState.getNearPlane(), glState.getFarPlane());
break;
......@@ -566,13 +570,17 @@ void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits
WARN() << "DIRTY_BIT_READ_FRAMEBUFFER_BINDING unimplemented";
break;
case gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING:
mPipelineDesc->updateViewport(glState.getViewport(), glState.getNearPlane(),
glState.getFarPlane(), isViewportFlipEnabled());
{
FramebufferVk *framebufferVk = vk::GetImpl(glState.getDrawFramebuffer());
mPipelineDesc->updateViewport(framebufferVk, glState.getViewport(),
glState.getNearPlane(), glState.getFarPlane(),
isViewportFlipEnabled());
updateColorMask(glState.getBlendState());
mPipelineDesc->updateCullMode(glState.getRasterizerState(),
isViewportFlipEnabled());
updateScissor(glState);
break;
}
case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING:
WARN() << "DIRTY_BIT_RENDERBUFFER_BINDING unimplemented";
break;
......
......@@ -782,8 +782,15 @@ gl::Error FramebufferVk::clearWithClearAttachments(ContextVk *contextVk,
// There is nothing to clear since the scissor is outside of the render area.
return gl::NoError();
}
clearRect.rect = gl_vk::GetRect(intersection);
if (contextVk->isViewportFlipEnabled())
{
clearRect.rect.offset.y = getRenderPassRenderArea().height - clearRect.rect.offset.y -
clearRect.rect.extent.height;
}
gl::AttachmentArray<VkClearAttachment> clearAttachments;
int clearAttachmentIndex = 0;
......@@ -889,7 +896,7 @@ gl::Error FramebufferVk::clearWithDraw(const gl::Context *context,
pipelineDesc.updateColorWriteMask(colorMaskFlags, getEmulatedAlphaAttachmentMask());
pipelineDesc.updateRenderPassDesc(getRenderPassDesc());
pipelineDesc.updateShaders(fullScreenQuad->queueSerial(), pushConstantColor->queueSerial());
pipelineDesc.updateViewport(renderArea, 0.0f, 1.0f, contextVk->isViewportFlipEnabled());
pipelineDesc.updateViewport(this, renderArea, 0.0f, 1.0f, contextVk->isViewportFlipEnabled());
const gl::State &glState = contextVk->getGLState();
if (glState.isScissorTestEnabled())
......
......@@ -13,6 +13,7 @@
#include "common/aligned_memory.h"
#include "libANGLE/SizedMRUCache.h"
#include "libANGLE/VertexAttribute.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
......@@ -637,7 +638,8 @@ void PipelineDesc::updateShaders(Serial vertexSerial, Serial fragmentSerial)
static_cast<uint32_t>(fragmentSerial.getValue());
}
void PipelineDesc::updateViewport(const gl::Rectangle &viewport,
void PipelineDesc::updateViewport(FramebufferVk *framebufferVk,
const gl::Rectangle &viewport,
float nearPlane,
float farPlane,
bool invertViewport)
......@@ -649,7 +651,9 @@ void PipelineDesc::updateViewport(const gl::Rectangle &viewport,
if (invertViewport)
{
mViewport.y += viewport.height;
gl::Box dimensions = framebufferVk->getState().getDimensions();
gl::Rectangle renderArea = gl::Rectangle(0, 0, dimensions.width, dimensions.height);
mViewport.y = static_cast<float>(renderArea.height - viewport.y);
mViewport.height = -mViewport.height;
}
updateDepthRange(nearPlane, farPlane);
......
......@@ -350,7 +350,8 @@ class PipelineDesc final
const ShaderModule &fragmentModule,
Pipeline *pipelineOut) const;
void updateViewport(const gl::Rectangle &viewport,
void updateViewport(FramebufferVk *framebufferVk,
const gl::Rectangle &viewport,
float nearPlane,
float farPlane,
bool invertViewport);
......
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