diff options
Diffstat (limited to 'mesalib/src/mapi/glapi')
-rw-r--r-- | mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml | 112 | ||||
-rw-r--r-- | mesalib/src/mapi/glapi/gen/gl_enums.py | 6 | ||||
-rw-r--r-- | mesalib/src/mapi/glapi/glapi.h | 11 | ||||
-rw-r--r-- | mesalib/src/mapi/glapi/glapi_getproc.c | 4 | ||||
-rw-r--r-- | mesalib/src/mapi/glapi/glapi_nop.c | 85 | ||||
-rw-r--r-- | mesalib/src/mapi/glapi/glapi_priv.h | 3 |
6 files changed, 182 insertions, 39 deletions
diff --git a/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml b/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml index 2fe1638fd..641e68f71 100644 --- a/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -7,6 +7,110 @@ <enum name="QUERY_TARGET" value="0x82EA"/> <enum name="TEXTURE_BINDING" value="0x82EB"/> + <!-- Buffer object functions --> + + <function name="CreateBuffers" offset="assign"> + <param name="n" type="GLsizei" /> + <param name="buffers" type="GLuint *" /> + </function> + + <function name="NamedBufferStorage" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="size" type="GLsizeiptr" /> + <param name="data" type="const GLvoid *" /> + <param name="flags" type="GLbitfield" /> + </function> + + <function name="NamedBufferData" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="size" type="GLsizeiptr" /> + <param name="data" type="const GLvoid *" /> + <param name="usage" type="GLenum" /> + </function> + + <function name="NamedBufferSubData" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="offset" type="GLintptr" /> + <param name="size" type="GLsizeiptr" /> + <param name="data" type="const GLvoid *" /> + </function> + + <function name="CopyNamedBufferSubData" offset="assign"> + <param name="readBuffer" type="GLuint" /> + <param name="writeBuffer" type="GLuint" /> + <param name="readOffset" type="GLintptr" /> + <param name="writeOffset" type="GLintptr" /> + <param name="size" type="GLsizeiptr" /> + </function> + + <function name="ClearNamedBufferData" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="internalformat" type="GLenum" /> + <param name="format" type="GLenum" /> + <param name="type" type="GLenum" /> + <param name="data" type="const GLvoid *" /> + </function> + + <function name="ClearNamedBufferSubData" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="internalformat" type="GLenum" /> + <param name="offset" type="GLintptr" /> + <param name="size" type="GLsizeiptr" /> + <param name="format" type="GLenum" /> + <param name="type" type="GLenum" /> + <param name="data" type="const GLvoid *" /> + </function> + + <function name="MapNamedBuffer" offset="assign"> + <return type="GLvoid *" /> + <param name="buffer" type="GLuint" /> + <param name="access" type="GLenum" /> + </function> + + <function name="MapNamedBufferRange" offset="assign"> + <return type="GLvoid *" /> + <param name="buffer" type="GLuint" /> + <param name="offset" type="GLintptr" /> + <param name="length" type="GLsizeiptr" /> + <param name="access" type="GLbitfield" /> + </function> + + <function name="UnmapNamedBuffer" offset="assign"> + <return type="GLboolean" /> + <param name="buffer" type="GLuint" /> + </function> + + <function name="FlushMappedNamedBufferRange" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="offset" type="GLintptr" /> + <param name="length" type="GLsizeiptr" /> + </function> + + <function name="GetNamedBufferParameteriv" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="pname" type="GLenum" /> + <param name="params" type="GLint *" /> + </function> + + <function name="GetNamedBufferParameteri64v" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="pname" type="GLenum" /> + <param name="params" type="GLint64 *" /> + </function> + + <function name="GetNamedBufferPointerv" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="pname" type="GLenum" /> + <param name="params" type="GLvoid **" /> + </function> + + <function name="GetNamedBufferSubData" offset="assign"> + <param name="buffer" type="GLuint" /> + <param name="offset" type="GLintptr" /> + <param name="size" type="GLsizeiptr" /> + <param name="data" type="GLvoid *" /> + </function> + <!-- Texture object functions --> <function name="CreateTextures" offset="assign"> @@ -21,6 +125,14 @@ <param name="buffer" type="GLuint" /> </function> + <function name="TextureBufferRange" offset="assign"> + <param name="texture" type="GLuint" /> + <param name="internalformat" type="GLenum" /> + <param name="buffer" type="GLuint" /> + <param name="offset" type="GLintptr" /> + <param name="size" type="GLsizeiptr" /> + </function> + <function name="TextureStorage1D" offset="assign"> <param name="texture" type="GLuint" /> <param name="levels" type="GLsizei" /> diff --git a/mesalib/src/mapi/glapi/gen/gl_enums.py b/mesalib/src/mapi/glapi/gen/gl_enums.py index d61618f4d..f45782df8 100644 --- a/mesalib/src/mapi/glapi/gen/gl_enums.py +++ b/mesalib/src/mapi/glapi/gen/gl_enums.py @@ -157,6 +157,12 @@ _mesa_lookup_prim_by_nr(GLuint nr) string_offsets = {} i = 0; + print '#if defined(__GNUC__)' + print '# define LONGSTRING __extension__' + print '#else' + print '# define LONGSTRING' + print '#endif' + print '' print 'LONGSTRING static const char enum_string_table[] = ' for enum, name in enum_table: print ' "%s\\0"' % (name) diff --git a/mesalib/src/mapi/glapi/glapi.h b/mesalib/src/mapi/glapi/glapi.h index 8d991fb3b..673295bca 100644 --- a/mesalib/src/mapi/glapi/glapi.h +++ b/mesalib/src/mapi/glapi/glapi.h @@ -80,6 +80,9 @@ extern "C" { #endif typedef void (*_glapi_proc)(void); + +typedef void (*_glapi_nop_handler_proc)(const char *name); + struct _glapi_table; @@ -159,6 +162,14 @@ _GLAPI_EXPORT struct _glapi_table * _glapi_create_table_from_handle(void *handle, const char *symbol_prefix); +_GLAPI_EXPORT void +_glapi_set_nop_handler(_glapi_nop_handler_proc func); + +/** Return pointer to new dispatch table filled with no-op functions */ +_GLAPI_EXPORT struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries); + + /** Deprecated function */ _GLAPI_EXPORT unsigned long _glthread_GetID(void); diff --git a/mesalib/src/mapi/glapi/glapi_getproc.c b/mesalib/src/mapi/glapi/glapi_getproc.c index bfde92cf2..524a771ca 100644 --- a/mesalib/src/mapi/glapi/glapi_getproc.c +++ b/mesalib/src/mapi/glapi/glapi_getproc.c @@ -30,6 +30,9 @@ */ +#include <assert.h> +#include <string.h> +#include <stdlib.h> #include "glapi/glapi_priv.h" #include "glapi/glapitable.h" @@ -37,6 +40,7 @@ #define FIRST_DYNAMIC_OFFSET (sizeof(struct _glapi_table) / sizeof(void *)) + /********************************************************************** * Static function management. */ diff --git a/mesalib/src/mapi/glapi/glapi_nop.c b/mesalib/src/mapi/glapi/glapi_nop.c index 628276e93..13db310b3 100644 --- a/mesalib/src/mapi/glapi/glapi_nop.c +++ b/mesalib/src/mapi/glapi/glapi_nop.c @@ -30,14 +30,22 @@ * This file defines a special dispatch table which is loaded with no-op * functions. * - * When there's no current rendering context, calling a GL function like - * glBegin() is a no-op. Apps should never normally do this. So as a - * debugging aid, each of the no-op functions will emit a warning to - * stderr if the MESA_DEBUG or LIBGL_DEBUG env var is set. + * Mesa can register a "no-op handler function" which will be called in + * the event that a no-op function is called. + * + * In the past, the dispatch table was loaded with pointers to a single + * no-op function. But that broke on Windows because the GL entrypoints + * use __stdcall convention. __stdcall means the callee cleans up the + * stack. So one no-op function can't properly clean up the stack. This + * would lead to crashes. + * + * Another benefit of unique no-op functions is we can accurately report + * the function's name in an error message. */ - +#include <stdlib.h> +#include <string.h> #include "glapi/glapi_priv.h" @@ -51,25 +59,32 @@ _glapi_set_warning_func(_glapi_proc func) { } -/* - * When GLAPIENTRY is __stdcall (i.e. Windows), the stack is popped by the - * callee making the number/type of arguments significant. + +/** + * We'll jump though this function pointer whenever a no-op function + * is called. */ -#if defined(_WIN32) || defined(DEBUG) +static _glapi_nop_handler_proc nop_handler = NULL; + + +/** + * Register the no-op handler call-back function. + */ +void +_glapi_set_nop_handler(_glapi_nop_handler_proc func) +{ + nop_handler = func; +} + /** * Called by each of the no-op GL entrypoints. */ -static int -Warn(const char *func) +static void +nop(const char *func) { -#if defined(DEBUG) - if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) { - fprintf(stderr, "GL User Error: gl%s called without a rendering context\n", - func); - } -#endif - return 0; + if (nop_handler) + nop_handler(func); } @@ -79,7 +94,8 @@ Warn(const char *func) static GLint NoOpUnused(void) { - return Warn(" function"); + nop("unused GL entry point"); + return 0; } /* @@ -89,31 +105,28 @@ NoOpUnused(void) #define KEYWORD1_ALT static #define KEYWORD2 GLAPIENTRY #define NAME(func) NoOp##func -#define DISPATCH(func, args, msg) Warn(#func); -#define RETURN_DISPATCH(func, args, msg) Warn(#func); return 0 +#define DISPATCH(func, args, msg) nop(#func); +#define RETURN_DISPATCH(func, args, msg) nop(#func); return 0 /* * Defines for the table of no-op entry points. */ #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name +#define DISPATCH_TABLE_NAME __glapi_noop_table +#define UNUSED_TABLE_NAME __unused_noop_functions + +#include "glapi/glapitemp.h" -#else -static int -NoOpGeneric(void) +/** Return pointer to new dispatch table filled with no-op functions */ +struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries) { - if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) { - fprintf(stderr, "GL User Error: calling GL function without a rendering context\n"); + struct _glapi_table *table = malloc(num_entries * sizeof(_glapi_proc)); + if (table) { + memcpy(table, __glapi_noop_table, + num_entries * sizeof(_glapi_proc)); } - return 0; + return table; } - -#define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric - -#endif - -#define DISPATCH_TABLE_NAME __glapi_noop_table -#define UNUSED_TABLE_NAME __unused_noop_functions - -#include "glapi/glapitemp.h" diff --git a/mesalib/src/mapi/glapi/glapi_priv.h b/mesalib/src/mapi/glapi/glapi_priv.h index d3682603d..50f710edc 100644 --- a/mesalib/src/mapi/glapi/glapi_priv.h +++ b/mesalib/src/mapi/glapi/glapi_priv.h @@ -26,9 +26,6 @@ #ifndef _GLAPI_PRIV_H #define _GLAPI_PRIV_H -#include <stdlib.h> -#include <string.h> -#include <stdio.h> #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> |