From df20f3357343ffec18c3f23ceded1774adb4904c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 11 Nov 2012 00:58:21 +0000 Subject: [PATCH] gl: Handle ClearBufferData blobs. --- helpers/glsize.hpp | 24 ++++++++++++++++++++---- specs/glapi.py | 8 ++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/helpers/glsize.hpp b/helpers/glsize.hpp index 9d39a3b..fe267e1 100644 --- a/helpers/glsize.hpp +++ b/helpers/glsize.hpp @@ -617,12 +617,12 @@ _align(X x, Y y) { return (x + (y - 1)) & ~(y - 1); } -static inline size_t -_gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLboolean has_unpack_subimage) { +static inline void +_gl_format_size(GLenum format, GLenum type, + unsigned & bits_per_element, unsigned & bits_per_pixel) +{ unsigned num_channels = _gl_format_channels(format); - unsigned bits_per_element; - unsigned bits_per_pixel; switch (type) { case GL_BITMAP: bits_per_pixel = bits_per_element = 1; @@ -677,6 +677,22 @@ _gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsize bits_per_pixel = bits_per_element = 0; break; } +} + +static inline size_t +_glClearBufferData_size(GLenum format, GLenum type) { + unsigned bits_per_element; + unsigned bits_per_pixel; + _gl_format_size(format, type, bits_per_element, bits_per_pixel); + return (bits_per_pixel + 7)/8; +} + +static inline size_t +_gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLboolean has_unpack_subimage) { + + unsigned bits_per_element; + unsigned bits_per_pixel; + _gl_format_size(format, type, bits_per_element, bits_per_pixel); GLint alignment = 4; GLint row_length = 0; diff --git a/specs/glapi.py b/specs/glapi.py index 9378721..257fe2e 100644 --- a/specs/glapi.py +++ b/specs/glapi.py @@ -1357,10 +1357,10 @@ glapi.addFunctions([ GlFunction(Void, "glGetObjectPtrLabel", [(OpaquePointer(Const(Void)), "ptr"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "label")], sideeffects=False), # GL_ARB_clear_buffer_object - GlFunction(Void, "glClearBufferData", [(GLenum, "target"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (OpaqueArray(Const(Void), "_glClearBufferData_size(format, type)"), "data")]), - GlFunction(Void, "glClearBufferSubData", [(GLenum, "target"), (GLenum, "internalformat"), (GLintptr, "offset"), (GLsizeiptr, "size"), (GLenum, "format"), (GLenum, "type"), (OpaqueArray(Const(Void), "_glClearBufferSubData_size(format, type)"), "data")]), - GlFunction(Void, "glClearNamedBufferDataEXT", [(GLbuffer, "buffer"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (OpaqueArray(Const(Void), "_glClearNamedBufferDataEXT_size(format, type)"), "data")]), - GlFunction(Void, "glClearNamedBufferSubDataEXT", [(GLbuffer, "buffer"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (GLsizeiptr, "offset"), (GLsizeiptr, "size"), (OpaqueArray(Const(Void), "_glClearNamedBufferSubDataEXT_size(format, type)"), "data")]), + GlFunction(Void, "glClearBufferData", [(GLenum, "target"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(Void), "_glClearBufferData_size(format, type)"), "data")]), + GlFunction(Void, "glClearBufferSubData", [(GLenum, "target"), (GLenum, "internalformat"), (GLintptr, "offset"), (GLsizeiptr, "size"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(Void), "_glClearBufferData_size(format, type)"), "data")]), + GlFunction(Void, "glClearNamedBufferDataEXT", [(GLbuffer, "buffer"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(Void), "_glClearBufferData_size(format, type)"), "data")]), + GlFunction(Void, "glClearNamedBufferSubDataEXT", [(GLbuffer, "buffer"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (GLsizeiptr, "offset"), (GLsizeiptr, "size"), (Blob(Const(Void), "_glClearBufferData_size(format, type)"), "data")]), # GL_ARB_compute_shader GlFunction(Void, "glDispatchCompute", [(GLuint, "num_groups_x"), (GLuint, "num_groups_y"), (GLuint, "num_groups_z")]), -- 2.43.0