From edc099cff55a6a3f9ad191acfbc8cc39f36228db Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Wed, 30 Dec 2015 23:04:16 +0000 Subject: gltrace: Honour range in glDrawRangeElement*. Based from Roland Scheidegger's patch on https://bugs.freedesktop.org/show_bug.cgi?id=80419#c94 Fixes https://github.com/apitrace/apitrace/issues/407#issuecomment-167866502 --- helpers/glsize.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'helpers') diff --git a/helpers/glsize.hpp b/helpers/glsize.hpp index dbac9772..bc74d875 100644 --- a/helpers/glsize.hpp +++ b/helpers/glsize.hpp @@ -494,10 +494,19 @@ _glDrawElementsBaseVertex_count(GLsizei count, GLenum type, const GLvoid *indice return maxindex + 1; } -#define _glDrawRangeElementsBaseVertex_count(start, end, count, type, indices, basevertex) _glDrawElementsBaseVertex_count(count, type, indices, basevertex) +static inline GLuint +_glDrawRangeElementsBaseVertex_count(GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex) +{ + if (end < start || + count < 0) { + return 0; + } + + return end + basevertex + 1; +} #define _glDrawElements_count(count, type, indices) _glDrawElementsBaseVertex_count(count, type, indices, 0) -#define _glDrawRangeElements_count(start, end, count, type, indices) _glDrawElements_count(count, type, indices) +#define _glDrawRangeElements_count(start, end, count, type, indices) _glDrawRangeElementsBaseVertex_count(start, end, count, type, indices, 0) #define _glDrawRangeElementsEXT_count _glDrawRangeElements_count /* FIXME take in consideration instancing */ -- cgit v1.2.3