Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for REGAL_LOG_FILE environment variable.

Add REGAL_LOG for enable/disable logging.
Bugfix for RegalDispatch stepping.
  • Loading branch information...
commit 0dcf2f035ecafe859faca6f6605a15391eee4819 1 parent 17ecc5e
@nigels-com nigels-com authored
View
4 examples/dreamtorus/src/render.cpp
@@ -48,6 +48,8 @@ struct Torus {
Torus( float c, float t ) : circleRadius( c ), tubeRadius( t ) {}
void Vertex( float u, float v )
{
+ glPushGroupMarkerEXT(0, "Torus::Vertex");
+
float theta = (float) (u * 2.0 * M_PI);
float rho = (float) (v * 2.0 * M_PI);
float x = (float) (cos( theta ) * ( circleRadius + cos( rho ) * tubeRadius ));
@@ -60,6 +62,8 @@ struct Torus {
glNormal3f( nx, ny, nz );
glMultiTexCoord2f( texunit, u, v );
glVertex3f( x, y, z );
+
+ glPopGroupMarkerEXT();
}
};
View
3  scripts/ApiCodeFilter.py
@@ -123,6 +123,7 @@ def foldImpossibleReturn(code):
#
# ->
#
+# case c:
# default: { ... }
#
@@ -134,7 +135,7 @@ def foldRedundantCase(code):
while (j+1)<len(tmp) and tmp[j].strip().startswith('case ') and tmp[j].strip().endswith(':'):
j = j + 1
if (j+1)<len(tmp) and tmp[j].strip().startswith('default:'):
- del tmp[i:j]
+ del tmp[i:j-1]
i = j + 1
else:
i = i + 1
View
2  scripts/ApiWrite.py
@@ -94,6 +94,8 @@ def writeEnums(file,name,enums):
print >>file, '%s.esVersions = %s'%(j.name,j.esVersions)
if getattr(j,'enableCap',None) != None:
print >>file, '%s.enableCap = %s'%(j.name,j.enableCap)
+ if getattr(j,'hint',None) != None:
+ print >>file, '%s.hint = %s'%(j.name,j.hint)
if getattr(j,'gluErrorString',None) != None:
print >>file, '%s.gluErrorString = \'%s\''%(j.name,j.gluErrorString)
print >>file, ''
View
6 scripts/EmuIff.py
@@ -221,8 +221,8 @@
'impl' : [ 'return _context->iff->CreateShader( _context, ${arg0} );', ],
},
'Hint' : {
- 'entries' : [ 'glHint', ],
- 'impl' : [ 'return _context->iff->Hint( _context, ${arg0plus} );', ],
- },
+ 'entries' : [ 'glHint' ],
+ 'impl' : [ ],
+ }
}
View
12 scripts/EmuMarker.py
@@ -1,6 +1,9 @@
#!/usr/bin/python -B
formulae = {
+
+ # GL_EXT_debug_marker
+
'Insert' : {
'entries' : [ 'glInsertEventMarkerEXT' ],
'impl' : [ '_context->marker->InsertEventMarker( _context, ${arg0plus} );',
@@ -18,5 +21,14 @@
'impl' : [ '_context->marker->PopGroupMarker( _context );',
'RegalAssert(_context->info);',
'if (!_context->info->gl_ext_debug_marker) return;' ]
+ },
+
+ # GL_GREMEDY_string_marker
+
+ 'GREMEDY' : {
+ 'entries' : [ 'glStringMarkerGREMEDY' ],
+ 'impl' : [ '_context->marker->InsertEventMarker( _context, ${arg0plus} );',
+ 'RegalAssert(_context->info);',
+ 'if (!_context->info->gl_gremedy_string_marker) return;' ]
}
}
View
1  scripts/gl.py
@@ -1732,6 +1732,7 @@
GL_GENERATE_MIPMAP = Enumerant('GL_GENERATE_MIPMAP', 0x8191, 'GL_VERSION_1_4')
GL_GENERATE_MIPMAP_HINT = Enumerant('GL_GENERATE_MIPMAP_HINT', 0x8192, 'GL_VERSION_1_4')
GL_GENERATE_MIPMAP_HINT.esVersions = [2.0]
+GL_GENERATE_MIPMAP_HINT.hint = True
GL_INCR_WRAP = Enumerant('GL_INCR_WRAP', 0x8507, 'GL_VERSION_1_4')
GL_INCR_WRAP.esVersions = [2.0]
GL_MAX_TEXTURE_LOD_BIAS = Enumerant('GL_MAX_TEXTURE_LOD_BIAS', 0x84fd, 'GL_VERSION_1_4')
View
7 scripts/regal/RegalContextInfo.py
@@ -218,17 +218,18 @@
#ifdef REGAL_GL_EXTENSIONS
regalExtensions = REGAL_EQUOTE(REGAL_GL_EXTENSIONS);
#else
- static const char *ourExtensions[7] = {
+ static const char *ourExtensions[8] = {
"GL_REGAL_log",
"GL_REGAL_enable",
"GL_REGAL_error_string",
"GL_REGAL_extension_query",
"GL_REGAL_ES1_0_compatibility",
"GL_REGAL_ES1_1_compatibility",
- "GL_EXT_debug_marker"
+ "GL_EXT_debug_marker",
+ "GL_GREMEDY_string_marker"
};
regalExtensionsSet.insert(extList.begin(),extList.end());
- regalExtensionsSet.insert(&ourExtensions[0],&ourExtensions[7]);
+ regalExtensionsSet.insert(&ourExtensions[0],&ourExtensions[8]);
regalExtensions = ::boost::print::detail::join(regalExtensionsSet,string(" "));
#endif
View
32 scripts/regal/RegalDispatchEmu.py
@@ -115,7 +115,7 @@ def apiEmuFuncDefineCode(apis, args):
code += ' case %d :\n' % l['level']
if l['ifdef']:
code += ' #if %s\n' % l['ifdef']
- if e != None and 'prefix' in e :
+ if e != None and 'prefix' in e and len(e['prefix']):
if l['member'] :
code += ' if (_context->%s) {\n' % l['member']
code += ' RegalEmuScopedActivate activate( _context, _context->%s );\n' % l['member']
@@ -151,7 +151,7 @@ def apiEmuFuncDefineCode(apis, args):
code += ' case %d :\n' % l['level']
if l['ifdef']:
code += ' #if %s\n' % l['ifdef']
- if e != None and 'impl' in e :
+ if e != None and 'impl' in e and len(e['impl']):
if l['member'] :
code += ' if (_context->%s) {\n' % l['member']
code += ' RegalEmuScopedActivate activate( _context, _context->%s );\n' % l['member']
@@ -164,9 +164,9 @@ def apiEmuFuncDefineCode(apis, args):
if l['ifdef']:
code += ' #endif\n'
code += ' default: {\n'
- # debug print
- # code += ' %s\n' % debugPrintFunction( function, 'GTrace' )
- # debug print
+
+ # glEnable/glDisable/glIsEnabled constraints for ES 2.0
+ # http://www.khronos.org/opengles/sdk/docs/man/xhtml/glEnable.xml
if name=='glEnable' or name=='glDisable' or name=='glIsEnabled':
code += ' if (_context->info->gles)\n'
@@ -186,6 +186,28 @@ def apiEmuFuncDefineCode(apis, args):
code += ' return;\n'
code += ' }\n'
+ # glHint constraints for ES 2.0
+ # http://www.khronos.org/opengles/sdk/docs/man/xhtml/glHint.xml
+
+ if name=='glHint':
+ code += ' if (_context->info->gles)\n'
+ code += ' switch (target)\n'
+ code += ' {\n'
+ for i in api.enums:
+ if i.name=='defines':
+ for j in i.enumerants:
+ if getattr(j,'esVersions',None)==None:
+ continue
+ if getattr(j,'hint',None)==None:
+ continue
+ if getattr(j,'esVersions',None) != None and getattr(j,'hint',None) != None and 2.0 in j.esVersions and j.hint == True:
+ code += ' case %s:\n'%(j.name)
+ code += ' break;\n'
+ code += ' default:\n'
+ code += ' Warning("%s does not support ",GLenumToString(target)," for ES 2.0.");\n'%(name)
+ code += ' return;\n'
+ code += ' }\n'
+
code += ' Dispatcher::ScopedStep stepDown(_context->dispatcher);\n'
if es2Name != None:
View
5 src/regal/Regal.cpp
@@ -15584,6 +15584,11 @@ REGAL_DECL void REGAL_CALL glStringMarkerGREMEDY(GLsizei len, const GLvoid *stri
RegalContext *_context = GET_REGAL_CONTEXT();
App("glStringMarkerGREMEDY","(", len, ", ", string, ")");
if (!_context) return;
+ if (_context->marker) {
+ _context->marker->InsertEventMarker( _context, len, string );
+ RegalAssert(_context->info);
+ if (!_context->info->gl_gremedy_string_marker) return;
+ }
_context->dispatcher.call(&_context->dispatcher.table().glStringMarkerGREMEDY)(len, string);
}
View
7 src/regal/RegalContextInfo.cpp
@@ -509,17 +509,18 @@ ContextInfo::init(const RegalContext &context)
#ifdef REGAL_GL_EXTENSIONS
regalExtensions = REGAL_EQUOTE(REGAL_GL_EXTENSIONS);
#else
- static const char *ourExtensions[7] = {
+ static const char *ourExtensions[8] = {
"GL_REGAL_log",
"GL_REGAL_enable",
"GL_REGAL_error_string",
"GL_REGAL_extension_query",
"GL_REGAL_ES1_0_compatibility",
"GL_REGAL_ES1_1_compatibility",
- "GL_EXT_debug_marker"
+ "GL_EXT_debug_marker",
+ "GL_GREMEDY_string_marker"
};
regalExtensionsSet.insert(extList.begin(),extList.end());
- regalExtensionsSet.insert(&ourExtensions[0],&ourExtensions[7]);
+ regalExtensionsSet.insert(&ourExtensions[0],&ourExtensions[8]);
regalExtensions = ::boost::print::detail::join(regalExtensionsSet,string(" "));
#endif
View
1,160 src/regal/RegalDispatchEmu.cpp
1,149 additions, 11 deletions not shown
View
68 src/regal/RegalDispatcher.h
@@ -54,7 +54,9 @@ struct Dispatcher
DispatchTable error;
#endif
+#if REGAL_EMULATION
DispatchTable emulation;
+#endif
#if REGAL_LOG
DispatchTable logging;
@@ -68,23 +70,6 @@ struct Dispatcher
Dispatcher();
~Dispatcher();
- void StepDown()
- {
- ++current;
- while (!enabled[current])
- ++current;
- RegalAssert(current<enabled.size());
- RegalAssert(current<disabled.size());
- }
-
- void StepUp()
- {
- RegalAssert(current>0);
- --current;
- while (!enabled[current] && current>0)
- --current;
- }
-
void push_back(DispatchTable &table, bool enable);
void enable(DispatchTable &table);
@@ -116,11 +101,10 @@ struct Dispatcher
RegalAssert(current<enabled.size());
- std::size_t i = current;
- while (!enabled[i])
- ++i;
+ while (!enabled[current])
+ ++current;
- DispatchTable *t = enabled[i];
+ DispatchTable *t = enabled[current];
RegalAssert(reinterpret_cast<void *>(func)>=reinterpret_cast<void *>(t));
RegalAssert(reinterpret_cast<void *>(func)< reinterpret_cast<void *>(t+1));
@@ -131,10 +115,10 @@ struct Dispatcher
while (!f)
{
- for (++i; !enabled[i]; ++i) {}
- RegalAssert(i<enabled.size());
- RegalAssert(enabled[i]);
- f = *reinterpret_cast<T *>(reinterpret_cast<char *>(enabled[i])+offset);
+ for (++current; !enabled[current]; ++current) {}
+ RegalAssert(current<enabled.size());
+ RegalAssert(enabled[current]);
+ f = *reinterpret_cast<T *>(reinterpret_cast<char *>(enabled[current])+offset);
}
return f;
@@ -144,25 +128,45 @@ struct Dispatcher
{
public:
ScopedStep(Dispatcher &dispatcher)
- : _dispatcher(dispatcher)
+ : _dispatcher(dispatcher),
+ _previous(dispatcher.current)
{
- _dispatcher.StepDown();
+ ++dispatcher.current;
+
+ // Skip disabled layers
+
+ while (!dispatcher.enabled[dispatcher.current])
+ ++dispatcher.current;
+
+ RegalAssert(dispatcher.current<dispatcher.enabled.size());
+ RegalAssert(dispatcher.current<dispatcher.disabled.size());
}
ScopedStep(Dispatcher *dispatcher)
- : _dispatcher(*dispatcher)
+ : _dispatcher(*dispatcher),
+ _previous(dispatcher->current)
{
RegalAssert(dispatcher);
- _dispatcher.StepDown();
+
+ ++dispatcher->current;
+
+ // Skip disabled layers
+
+ while (!dispatcher->enabled[dispatcher->current])
+ ++dispatcher->current;
+
+ RegalAssert(dispatcher->current<dispatcher->enabled.size());
+ RegalAssert(dispatcher->current<dispatcher->disabled.size());
}
~ScopedStep()
{
- _dispatcher.StepUp();
+ _dispatcher.current = _previous;
}
private:
- Dispatcher &_dispatcher;
+ Dispatcher &_dispatcher;
+ std::size_t _previous; // Previous current
// make these private, not needed
@@ -174,7 +178,7 @@ struct Dispatcher
std::vector<DispatchTable *> enabled;
std::vector<DispatchTable *> disabled;
- std::size_t current; // 0 is the top, enabled.size()-1 the bottom
+ std::size_t current; // 0 is the top, enabled.size()-1 the bottom
};
REGAL_NAMESPACE_END
View
36 src/regal/RegalIff.cpp
@@ -53,8 +53,7 @@ REGAL_NAMESPACE_BEGIN
using namespace ::REGAL_NAMESPACE_INTERNAL::Logging;
using namespace ::REGAL_NAMESPACE_INTERNAL::Token;
-namespace {
- static int progcount = -1;
+ static int progcount = -1;
typedef RegalIff RFF;
typedef RegalIff::State State;
@@ -146,20 +145,20 @@ namespace {
}
if( st.lighting ) {
src << "\n";
- src << "#define ME_AMBIENT " << ME_Ambient << "\n";
- src << "#define ME_DIFFUSE " << ME_Diffuse << "\n";
- src << "#define ME_SPECULAR " << ME_Specular << "\n";
- src << "#define ME_EMISSION " << ME_Emission << "\n";
- src << "#define ME_SHININESS " << ME_Shininess << "\n";
- src << "#define ME_ELEMENTS " << ME_Elements << "\n";
+ src << "#define ME_AMBIENT " << int(ME_Ambient) << "\n";
+ src << "#define ME_DIFFUSE " << int(ME_Diffuse) << "\n";
+ src << "#define ME_SPECULAR " << int(ME_Specular) << "\n";
+ src << "#define ME_EMISSION " << int(ME_Emission) << "\n";
+ src << "#define ME_SHININESS " << int(ME_Shininess) << "\n";
+ src << "#define ME_ELEMENTS " << int(ME_Elements) << "\n";
src << "\n";
- src << "#define LE_AMBIENT " << LE_Ambient << "\n";
- src << "#define LE_DIFFUSE " << LE_Diffuse << "\n";
- src << "#define LE_SPECULAR " << LE_Specular << "\n";
- src << "#define LE_POSITION " << LE_Position << "\n";
- src << "#define LE_SPOTDIR " << LE_SpotDir << "\n";
- src << "#define LE_ATTEN " << LE_Atten << "\n";
- src << "#define LE_ELEMENTS " << LE_Elements << "\n";
+ src << "#define LE_AMBIENT " << int(LE_Ambient) << "\n";
+ src << "#define LE_DIFFUSE " << int(LE_Diffuse) << "\n";
+ src << "#define LE_SPECULAR " << int(LE_Specular) << "\n";
+ src << "#define LE_POSITION " << int(LE_Position) << "\n";
+ src << "#define LE_SPOTDIR " << int(LE_SpotDir) << "\n";
+ src << "#define LE_ATTEN " << int(LE_Atten) << "\n";
+ src << "#define LE_ELEMENTS " << int(LE_Elements) << "\n";
src << "\n";
}
@@ -1101,10 +1100,9 @@ namespace {
return r;
}
- // debug
- GLchar dbgLog[1<<15];
- GLsizei dbgLogLen;
-}
+// debug
+static GLchar dbgLog[1<<15];
+static GLsizei dbgLogLen;
bool State::SetEnable( RFF * ffn, bool enable, GLenum cap ) {
RFF::Version & ver = ffn->ver;
View
16 src/regal/RegalIff.h
@@ -775,22 +775,6 @@ struct RegalIff : public RegalEmu {
}
}
- void Hint( RegalContext * ctx, GLenum target, GLenum mode) {
- if ( ctx->info->gles && ctx->info->gles_version_major >= 2 ) {
- switch ( target ) {
- case GL_PERSPECTIVE_CORRECTION_HINT:
- case GL_POINT_SMOOTH_HINT:
- case GL_LINE_SMOOTH_HINT:
- case GL_FOG_HINT:
- // ignore these unused hints in ES 2.0
- return;
- }
- }
- DispatchTable &tbl = ctx->dispatcher.emulation;
- tbl.glHint( target, mode );
- }
-
-
void Provoke( RegalContext * ctx ) {
memcpy( immArray + immCurrent * maxVertexAttribs * 16, &immVab.attr[0].x, maxVertexAttribs * 16 );
immCurrent++;
View
55 src/regal/RegalLog.cpp
@@ -88,7 +88,10 @@ namespace Logging {
int maxLines = (REGAL_LOG_MAX_LINES);
bool callback = (REGAL_LOG_CALLBACK);
- bool stdOut = (REGAL_LOG_STDOUT);
+
+ bool log = (REGAL_LOG);
+ std::string logFilename = "stdout";
+ FILE *logOutput = NULL;
bool json = false;
std::string jsonFilename;
@@ -132,8 +135,14 @@ namespace Logging {
const char *ml = GetEnv("REGAL_LOG_MAX_LINES");
if (ml) maxLines = atoi(ml);
- const char *bl = GetEnv("REGAL_HTTP_LOG_LIMIT");
- if (bl) bufferLimit = atoi(bl);
+ const char *cb = GetEnv("REGAL_LOG_CALLBACK");
+ if (cb) callback = atoi(cb)!=0;
+
+ const char *rl = GetEnv("REGAL_LOG");
+ if (rl) log = atoi(rl)!=0;
+
+ const char *rlf = GetEnv("REGAL_LOG_FILE");
+ if (rlf) logFilename = rlf;
const char *js = GetEnv("REGAL_LOG_JSON");
if (js) json = atoi(js)!=0;
@@ -141,11 +150,8 @@ namespace Logging {
const char *jf = GetEnv("REGAL_LOG_JSON_FILE");
if (jf) jsonFilename = jf;
- const char *cb = GetEnv("REGAL_LOG_CALLBACK");
- if (cb) callback = atoi(cb)!=0;
-
- const char *so = GetEnv("REGAL_LOG_STDOUT");
- if (so) stdOut = atoi(so)!=0;
+ const char *bl = GetEnv("REGAL_HTTP_LOG_LIMIT");
+ if (bl) bufferLimit = atoi(bl);
#endif
#ifdef REGAL_HTTP_LOG_LIMIT
@@ -157,6 +163,19 @@ namespace Logging {
if (bufferLimit)
buffer = new list<string>();
+ if (logFilename.length())
+ {
+ if (logFilename=="stdout")
+ logOutput = stdout;
+ else
+ {
+ if (logFilename=="stderr")
+ logOutput = stderr;
+ else
+ logOutput = fopen(logFilename.c_str(),"wt");
+ }
+ }
+
if (jsonFilename.length())
{
if (jsonFilename=="stdout")
@@ -204,6 +223,10 @@ namespace Logging {
#endif
#if REGAL_LOG_JSON
+ Info("REGAL_LOG ", log ? "enabled" : "disabled");
+#endif
+
+#if REGAL_LOG_JSON
Info("REGAL_LOG_JSON ", json ? "enabled" : "disabled");
#endif
@@ -408,20 +431,20 @@ namespace Logging {
}
#endif
-#if REGAL_LOG_STDOUT
- if (stdOut)
+#if REGAL_LOG
+ if (log && logOutput)
{
#if REGAL_SYS_WGL
OutputDebugStringA(m.c_str());
- fprintf(stdout, "%s", m.c_str());
- fflush(stdout);
+ fprintf(logOutput, "%s", m.c_str());
+ fflush(logOutput);
#elif REGAL_SYS_ANDROID
#elif REGAL_SYS_NACL
- fprintf(stdout, "%s", m.c_str());
- fflush(stdout);
+ fprintf(logOutput, "%s", m.c_str());
+ fflush(logOutput);
#else
- fprintf(stdout, "%s", m.c_str());
- fflush(stdout);
+ fprintf(logOutput, "%s", m.c_str());
+ fflush(logOutput);
#endif
}
#endif
View
27 src/regal/RegalLog.h
@@ -87,6 +87,14 @@ REGAL_NAMESPACE_BEGIN
# define REGAL_LOG_HTTP 1
#endif
+#ifndef REGAL_LOG
+# ifdef NDEBUG
+# define REGAL_LOG 0
+# else
+# define REGAL_LOG 1
+# endif
+#endif
+
#ifndef REGAL_LOG_MAX_LINES
# define REGAL_LOG_MAX_LINES -1 // unlimited by default
#endif
@@ -99,14 +107,6 @@ REGAL_NAMESPACE_BEGIN
# define REGAL_LOG_CALLBACK 1
#endif
-#ifndef REGAL_LOG_STDOUT
-# ifdef NDEBUG
-# define REGAL_LOG_STDOUT 0
-# else
-# define REGAL_LOG_STDOUT 1
-# endif
-#endif
-
#ifdef REGAL_LOG_ALL
# undef REGAL_LOG_ERROR
# undef REGAL_LOG_WARNING
@@ -145,8 +145,17 @@ namespace Logging
extern int maxLines;
+ // Callback output
+
extern bool callback;
- extern bool stdOut;
+
+ // Logging output
+
+ extern bool log;
+ extern std::string logFilename;
+ extern FILE *logOutput;
+
+ // JSON output
extern bool json;
extern std::string jsonFilename;
View
13 src/regal/RegalMarker.h
@@ -57,21 +57,26 @@ struct Marker {
void Init(RegalContext *ctx)
{
UNUSED_PARAMETER(ctx);
- Internal("RegalMarker::Init","()");
+ Internal("Regal::Marker::Init","()");
}
void InsertEventMarker(RegalContext *ctx, GLsizei length, const char *marker)
{
UNUSED_PARAMETER(ctx);
- Internal("RegalMarker::InsertEventMarker","()");
+ Internal("Regal::Marker::InsertEventMarker","()");
std::string m = toString(length,marker);
Info("/* ",m," */");
}
+ void InsertEventMarker(RegalContext *ctx, GLsizei length, const void *marker)
+ {
+ InsertEventMarker(ctx,length,static_cast<const char *>(marker));
+ }
+
void PushGroupMarker(RegalContext *ctx, GLsizei length, const char *marker)
{
UNUSED_PARAMETER(ctx);
- Internal("RegalMarker::PushGroupMarker","()");
+ Internal("Regal::Marker::PushGroupMarker","()");
std::string m = toString(length,marker);
Info("/* ",m," ... */");
markerStack.push_back(std::string());
@@ -81,7 +86,7 @@ struct Marker {
void PopGroupMarker(RegalContext *ctx)
{
UNUSED_PARAMETER(ctx);
- Internal("RegalMarker::PopGroupMarkerEXT","()");
+ Internal("Regal::Marker::PopGroupMarkerEXT","()");
std::string m;
m.swap(markerStack.back());
markerStack.pop_back();
Please sign in to comment.
Something went wrong with that request. Please try again.