Such as GL_COMPRESSED_TEXTURE_FORMATS.
#define _glVertexAttribPointerARB_size(size, type, normalized, stride, count) _glArrayPointer_size(size, type, stride, count)
#define _glVertexAttribPointerNV_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
+/**
+ * Same as glGetIntegerv, but passing the result in the return value.
+ */
+static inline GLint
+_glGetInteger(GLenum pname) {
+ GLint param = 0;
+ _glGetIntegerv(pname, ¶m);
+ return param;
+}
+
static inline GLint
_element_array_buffer_binding(void) {
- GLint element_array_buffer = 0;
- _glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &element_array_buffer);
- return element_array_buffer;
+ return _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);
}
static inline GLuint
elem_type = self.inflector.reduced_type(array.type)
inflection = self.inflector.inflect(array.type)
assert inflection.endswith('v')
- print ' %s %s[%s + 1];' % (elem_type, temp_name, array.length)
- print ' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array.length, temp_name)
- print ' %s[%s] = (%s)0xdeadc0de;' % (temp_name, array.length, elem_type)
+ array_length = array.length
+ if array_length.isdigit():
+ # Static integer length
+ print ' %s %s[%s + 1];' % (elem_type, temp_name, array_length)
+ else:
+ # Put the length in a variable to avoid recomputing it every time
+ print ' size_t _%s_length = %s;' % (temp_name, array_length)
+ array_length = '_%s_length' % temp_name
+ # Allocate a dynamic sized array
+ print ' %s *%s = _allocator.alloc<%s>(%s + 1);' % (elem_type, temp_name, elem_type, array_length)
+ print ' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array_length, temp_name)
+ print ' %s[%s] = (%s)0xdeadc0de;' % (temp_name, array_length, elem_type)
print ' %s(%s, %s);' % (inflection + self.suffix, ', '.join(args), temp_name)
# Simple buffer overflow detection
- print ' assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array.length, elem_type)
+ print ' assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array_length, elem_type)
return temp_name
def visitOpaque(self, pointer, args):
print '#include <string.h>'
print
print '#include "json.hpp"'
+ print '#include "scoped_allocator.hpp"'
print '#include "glproc.hpp"'
print '#include "glsize.hpp"'
print '#include "glstate.hpp"'
print 'void dumpParameters(JSONWriter &json, Context &context)'
print '{'
+ print ' ScopedAllocator _allocator;'
+ print ' (void)_allocator;'
+ print
print ' json.beginMember("parameters");'
print ' json.beginObject();'
("glGetTexLevelParameter", I, 1, "GL_TEXTURE_COMPRESSED_IMAGE_SIZE"), # 0x86A0
("glGetTexLevelParameter", B, 1, "GL_TEXTURE_COMPRESSED"), # 0x86A1
("glGet", I, 1, "GL_NUM_COMPRESSED_TEXTURE_FORMATS"), # 0x86A2
- #XXX: the list is GL_NUM_COMPRESSED_TEXTURES
- #("glGet", E, 1, "GL_COMPRESSED_TEXTURE_FORMATS"), # 0x86A3
+ ("glGet", E, '_glGetInteger(GL_NUM_COMPRESSED_TEXTURE_FORMATS)', "GL_COMPRESSED_TEXTURE_FORMATS"), # 0x86A3
("glGet", I, 1, "GL_MAX_VERTEX_UNITS_ARB"), # 0x86A4
("glGet", I, 1, "GL_ACTIVE_VERTEX_UNITS_ARB"), # 0x86A5
("glGet", B, 1, "GL_WEIGHT_SUM_UNITY_ARB"), # 0x86A6
print ' switch (pname) {'
for function, type, count, name in glparams.parameters:
if type is not None:
- print ' case %s: return %u;' % (name, count)
- print ' case GL_COMPRESSED_TEXTURE_FORMATS: {'
- print ' GLint num_compressed_texture_formats = 0;'
- print ' _glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num_compressed_texture_formats);'
- print ' return num_compressed_texture_formats;'
- print ' }'
+ print ' case %s: return %s;' % (name, count)
print ' default:'
print r' os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);'
print ' return 1;'