[EGL] Move GLWindowingData creation into it's own method

The GLWindowingData creation was done at three places
with almost no difference.
This commit is contained in:
Peter Gal
2017-11-13 19:20:09 +01:00
committed by Baldur Karlsson
parent ca95a9c3ab
commit 2ae9e8a4bc
4 changed files with 75 additions and 118 deletions
+2 -79
View File
@@ -103,36 +103,7 @@ public:
if(real.CreateContext && real.ChooseConfig && real.CreatePbufferSurface)
{
const EGLint ctxAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_CONTEXT_FLAGS_KHR,
EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR, EGL_NONE};
const EGLint attribs[] = {EGL_RED_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_BLUE_SIZE,
8,
EGL_SURFACE_TYPE,
EGL_PBUFFER_BIT,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES3_BIT,
EGL_CONFORMANT,
EGL_OPENGL_ES3_BIT,
EGL_COLOR_BUFFER_TYPE,
EGL_RGB_BUFFER,
EGL_NONE};
EGLConfig config;
EGLint numConfigs;
EGLBoolean configFound = real.ChooseConfig(share.egl_dpy, attribs, &config, 1, &numConfigs);
if(configFound)
{
const EGLint pbAttribs[] = {EGL_WIDTH, 32, EGL_HEIGHT, 32, EGL_NONE};
ret.egl_wnd = real.CreatePbufferSurface(share.egl_dpy, config, pbAttribs);
ret.egl_dpy = share.egl_dpy;
ret.egl_ctx = real.CreateContext(share.egl_dpy, config, share.ctx, ctxAttribs);
}
ret = CreateWindowingData(real, share.egl_dpy, share.ctx, 0);
}
return ret;
@@ -186,7 +157,6 @@ public:
GLWindowingData MakeOutputWindow(WindowingSystem system, void *data, bool depth,
GLWindowingData share_context)
{
GLWindowingData ret;
EGLNativeWindowType window = 0;
switch(system)
@@ -210,54 +180,7 @@ public:
EGLDisplay eglDisplay = real.GetDisplay(EGL_DEFAULT_DISPLAY);
RDCASSERT(eglDisplay);
static const EGLint configAttribs[] = {EGL_RED_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_BLUE_SIZE,
8,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES3_BIT,
EGL_SURFACE_TYPE,
EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
EGL_NONE};
EGLint numConfigs;
EGLConfig config;
if(!real.ChooseConfig(eglDisplay, configAttribs, &config, 1, &numConfigs))
{
RDCERR("Couldn't find a suitable EGL config");
return ret;
}
static const EGLint ctxAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_CONTEXT_FLAGS_KHR,
EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR, EGL_NONE};
EGLContext ctx = real.CreateContext(eglDisplay, config, share_context.ctx, ctxAttribs);
if(ctx == NULL)
{
RDCERR("Couldn't create GL ES context");
return ret;
}
EGLSurface surface = 0;
if(window != 0)
{
surface = real.CreateWindowSurface(eglDisplay, config, window, NULL);
}
else
{
static const EGLint pbAttribs[] = {EGL_WIDTH, 32, EGL_HEIGHT, 32, EGL_NONE};
surface = real.CreatePbufferSurface(eglDisplay, config, pbAttribs);
}
ret.egl_dpy = eglDisplay;
ret.egl_ctx = ctx;
ret.egl_wnd = surface;
return ret;
return CreateWindowingData(real, eglDisplay, share_context.ctx, window);
}
bool DrawQuads(float width, float height, const std::vector<Vec4f> &vertices);
+60
View File
@@ -51,3 +51,63 @@ bool EGLPointers::LoadSymbolsFrom(void *lib_handle)
m_initialized = symbols_ok;
return symbols_ok;
}
GLWindowingData CreateWindowingData(const EGLPointers &egl, EGLDisplay eglDisplay,
EGLContext share_ctx, EGLNativeWindowType window)
{
GLWindowingData ret;
ret.egl_dpy = eglDisplay;
ret.egl_ctx = NULL;
ret.egl_wnd = NULL;
EGLint surfaceType = (window == 0) ? EGL_PBUFFER_BIT : EGL_WINDOW_BIT;
const EGLint configAttribs[] = {EGL_RED_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_BLUE_SIZE,
8,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES3_BIT,
EGL_CONFORMANT,
EGL_OPENGL_ES3_BIT,
EGL_SURFACE_TYPE,
surfaceType,
EGL_COLOR_BUFFER_TYPE,
EGL_RGB_BUFFER,
EGL_NONE};
EGLint numConfigs;
EGLConfig config;
if(!egl.ChooseConfig(eglDisplay, configAttribs, &config, 1, &numConfigs))
{
RDCERR("Couldn't find a suitable EGL config");
return ret;
}
static const EGLint ctxAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_CONTEXT_FLAGS_KHR,
EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR, EGL_NONE};
EGLContext ctx = egl.CreateContext(eglDisplay, config, share_ctx, ctxAttribs);
if(ctx == NULL)
{
RDCERR("Couldn't create GL ES context");
return ret;
}
ret.egl_ctx = ctx;
EGLSurface surface = 0;
if(window != 0)
{
surface = egl.CreateWindowSurface(eglDisplay, config, window, NULL);
}
else
{
static const EGLint pbAttribs[] = {EGL_WIDTH, 32, EGL_HEIGHT, 32, EGL_NONE};
surface = egl.CreatePbufferSurface(eglDisplay, config, pbAttribs);
}
ret.egl_wnd = surface;
return ret;
}
+3
View File
@@ -87,3 +87,6 @@ public:
private:
bool m_initialized;
};
GLWindowingData CreateWindowingData(const EGLPointers &egl, EGLDisplay eglDisplay,
EGLContext share_ctx, EGLNativeWindowType window);
+10 -39
View File
@@ -109,56 +109,31 @@ ReplayStatus GLES_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver)
int major, minor;
egl.Initialize(eglDisplay, &major, &minor);
static const EGLint configAttribs[] = {EGL_RED_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_BLUE_SIZE,
8,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES3_BIT,
EGL_SURFACE_TYPE,
EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
EGL_NONE};
EGLint numConfigs;
EGLConfig config;
if(!egl.ChooseConfig(eglDisplay, configAttribs, &config, 1, &numConfigs))
{
RDCERR("Couldn't find a suitable EGL config");
return ReplayStatus::APIInitFailed;
}
static const EGLint ctxAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_CONTEXT_FLAGS_KHR,
EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR, EGL_NONE};
GLReplay::PreContextInitCounters();
EGLContext ctx = egl.CreateContext(eglDisplay, config, EGL_NO_CONTEXT, ctxAttribs);
if(ctx == NULL)
GLWindowingData data = CreateWindowingData(egl, eglDisplay, EGL_NO_CONTEXT, 0);
if(data.egl_ctx == NULL)
{
GLReplay::PostContextShutdownCounters();
RDCERR("Couldn't create GL ES 3.x context - RenderDoc requires OpenGL ES 3.x availability");
return ReplayStatus::APIHardwareUnsupported;
}
static const EGLint pbAttribs[] = {EGL_WIDTH, 32, EGL_HEIGHT, 32, EGL_NONE};
EGLSurface pbuffer = egl.CreatePbufferSurface(eglDisplay, config, pbAttribs);
if(pbuffer == NULL)
if(data.egl_wnd == NULL)
{
RDCERR("Couldn't create a suitable PBuffer");
egl.DestroySurface(eglDisplay, pbuffer);
egl.DestroyContext(eglDisplay, data.egl_ctx);
GLReplay::PostContextShutdownCounters();
return ReplayStatus::APIInitFailed;
}
EGLBoolean res = egl.MakeCurrent(eglDisplay, pbuffer, pbuffer, ctx);
EGLBoolean res = egl.MakeCurrent(eglDisplay, data.egl_wnd, data.egl_wnd, data.egl_ctx);
if(!res)
{
RDCERR("Couldn't active the created GL ES context");
egl.DestroySurface(eglDisplay, pbuffer);
egl.DestroyContext(eglDisplay, ctx);
egl.DestroySurface(eglDisplay, data.egl_wnd);
egl.DestroyContext(eglDisplay, data.egl_ctx);
GLReplay::PostContextShutdownCounters();
return ReplayStatus::APIInitFailed;
}
@@ -169,8 +144,8 @@ ReplayStatus GLES_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver)
bool extensionsValidated = ValidateFunctionPointers(real);
if(!extensionsValidated)
{
egl.DestroySurface(eglDisplay, pbuffer);
egl.DestroyContext(eglDisplay, ctx);
egl.DestroySurface(eglDisplay, data.egl_wnd);
egl.DestroyContext(eglDisplay, data.egl_ctx);
GLReplay::PostContextShutdownCounters();
return ReplayStatus::APIHardwareUnsupported;
}
@@ -182,10 +157,6 @@ ReplayStatus GLES_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver)
RDCLOG("Created OPEN GL ES replay device.");
GLReplay *replay = gl->GetReplay();
replay->SetProxy(rdc == NULL);
GLWindowingData data;
data.egl_dpy = eglDisplay;
data.egl_ctx = ctx;
data.egl_wnd = pbuffer;
replay->SetReplayData(data);
*driver = (IReplayDriver *)replay;