diff options
-rw-r--r-- | common/trace_parser_flags.cpp | 8 | ||||
-rw-r--r-- | helpers/glfeatures.cpp | 8 | ||||
-rw-r--r-- | helpers/glfeatures.hpp | 3 | ||||
-rw-r--r-- | retrace/glretrace.py | 57 | ||||
-rw-r--r-- | specs/glapi.py | 28 | ||||
-rw-r--r-- | wrappers/gltrace.py | 14 |
6 files changed, 74 insertions, 44 deletions
diff --git a/common/trace_parser_flags.cpp b/common/trace_parser_flags.cpp index d4a07257..98720406 100644 --- a/common/trace_parser_flags.cpp +++ b/common/trace_parser_flags.cpp @@ -338,14 +338,6 @@ callFlagTable[] = { { "glGetProgramivARB", CALL_FLAG_NO_SIDE_EFFECTS }, { "glGetProgramivNV", CALL_FLAG_NO_SIDE_EFFECTS }, { "glGetQueryIndexediv", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjecti64v", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjecti64vEXT", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjectiv", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjectivARB", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjectui64v", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjectui64vEXT", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjectuiv", CALL_FLAG_NO_SIDE_EFFECTS }, - { "glGetQueryObjectuivARB", CALL_FLAG_NO_SIDE_EFFECTS }, { "glGetQueryiv", CALL_FLAG_NO_SIDE_EFFECTS }, { "glGetQueryivARB", CALL_FLAG_NO_SIDE_EFFECTS }, { "glGetRenderbufferParameteriv", CALL_FLAG_NO_SIDE_EFFECTS }, diff --git a/helpers/glfeatures.cpp b/helpers/glfeatures.cpp index 39531e71..e862b89e 100644 --- a/helpers/glfeatures.cpp +++ b/helpers/glfeatures.cpp @@ -356,6 +356,14 @@ Features::load(const Profile & profile, const Extensions & ext) ext.has("GL_ARB_pixel_buffer_object") || ext.has("GL_EXT_pixel_buffer_object"); } + + if (profile.desktop()) { + query_buffer_object = profile.versionGreaterOrEqual(4, 4) || + ext.has("GL_ARB_query_buffer_object") || + ext.has("GL_AMD_query_buffer_object"); + } else { + query_buffer_object = 0; + } } diff --git a/helpers/glfeatures.hpp b/helpers/glfeatures.hpp index 916004c8..3ac176d3 100644 --- a/helpers/glfeatures.hpp +++ b/helpers/glfeatures.hpp @@ -69,7 +69,7 @@ struct Profile { } inline bool - desktop(void) { + desktop(void) const { return api == API_GL; } @@ -156,6 +156,7 @@ struct Features unsigned ARB_program_interface_query:1; unsigned pixel_buffer_object:1; + unsigned query_buffer_object:1; Features(void); diff --git a/retrace/glretrace.py b/retrace/glretrace.py index 0cb703e1..b916c1ad 100644 --- a/retrace/glretrace.py +++ b/retrace/glretrace.py @@ -43,9 +43,11 @@ class GlRetracer(Retracer): # Ensure pack function have side effects abort = False for function in api.getAllFunctions(): - if not function.sideeffects and self.pack_function_regex.match(function.name): - sys.stderr.write('error: function %s must have sideeffects\n' % function.name) - abort = True + if not function.sideeffects: + if self.pack_function_regex.match(function.name) or \ + function.name.startswith('glGetQueryObject'): + sys.stderr.write('error: function %s must have sideeffects\n' % function.name) + abort = True if abort: sys.exit(1) @@ -125,6 +127,24 @@ class GlRetracer(Retracer): is_draw_indirect = self.draw_indirect_function_regex.match(function.name) is not None is_misc_draw = self.misc_draw_function_regex.match(function.name) + if function.name.startswith('gl') and not function.name.startswith('glX'): + # The Windows OpenGL runtime will skip calls when there's no + # context bound to the current context, but this might cause + # crashes on other systems, particularly with NVIDIA Linux drivers. + print r' glretrace::Context *currentContext = glretrace::getCurrentContext();' + print r' if (!currentContext) {' + print r' if (retrace::debug) {' + print r' retrace::warning(call) << "no current context\n";' + print r' }' + print r'#ifndef _WIN32' + print r' return;' + print r'#endif' + print r' }' + + print r' if (retrace::markers) {' + print r' glretrace::insertCallMarker(call, currentContext);' + print r' }' + # For backwards compatibility with old traces where non VBO drawing was supported if (is_array_pointer or is_draw_arrays or is_draw_elements) and not is_draw_indirect: print ' if (retrace::parser->getVersion() < 1) {' @@ -153,6 +173,16 @@ class GlRetracer(Retracer): print ' return;' print ' }' + # When no query buffer object is bound, glGetQueryObject is a no-op. + if function.name.startswith('glGetQueryObject'): + print r' GLint _query_buffer = 0;' + print r' if (currentContext->features().query_buffer_object) {' + print r' glGetIntegerv(GL_QUERY_BUFFER_BINDING, &_query_buffer);' + print r' }' + print r' if (!_query_buffer) {' + print r' return;' + print r' }' + # Pre-snapshots if self.bind_framebuffer_function_regex.match(function.name): print ' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);' @@ -197,24 +227,6 @@ class GlRetracer(Retracer): # then just blit to the drawable without ever calling glViewport. print ' glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));' - if function.name.startswith('gl') and not function.name.startswith('glX'): - # The Windows OpenGL runtime will skip calls when there's no - # context bound to the current context, but this might cause - # crashes on other systems, particularly with NVIDIA Linux drivers. - print r' glretrace::Context *currentContext = glretrace::getCurrentContext();' - print r' if (!currentContext) {' - print r' if (retrace::debug) {' - print r' retrace::warning(call) << "no current context\n";' - print r' }' - print r'#ifndef _WIN32' - print r' return;' - print r'#endif' - print r' }' - - print r' if (retrace::markers) {' - print r' glretrace::insertCallMarker(call, currentContext);' - print r' }' - if function.name == "glEnd": print r' if (currentContext) {' print r' currentContext->insideBeginEnd = false;' @@ -500,6 +512,9 @@ class GlRetracer(Retracer): assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque)) print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue) return + if function.name.startswith('glGetQueryObject') and arg.output: + print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue) + return if (arg.type.depends(glapi.GLlocation) or \ arg.type.depends(glapi.GLsubroutine)) \ diff --git a/specs/glapi.py b/specs/glapi.py index 2ab59bd4..7692778a 100644 --- a/specs/glapi.py +++ b/specs/glapi.py @@ -553,8 +553,8 @@ glapi.addFunctions([ GlFunction(Void, "glBeginQuery", [(GLenum, "target"), (GLquery, "id")]), GlFunction(Void, "glEndQuery", [(GLenum, "target")]), GlFunction(Void, "glGetQueryiv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectuiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False), + GlFunction(Void, "glGetQueryObjectiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjectuiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")]), GlFunction(Void, "glBindBuffer", [(GLenum, "target"), (GLbuffer, "buffer")]), GlFunction(Void, "glDeleteBuffers", [(GLsizei, "n"), (Array(Const(GLbuffer), "n"), "buffer")]), GlFunction(Void, "glGenBuffers", [(GLsizei, "n"), Out(Array(GLbuffer, "n"), "buffer")]), @@ -903,10 +903,10 @@ glapi.addFunctions([ GlFunction(Void, "glEndQueryANGLE", [(GLenum, "target")]), GlFunction(Void, "glQueryCounterANGLE", [(GLquery, "id"), (GLenum, "target")]), GlFunction(Void, "glGetQueryivANGLE", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectivANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectuivANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjecti64vANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectui64vANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64, "_gl_param_size(pname)"), "params")], sideeffects=False), + GlFunction(Void, "glGetQueryObjectivANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjectuivANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjecti64vANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjectui64vANGLE", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64, "_gl_param_size(pname)"), "params")]), # GL_ANGLE_translated_shader_source GlFunction(Void, "glGetTranslatedShaderSourceANGLE", [(GLshader, "shader"), (GLsizei, "bufsize"), Out(Pointer(GLsizei), "length"), OutGlString(GLchar, "length", "source")], sideeffects=False), @@ -1372,8 +1372,8 @@ glapi.addFunctions([ GlFunction(Void, "glBeginQueryARB", [(GLenum, "target"), (GLquery, "id")]), GlFunction(Void, "glEndQueryARB", [(GLenum, "target")]), GlFunction(Void, "glGetQueryivARB", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectuivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False), + GlFunction(Void, "glGetQueryObjectivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjectuivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")]), # GL_ARB_parallel_shader_compile GlFunction(Void, "glMaxShaderCompilerThreadsARB", [(GLuint, "count")]), @@ -1629,8 +1629,8 @@ glapi.addFunctions([ # GL_ARB_timer_query GlFunction(Void, "glQueryCounter", [(GLquery, "id"), (GLenum, "target")]), - GlFunction(Void, "glGetQueryObjecti64v", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectui64v", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64, "_gl_param_size(pname)"), "params")], sideeffects=False), + GlFunction(Void, "glGetQueryObjecti64v", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjectui64v", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64, "_gl_param_size(pname)"), "params")]), # GL_ARB_transform_feedback2 GlFunction(Void, "glBindTransformFeedback", [(GLenum, "target"), (GLfeedback, "id")]), @@ -2336,10 +2336,10 @@ glapi.addFunctions([ GlFunction(Void, "glEndQueryEXT", [(GLenum, "target")]), GlFunction(Void, "glQueryCounterEXT", [(GLquery, "id"), (GLenum, "target")]), GlFunction(Void, "glGetQueryivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectivEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectuivEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjecti64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")], sideeffects=False), - GlFunction(Void, "glGetQueryObjectui64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64, "_gl_param_size(pname)"), "params")], sideeffects=False), + GlFunction(Void, "glGetQueryObjectivEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjectuivEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjecti64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")]), + GlFunction(Void, "glGetQueryObjectui64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64, "_gl_param_size(pname)"), "params")]), # GL_EXT_draw_buffers GlFunction(Void, "glDrawBuffersEXT", [(GLsizei, "n"), (Array(Const(GLenum), "n"), "bufs")]), diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py index a89874f2..ae6f292f 100644 --- a/wrappers/gltrace.py +++ b/wrappers/gltrace.py @@ -943,6 +943,20 @@ class GlTracer(Tracer): print ' }' return + # Recognize offsets instead of pointers when query buffer is bound + if function.name.startswith('glGetQueryObject') and arg.output: + print r' gltrace::Context *_ctx = gltrace::getContext();' + print r' GLint _query_buffer = 0;' + print r' if (_ctx->features.query_buffer_object) {' + print r' _query_buffer = _glGetInteger(GL_QUERY_BUFFER_BINDING);' + print r' }' + print r' if (_query_buffer) {' + print r' trace::localWriter.writePointer((uintptr_t)%s);' % arg.name + print r' } else {' + Tracer.serializeArgValue(self, function, arg) + print r' }' + return + # Several GL state functions take GLenum symbolic names as # integer/floats; so dump the symbolic name whenever possible if function.name.startswith('gl') \ |