Commit 0d3afab8 by Corentin Wallez

Implement Pbuffers for the GLX EGL implementation

BUG=angleproject:892 Change-Id: I32b9bbb35d99621f16a055fb544ec0691dfcd5a0 Reviewed-on: https://chromium-review.googlesource.com/270261Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent be39156b
......@@ -17,6 +17,7 @@
#include "libANGLE/Config.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/gl/glx/PbufferSurfaceGLX.h"
#include "libANGLE/renderer/gl/glx/WindowSurfaceGLX.h"
namespace rx
......@@ -192,9 +193,14 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::Config *configuration,
SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::Config *configuration,
const egl::AttributeMap &attribs)
{
//TODO(cwallez) WGL implements it
UNIMPLEMENTED();
return nullptr;
ASSERT(configIdToGLXConfig.count(configuration->configID) > 0);
GLXFBConfig fbConfig = configIdToGLXConfig[configuration->configID];
EGLint width = attribs.get(EGL_WIDTH, 0);
EGLint height = attribs.get(EGL_HEIGHT, 0);
bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE);
return new PbufferSurfaceGLX(width, height, largest, mGLX, mXDisplay, mContext, fbConfig);
}
SurfaceImpl* DisplayGLX::createPbufferFromClientBuffer(const egl::Config *configuration,
......
......@@ -42,6 +42,7 @@ FunctionsGLX::FunctionsGLX()
destroyWindow(nullptr),
createPbuffer(nullptr),
destroyPbuffer(nullptr),
queryDrawable(nullptr),
createContextAttribsARB(nullptr),
mLibHandle(nullptr)
{
......@@ -124,6 +125,7 @@ egl::Error FunctionsGLX::initialize(Display *xDisplay)
GET_PROC_OR_ERROR(&destroyWindow, "glXDestroyWindow");
GET_PROC_OR_ERROR(&createPbuffer, "glXCreatePbuffer");
GET_PROC_OR_ERROR(&destroyPbuffer, "glXDestroyPbuffer");
GET_PROC_OR_ERROR(&queryDrawable, "glXQueryDrawable");
// Extensions
if (hasExtension("GLX_ARB_create_context"))
......
......@@ -55,6 +55,7 @@ class FunctionsGLX : angle::NonCopyable
PFNGLXDESTROYWINDOWPROC destroyWindow;
PFNGLXCREATEPBUFFERPROC createPbuffer;
PFNGLXDESTROYPBUFFERPROC destroyPbuffer;
PFNGLXQUERYDRAWABLEPROC queryDrawable;
// GLX_ARB_create_context
PFNGLXCREATECONTEXTATTRIBSARBPROC createContextAttribsARB;
......
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PbufferSurfaceGLX.cpp: GLX implementation of egl::Surface for PBuffers
#include "libANGLE/renderer/gl/glx/PbufferSurfaceGLX.h"
#include "common/debug.h"
#include "libANGLE/renderer/gl/glx/FunctionsGLX.h"
namespace rx
{
PbufferSurfaceGLX::PbufferSurfaceGLX(EGLint width, EGLint height, bool largest, const FunctionsGLX &glx,
Display *display, GLXContext context, GLXFBConfig fbConfig)
: SurfaceGL(),
mWidth(width),
mHeight(height),
mLargest(largest),
mGLX(glx),
mDisplay(display),
mContext(context),
mFBConfig(fbConfig),
mPbuffer(0)
{
}
PbufferSurfaceGLX::~PbufferSurfaceGLX()
{
if (mPbuffer)
{
mGLX.destroyPbuffer(mDisplay, mPbuffer);
}
}
egl::Error PbufferSurfaceGLX::initialize()
{
const int attribs[] =
{
GLX_PBUFFER_WIDTH, static_cast<int>(mWidth),
GLX_PBUFFER_HEIGHT, static_cast<int>(mHeight),
GLX_LARGEST_PBUFFER, mLargest,
None
};
mPbuffer = mGLX.createPbuffer(mDisplay, mFBConfig, attribs);
if (!mPbuffer)
{
return egl::Error(EGL_BAD_ALLOC, "Failed to create a native GLX pbuffer.");
}
if (mLargest)
{
mGLX.queryDrawable(mDisplay, mPbuffer, GLX_WIDTH, &mWidth);
mGLX.queryDrawable(mDisplay, mPbuffer, GLX_HEIGHT, &mHeight);
}
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceGLX::makeCurrent()
{
if (mGLX.makeCurrent(mDisplay, mPbuffer, mContext) != True)
{
return egl::Error(EGL_BAD_DISPLAY);
}
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceGLX::swap()
{
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceGLX::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
{
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceGLX::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceGLX::bindTexImage(EGLint buffer)
{
UNIMPLEMENTED();
return egl::Error(EGL_SUCCESS);
}
egl::Error PbufferSurfaceGLX::releaseTexImage(EGLint buffer)
{
UNIMPLEMENTED();
return egl::Error(EGL_SUCCESS);
}
void PbufferSurfaceGLX::setSwapInterval(EGLint interval)
{
}
EGLint PbufferSurfaceGLX::getWidth() const
{
return mWidth;
}
EGLint PbufferSurfaceGLX::getHeight() const
{
return mHeight;
}
EGLint PbufferSurfaceGLX::isPostSubBufferSupported() const
{
UNIMPLEMENTED();
return EGL_FALSE;
}
}
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PBufferSurfaceGLX.h: GLX implementation of egl::Surface for PBuffers
#ifndef LIBANGLE_RENDERER_GL_GLX_PBUFFERSURFACEGLX_H_
#define LIBANGLE_RENDERER_GL_GLX_PBUFFERSURFACEGLX_H_
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/glx/platform_glx.h"
#include <GL/glxext.h>
namespace rx
{
class FunctionsGLX;
class PbufferSurfaceGLX : public SurfaceGL
{
public:
PbufferSurfaceGLX(EGLint width, EGLint height, bool largest, const FunctionsGLX &glx,
Display *display, GLXContext context, GLXFBConfig fbConfig);
~PbufferSurfaceGLX() override;
egl::Error initialize();
egl::Error makeCurrent() override;
egl::Error swap() override;
egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(EGLint buffer) override;
egl::Error releaseTexImage(EGLint buffer) override;
void setSwapInterval(EGLint interval) override;
EGLint getWidth() const override;
EGLint getHeight() const override;
EGLint isPostSubBufferSupported() const override;
private:
unsigned mWidth;
unsigned mHeight;
bool mLargest;
const FunctionsGLX &mGLX;
Display *mDisplay;
GLXContext mContext;
GLXFBConfig mFBConfig;
GLXPbuffer mPbuffer;
};
}
#endif // LIBANGLE_RENDERER_GL_GLX_PBUFFERSURFACEGLX_H_
......@@ -15,7 +15,7 @@
namespace rx
{
WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx, EGLNativeWindowType window, Display* display, GLXContext context, GLXFBConfig fbConfig)
WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx, EGLNativeWindowType window, Display *display, GLXContext context, GLXFBConfig fbConfig)
: SurfaceGL(),
mGLX(glx),
mParent(window),
......
......@@ -20,7 +20,7 @@ class FunctionsGLX;
class WindowSurfaceGLX : public SurfaceGL
{
public:
WindowSurfaceGLX(const FunctionsGLX &glx, Window window, Display* display, GLXContext context, GLXFBConfig fbConfig);
WindowSurfaceGLX(const FunctionsGLX &glx, Window window, Display *display, GLXContext context, GLXFBConfig fbConfig);
~WindowSurfaceGLX() override;
egl::Error initialize();
......
......@@ -439,6 +439,8 @@
'libANGLE/renderer/gl/glx/DisplayGLX.h',
'libANGLE/renderer/gl/glx/FunctionsGLX.cpp',
'libANGLE/renderer/gl/glx/FunctionsGLX.h',
'libANGLE/renderer/gl/glx/PbufferSurfaceGLX.cpp',
'libANGLE/renderer/gl/glx/PbufferSurfaceGLX.h',
'libANGLE/renderer/gl/glx/WindowSurfaceGLX.cpp',
'libANGLE/renderer/gl/glx/WindowSurfaceGLX.h',
'libANGLE/renderer/gl/glx/functionsglx_typedefs.h',
......
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