From 5906a67152063e336dd4bdbce9373cb4b0c4a39b Mon Sep 17 00:00:00 2001 From: Alexandros Frantzis Date: Mon, 5 Dec 2011 11:43:32 +0200 Subject: [PATCH] Try to guess the proper visual to use for EGL contexts and drawables. For contexts, use the visual created for the current Profile. For drawables, try to guess the proper visual from the requested config and the last used profile. --- glretrace_egl.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/glretrace_egl.cpp b/glretrace_egl.cpp index ce03752..7393ab1 100644 --- a/glretrace_egl.cpp +++ b/glretrace_egl.cpp @@ -46,10 +46,13 @@ using namespace glretrace; typedef std::map DrawableMap; typedef std::map ContextMap; +typedef std::map ProfileMap; static DrawableMap drawable_map; static ContextMap context_map; +static ProfileMap profile_map; static unsigned int current_api = EGL_OPENGL_ES_API; +static glws::Profile last_profile = glws::PROFILE_COMPAT; static glws::Drawable * getDrawable(unsigned long long surface_ptr) { @@ -77,8 +80,20 @@ getContext(unsigned long long context_ptr) { static void retrace_eglCreateWindowSurface(trace::Call &call) { unsigned long long orig_surface = call.ret->toUIntPtr(); + unsigned long long orig_config = call.arg(1).toUIntPtr(); + ProfileMap::iterator it = profile_map.find(orig_config); + glws::Profile profile; + + // If the requested config is associated with a profile, use that + // profile. Otherwise, assume that the last used profile is what + // the user wants. + if (it != profile_map.end()) { + profile = it->second; + } else { + profile = last_profile; + } - glws::Drawable *drawable = glws::createDrawable(glretrace::visual[glws::PROFILE_COMPAT]); + glws::Drawable *drawable = glws::createDrawable(glretrace::visual[profile]); drawable_map[orig_surface] = drawable; } @@ -100,6 +115,7 @@ static void retrace_eglBindAPI(trace::Call &call) { static void retrace_eglCreateContext(trace::Call &call) { unsigned long long orig_context = call.ret->toUIntPtr(); + unsigned long long orig_config = call.arg(1).toUIntPtr(); glws::Context *share_context = getContext(call.arg(2).toUIntPtr()); trace::Array *attrib_array = dynamic_cast(&call.arg(3)); glws::Profile profile; @@ -126,7 +142,7 @@ static void retrace_eglCreateContext(trace::Call &call) { } - glws::Context *context = glws::createContext(glretrace::visual[glws::PROFILE_COMPAT], share_context, profile); + glws::Context *context = glws::createContext(glretrace::visual[profile], share_context, profile); if (!context) { const char *name; switch (profile) { @@ -149,6 +165,8 @@ static void retrace_eglCreateContext(trace::Call &call) { } context_map[orig_context] = context; + profile_map[orig_config] = profile; + last_profile = profile; } static void retrace_eglDestroyContext(trace::Call &call) { -- 2.7.4