Commit 84f505db by Corentin Wallez

Revert "GLX backend: fallback to lesser swap_control extensions"

This reverts commit 26e3736f.
parent 0e39f492
......@@ -26,13 +26,6 @@ static int IgnoreX11Errors(Display *, XErrorEvent *)
return 0;
}
SwapControlData::SwapControlData()
: targetSwapInterval(0),
maxSwapInterval(-1),
currentSwapInterval(-1)
{
}
class FunctionsGLGLX : public FunctionsGL
{
public:
......@@ -62,10 +55,6 @@ DisplayGLX::DisplayGLX()
mDummyPbuffer(0),
mUsesNewXDisplay(false),
mIsMesa(false),
mSwapControl(SwapControl::Absent),
mMinSwapInterval(0),
mMaxSwapInterval(0),
mCurrentSwapInterval(-1),
mEGLDisplay(nullptr)
{
}
......@@ -113,40 +102,6 @@ egl::Error DisplayGLX::initialize(egl::Display *display)
}
}
// Choose the swap_control extension to use, if any.
// The EXT version is better as it allows glXSwapInterval to be called per
// window, while we'll potentially need to change the swap interval on each
// swap buffers when using the SGI or MESA versions.
if (mGLX.hasExtension("GLX_EXT_swap_control"))
{
mSwapControl = SwapControl::EXT;
// In GLX_EXT_swap_control querying these is done on a GLXWindow so we just
// set default values.
mMinSwapInterval = 0;
mMaxSwapInterval = 4;
}
else if (mGLX.hasExtension("GLX_MESA_swap_control"))
{
// If we have the Mesa or SGI extension, assume that you can at least set
// a swap interval of 0 or 1.
mSwapControl = SwapControl::Mesa;
mMinSwapInterval = 0;
mMinSwapInterval = 1;
}
else if (mGLX.hasExtension("GLX_SGI_swap_control"))
{
mSwapControl = SwapControl::SGI;
mMinSwapInterval = 0;
mMinSwapInterval = 1;
}
else
{
mSwapControl = SwapControl::Absent;
mMinSwapInterval = 1;
mMinSwapInterval = 1;
}
// When glXMakeCurrent is called, the context and the surface must be
// compatible which in glX-speak means that their config have the same
// color buffer type, are both RGBA or ColorIndex, and their buffers have
......@@ -383,6 +338,8 @@ egl::ConfigSet DisplayGLX::generateConfigs() const
egl::ConfigSet configs;
configIdToGLXConfig.clear();
bool hasSwapControl = mGLX.hasExtension("GLX_EXT_swap_control");
int contextRedSize = getGLXFBConfigAttrib(mContextConfig, GLX_RED_SIZE);
int contextGreenSize = getGLXFBConfigAttrib(mContextConfig, GLX_GREEN_SIZE);
int contextBlueSize = getGLXFBConfigAttrib(mContextConfig, GLX_BLUE_SIZE);
......@@ -517,9 +474,17 @@ egl::ConfigSet DisplayGLX::generateConfigs() const
(glxDrawable & GLX_PBUFFER_BIT ? EGL_PBUFFER_BIT : 0) |
(glxDrawable & GLX_PIXMAP_BIT ? EGL_PIXMAP_BIT : 0);
config.minSwapInterval = mMinSwapInterval;
config.maxSwapInterval = mMaxSwapInterval;
if (hasSwapControl)
{
// In GLX_EXT_swap_control querying these is done on a GLXWindow so we just set a default value.
config.minSwapInterval = 0;
config.maxSwapInterval = 4;
}
else
{
config.minSwapInterval = 1;
config.maxSwapInterval = 1;
}
// TODO(cwallez) wildly guessing these formats, another TODO says they should be removed anyway
config.renderTargetFormat = GL_RGBA8;
config.depthStencilFormat = GL_DEPTH24_STENCIL8;
......@@ -592,42 +557,6 @@ void DisplayGLX::syncXCommands() const
}
}
void DisplayGLX::setSwapInterval(glx::Drawable drawable, SwapControlData *data)
{
// TODO(cwallez) error checking?
if (mSwapControl == SwapControl::EXT)
{
// Prefer the EXT extension, it gives per-drawable swap intervals, which will
// minimize the number of driver calls.
if (data->maxSwapInterval < 0)
{
unsigned int maxSwapInterval = 0;
mGLX.queryDrawable(drawable, GLX_MAX_SWAP_INTERVAL_EXT, &maxSwapInterval);
data->maxSwapInterval = maxSwapInterval;
}
if (data->currentSwapInterval != data->targetSwapInterval)
{
const int realInterval = std::min(data->targetSwapInterval, data->maxSwapInterval);
mGLX.swapIntervalEXT(drawable, realInterval);
data->currentSwapInterval = data->targetSwapInterval;
}
}
else if (mCurrentSwapInterval != data->targetSwapInterval)
{
// With the Mesa or SGI extensions we can still do per-drawable swap control
// manually but it is more expensive in number of driver calls.
if (mSwapControl == SwapControl::Mesa)
{
mGLX.swapIntervalMESA(data->targetSwapInterval);
}
else if (mSwapControl == SwapControl::Mesa)
{
mGLX.swapIntervalSGI(data->targetSwapInterval);
}
mCurrentSwapInterval = data->targetSwapInterval;
}
}
const FunctionsGL *DisplayGLX::getFunctionsGL() const
{
return mFunctionsGL;
......
......@@ -20,20 +20,6 @@ namespace rx
class FunctionsGLX;
// State-tracking data for the swap control to allow DisplayGLX to remember per
// drawable information for swap control.
struct SwapControlData
{
SwapControlData();
// Set by the drawable
int targetSwapInterval;
// DisplayGLX-side state-tracking
int maxSwapInterval;
int currentSwapInterval;
};
class DisplayGLX : public DisplayGL
{
public:
......@@ -73,12 +59,6 @@ class DisplayGLX : public DisplayGL
// between the application's display and ANGLE's one.
void syncXCommands() const;
// Depending on the supported GLX extension, swap interval can be set
// globally or per drawable. This function will make sure the drawable's
// swap interval is the one required so that the subsequent swapBuffers
// acts as expected.
void setSwapInterval(glx::Drawable drawable, SwapControlData *data);
private:
const FunctionsGL *getFunctionsGL() const override;
......@@ -103,18 +83,6 @@ class DisplayGLX : public DisplayGL
bool mUsesNewXDisplay;
bool mIsMesa;
enum class SwapControl
{
Absent,
EXT,
Mesa,
SGI,
};
SwapControl mSwapControl;
int mMinSwapInterval;
int mMaxSwapInterval;
int mCurrentSwapInterval;
FunctionsGLX mGLX;
egl::Display *mEGLDisplay;
};
......
......@@ -55,9 +55,7 @@ struct FunctionsGLX::GLXFunctionTable
destroyPbufferPtr(nullptr),
queryDrawablePtr(nullptr),
createContextAttribsARBPtr(nullptr),
swapIntervalEXTPtr(nullptr),
swapIntervalMESAPtr(nullptr),
swapIntervalSGIPtr(nullptr)
swapIntervalEXTPtr(nullptr)
{
}
......@@ -91,12 +89,6 @@ struct FunctionsGLX::GLXFunctionTable
// GLX_EXT_swap_control
PFNGLXSWAPINTERVALEXTPROC swapIntervalEXTPtr;
// GLX_MESA_swap_control
PFNGLXSWAPINTERVALMESAPROC swapIntervalMESAPtr;
// GLX_SGI_swap_control
PFNGLXSWAPINTERVALSGIPROC swapIntervalSGIPtr;
};
FunctionsGLX::FunctionsGLX()
......@@ -221,17 +213,17 @@ bool FunctionsGLX::initialize(Display *xDisplay, int screen, std::string *errorS
{
GET_PROC_OR_ERROR(&mFnPtrs->createContextAttribsARBPtr, glXCreateContextAttribsARB);
}
if (hasExtension("GLX_EXT_swap_control"))
else
{
GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalEXTPtr, glXSwapIntervalEXT);
mFnPtrs->createContextAttribsARBPtr = nullptr;
}
if (hasExtension("GLX_MESA_swap_control"))
if (hasExtension("GLX_EXT_swap_control"))
{
GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalMESAPtr, glXSwapIntervalMESA);
GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalEXTPtr, glXSwapIntervalEXT);
}
if (hasExtension("GLX_SGI_swap_control"))
else
{
GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalSGIPtr, glXSwapIntervalSGI);
mFnPtrs->swapIntervalEXTPtr = nullptr;
}
#undef GET_FNPTR_OR_ERROR
......@@ -368,14 +360,4 @@ void FunctionsGLX::swapIntervalEXT(glx::Drawable drawable, int intervals) const
mFnPtrs->swapIntervalEXTPtr(mXDisplay, drawable, intervals);
}
int FunctionsGLX::swapIntervalMESA(int intervals) const
{
return mFnPtrs->swapIntervalMESAPtr(intervals);
}
int FunctionsGLX::swapIntervalSGI(int intervals) const
{
return mFnPtrs->swapIntervalSGIPtr(intervals);
}
}
......@@ -67,12 +67,6 @@ class FunctionsGLX
// GLX_EXT_swap_control
void swapIntervalEXT(glx::Drawable drawable, int interval) const;
// GLX_MESA_swap_control
int swapIntervalMESA(int interval) const;
// GLX_SGI_swap_control
int swapIntervalSGI(int interval) const;
private:
// So as to isolate GLX from angle we do not include angleutils.h and cannot
// use angle::NonCopyable so we replicated it here instead.
......
......@@ -28,10 +28,11 @@ WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx,
mWindow(0),
mDisplay(display),
mGLX(glx),
mGLXDisplay(glxDisplay),
mGLXDisplay(*glxDisplay),
mContext(context),
mFBConfig(fbConfig),
mGLXWindow(0)
mGLXWindow(0),
mMaxSwapInterval(1)
{
}
......@@ -47,7 +48,7 @@ WindowSurfaceGLX::~WindowSurfaceGLX()
XDestroyWindow(mDisplay, mWindow);
}
mGLXDisplay->syncXCommands();
mGLXDisplay.syncXCommands();
}
egl::Error WindowSurfaceGLX::initialize()
......@@ -94,13 +95,18 @@ egl::Error WindowSurfaceGLX::initialize()
0, visualInfo->depth, InputOutput, visual, attributeMask, &attributes);
mGLXWindow = mGLX.createWindow(mFBConfig, mWindow, nullptr);
if (mGLX.hasExtension("GLX_EXT_swap_control"))
{
mGLX.queryDrawable(mGLXWindow, GLX_MAX_SWAP_INTERVAL_EXT, &mMaxSwapInterval);
}
XMapWindow(mDisplay, mWindow);
XFlush(mDisplay);
XFree(visualInfo);
XFreeColormap(mDisplay, colormap);
mGLXDisplay->syncXCommands();
mGLXDisplay.syncXCommands();
return egl::Error(EGL_SUCCESS);
}
......@@ -134,7 +140,6 @@ egl::Error WindowSurfaceGLX::swap()
mGLX.waitX();
}
mGLXDisplay->setSwapInterval(mGLXWindow, &mSwapControl);
mGLX.swapBuffers(mGLXWindow);
return egl::Error(EGL_SUCCESS);
......@@ -166,7 +171,12 @@ egl::Error WindowSurfaceGLX::releaseTexImage(EGLint buffer)
void WindowSurfaceGLX::setSwapInterval(EGLint interval)
{
mSwapControl.targetSwapInterval = interval;
if (mGLX.hasExtension("GLX_EXT_swap_control"))
{
// TODO(cwallez) error checking?
const int realInterval = std::min(interval, static_cast<int>(mMaxSwapInterval));
mGLX.swapIntervalEXT(mGLXWindow, realInterval);
}
}
EGLint WindowSurfaceGLX::getWidth() const
......
......@@ -10,7 +10,6 @@
#define LIBANGLE_RENDERER_GL_GLX_WINDOWSURFACEGLX_H_
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/glx/DisplayGLX.h"
#include "libANGLE/renderer/gl/glx/platform_glx.h"
namespace rx
......@@ -56,13 +55,12 @@ class WindowSurfaceGLX : public SurfaceGL
Display *mDisplay;
const FunctionsGLX &mGLX;
DisplayGLX *mGLXDisplay;
const DisplayGLX &mGLXDisplay;
glx::Context mContext;
glx::FBConfig mFBConfig;
glx::Window mGLXWindow;
SwapControlData mSwapControl;
unsigned int mMaxSwapInterval;
};
}
......
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