summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-05-08 22:48:43 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-05-10 03:25:25 -0700
commit898d6e6da517052271a3f9828ee966b56075efe3 (patch)
tree04abc3bfa36659a8e3c057f33ca1ca30dd3f8d0a
parentdddc5b8534d68b5315d9b9aaafd45d8a79e36198 (diff)
gltrace: Only check primitive restart index if supported.
-rw-r--r--helpers/glfeatures.cpp5
-rw-r--r--helpers/glfeatures.hpp1
-rw-r--r--wrappers/gltrace.py2
-rw-r--r--wrappers/gltrace_arrays.cpp25
-rw-r--r--wrappers/gltrace_arrays.hpp13
5 files changed, 29 insertions, 17 deletions
diff --git a/helpers/glfeatures.cpp b/helpers/glfeatures.cpp
index eef92089..033d823e 100644
--- a/helpers/glfeatures.cpp
+++ b/helpers/glfeatures.cpp
@@ -367,6 +367,9 @@ Features::load(const Profile & profile, const Extensions & ext)
query_buffer_object = profile.versionGreaterOrEqual(4, 4) ||
ext.has("GL_ARB_query_buffer_object") ||
ext.has("GL_AMD_query_buffer_object");
+
+ primitive_restart = profile.versionGreaterOrEqual(3, 1) ||
+ ext.has("GL_NV_primitive_restart");
} else {
texture_3d = 1;
@@ -386,6 +389,8 @@ Features::load(const Profile & profile, const Extensions & ext)
read_framebuffer_object = 0;
query_buffer_object = 0;
+
+ primitive_restart = 0;
}
}
diff --git a/helpers/glfeatures.hpp b/helpers/glfeatures.hpp
index c9fc796e..8aa0c921 100644
--- a/helpers/glfeatures.hpp
+++ b/helpers/glfeatures.hpp
@@ -161,6 +161,7 @@ struct Features
unsigned framebuffer_object:1;
unsigned read_framebuffer_object:1;
unsigned query_buffer_object:1;
+ unsigned primitive_restart:1;
Features(void);
diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py
index 065f7608..fb08436f 100644
--- a/wrappers/gltrace.py
+++ b/wrappers/gltrace.py
@@ -491,7 +491,7 @@ class GlTracer(Tracer):
continue
print r' _params.%s = %s;' % (paramsMember, arg.name)
- print ' GLuint _count = _glDraw_count(_params);'
+ print ' GLuint _count = _glDraw_count(_ctx, _params);'
# Some apps, in particular Quake3, can tell the driver to lock more
# vertices than those actually required for the draw call.
print ' if (_checkLockArraysEXT) {'
diff --git a/wrappers/gltrace_arrays.cpp b/wrappers/gltrace_arrays.cpp
index 8986131d..30d70220 100644
--- a/wrappers/gltrace_arrays.cpp
+++ b/wrappers/gltrace_arrays.cpp
@@ -25,13 +25,14 @@
#include "gltrace_arrays.hpp"
+#include "gltrace.hpp"
/* FIXME take in consideration instancing */
GLuint
-_glDraw_count(const DrawArraysParams &params)
+_glDraw_count(gltrace::Context *ctx, const DrawArraysParams &params)
{
if (!params.count) {
return 0;
@@ -41,7 +42,7 @@ _glDraw_count(const DrawArraysParams &params)
GLuint
-_glDraw_count(const DrawElementsParams &params)
+_glDraw_count(gltrace::Context *ctx, const DrawElementsParams &params)
{
if (params.end < params.start ||
params.count <= 0) {
@@ -82,13 +83,13 @@ _glDraw_count(const DrawElementsParams &params)
GLuint maxindex = 0;
- GLboolean restart_enabled = _glIsEnabled(GL_PRIMITIVE_RESTART);
- while ((_glGetError() == GL_INVALID_ENUM))
- ;
-
+ GLboolean restart_enabled = GL_FALSE;
GLuint restart_index = 0;
- if (restart_enabled) {
- restart_index = (GLuint)_glGetInteger(GL_PRIMITIVE_RESTART_INDEX);
+ if (ctx->features.primitive_restart) {
+ _glIsEnabled(GL_PRIMITIVE_RESTART);
+ if (restart_enabled) {
+ restart_index = (GLuint)_glGetInteger(GL_PRIMITIVE_RESTART_INDEX);
+ }
}
GLsizei i;
@@ -140,7 +141,7 @@ _glDraw_count(const DrawElementsParams &params)
GLuint
-_glDraw_count(const MultiDrawArraysParams &params)
+_glDraw_count(gltrace::Context *ctx, const MultiDrawArraysParams &params)
{
GLuint _count = 0;
for (GLsizei draw = 0; draw < params.drawcount; ++draw) {
@@ -153,7 +154,7 @@ _glDraw_count(const MultiDrawArraysParams &params)
}
params_draw.instancecount = params.instancecount;
params_draw.baseinstance = params.baseinstance;
- GLuint _count_draw = _glDraw_count(params_draw);
+ GLuint _count_draw = _glDraw_count(ctx, params_draw);
_count = std::max(_count, _count_draw);
}
return _count;
@@ -161,7 +162,7 @@ _glDraw_count(const MultiDrawArraysParams &params)
GLuint
-_glDraw_count(const MultiDrawElementsParams &params)
+_glDraw_count(gltrace::Context *ctx, const MultiDrawElementsParams &params)
{
GLuint _count = 0;
for (GLsizei draw = 0; draw < params.drawcount; ++draw) {
@@ -178,7 +179,7 @@ _glDraw_count(const MultiDrawElementsParams &params)
}
params_draw.instancecount = params.instancecount;
params_draw.baseinstance = params.baseinstance;
- GLuint _count_draw = _glDraw_count(params_draw);
+ GLuint _count_draw = _glDraw_count(ctx, params_draw);
_count = std::max(_count, _count_draw);
}
return _count;
diff --git a/wrappers/gltrace_arrays.hpp b/wrappers/gltrace_arrays.hpp
index 2ecf893c..9b476f19 100644
--- a/wrappers/gltrace_arrays.hpp
+++ b/wrappers/gltrace_arrays.hpp
@@ -30,6 +30,11 @@
#include "glsize.hpp"
+namespace gltrace {
+ class Context;
+};
+
+
/*
* TODO: Unify all draw params structure into a single structure.
*/
@@ -80,13 +85,13 @@ struct MultiDrawElementsParams
GLuint
-_glDraw_count(const DrawArraysParams &params);
+_glDraw_count(gltrace::Context *ctx, const DrawArraysParams &params);
GLuint
-_glDraw_count(const DrawElementsParams &params);
+_glDraw_count(gltrace::Context *ctx, const DrawElementsParams &params);
GLuint
-_glDraw_count(const MultiDrawArraysParams &params);
+_glDraw_count(gltrace::Context *ctx, const MultiDrawArraysParams &params);
GLuint
-_glDraw_count(const MultiDrawElementsParams &params);
+_glDraw_count(gltrace::Context *ctx, const MultiDrawElementsParams &params);