summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--CMakeLists.txt14
-rw-r--r--glimports.hpp4
-rw-r--r--glretrace.hpp69
-rw-r--r--glretrace.py287
-rw-r--r--glretrace_main.cpp299
-rw-r--r--glstate.py4
-rw-r--r--glxapi.py2
-rw-r--r--retrace.cpp (renamed from glstate.hpp)13
-rw-r--r--retrace.hpp12
-rw-r--r--retrace.py17
-rw-r--r--trace_model.hpp2
12 files changed, 422 insertions, 305 deletions
diff --git a/.gitignore b/.gitignore
index a09d5fc5..7ab2596b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,8 +31,8 @@ dump
dxsdk
glproc.hpp
glretrace
-glretrace.cpp
-glstate.cpp
+glretrace_gl.cpp
+glretrace_state.cpp
glxtrace.cpp
traces
wgltrace.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8fb356e9..06f7a5e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -205,14 +205,14 @@ add_executable (dump dump.cpp)
target_link_libraries (dump trace)
add_custom_command (
- OUTPUT glretrace.cpp
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace.cpp
+ OUTPUT glretrace_gl.cpp
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
DEPENDS glretrace.py retrace.py codegen.py glapi.py glenum.py stdapi.py
)
add_custom_command (
- OUTPUT glstate.cpp
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate.cpp
+ OUTPUT glretrace_state.cpp
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_state.cpp
DEPENDS glstate.py glenum.py stdapi.py
)
@@ -222,8 +222,10 @@ include_directories (
)
add_executable (glretrace
- glretrace.cpp
- glstate.cpp
+ glretrace_gl.cpp
+ glretrace_main.cpp
+ glretrace_state.cpp
+ retrace.cpp
${glws}
image.cpp
${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
diff --git a/glimports.hpp b/glimports.hpp
index e8d2c5c6..4b210834 100644
--- a/glimports.hpp
+++ b/glimports.hpp
@@ -67,6 +67,7 @@
#ifdef __MINGW32__
+extern "C"
typedef struct _WGLSWAP
{
HDC hdc;
@@ -82,6 +83,9 @@ typedef struct _WGLSWAP
#include <GL/glx.h>
#include <GL/glext.h>
+/* Prevent collision with Trace::Bool */
+#undef Bool
+
#endif /* !WIN32 */
#endif /* _GLIMPORTS_HPP_ */
diff --git a/glretrace.hpp b/glretrace.hpp
new file mode 100644
index 00000000..ac44aff5
--- /dev/null
+++ b/glretrace.hpp
@@ -0,0 +1,69 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _GLRETRACE_HPP_
+#define _GLRETRACE_HPP_
+
+#include <ostream>
+
+#include "trace_parser.hpp"
+#include "glws.hpp"
+
+
+namespace glretrace {
+
+
+extern bool double_buffer;
+extern bool insideGlBeginEnd;
+extern Trace::Parser parser;
+extern glws::WindowSystem *ws;
+extern glws::Visual *visual;
+extern glws::Drawable *drawable;
+extern glws::Context *context;
+
+extern int window_width;
+extern int window_height;
+extern bool reshape_window;
+
+extern unsigned frame;
+extern long long startTime;
+extern bool wait;
+
+extern bool benchmark;
+extern const char *compare_prefix;
+extern const char *snapshot_prefix;
+
+extern unsigned dump_state;
+
+void
+checkGlError(void);
+
+void state_dump(std::ostream &os);
+
+
+} /* namespace glretrace */
+
+
+#endif /* _GLRETRACE_HPP_ */
diff --git a/glretrace.py b/glretrace.py
index 759e9d99..d14b5484 100644
--- a/glretrace.py
+++ b/glretrace.py
@@ -125,25 +125,25 @@ class GlRetracer(Retracer):
def call_function(self, function):
if function.name == "glViewport":
- print ' if (x + width > __window_width) {'
- print ' __window_width = x + width;'
- print ' __reshape_window = true;'
+ print ' if (x + width > glretrace::window_width) {'
+ print ' glretrace::window_width = x + width;'
+ print ' glretrace::reshape_window = true;'
print ' }'
- print ' if (y + height > __window_height) {'
- print ' __window_height = y + height;'
- print ' __reshape_window = true;'
+ print ' if (y + height > glretrace::window_height) {'
+ print ' glretrace::window_height = y + height;'
+ print ' glretrace::reshape_window = true;'
print ' }'
if function.name == "glEnd":
- print ' insideGlBeginEnd = false;'
+ print ' glretrace::insideGlBeginEnd = false;'
Retracer.call_function(self, function)
if function.name == "glBegin":
- print ' insideGlBeginEnd = true;'
+ print ' glretrace::insideGlBeginEnd = true;'
else:
# glGetError is not allowed inside glBegin/glEnd
- print ' checkGlError();'
+ print ' glretrace::checkGlError();'
def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
if function.name in self.array_pointer_function_names and arg.name == 'pointer':
@@ -163,278 +163,11 @@ class GlRetracer(Retracer):
if __name__ == '__main__':
print r'''
-#include <string.h>
-#include <stdio.h>
-#include <iostream>
-
#include "glproc.hpp"
-#include "glstate.hpp"
-#include "glws.hpp"
-
-static bool double_buffer = false;
-static bool insideGlBeginEnd = false;
-
-static int __window_width = 256, __window_height = 256;
-bool __reshape_window = false;
-
-unsigned __frame = 0;
-long long __startTime = 0;
-bool __wait = false;
-
-bool __benchmark = false;
-const char *__compare_prefix = NULL;
-const char *__snapshot_prefix = NULL;
+#include "glretrace.hpp"
-unsigned __dump_state = ~0;
-
-static void
-checkGlError(void) {
- if (__benchmark || insideGlBeginEnd) {
- return;
- }
-
- GLenum error = glGetError();
- if (error == GL_NO_ERROR) {
- return;
- }
-
- std::cerr << "warning: glGetError() = ";
- switch (error) {
- case GL_INVALID_ENUM:
- std::cerr << "GL_INVALID_ENUM";
- break;
- case GL_INVALID_VALUE:
- std::cerr << "GL_INVALID_VALUE";
- break;
- case GL_INVALID_OPERATION:
- std::cerr << "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- std::cerr << "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- std::cerr << "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- std::cerr << "GL_OUT_OF_MEMORY";
- break;
- case GL_INVALID_FRAMEBUFFER_OPERATION:
- std::cerr << "GL_INVALID_FRAMEBUFFER_OPERATION";
- break;
- case GL_TABLE_TOO_LARGE:
- std::cerr << "GL_TABLE_TOO_LARGE";
- break;
- default:
- std::cerr << error;
- break;
- }
- std::cerr << "\n";
-}
'''
api = glapi.glapi
retracer = GlRetracer()
retracer.retrace_api(glapi.glapi)
- print r'''
-
-static Trace::Parser parser;
-static glws::WindowSystem *__ws = NULL;
-static glws::Visual *__visual = NULL;
-static glws::Drawable *__drawable = NULL;
-static glws::Context *__context = NULL;
-
-#include "image.hpp"
-
-static void snapshot(Image::Image &image) {
- GLint drawbuffer = double_buffer ? GL_BACK : GL_FRONT;
- GLint readbuffer = double_buffer ? GL_BACK : GL_FRONT;
- glGetIntegerv(GL_READ_BUFFER, &drawbuffer);
- glGetIntegerv(GL_READ_BUFFER, &readbuffer);
- glReadBuffer(drawbuffer);
- glReadPixels(0, 0, image.width, image.height, GL_RGBA, GL_UNSIGNED_BYTE, image.pixels);
- checkGlError();
- glReadBuffer(readbuffer);
-}
-
-static void frame_complete(void) {
- ++__frame;
-
- if (!__reshape_window && (__snapshot_prefix || __compare_prefix)) {
- Image::Image *ref = NULL;
- if (__compare_prefix) {
- char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s%04u.png", __compare_prefix, __frame);
- ref = Image::readPNG(filename);
- if (!ref) {
- return;
- }
- if (verbosity >= 0)
- std::cout << "Read " << filename << "\n";
- }
-
- Image::Image src(__window_width, __window_height, true);
- snapshot(src);
-
- if (__snapshot_prefix) {
- char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s%04u.png", __snapshot_prefix, __frame);
- if (src.writePNG(filename) && verbosity >= 0) {
- std::cout << "Wrote " << filename << "\n";
- }
- }
-
- if (ref) {
- std::cout << "Frame " << __frame << " average precision of " << src.compare(*ref) << " bits\n";
- delete ref;
- }
- }
-
- if (__reshape_window) {
- // XXX: doesn't quite work
- __drawable->resize(__window_width, __window_height);
- __reshape_window = false;
- }
-
- __ws->processEvents();
-}
-
-static void display(void) {
- Trace::Call *call;
-
- while ((call = parser.parse_call())) {
- const std::string &name = call->name();
-
- if ((name[0] == 'w' && name[1] == 'g' && name[2] == 'l') ||
- (name[0] == 'g' && name[1] == 'l' && name[2] == 'X')) {
- // XXX: We ignore the majority of the OS-specific calls for now
- if (name == "glXSwapBuffers" ||
- name == "wglSwapBuffers") {
- if (verbosity >= 1) {
- std::cout << *call;
- std::cout.flush();
- };
- frame_complete();
- if (double_buffer)
- __drawable->swapBuffers();
- else
- glFlush();
- } else if (name == "glXMakeCurrent" ||
- name == "wglMakeCurrent") {
- glFlush();
- if (!double_buffer) {
- frame_complete();
- }
- } else {
- continue;
- }
- }
-
- if (name == "glFlush") {
- glFlush();
- if (!double_buffer) {
- frame_complete();
- }
- }
-
- retrace_call(*call);
-
- if (!insideGlBeginEnd && call->no >= __dump_state) {
- state_dump(std::cout);
- exit(0);
- }
-
- delete call;
- }
-
- // Reached the end of trace
- glFlush();
-
- long long endTime = OS::GetTime();
- float timeInterval = (endTime - __startTime) * 1.0E-6;
-
- if (verbosity >= -1) {
- std::cout <<
- "Rendered " << __frame << " frames"
- " in " << timeInterval << " secs,"
- " average of " << (__frame/timeInterval) << " fps\n";
- }
-
- if (__wait) {
- while (__ws->processEvents()) {}
- } else {
- exit(0);
- }
-}
-
-static void usage(void) {
- std::cout <<
- "Usage: glretrace [OPTION] TRACE\n"
- "Replay TRACE.\n"
- "\n"
- " -b benchmark (no glgeterror; no messages)\n"
- " -c PREFIX compare against snapshots\n"
- " -db use a double buffer visual\n"
- " -s PREFIX take snapshots\n"
- " -v verbose output\n"
- " -D CALLNO dump state at specific call no\n"
- " -w wait on final frame\n";
-}
-
-int main(int argc, char **argv)
-{
-
- int i;
- for (i = 1; i < argc; ++i) {
- const char *arg = argv[i];
-
- if (arg[0] != '-') {
- break;
- }
-
- if (!strcmp(arg, "--")) {
- break;
- } else if (!strcmp(arg, "-b")) {
- __benchmark = true;
- verbosity = -1;
- } else if (!strcmp(arg, "-c")) {
- __compare_prefix = argv[++i];
- } else if (!strcmp(arg, "-D")) {
- __dump_state = atoi(argv[++i]);
- verbosity = -2;
- } else if (!strcmp(arg, "-db")) {
- double_buffer = true;
- } else if (!strcmp(arg, "--help")) {
- usage();
- return 0;
- } else if (!strcmp(arg, "-s")) {
- __snapshot_prefix = argv[++i];
- } else if (!strcmp(arg, "-v")) {
- ++verbosity;
- } else if (!strcmp(arg, "-w")) {
- __wait = true;
- } else {
- std::cerr << "error: unknown option " << arg << "\n";
- usage();
- return 1;
- }
- }
-
- __ws = glws::createNativeWindowSystem();
- __visual = __ws->createVisual(double_buffer);
- __drawable = __ws->createDrawable(__visual);
- __drawable->resize(__window_width, __window_height);
- __context = __ws->createContext(__visual);
- __ws->makeCurrent(__drawable, __context);
-
- for ( ; i < argc; ++i) {
- if (parser.open(argv[i])) {
- __startTime = OS::GetTime();
- display();
- parser.close();
- }
- }
-
- return 0;
-}
-
-'''
diff --git a/glretrace_main.cpp b/glretrace_main.cpp
new file mode 100644
index 00000000..1f3e594c
--- /dev/null
+++ b/glretrace_main.cpp
@@ -0,0 +1,299 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+
+#include "image.hpp"
+#include "retrace.hpp"
+#include "glproc.hpp"
+#include "glretrace.hpp"
+
+
+namespace glretrace {
+
+bool double_buffer = false;
+bool insideGlBeginEnd = false;
+Trace::Parser parser;
+glws::WindowSystem *ws = NULL;
+glws::Visual *visual = NULL;
+glws::Drawable *drawable = NULL;
+glws::Context *context = NULL;
+
+int window_width = 256, window_height = 256;
+bool reshape_window = false;
+
+unsigned frame = 0;
+long long startTime = 0;
+bool wait = false;
+
+bool benchmark = false;
+const char *compare_prefix = NULL;
+const char *snapshot_prefix = NULL;
+
+unsigned dump_state = ~0;
+
+void
+checkGlError(void) {
+ if (benchmark || insideGlBeginEnd) {
+ return;
+ }
+
+ GLenum error = glGetError();
+ if (error == GL_NO_ERROR) {
+ return;
+ }
+
+ std::cerr << "warning: glGetError() = ";
+ switch (error) {
+ case GL_INVALID_ENUM:
+ std::cerr << "GL_INVALID_ENUM";
+ break;
+ case GL_INVALID_VALUE:
+ std::cerr << "GL_INVALID_VALUE";
+ break;
+ case GL_INVALID_OPERATION:
+ std::cerr << "GL_INVALID_OPERATION";
+ break;
+ case GL_STACK_OVERFLOW:
+ std::cerr << "GL_STACK_OVERFLOW";
+ break;
+ case GL_STACK_UNDERFLOW:
+ std::cerr << "GL_STACK_UNDERFLOW";
+ break;
+ case GL_OUT_OF_MEMORY:
+ std::cerr << "GL_OUT_OF_MEMORY";
+ break;
+ case GL_INVALID_FRAMEBUFFER_OPERATION:
+ std::cerr << "GL_INVALID_FRAMEBUFFER_OPERATION";
+ break;
+ case GL_TABLE_TOO_LARGE:
+ std::cerr << "GL_TABLE_TOO_LARGE";
+ break;
+ default:
+ std::cerr << error;
+ break;
+ }
+ std::cerr << "\n";
+}
+
+
+static void snapshot(Image::Image &image) {
+ GLint drawbuffer = double_buffer ? GL_BACK : GL_FRONT;
+ GLint readbuffer = double_buffer ? GL_BACK : GL_FRONT;
+ glGetIntegerv(GL_READ_BUFFER, &drawbuffer);
+ glGetIntegerv(GL_READ_BUFFER, &readbuffer);
+ glReadBuffer(drawbuffer);
+ glReadPixels(0, 0, image.width, image.height, GL_RGBA, GL_UNSIGNED_BYTE, image.pixels);
+ checkGlError();
+ glReadBuffer(readbuffer);
+}
+
+
+static void frame_complete(void) {
+ ++frame;
+
+ if (!reshape_window && (snapshot_prefix || compare_prefix)) {
+ Image::Image *ref = NULL;
+ if (compare_prefix) {
+ char filename[PATH_MAX];
+ snprintf(filename, sizeof filename, "%s%04u.png", compare_prefix, frame);
+ ref = Image::readPNG(filename);
+ if (!ref) {
+ return;
+ }
+ if (retrace::verbosity >= 0)
+ std::cout << "Read " << filename << "\n";
+ }
+
+ Image::Image src(window_width, window_height, true);
+ snapshot(src);
+
+ if (snapshot_prefix) {
+ char filename[PATH_MAX];
+ snprintf(filename, sizeof filename, "%s%04u.png", snapshot_prefix, frame);
+ if (src.writePNG(filename) && retrace::verbosity >= 0) {
+ std::cout << "Wrote " << filename << "\n";
+ }
+ }
+
+ if (ref) {
+ std::cout << "Frame " << frame << " average precision of " << src.compare(*ref) << " bits\n";
+ delete ref;
+ }
+ }
+
+ if (reshape_window) {
+ // XXX: doesn't quite work
+ drawable->resize(window_width, window_height);
+ reshape_window = false;
+ }
+
+ ws->processEvents();
+}
+
+
+static void display(void) {
+ Trace::Call *call;
+
+ while ((call = parser.parse_call())) {
+ const std::string &name = call->name();
+
+ if ((name[0] == 'w' && name[1] == 'g' && name[2] == 'l') ||
+ (name[0] == 'g' && name[1] == 'l' && name[2] == 'X')) {
+ // XXX: We ignore the majority of the OS-specific calls for now
+ if (name == "glXSwapBuffers" ||
+ name == "wglSwapBuffers") {
+ if (retrace::verbosity >= 1) {
+ std::cout << *call;
+ std::cout.flush();
+ };
+ frame_complete();
+ if (double_buffer)
+ drawable->swapBuffers();
+ else
+ glFlush();
+ } else if (name == "glXMakeCurrent" ||
+ name == "wglMakeCurrent") {
+ glFlush();
+ if (!double_buffer) {
+ frame_complete();
+ }
+ } else {
+ continue;
+ }
+ }
+
+ if (name == "glFlush") {
+ glFlush();
+ if (!double_buffer) {
+ frame_complete();
+ }
+ }
+
+ retrace::retrace_call(*call);
+
+ if (!insideGlBeginEnd && call->no >= dump_state) {
+ state_dump(std::cout);
+ exit(0);
+ }
+
+ delete call;
+ }
+
+ // Reached the end of trace
+ glFlush();
+
+ long long endTime = OS::GetTime();
+ float timeInterval = (endTime - startTime) * 1.0E-6;
+
+ if (retrace::verbosity >= -1) {
+ std::cout <<
+ "Rendered " << frame << " frames"
+ " in " << timeInterval << " secs,"
+ " average of " << (frame/timeInterval) << " fps\n";
+ }
+
+ if (wait) {
+ while (ws->processEvents()) {}
+ } else {
+ exit(0);
+ }
+}
+
+
+static void usage(void) {
+ std::cout <<
+ "Usage: glretrace [OPTION] TRACE\n"
+ "Replay TRACE.\n"
+ "\n"
+ " -b benchmark (no glgeterror; no messages)\n"
+ " -c PREFIX compare against snapshots\n"
+ " -db use a double buffer visual\n"
+ " -s PREFIX take snapshots\n"
+ " -v verbose output\n"
+ " -D CALLNO dump state at specific call no\n"
+ " -w wait on final frame\n";
+}
+
+extern "C"
+int main(int argc, char **argv)
+{
+
+ int i;
+ for (i = 1; i < argc; ++i) {
+ const char *arg = argv[i];
+
+ if (arg[0] != '-') {
+ break;
+ }
+
+ if (!strcmp(arg, "--")) {
+ break;
+ } else if (!strcmp(arg, "-b")) {
+ benchmark = true;
+ retrace::verbosity = -1;
+ } else if (!strcmp(arg, "-c")) {
+ compare_prefix = argv[++i];
+ } else if (!strcmp(arg, "-D")) {
+ dump_state = atoi(argv[++i]);
+ retrace::verbosity = -2;
+ } else if (!strcmp(arg, "-db")) {
+ double_buffer = true;
+ } else if (!strcmp(arg, "--help")) {
+ usage();
+ return 0;
+ } else if (!strcmp(arg, "-s")) {
+ snapshot_prefix = argv[++i];
+ } else if (!strcmp(arg, "-v")) {
+ ++retrace::verbosity;
+ } else if (!strcmp(arg, "-w")) {
+ wait = true;
+ } else {
+ std::cerr << "error: unknown option " << arg << "\n";
+ usage();
+ return 1;
+ }
+ }
+
+ ws = glws::createNativeWindowSystem();
+ visual = ws->createVisual(double_buffer);
+ drawable = ws->createDrawable(visual);
+ drawable->resize(window_width, window_height);
+ context = ws->createContext(visual);
+ ws->makeCurrent(drawable, context);
+
+ for ( ; i < argc; ++i) {
+ if (parser.open(argv[i])) {
+ startTime = OS::GetTime();
+ display();
+ parser.close();
+ }
+ }
+
+ return 0;
+}
+
+} /* namespace glretrace */
diff --git a/glstate.py b/glstate.py
index d46cf607..82f8b9f0 100644
--- a/glstate.py
+++ b/glstate.py
@@ -2958,7 +2958,7 @@ class StateDumper:
print '#include "json.hpp"'
print '#include "glimports.hpp"'
print '#include "glproc.hpp"'
- print '#include "glstate.hpp"'
+ print '#include "glretrace.hpp"'
print
print 'static void'
@@ -3146,7 +3146,7 @@ writeTextureImage(JSONWriter &json, GLenum target, GLint level)
print '}'
print
- print 'void state_dump(std::ostream &os)'
+ print 'void glretrace::state_dump(std::ostream &os)'
print '{'
print ' JSONWriter json(os);'
self.dump_parameters()
diff --git a/glxapi.py b/glxapi.py
index 7000b149..f96533b5 100644
--- a/glxapi.py
+++ b/glxapi.py
@@ -58,7 +58,7 @@ XVisualInfo = Struct("XVisualInfo", [
(Int, "bits_per_rgb"),
])
-Bool_ = Enum("Bool", [
+Bool_ = FakeEnum(Int, [
"False",
"True",
])
diff --git a/glstate.hpp b/retrace.cpp
index 521830b2..e5089a72 100644
--- a/glstate.hpp
+++ b/retrace.cpp
@@ -23,11 +23,14 @@
*
**************************************************************************/
-#ifndef _GLSTATE_HPP_
-#define _GLSTATE_HPP_
-#include <ostream>
+#include "retrace.hpp"
-void state_dump(std::ostream &os);
-#endif /* _GLSTATE_HPP_ */
+namespace retrace {
+
+
+int verbosity = 0;
+
+
+} /* namespace retrace */
diff --git a/retrace.hpp b/retrace.hpp
index c87fc946..916cf382 100644
--- a/retrace.hpp
+++ b/retrace.hpp
@@ -28,6 +28,9 @@
#include <map>
+#include "trace_model.hpp"
+
+
namespace retrace {
@@ -73,6 +76,15 @@ public:
};
+/**
+ * Output verbosity when retracing files.
+ */
+extern int verbosity;
+
+
+bool retrace_call(Trace::Call &call);
+
+
} /* namespace retrace */
#endif /* _RETRACE_HPP_ */
diff --git a/retrace.py b/retrace.py
index 1cdb10a8..7fcae527 100644
--- a/retrace.py
+++ b/retrace.py
@@ -99,7 +99,7 @@ class ValueExtractor(stdapi.Visitor):
def visit_handle(self, handle, lvalue, rvalue):
self.visit(handle.type, lvalue, handle_entry(handle, rvalue));
- print ' if (verbosity >= 2)'
+ print ' if (retrace::verbosity >= 2)'
print ' std::cout << "%s " << static_cast<%s>(%s) << " <- " << %s << "\\n";' % (handle.name, handle.type, rvalue, lvalue)
def visit_blob(self, blob, lvalue, rvalue):
@@ -150,7 +150,7 @@ class ValueWrapper(stdapi.Visitor):
rvalue = "static_cast<%s>(%s)" % (handle.type, rvalue)
entry = handle_entry(handle, rvalue)
print " %s = %s;" % (entry, lvalue)
- print ' if (verbosity >= 2)'
+ print ' if (retrace::verbosity >= 2)'
print ' std::cout << "{handle.name} " << {rvalue} << " -> " << {lvalue} << "\\n";'.format(**locals())
else:
i = '__h' + handle.id
@@ -159,7 +159,7 @@ class ValueWrapper(stdapi.Visitor):
entry = handle_entry(handle, rvalue)
print ' for({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals())
print ' {entry} = {lvalue};'.format(**locals())
- print ' if (verbosity >= 2)'
+ print ' if (retrace::verbosity >= 2)'
print ' std::cout << "{handle.name} " << ({rvalue}) << " -> " << ({lvalue}) << "\\n";'.format(**locals())
print ' }'
@@ -212,7 +212,7 @@ class Retracer:
print ' // FIXME: result'
def fail_function(self, function):
- print ' if (verbosity >= 0)'
+ print ' if (retrace::verbosity >= 0)'
print ' std::cerr << "warning: unsupported call %s\\n";' % function.name
print ' return;'
@@ -237,10 +237,10 @@ class Retracer:
if function.sideeffects:
self.retrace_function(function)
- print 'static bool retrace_call(Trace::Call &call) {'
+ print 'bool retrace::retrace_call(Trace::Call &call) {'
print ' const char *name = call.name().c_str();'
print
- print ' if (verbosity >= 1) {'
+ print ' if (retrace::verbosity >= 1) {'
print ' std::cout << call;'
print ' std::cout.flush();'
print ' };'
@@ -256,7 +256,7 @@ class Retracer:
string_switch('name', func_dict.keys(), handle_case)
- print ' if (verbosity >= 0)'
+ print ' if (retrace::verbosity >= 0)'
print ' std::cerr << "warning: unknown call " << call.name() << "\\n";'
print ' return false;'
print '}'
@@ -282,8 +282,5 @@ class Retracer:
handle_names.add(handle.name)
print
- print 'int verbosity = 0;'
- print
-
self.retrace_functions(api.functions)
diff --git a/trace_model.hpp b/trace_model.hpp
index 54c142e0..6adf4c2a 100644
--- a/trace_model.hpp
+++ b/trace_model.hpp
@@ -114,8 +114,6 @@ public:
};
-#undef Bool
-
class Bool : public Value
{
public: