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 ...@@ -435,9 +435,13 @@ void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits
updateScissor(glState); updateScissor(glState);
break; break;
case gl::State::DIRTY_BIT_VIEWPORT: 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; break;
}
case gl::State::DIRTY_BIT_DEPTH_RANGE: case gl::State::DIRTY_BIT_DEPTH_RANGE:
mPipelineDesc->updateDepthRange(glState.getNearPlane(), glState.getFarPlane()); mPipelineDesc->updateDepthRange(glState.getNearPlane(), glState.getFarPlane());
break; break;
...@@ -566,13 +570,17 @@ void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits ...@@ -566,13 +570,17 @@ void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits
WARN() << "DIRTY_BIT_READ_FRAMEBUFFER_BINDING unimplemented"; WARN() << "DIRTY_BIT_READ_FRAMEBUFFER_BINDING unimplemented";
break; break;
case gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING: 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()); updateColorMask(glState.getBlendState());
mPipelineDesc->updateCullMode(glState.getRasterizerState(), mPipelineDesc->updateCullMode(glState.getRasterizerState(),
isViewportFlipEnabled()); isViewportFlipEnabled());
updateScissor(glState); updateScissor(glState);
break; break;
}
case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING: case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING:
WARN() << "DIRTY_BIT_RENDERBUFFER_BINDING unimplemented"; WARN() << "DIRTY_BIT_RENDERBUFFER_BINDING unimplemented";
break; break;
......
...@@ -782,8 +782,15 @@ gl::Error FramebufferVk::clearWithClearAttachments(ContextVk *contextVk, ...@@ -782,8 +782,15 @@ gl::Error FramebufferVk::clearWithClearAttachments(ContextVk *contextVk,
// There is nothing to clear since the scissor is outside of the render area. // There is nothing to clear since the scissor is outside of the render area.
return gl::NoError(); return gl::NoError();
} }
clearRect.rect = gl_vk::GetRect(intersection); 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; gl::AttachmentArray<VkClearAttachment> clearAttachments;
int clearAttachmentIndex = 0; int clearAttachmentIndex = 0;
...@@ -889,7 +896,7 @@ gl::Error FramebufferVk::clearWithDraw(const gl::Context *context, ...@@ -889,7 +896,7 @@ gl::Error FramebufferVk::clearWithDraw(const gl::Context *context,
pipelineDesc.updateColorWriteMask(colorMaskFlags, getEmulatedAlphaAttachmentMask()); pipelineDesc.updateColorWriteMask(colorMaskFlags, getEmulatedAlphaAttachmentMask());
pipelineDesc.updateRenderPassDesc(getRenderPassDesc()); pipelineDesc.updateRenderPassDesc(getRenderPassDesc());
pipelineDesc.updateShaders(fullScreenQuad->queueSerial(), pushConstantColor->queueSerial()); 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(); const gl::State &glState = contextVk->getGLState();
if (glState.isScissorTestEnabled()) if (glState.isScissorTestEnabled())
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "common/aligned_memory.h" #include "common/aligned_memory.h"
#include "libANGLE/SizedMRUCache.h" #include "libANGLE/SizedMRUCache.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/ProgramVk.h" #include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h" #include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
...@@ -637,7 +638,8 @@ void PipelineDesc::updateShaders(Serial vertexSerial, Serial fragmentSerial) ...@@ -637,7 +638,8 @@ void PipelineDesc::updateShaders(Serial vertexSerial, Serial fragmentSerial)
static_cast<uint32_t>(fragmentSerial.getValue()); 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 nearPlane,
float farPlane, float farPlane,
bool invertViewport) bool invertViewport)
...@@ -649,7 +651,9 @@ void PipelineDesc::updateViewport(const gl::Rectangle &viewport, ...@@ -649,7 +651,9 @@ void PipelineDesc::updateViewport(const gl::Rectangle &viewport,
if (invertViewport) 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; mViewport.height = -mViewport.height;
} }
updateDepthRange(nearPlane, farPlane); updateDepthRange(nearPlane, farPlane);
......
...@@ -350,7 +350,8 @@ class PipelineDesc final ...@@ -350,7 +350,8 @@ class PipelineDesc final
const ShaderModule &fragmentModule, const ShaderModule &fragmentModule,
Pipeline *pipelineOut) const; Pipeline *pipelineOut) const;
void updateViewport(const gl::Rectangle &viewport, void updateViewport(FramebufferVk *framebufferVk,
const gl::Rectangle &viewport,
float nearPlane, float nearPlane,
float farPlane, float farPlane,
bool invertViewport); 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