Skip to content

Commit

Permalink
helpers: rename glprofile to glfeatures.
Browse files Browse the repository at this point in the history
This module will have more than just description of OpenGL profiles, but
actual features.
  • Loading branch information
jrfonseca committed Apr 4, 2016
1 parent 55a270c commit 9ed6462
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 96 deletions.
2 changes: 1 addition & 1 deletion helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include_directories (
)

add_convenience_library (glhelpers
glprofile.cpp
glfeatures.cpp
eglsize.cpp
)
add_dependencies (glhelpers glproc)
Expand Down
6 changes: 3 additions & 3 deletions helpers/glprofile.cpp → helpers/glfeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
**************************************************************************/


#include "glprofile.hpp"
#include "glfeatures.hpp"

#include <assert.h>

Expand All @@ -34,7 +34,7 @@
#include "glproc.hpp"


namespace glprofile {
namespace glfeatures {


bool
Expand Down Expand Up @@ -322,4 +322,4 @@ Extensions::has(const char *string) const
}


} /* namespace glprofile */
} /* namespace glfeatures */
6 changes: 2 additions & 4 deletions helpers/glprofile.hpp → helpers/glfeatures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <string>


namespace glprofile {
namespace glfeatures {


enum Api {
Expand Down Expand Up @@ -138,6 +138,4 @@ struct Extensions



} /* namespace glprofile */


} /* namespace glfeatures */
12 changes: 6 additions & 6 deletions retrace/glretrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ struct Context {
bool KHR_debug;
GLsizei maxDebugMessageLength = 0;

inline glprofile::Profile
inline glfeatures::Profile
profile(void) const {
return wsContext->profile;
}

inline glprofile::Profile
inline glfeatures::Profile
actualProfile(void) const {
return wsContext->actualProfile;
}
Expand All @@ -84,7 +84,7 @@ extern std::vector<MetricBackend*> metricBackends;
extern MetricBackend* curMetricBackend;
extern MetricWriter profiler;

extern glprofile::Profile defaultProfile;
extern glfeatures::Profile defaultProfile;

extern bool supportsARBShaderObjects;

Expand All @@ -101,12 +101,12 @@ getCurrentContext(void) {
int
parseAttrib(const trace::Value *attribs, int param, int default_ = 0, int terminator = 0);

glprofile::Profile
glfeatures::Profile
parseContextAttribList(const trace::Value *attribs);


glws::Drawable *
createDrawable(glprofile::Profile profile);
createDrawable(glfeatures::Profile profile);

glws::Drawable *
createDrawable(void);
Expand All @@ -115,7 +115,7 @@ glws::Drawable *
createPbuffer(int width, int height, const glws::pbuffer_info *info);

Context *
createContext(Context *shareContext, glprofile::Profile profile);
createContext(Context *shareContext, glfeatures::Profile profile);

Context *
createContext(Context *shareContext = 0);
Expand Down
16 changes: 8 additions & 8 deletions retrace/glretrace_cgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ static Context *sharedContext = NULL;

struct PixelFormat
{
glprofile::Profile profile;
glfeatures::Profile profile;

PixelFormat() :
profile(glprofile::API_GL, 1, 0)
profile(glfeatures::API_GL, 1, 0)
{}
};


static glws::Drawable *
getDrawable(unsigned long drawable_id, glprofile::Profile profile) {
getDrawable(unsigned long drawable_id, glfeatures::Profile profile) {
if (drawable_id == 0) {
return NULL;
}
Expand Down Expand Up @@ -235,13 +235,13 @@ static void retrace_CGLChoosePixelFormat(trace::Call &call) {
case 0:
break;
case kCGLOGLPVersion_Legacy:
pixelFormat->profile = glprofile::Profile(glprofile::API_GL, 1, 0);
pixelFormat->profile = glfeatures::Profile(glfeatures::API_GL, 1, 0);
break;
case kCGLOGLPVersion_GL3_Core:
pixelFormat->profile = glprofile::Profile(glprofile::API_GL, 3, 2, true, true);
pixelFormat->profile = glfeatures::Profile(glfeatures::API_GL, 3, 2, true, true);
break;
case kCGLOGLPVersion_GL4_Core:
pixelFormat->profile = glprofile::Profile(glprofile::API_GL, 4, 1, true, true);
pixelFormat->profile = glfeatures::Profile(glfeatures::API_GL, 4, 1, true, true);
break;
default:
retrace::warning(call) << "unexpected opengl profile " << std::hex << profile << std::dec << "\n";
Expand Down Expand Up @@ -276,7 +276,7 @@ static void retrace_CGLCreateContext(trace::Call &call) {

trace::Value & pix = call.argByName("pix");
const PixelFormat *pixelFormat = retrace::asObjPointer<PixelFormat>(call, pix);
glprofile::Profile profile = pixelFormat ? pixelFormat->profile : glretrace::defaultProfile;
glfeatures::Profile profile = pixelFormat ? pixelFormat->profile : glretrace::defaultProfile;

unsigned long long share = call.arg(1).toUIntPtr();
Context *sharedContext = getContext(share);
Expand Down Expand Up @@ -354,7 +354,7 @@ static void retrace_CGLSetCurrentContext(trace::Call &call) {
glws::Drawable *new_drawable = NULL;
if (new_context) {
if (!new_context->drawable) {
glprofile::Profile profile = new_context->profile();
glfeatures::Profile profile = new_context->profile();
new_context->drawable = glretrace::createDrawable(profile);
}
new_drawable = new_context->drawable;
Expand Down
18 changes: 9 additions & 9 deletions retrace/glretrace_egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using namespace glretrace;

typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
typedef std::map<unsigned long long, Context *> ContextMap;
typedef std::map<unsigned long long, glprofile::Profile> ProfileMap;
typedef std::map<unsigned long long, glfeatures::Profile> ProfileMap;
static DrawableMap drawable_map;
static ContextMap context_map;
static ProfileMap profile_map;
Expand All @@ -61,7 +61,7 @@ static unsigned int current_api = EGL_OPENGL_ES_API;
* instead of guessing. For now, start with a guess of ES2 profile, which
* should be the most common case for EGL.
*/
static glprofile::Profile last_profile(glprofile::API_GLES, 2, 0);
static glfeatures::Profile last_profile(glfeatures::API_GLES, 2, 0);

static glws::Drawable *null_drawable = NULL;

Expand Down Expand Up @@ -103,7 +103,7 @@ getContext(unsigned long long context_ptr) {
static void createDrawable(unsigned long long orig_config, unsigned long long orig_surface)
{
ProfileMap::iterator it = profile_map.find(orig_config);
glprofile::Profile profile;
glfeatures::Profile profile;

// If the requested config is associated with a profile, use that
// profile. Otherwise, assume that the last used profile is what
Expand All @@ -130,13 +130,13 @@ static void retrace_eglChooseConfig(trace::Call &call) {
return;
}

glprofile::Profile profile;
glfeatures::Profile profile;
unsigned renderableType = parseAttrib(attrib_array, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT);
std::cerr << "renderableType = " << renderableType << "\n";
if (renderableType & EGL_OPENGL_BIT) {
profile = glprofile::Profile(glprofile::API_GL, 1, 0);
profile = glfeatures::Profile(glfeatures::API_GL, 1, 0);
} else {
profile.api = glprofile::API_GLES;
profile.api = glfeatures::API_GLES;
if (renderableType & EGL_OPENGL_ES3_BIT) {
profile.major = 3;
} else if (renderableType & EGL_OPENGL_ES2_BIT) {
Expand Down Expand Up @@ -195,11 +195,11 @@ static void retrace_eglCreateContext(trace::Call &call) {
unsigned long long orig_config = call.arg(1).toUIntPtr();
Context *share_context = getContext(call.arg(2).toUIntPtr());
trace::Array *attrib_array = call.arg(3).toArray();
glprofile::Profile profile;
glfeatures::Profile profile;

switch (current_api) {
case EGL_OPENGL_API:
profile.api = glprofile::API_GL;
profile.api = glfeatures::API_GL;
profile.major = parseAttrib(attrib_array, EGL_CONTEXT_MAJOR_VERSION, 1);
profile.minor = parseAttrib(attrib_array, EGL_CONTEXT_MINOR_VERSION, 0);
if (profile.versionGreaterOrEqual(3,2)) {
Expand All @@ -215,7 +215,7 @@ static void retrace_eglCreateContext(trace::Call &call) {
break;
case EGL_OPENGL_ES_API:
default:
profile.api = glprofile::API_GLES;
profile.api = glfeatures::API_GLES;
profile.major = parseAttrib(attrib_array, EGL_CONTEXT_MAJOR_VERSION, 1);
profile.minor = parseAttrib(attrib_array, EGL_CONTEXT_MINOR_VERSION, 0);
break;
Expand Down
2 changes: 1 addition & 1 deletion retrace/glretrace_glx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static void retrace_glXCreateContextAttribsARB(trace::Call &call) {
Context *share_context = getContext(call.arg(2).toUIntPtr());

const trace::Value * attrib_list = &call.arg(4);
glprofile::Profile profile = parseContextAttribList(attrib_list);
glfeatures::Profile profile = parseContextAttribList(attrib_list);

Context *context = glretrace::createContext(share_context, profile);
context_map[orig_context] = context;
Expand Down
12 changes: 6 additions & 6 deletions retrace/glretrace_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

namespace glretrace {

glprofile::Profile defaultProfile(glprofile::API_GL, 1, 0);
glfeatures::Profile defaultProfile(glfeatures::API_GL, 1, 0);

bool supportsARBShaderObjects = false;

Expand Down Expand Up @@ -155,7 +155,7 @@ insertCallMarker(trace::Call &call, Context *currentContext)
return;
}

glprofile::Profile currentProfile = currentContext->actualProfile();
glfeatures::Profile currentProfile = currentContext->actualProfile();

std::stringstream ss;
trace::dump(call, ss,
Expand Down Expand Up @@ -431,11 +431,11 @@ initContext() {
assert(currentContext);

/* Ensure we have adequate extension support */
glprofile::Profile currentProfile = currentContext->actualProfile();
supportsTimestamp = currentProfile.versionGreaterOrEqual(glprofile::API_GL, 3, 3) ||
glfeatures::Profile currentProfile = currentContext->actualProfile();
supportsTimestamp = currentProfile.versionGreaterOrEqual(glfeatures::API_GL, 3, 3) ||
currentContext->hasExtension("GL_ARB_timer_query");
supportsElapsed = currentContext->hasExtension("GL_EXT_timer_query") || supportsTimestamp;
supportsOcclusion = currentProfile.versionGreaterOrEqual(glprofile::API_GL, 1, 5);
supportsOcclusion = currentProfile.versionGreaterOrEqual(glfeatures::API_GL, 1, 5);
supportsARBShaderObjects = currentContext->hasExtension("GL_ARB_shader_objects");

currentContext->KHR_debug = currentContext->hasExtension("GL_KHR_debug");
Expand Down Expand Up @@ -823,7 +823,7 @@ static GLDumper glDumper;
void
retrace::setFeatureLevel(const char *featureLevel)
{
glretrace::defaultProfile = glprofile::Profile(glprofile::API_GL, 3, 2, true);
glretrace::defaultProfile = glfeatures::Profile(glfeatures::API_GL, 3, 2, true);
}


Expand Down
4 changes: 2 additions & 2 deletions retrace/glretrace_wgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static void retrace_wglShareLists(trace::Call &call) {
Context *share_context = getContext(hglrc1);
Context *old_context = getContext(hglrc2);

glprofile::Profile profile = old_context->profile();
glfeatures::Profile profile = old_context->profile();
Context *new_context = glretrace::createContext(share_context, profile);
if (new_context) {
glretrace::Context *currentContext = glretrace::getCurrentContext();
Expand Down Expand Up @@ -279,7 +279,7 @@ static void retrace_wglCreateContextAttribsARB(trace::Call &call) {
Context *share_context = getContext(call.arg(1).toUIntPtr());

const trace::Value * attribList = &call.arg(2);
glprofile::Profile profile = parseContextAttribList(attribList);
glfeatures::Profile profile = parseContextAttribList(attribList);

Context *context = glretrace::createContext(share_context, profile);
context_map[orig_context] = context;
Expand Down
20 changes: 10 additions & 10 deletions retrace/glretrace_ws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
namespace glretrace {


static std::map<glprofile::Profile, glws::Visual *>
static std::map<glfeatures::Profile, glws::Visual *>
visuals;


inline glws::Visual *
getVisual(glprofile::Profile profile) {
std::map<glprofile::Profile, glws::Visual *>::iterator it = visuals.find(profile);
getVisual(glfeatures::Profile profile) {
std::map<glfeatures::Profile, glws::Visual *>::iterator it = visuals.find(profile);
if (it == visuals.end()) {
glws::Visual *visual = NULL;
unsigned samples = retrace::samples;
Expand All @@ -76,7 +76,7 @@ getVisual(glprofile::Profile profile) {


static glws::Drawable *
createDrawableHelper(glprofile::Profile profile, int width = 32, int height = 32,
createDrawableHelper(glfeatures::Profile profile, int width = 32, int height = 32,
const glws::pbuffer_info *pbInfo = NULL) {
glws::Visual *visual = getVisual(profile);
glws::Drawable *draw = glws::createDrawable(visual, width, height, pbInfo);
Expand All @@ -93,7 +93,7 @@ createDrawableHelper(glprofile::Profile profile, int width = 32, int height = 32


glws::Drawable *
createDrawable(glprofile::Profile profile) {
createDrawable(glfeatures::Profile profile) {
return createDrawableHelper(profile);
}

Expand All @@ -116,7 +116,7 @@ createPbuffer(int width, int height, const glws::pbuffer_info *pbInfo) {


Context *
createContext(Context *shareContext, glprofile::Profile profile) {
createContext(Context *shareContext, glfeatures::Profile profile) {
glws::Visual *visual = getVisual(profile);
glws::Context *shareWsContext = shareContext ? shareContext->wsContext : NULL;
glws::Context *ctx = glws::createContext(visual, shareWsContext, retrace::debug);
Expand Down Expand Up @@ -281,7 +281,7 @@ parseAttrib(const trace::Value *attribs, int param, int default_, int terminator
/**
* Parse GLX/WGL_ARB_create_context attribute list.
*/
glprofile::Profile
glfeatures::Profile
parseContextAttribList(const trace::Value *attribs)
{
// {GLX,WGL}_CONTEXT_MAJOR_VERSION_ARB
Expand All @@ -308,11 +308,11 @@ parseContextAttribList(const trace::Value *attribs)
// {GLX,WGL}_CONTEXT_ES_PROFILE_BIT_EXT
bool es_profile = profile_mask & 0x0004;

glprofile::Profile profile;
glfeatures::Profile profile;
if (es_profile) {
profile.api = glprofile::API_GLES;
profile.api = glfeatures::API_GLES;
} else {
profile.api = glprofile::API_GL;
profile.api = glfeatures::API_GL;
profile.core = core_profile;
profile.forwardCompatible = forward_compatible;
}
Expand Down
4 changes: 2 additions & 2 deletions retrace/glstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace glstate {
Context::Context(void) {
memset(this, 0, sizeof *this);

glprofile::Profile profile = glprofile::getCurrentContextProfile();
glprofile::Extensions ext;
glfeatures::Profile profile = glfeatures::getCurrentContextProfile();
glfeatures::Extensions ext;

ext.getCurrentContextExtensions(profile);

Expand Down
8 changes: 4 additions & 4 deletions retrace/glws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Context::initialize(void)
{
assert(!initialized);

actualProfile = glprofile::getCurrentContextProfile();
actualProfile = glfeatures::getCurrentContextProfile();
actualExtensions.getCurrentContextExtensions(actualProfile);

/* Ensure we got a matching profile.
Expand All @@ -88,10 +88,10 @@ Context::initialize(void)
*
* Also, see if OpenGL ES can be handled through ARB_ES*_compatibility.
*/
glprofile::Profile expectedProfile = profile;
glfeatures::Profile expectedProfile = profile;
if (!actualProfile.matches(expectedProfile)) {
if (expectedProfile.api == glprofile::API_GLES &&
actualProfile.api == glprofile::API_GL &&
if (expectedProfile.api == glfeatures::API_GLES &&
actualProfile.api == glfeatures::API_GL &&
((expectedProfile.major == 2 && actualExtensions.has("GL_ARB_ES2_compatibility")) ||
(expectedProfile.major == 3 && actualExtensions.has("GL_ARB_ES3_compatibility")))) {
std::cerr << "warning: context mismatch:"
Expand Down
Loading

0 comments on commit 9ed6462

Please sign in to comment.