Commit d756145d by Cooper Partin Committed by Geoff Lang

Re-land "Added support for premultiplied alpha mode for composition swapchains"

Change-Id: Ic0c863c3d4936947fc520a5394e38e458659df46 Reviewed-on: https://chromium-review.googlesource.com/298880Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 62d31cb6
...@@ -33,8 +33,14 @@ SurfaceD3D *SurfaceD3D::createFromWindow(RendererD3D *renderer, egl::Display *di ...@@ -33,8 +33,14 @@ SurfaceD3D *SurfaceD3D::createFromWindow(RendererD3D *renderer, egl::Display *di
return new SurfaceD3D(renderer, display, config, width, height, fixedSize, static_cast<EGLClientBuffer>(0), window); return new SurfaceD3D(renderer, display, config, width, height, fixedSize, static_cast<EGLClientBuffer>(0), window);
} }
SurfaceD3D::SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl::Config *config, EGLint width, EGLint height, EGLint fixedSize, SurfaceD3D::SurfaceD3D(RendererD3D *renderer,
EGLClientBuffer shareHandle, EGLNativeWindowType window) egl::Display *display,
const egl::Config *config,
EGLint width,
EGLint height,
EGLint fixedSize,
EGLClientBuffer shareHandle,
EGLNativeWindowType window)
: SurfaceImpl(), : SurfaceImpl(),
mRenderer(renderer), mRenderer(renderer),
mDisplay(display), mDisplay(display),
...@@ -43,11 +49,11 @@ SurfaceD3D::SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl:: ...@@ -43,11 +49,11 @@ SurfaceD3D::SurfaceD3D(RendererD3D *renderer, egl::Display *display, const egl::
mDepthStencilFormat(config->depthStencilFormat), mDepthStencilFormat(config->depthStencilFormat),
mSwapChain(nullptr), mSwapChain(nullptr),
mSwapIntervalDirty(true), mSwapIntervalDirty(true),
mNativeWindow(window), mNativeWindow(window, config),
mWidth(width), mWidth(width),
mHeight(height), mHeight(height),
mSwapInterval(1), mSwapInterval(1),
mShareHandle(reinterpret_cast<HANDLE*>(shareHandle)) mShareHandle(reinterpret_cast<HANDLE *>(shareHandle))
{ {
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "common/platform.h" #include "common/platform.h"
#include <EGL/eglplatform.h> #include <EGL/eglplatform.h>
#include "libANGLE/Config.h"
// DXGISwapChain and DXGIFactory are typedef'd to specific required // DXGISwapChain and DXGIFactory are typedef'd to specific required
// types. The HWND NativeWindow implementation requires IDXGISwapChain // types. The HWND NativeWindow implementation requires IDXGISwapChain
...@@ -49,7 +50,7 @@ namespace rx ...@@ -49,7 +50,7 @@ namespace rx
class NativeWindow class NativeWindow
{ {
public: public:
explicit NativeWindow(EGLNativeWindowType window); explicit NativeWindow(EGLNativeWindowType window, const egl::Config *config);
bool initialize(); bool initialize();
bool getClientRect(LPRECT rect); bool getClientRect(LPRECT rect);
...@@ -66,6 +67,7 @@ class NativeWindow ...@@ -66,6 +67,7 @@ class NativeWindow
EGLNativeWindowType mWindow; EGLNativeWindowType mWindow;
#if defined(ANGLE_ENABLE_WINDOWS_STORE) #if defined(ANGLE_ENABLE_WINDOWS_STORE)
const egl::Config *mConfig;
std::shared_ptr<InspectableNativeWindow> mImpl; std::shared_ptr<InspectableNativeWindow> mImpl;
#endif #endif
......
...@@ -678,15 +678,13 @@ void Renderer11::populateRenderer11DeviceCaps() ...@@ -678,15 +678,13 @@ void Renderer11::populateRenderer11DeviceCaps()
egl::ConfigSet Renderer11::generateConfigs() const egl::ConfigSet Renderer11::generateConfigs() const
{ {
static const GLenum colorBufferFormats[] = static const GLenum colorBufferFormats[] = {
{
// 32-bit supported formats // 32-bit supported formats
GL_BGRA8_EXT, GL_BGRA8_EXT, GL_RGBA8_OES,
GL_RGBA8_OES, // 24-bit supported formats
GL_RGB8_OES,
// 16-bit supported formats // 16-bit supported formats
GL_RGBA4, GL_RGBA4, GL_RGB5_A1, GL_RGB565,
GL_RGB5_A1,
GL_RGB565,
}; };
static const GLenum depthStencilBufferFormats[] = static const GLenum depthStencilBufferFormats[] =
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
namespace rx namespace rx
{ {
NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window) NativeWindow::NativeWindow(EGLNativeWindowType window, const egl::Config *)
: mWindow(window)
{ {
} }
......
...@@ -134,7 +134,13 @@ void CoreWindowNativeWindow::unregisterForSizeChangeEvents() ...@@ -134,7 +134,13 @@ void CoreWindowNativeWindow::unregisterForSizeChangeEvents()
mSizeChangedEventToken.value = 0; mSizeChangedEventToken.value = 0;
} }
HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
DXGIFactory *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
DXGISwapChain **swapChain)
{ {
if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0) if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
{ {
...@@ -152,6 +158,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactor ...@@ -152,6 +158,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactor
swapChainDesc.BufferCount = 2; swapChainDesc.BufferCount = 2;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
*swapChain = nullptr; *swapChain = nullptr;
......
...@@ -25,7 +25,13 @@ class CoreWindowNativeWindow : public InspectableNativeWindow, public std::enabl ...@@ -25,7 +25,13 @@ class CoreWindowNativeWindow : public InspectableNativeWindow, public std::enabl
~CoreWindowNativeWindow(); ~CoreWindowNativeWindow();
bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override; bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override;
HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) override; HRESULT createSwapChain(ID3D11Device *device,
DXGIFactory *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
DXGISwapChain **swapChain) override;
protected: protected:
HRESULT scaleSwapChain(const SIZE &windowSize, const RECT &clientRect) override; HRESULT scaleSwapChain(const SIZE &windowSize, const RECT &clientRect) override;
......
...@@ -11,9 +11,10 @@ ...@@ -11,9 +11,10 @@
namespace rx namespace rx
{ {
NativeWindow::NativeWindow(EGLNativeWindowType window) NativeWindow::NativeWindow(EGLNativeWindowType window, const egl::Config *config)
{ {
mWindow = window; mWindow = window;
mConfig = config;
} }
bool NativeWindow::initialize() bool NativeWindow::initialize()
...@@ -83,7 +84,9 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory ...@@ -83,7 +84,9 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory
{ {
if (mImpl) if (mImpl)
{ {
return mImpl->createSwapChain(device, factory, format, width, height, swapChain); bool containsAlpha = (mConfig->alphaSize > 0);
return mImpl->createSwapChain(device, factory, format, width, height, containsAlpha,
swapChain);
} }
return E_UNEXPECTED; return E_UNEXPECTED;
......
...@@ -43,7 +43,13 @@ class InspectableNativeWindow ...@@ -43,7 +43,13 @@ class InspectableNativeWindow
virtual ~InspectableNativeWindow(){} virtual ~InspectableNativeWindow(){}
virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0; virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0;
virtual HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) = 0; virtual HRESULT createSwapChain(ID3D11Device *device,
DXGIFactory *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
DXGISwapChain **swapChain) = 0;
bool getClientRect(RECT *rect) bool getClientRect(RECT *rect)
{ {
......
...@@ -146,7 +146,13 @@ void SwapChainPanelNativeWindow::unregisterForSizeChangeEvents() ...@@ -146,7 +146,13 @@ void SwapChainPanelNativeWindow::unregisterForSizeChangeEvents()
mSizeChangedEventToken.value = 0; mSizeChangedEventToken.value = 0;
} }
HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device,
DXGIFactory *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
DXGISwapChain **swapChain)
{ {
if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0) if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
{ {
...@@ -164,7 +170,8 @@ HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device, DXGIFa ...@@ -164,7 +170,8 @@ HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device, DXGIFa
swapChainDesc.BufferCount = 2; swapChainDesc.BufferCount = 2;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; swapChainDesc.AlphaMode =
containsAlpha ? DXGI_ALPHA_MODE_PREMULTIPLIED : DXGI_ALPHA_MODE_IGNORE;
*swapChain = nullptr; *swapChain = nullptr;
......
...@@ -19,7 +19,13 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::e ...@@ -19,7 +19,13 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::e
~SwapChainPanelNativeWindow(); ~SwapChainPanelNativeWindow();
bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override; bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override;
HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) override; HRESULT createSwapChain(ID3D11Device *device,
DXGIFactory *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
DXGISwapChain **swapChain) override;
protected: protected:
HRESULT scaleSwapChain(const SIZE &windowSize, const RECT &clientRect) override; HRESULT scaleSwapChain(const SIZE &windowSize, const RECT &clientRect) override;
......
...@@ -342,8 +342,7 @@ TEST_F(EGLSurfaceTest, ResizeD3DWindow) ...@@ -342,8 +342,7 @@ TEST_F(EGLSurfaceTest, ResizeD3DWindow)
// support GL_RGB565 // support GL_RGB565
TEST_F(EGLSurfaceTest, CreateWithEGLConfig5650Support) TEST_F(EGLSurfaceTest, CreateWithEGLConfig5650Support)
{ {
const char *extensionsString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); if (!ANGLETest::eglDisplayExtensionEnabled(EGL_NO_DISPLAY, "EGL_ANGLE_platform_angle_d3d"))
if (strstr(extensionsString, "EGL_ANGLE_platform_angle_d3d") == nullptr)
{ {
std::cout << "D3D Platform not supported in ANGLE" << std::endl; std::cout << "D3D Platform not supported in ANGLE" << std::endl;
return; return;
...@@ -372,7 +371,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5650Support) ...@@ -372,7 +371,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5650Support)
initializeSurface(config); initializeSurface(config);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext); eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_TRUE(eglGetError() == EGL_SUCCESS); ASSERT_EGL_SUCCESS();
GLuint program = createProgram(); GLuint program = createProgram();
drawWithProgram(program); drawWithProgram(program);
...@@ -384,8 +383,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5650Support) ...@@ -384,8 +383,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5650Support)
// support GL_RGBA4 // support GL_RGBA4
TEST_F(EGLSurfaceTest, CreateWithEGLConfig4444Support) TEST_F(EGLSurfaceTest, CreateWithEGLConfig4444Support)
{ {
const char *extensionsString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); if (!ANGLETest::eglDisplayExtensionEnabled(EGL_NO_DISPLAY, "EGL_ANGLE_platform_angle_d3d"))
if (strstr(extensionsString, "EGL_ANGLE_platform_angle_d3d") == nullptr)
{ {
std::cout << "D3D Platform not supported in ANGLE" << std::endl; std::cout << "D3D Platform not supported in ANGLE" << std::endl;
return; return;
...@@ -414,7 +412,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig4444Support) ...@@ -414,7 +412,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig4444Support)
initializeSurface(config); initializeSurface(config);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext); eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_TRUE(eglGetError() == EGL_SUCCESS); ASSERT_EGL_SUCCESS();
GLuint program = createProgram(); GLuint program = createProgram();
drawWithProgram(program); drawWithProgram(program);
...@@ -426,8 +424,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig4444Support) ...@@ -426,8 +424,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig4444Support)
// support GL_RGB5_A1 // support GL_RGB5_A1
TEST_F(EGLSurfaceTest, CreateWithEGLConfig5551Support) TEST_F(EGLSurfaceTest, CreateWithEGLConfig5551Support)
{ {
const char *extensionsString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); if (!ANGLETest::eglDisplayExtensionEnabled(EGL_NO_DISPLAY, "EGL_ANGLE_platform_angle_d3d"))
if (strstr(extensionsString, "EGL_ANGLE_platform_angle_d3d") == nullptr)
{ {
std::cout << "D3D Platform not supported in ANGLE" << std::endl; std::cout << "D3D Platform not supported in ANGLE" << std::endl;
return; return;
...@@ -456,7 +453,48 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5551Support) ...@@ -456,7 +453,48 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5551Support)
initializeSurface(config); initializeSurface(config);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext); eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_TRUE(eglGetError() == EGL_SUCCESS); ASSERT_EGL_SUCCESS();
GLuint program = createProgram();
drawWithProgram(program);
EXPECT_GL_NO_ERROR();
glDeleteProgram(program);
}
// Test creating a surface that supports a EGLConfig without alpha support
TEST_F(EGLSurfaceTest, CreateWithEGLConfig8880Support)
{
if (!ANGLETest::eglDisplayExtensionEnabled(EGL_NO_DISPLAY, "EGL_ANGLE_platform_angle_d3d"))
{
std::cout << "D3D Platform not supported in ANGLE" << std::endl;
return;
}
const EGLint configAttributes[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, 0,
EGL_STENCIL_SIZE, 0,
EGL_SAMPLE_BUFFERS, 0,
EGL_NONE
};
initializeDisplay(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE);
EGLConfig config;
if (EGLWindow::FindEGLConfig(mDisplay, configAttributes, &config) == EGL_FALSE)
{
std::cout << "EGLConfig for a GL_RGB8_OES surface is not supported, skipping test"
<< std::endl;
return;
}
initializeSurface(config);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_EGL_SUCCESS();
GLuint program = createProgram(); GLuint program = createProgram();
drawWithProgram(program); drawWithProgram(program);
......
...@@ -27,6 +27,7 @@ class D3D11InputLayoutCacheTest : public ANGLETest ...@@ -27,6 +27,7 @@ class D3D11InputLayoutCacheTest : public ANGLETest
setWindowWidth(64); setWindowWidth(64);
setWindowHeight(64); setWindowHeight(64);
setConfigRedBits(8); setConfigRedBits(8);
setConfigAlphaBits(8);
} }
GLuint makeProgramWithAttribCount(unsigned int attribCount) GLuint makeProgramWithAttribCount(unsigned int attribCount)
......
...@@ -68,6 +68,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -68,6 +68,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
static bool InitTestWindow(); static bool InitTestWindow();
static bool DestroyTestWindow(); static bool DestroyTestWindow();
static void SetWindowVisible(bool isVisible); static void SetWindowVisible(bool isVisible);
static bool eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName);
protected: protected:
virtual void SetUp(); virtual void SetUp();
...@@ -78,7 +79,6 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -78,7 +79,6 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth, GLfloat quadScale = 1.0f); static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth, GLfloat quadScale = 1.0f);
static GLuint compileShader(GLenum type, const std::string &source); static GLuint compileShader(GLenum type, const std::string &source);
static bool extensionEnabled(const std::string &extName); static bool extensionEnabled(const std::string &extName);
static bool eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName);
static bool eglClientExtensionEnabled(const std::string &extName); static bool eglClientExtensionEnabled(const std::string &extName);
void setWindowWidth(int width); void setWindowWidth(int width);
......
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