Commit caa55cd7 by Geoff Lang Committed by Commit Bot

Vulkan: Support EGL_ANGLE_surface_orientation for vertical surface flipping.

This is a simpler way of flipping when the client is aware of the extension. This allows Chrome to render with the correct orientation. BUG=angleproject:2709 Change-Id: I52216b765a42930f2be043a07fe441a9f875a14d Reviewed-on: https://chromium-review.googlesource.com/1127342Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 189ad877
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/vulkan/BufferVk.h" #include "libANGLE/renderer/vulkan/BufferVk.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/CompilerVk.h" #include "libANGLE/renderer/vulkan/CompilerVk.h"
...@@ -52,7 +53,8 @@ ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer) ...@@ -52,7 +53,8 @@ ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer)
mCurrentDrawMode(gl::PrimitiveMode::InvalidEnum), mCurrentDrawMode(gl::PrimitiveMode::InvalidEnum),
mTexturesDirty(false), mTexturesDirty(false),
mVertexArrayBindingHasChanged(false), mVertexArrayBindingHasChanged(false),
mClearColorMask(kAllColorChannelsMask) mClearColorMask(kAllColorChannelsMask),
mFlipYForCurrentSurface(false)
{ {
memset(&mClearColorValue, 0, sizeof(mClearColorValue)); memset(&mClearColorValue, 0, sizeof(mClearColorValue));
memset(&mClearDepthStencilValue, 0, sizeof(mClearDepthStencilValue)); memset(&mClearDepthStencilValue, 0, sizeof(mClearDepthStencilValue));
...@@ -378,10 +380,10 @@ void ContextVk::popDebugGroup() ...@@ -378,10 +380,10 @@ void ContextVk::popDebugGroup()
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
bool ContextVk::isViewportFlipEnabled() bool ContextVk::isViewportFlipEnabled() const
{ {
gl::Framebuffer *framebuffer = mState.getState().getDrawFramebuffer(); gl::Framebuffer *framebuffer = mState.getState().getDrawFramebuffer();
return framebuffer->isDefault() && mRenderer->getFeatures().flipViewportY; return framebuffer->isDefault() && mFlipYForCurrentSurface;
} }
void ContextVk::updateColorMask(const gl::BlendState &blendState) void ContextVk::updateColorMask(const gl::BlendState &blendState)
...@@ -671,8 +673,14 @@ GLint64 ContextVk::getTimestamp() ...@@ -671,8 +673,14 @@ GLint64 ContextVk::getTimestamp()
return GLint64(); return GLint64();
} }
void ContextVk::onMakeCurrent(const gl::Context * /*context*/) void ContextVk::onMakeCurrent(const gl::Context *context)
{ {
// Flip viewports if FeaturesVk::flipViewportY is enabled and the user did not request that the
// surface is flipped.
egl::Surface *drawSurface = context->getCurrentDrawSurface();
mFlipYForCurrentSurface =
drawSurface != nullptr && mRenderer->getFeatures().flipViewportY &&
!IsMaskFlagSet(drawSurface->getOrientation(), EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE);
} }
gl::Caps ContextVk::getNativeCaps() const gl::Caps ContextVk::getNativeCaps() const
......
...@@ -87,7 +87,7 @@ class ContextVk : public ContextImpl ...@@ -87,7 +87,7 @@ class ContextVk : public ContextImpl
void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) override; void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) override;
void popDebugGroup() override; void popDebugGroup() override;
bool isViewportFlipEnabled(); bool isViewportFlipEnabled() const;
// State sync with dirty bits. // State sync with dirty bits.
gl::Error syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) override; gl::Error syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) override;
...@@ -200,6 +200,10 @@ class ContextVk : public ContextImpl ...@@ -200,6 +200,10 @@ class ContextVk : public ContextImpl
VkColorComponentFlags mClearColorMask; VkColorComponentFlags mClearColorMask;
IncompleteTextureSet mIncompleteTextures; IncompleteTextureSet mIncompleteTextures;
// If the current surface bound to this context wants to have all rendering flipped vertically.
// Updated on calls to onMakeCurrent.
bool mFlipYForCurrentSurface;
}; };
} // namespace rx } // namespace rx
......
...@@ -161,6 +161,7 @@ gl::Version DisplayVk::getMaxSupportedESVersion() const ...@@ -161,6 +161,7 @@ gl::Version DisplayVk::getMaxSupportedESVersion() const
void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
{ {
outExtensions->surfaceOrientation = true;
} }
void DisplayVk::generateCaps(egl::Caps *outCaps) const void DisplayVk::generateCaps(egl::Caps *outCaps) const
......
...@@ -224,7 +224,9 @@ egl::Config GenerateDefaultConfig(const VkPhysicalDeviceProperties &physicalDevi ...@@ -224,7 +224,9 @@ egl::Config GenerateDefaultConfig(const VkPhysicalDeviceProperties &physicalDevi
config.sampleBuffers = (sampleCount > 0) ? 1 : 0; config.sampleBuffers = (sampleCount > 0) ? 1 : 0;
config.samples = sampleCount; config.samples = sampleCount;
config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT; config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
config.optimalOrientation = 0; // Vulkan surfaces use a different origin than OpenGL, always prefer to be flipped vertically if
// possible.
config.optimalOrientation = EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE;
config.transparentType = EGL_NONE; config.transparentType = EGL_NONE;
config.transparentRedValue = 0; config.transparentRedValue = 0;
config.transparentGreenValue = 0; config.transparentGreenValue = 0;
......
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