From 1a8a230a61289392e8300901dfabd7911799cbc3 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 13 Mar 2010 16:46:19 +0100 Subject: radeon: fix glCopyTex(Sub)Image Fallback to swrast for software renderbuffers --- src/mesa/drivers/dri/radeon/radeon_tex_copy.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c index e57d77e7ef..fb6f2e56af 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c +++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c @@ -59,18 +59,27 @@ do_copy_texsubimage(GLcontext *ctx, } if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { - rrb = radeon_renderbuffer(ctx->ReadBuffer->_DepthBuffer); + if (ctx->ReadBuffer->_DepthBuffer && ctx->ReadBuffer->_DepthBuffer->Wrapped) { + rrb = radeon_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped); + } else { + rrb = radeon_renderbuffer(ctx->ReadBuffer->_DepthBuffer); + } flip_y = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Type == GL_NONE; } else { rrb = radeon_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); flip_y = ctx->ReadBuffer->Attachment[BUFFER_COLOR0].Type == GL_NONE; } + // This is software renderbuffer, fallback to swrast + if (!rrb) { + return GL_FALSE; + } + if (!timg->mt) { radeon_validate_texture_miptree(ctx, &tobj->base); } - assert(rrb && rrb->bo); + assert(rrb->bo); assert(timg->mt); assert(timg->mt->bo); assert(timg->base.Width >= dstx + width); -- cgit v1.2.3 From aba40bd4345e36fb56817673369b275f0e9a9c43 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 13 Mar 2010 17:27:51 +0100 Subject: radeon: fix gl format to mesa format mapping and add GL_BGRA formats --- src/mesa/drivers/dri/radeon/radeon_pixel_read.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/radeon/radeon_pixel_read.c b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c index b180c1d9a5..dadb8002c7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_pixel_read.c +++ b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c @@ -50,22 +50,33 @@ static gl_format gl_format_and_type_to_mesa_format(GLenum format, GLenum type) break; case GL_RGBA: switch (type) { - case GL_UNSIGNED_BYTE: - return MESA_FORMAT_RGBA8888_REV; case GL_FLOAT: return MESA_FORMAT_RGBA_FLOAT32; + case GL_UNSIGNED_SHORT_5_5_5_1: + return MESA_FORMAT_RGBA5551; + case GL_UNSIGNED_INT_8_8_8_8: + return MESA_FORMAT_RGBA8888; + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_INT_8_8_8_8_REV: + return MESA_FORMAT_RGBA8888_REV; + } + break; + case GL_BGRA: + switch (type) { case GL_UNSIGNED_SHORT_4_4_4_4: - return MESA_FORMAT_ARGB4444; + return MESA_FORMAT_ARGB4444_REV; case GL_UNSIGNED_SHORT_4_4_4_4_REV: return MESA_FORMAT_ARGB4444; case GL_UNSIGNED_SHORT_5_5_5_1: - return MESA_FORMAT_RGBA5551; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: return MESA_FORMAT_ARGB1555_REV; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + return MESA_FORMAT_ARGB1555; case GL_UNSIGNED_INT_8_8_8_8: - return MESA_FORMAT_ARGB8888; - case GL_UNSIGNED_INT_8_8_8_8_REV: return MESA_FORMAT_ARGB8888_REV; + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_INT_8_8_8_8_REV: + return MESA_FORMAT_ARGB8888; + } break; } -- cgit v1.2.3 From 18ecf41835059d4506402641833e7911d7de3ec4 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 13 Mar 2010 17:28:33 +0100 Subject: r300: blits for small dst pitch work just fine --- src/mesa/drivers/dri/r300/r300_blit.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index d870c7f852..fa60628a5e 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -582,12 +582,6 @@ unsigned r300_blit(GLcontext *ctx, if (dst_pitch % 2 > 0) ++dst_pitch; - /* Rendering to small buffer doesn't work. - * Looks like a hw limitation. - */ - if (dst_pitch < 32) - return 0; - /* Need to clamp the region size to make sure * we don't read outside of the source buffer * or write outside of the destination buffer. -- cgit v1.2.3 From abc847c20da92e52f29da40c6dd014f5caf46d8b Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 13 Mar 2010 17:33:48 +0100 Subject: radeon: add some debuging info for glCopyTex(Sub)Image --- src/mesa/drivers/dri/radeon/radeon_tex_copy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c index fb6f2e56af..29fd31ac23 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c +++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c @@ -28,6 +28,7 @@ #include "radeon_common.h" #include "radeon_texture.h" +#include "main/enums.h" #include "main/image.h" #include "main/teximage.h" #include "main/texstate.h" @@ -183,6 +184,10 @@ radeonCopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, return; fail: + radeon_print(RADEON_FALLBACKS, RADEON_NORMAL, + "Falling back to sw for glCopyTexImage2D (internalFormat %s, border %d)\n", + _mesa_lookup_enum_by_nr(internalFormat), border); + _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, width, height, border); } @@ -201,7 +206,8 @@ radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, radeon_tex_obj(texObj), (radeon_texture_image *)texImage, xoffset, yoffset, x, y, width, height)) { - //DEBUG_FALLBACKS + radeon_print(RADEON_FALLBACKS, RADEON_NORMAL, + "Falling back to sw for glCopyTexSubImage2D\n"); _mesa_meta_CopyTexSubImage2D(ctx, target, level, xoffset, yoffset, x, y, width, height); -- cgit v1.2.3 From 6c8e5151f14bc642e3995a42ad0f90f407c04d5c Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 11 Mar 2010 18:04:02 +0200 Subject: glapi: organize arch-specific code by arch --- src/mesa/glapi/glapi_entrypoint.c | 69 ++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 19 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/glapi/glapi_entrypoint.c b/src/mesa/glapi/glapi_entrypoint.c index 5e6e5995f2..7fffd2986f 100644 --- a/src/mesa/glapi/glapi_entrypoint.c +++ b/src/mesa/glapi/glapi_entrypoint.c @@ -65,7 +65,7 @@ get_entrypoint_address(GLuint functionOffset) #endif -#if defined(PTHREADS) || defined(GLX_USE_TLS) +#if defined(USE_X86_ASM) /** * Perform platform-specific GL API entry-point fixups. @@ -73,7 +73,7 @@ get_entrypoint_address(GLuint functionOffset) static void init_glapi_relocs( void ) { -#if defined(USE_X86_ASM) && defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT) +#if defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT) extern unsigned long _x86_get_dispatch(void); char run_time_patch[] = { 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */ @@ -88,8 +88,16 @@ init_glapi_relocs( void ) curr_func += DISPATCH_FUNCTION_SIZE; } #endif -#ifdef USE_SPARC_ASM - extern void __glapi_sparc_icache_flush(unsigned int *); +} + +#elif defined(USE_SPARC_ASM) + +extern void __glapi_sparc_icache_flush(unsigned int *); + +static void +init_glapi_relocs( void ) +{ +#if defined(PTHREADS) || defined(GLX_USE_TLS) static const unsigned int template[] = { #ifdef GLX_USE_TLS 0x05000000, /* sethi %hi(_glapi_tls_Dispatch), %g2 */ @@ -155,7 +163,7 @@ init_glapi_relocs( void ) int idx; #endif -#if defined(GLX_USE_TLS) +#ifdef GLX_USE_TLS code[0] = template[0] | (dispatch >> 10); code[1] = template[1]; __glapi_sparc_icache_flush(&code[0]); @@ -215,24 +223,25 @@ init_glapi_relocs( void ) #endif } +#else + +static void +init_glapi_relocs( void ) { } + +#endif /* USE_*_ASM */ + + void init_glapi_relocs_once( void ) { +#if defined(PTHREADS) || defined(GLX_USE_TLS) static pthread_once_t once_control = PTHREAD_ONCE_INIT; pthread_once( & once_control, init_glapi_relocs ); +#endif } -#else -void -init_glapi_relocs_once( void ) { } - -#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */ - - -#ifdef USE_SPARC_ASM -extern void __glapi_sparc_icache_flush(unsigned int *); -#endif +#if defined(USE_X86_ASM) /** * Generate a dispatch function (entrypoint) which jumps through @@ -242,7 +251,6 @@ extern void __glapi_sparc_icache_flush(unsigned int *); _glapi_proc generate_entrypoint(GLuint functionOffset) { -#if defined(USE_X86_ASM) /* 32 is chosen as something of a magic offset. For x86, the dispatch * at offset 32 is the first one where the offset in the * "jmp OFFSET*4(%eax)" can't be encoded in a single byte. @@ -258,8 +266,13 @@ generate_entrypoint(GLuint functionOffset) } return (_glapi_proc) code; +} + #elif defined(USE_SPARC_ASM) +_glapi_proc +generate_entrypoint(GLuint functionOffset) +{ #if defined(PTHREADS) || defined(GLX_USE_TLS) static const unsigned int template[] = { 0x07000000, /* sethi %hi(0), %g3 */ @@ -287,13 +300,21 @@ generate_entrypoint(GLuint functionOffset) } return (_glapi_proc) code; #endif +} #else + +_glapi_proc +generate_entrypoint(GLuint functionOffset) +{ (void) functionOffset; return NULL; -#endif /* USE_*_ASM */ } +#endif /* USE_*_ASM */ + + +#if defined(USE_X86_ASM) /** * This function inserts a new dispatch offset into the assembly language @@ -302,7 +323,6 @@ generate_entrypoint(GLuint functionOffset) void fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) { -#if defined(USE_X86_ASM) GLubyte * const code = (GLubyte *) entrypoint; #if DISPATCH_FUNCTION_SIZE == 32 @@ -315,17 +335,28 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) #else # error Invalid DISPATCH_FUNCTION_SIZE! #endif +} #elif defined(USE_SPARC_ASM) + +void +fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) +{ unsigned int *code = (unsigned int *) entrypoint; + code[0] &= ~0x3fffff; code[0] |= (offset * sizeof(void *)) & 0x3fffff; __glapi_sparc_icache_flush(&code[0]); +} + #else +void +fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) +{ /* an unimplemented architecture */ (void) entrypoint; (void) offset; +} #endif /* USE_*_ASM */ -} -- cgit v1.2.3 From 0ed0114de9f057e928124bada7289a4496a6d35f Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 11 Mar 2010 18:04:02 +0200 Subject: glapi: organize arch-specific code by arch (2) --- src/mesa/glapi/glapi_entrypoint.c | 154 ++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 81 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/glapi/glapi_entrypoint.c b/src/mesa/glapi/glapi_entrypoint.c index 7fffd2986f..9bc3878354 100644 --- a/src/mesa/glapi/glapi_entrypoint.c +++ b/src/mesa/glapi/glapi_entrypoint.c @@ -90,6 +90,55 @@ init_glapi_relocs( void ) #endif } + +/** + * Generate a dispatch function (entrypoint) which jumps through + * the given slot number (offset) in the current dispatch table. + * We need assembly language in order to accomplish this. + */ +_glapi_proc +generate_entrypoint(GLuint functionOffset) +{ + /* 32 is chosen as something of a magic offset. For x86, the dispatch + * at offset 32 is the first one where the offset in the + * "jmp OFFSET*4(%eax)" can't be encoded in a single byte. + */ + const GLubyte * const template_func = gl_dispatch_functions_start + + (DISPATCH_FUNCTION_SIZE * 32); + GLubyte * const code = (GLubyte *) malloc(DISPATCH_FUNCTION_SIZE); + + + if ( code != NULL ) { + (void) memcpy(code, template_func, DISPATCH_FUNCTION_SIZE); + fill_in_entrypoint_offset( (_glapi_proc) code, functionOffset ); + } + + return (_glapi_proc) code; +} + + +/** + * This function inserts a new dispatch offset into the assembly language + * stub that was generated with the preceeding function. + */ +void +fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) +{ + GLubyte * const code = (GLubyte *) entrypoint; + +#if DISPATCH_FUNCTION_SIZE == 32 + *((unsigned int *)(code + 11)) = 4 * offset; + *((unsigned int *)(code + 22)) = 4 * offset; +#elif DISPATCH_FUNCTION_SIZE == 16 && defined( GLX_USE_TLS ) + *((unsigned int *)(code + 8)) = 4 * offset; +#elif DISPATCH_FUNCTION_SIZE == 16 + *((unsigned int *)(code + 7)) = 4 * offset; +#else +# error Invalid DISPATCH_FUNCTION_SIZE! +#endif +} + + #elif defined(USE_SPARC_ASM) extern void __glapi_sparc_icache_flush(unsigned int *); @@ -223,52 +272,6 @@ init_glapi_relocs( void ) #endif } -#else - -static void -init_glapi_relocs( void ) { } - -#endif /* USE_*_ASM */ - - -void -init_glapi_relocs_once( void ) -{ -#if defined(PTHREADS) || defined(GLX_USE_TLS) - static pthread_once_t once_control = PTHREAD_ONCE_INIT; - pthread_once( & once_control, init_glapi_relocs ); -#endif -} - - -#if defined(USE_X86_ASM) - -/** - * Generate a dispatch function (entrypoint) which jumps through - * the given slot number (offset) in the current dispatch table. - * We need assembly language in order to accomplish this. - */ -_glapi_proc -generate_entrypoint(GLuint functionOffset) -{ - /* 32 is chosen as something of a magic offset. For x86, the dispatch - * at offset 32 is the first one where the offset in the - * "jmp OFFSET*4(%eax)" can't be encoded in a single byte. - */ - const GLubyte * const template_func = gl_dispatch_functions_start - + (DISPATCH_FUNCTION_SIZE * 32); - GLubyte * const code = (GLubyte *) malloc(DISPATCH_FUNCTION_SIZE); - - - if ( code != NULL ) { - (void) memcpy(code, template_func, DISPATCH_FUNCTION_SIZE); - fill_in_entrypoint_offset( (_glapi_proc) code, functionOffset ); - } - - return (_glapi_proc) code; -} - -#elif defined(USE_SPARC_ASM) _glapi_proc generate_entrypoint(GLuint functionOffset) @@ -302,54 +305,33 @@ generate_entrypoint(GLuint functionOffset) #endif } -#else -_glapi_proc -generate_entrypoint(GLuint functionOffset) +void +fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) { - (void) functionOffset; - return NULL; -} + unsigned int *code = (unsigned int *) entrypoint; -#endif /* USE_*_ASM */ + code[0] &= ~0x3fffff; + code[0] |= (offset * sizeof(void *)) & 0x3fffff; + __glapi_sparc_icache_flush(&code[0]); +} -#if defined(USE_X86_ASM) +#else /* USE_*_ASM */ -/** - * This function inserts a new dispatch offset into the assembly language - * stub that was generated with the preceeding function. - */ -void -fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) +static void +init_glapi_relocs( void ) { - GLubyte * const code = (GLubyte *) entrypoint; - -#if DISPATCH_FUNCTION_SIZE == 32 - *((unsigned int *)(code + 11)) = 4 * offset; - *((unsigned int *)(code + 22)) = 4 * offset; -#elif DISPATCH_FUNCTION_SIZE == 16 && defined( GLX_USE_TLS ) - *((unsigned int *)(code + 8)) = 4 * offset; -#elif DISPATCH_FUNCTION_SIZE == 16 - *((unsigned int *)(code + 7)) = 4 * offset; -#else -# error Invalid DISPATCH_FUNCTION_SIZE! -#endif } -#elif defined(USE_SPARC_ASM) -void -fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) +_glapi_proc +generate_entrypoint(GLuint functionOffset) { - unsigned int *code = (unsigned int *) entrypoint; - - code[0] &= ~0x3fffff; - code[0] |= (offset * sizeof(void *)) & 0x3fffff; - __glapi_sparc_icache_flush(&code[0]); + (void) functionOffset; + return NULL; } -#else void fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) @@ -360,3 +342,13 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) } #endif /* USE_*_ASM */ + + +void +init_glapi_relocs_once( void ) +{ +#if defined(PTHREADS) || defined(GLX_USE_TLS) + static pthread_once_t once_control = PTHREAD_ONCE_INIT; + pthread_once( & once_control, init_glapi_relocs ); +#endif +} -- cgit v1.2.3 From 9a649c8eaa38b5f8f5a89c2571ed66a6f51daeba Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 11 Mar 2010 18:04:03 +0200 Subject: glapi: more organize code by arch It seems that x86-64 with tls will fail to compile or load due to a missining gl_dispatch_functions_start symbol. Not changing though, since this is how it used to be and cannot test. --- src/mesa/glapi/glapi_priv.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/glapi/glapi_priv.h b/src/mesa/glapi/glapi_priv.h index 7cd81ee8dc..a8516f71a3 100644 --- a/src/mesa/glapi/glapi_priv.h +++ b/src/mesa/glapi/glapi_priv.h @@ -52,15 +52,21 @@ extern _glapi_proc get_entrypoint_address(GLuint functionOffset); -#if defined(USE_X64_64_ASM) && defined(GLX_USE_TLS) -# define DISPATCH_FUNCTION_SIZE 16 -#elif defined(USE_X86_ASM) -# if defined(THREADS) && !defined(GLX_USE_TLS) +#if defined(USE_X86_ASM) +# if defined(GLX_USE_TLS) +# define DISPATCH_FUNCTION_SIZE 16 +# elif defined(THREADS) # define DISPATCH_FUNCTION_SIZE 32 # else # define DISPATCH_FUNCTION_SIZE 16 # endif #endif +#if defined(USE_X64_64_ASM) +# if defined(GLX_USE_TLS) +# define DISPATCH_FUNCTION_SIZE 16 +# endif +#endif + #endif -- cgit v1.2.3 From 8fd7ee1815dd5880f94f13d88225d7be6f549ae6 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 11 Mar 2010 18:04:03 +0200 Subject: glapi: this one should be by THREAD --- src/mesa/glapi/glapi_entrypoint.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/glapi/glapi_entrypoint.c b/src/mesa/glapi/glapi_entrypoint.c index 9bc3878354..3256867b16 100644 --- a/src/mesa/glapi/glapi_entrypoint.c +++ b/src/mesa/glapi/glapi_entrypoint.c @@ -126,15 +126,13 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) { GLubyte * const code = (GLubyte *) entrypoint; -#if DISPATCH_FUNCTION_SIZE == 32 +#if defined(GLX_USE_TLS) + *((unsigned int *)(code + 8)) = 4 * offset; +#elif defined(THREADS) *((unsigned int *)(code + 11)) = 4 * offset; *((unsigned int *)(code + 22)) = 4 * offset; -#elif DISPATCH_FUNCTION_SIZE == 16 && defined( GLX_USE_TLS ) - *((unsigned int *)(code + 8)) = 4 * offset; -#elif DISPATCH_FUNCTION_SIZE == 16 - *((unsigned int *)(code + 7)) = 4 * offset; #else -# error Invalid DISPATCH_FUNCTION_SIZE! + *((unsigned int *)(code + 7)) = 4 * offset; #endif } -- cgit v1.2.3 From 41eab95b3bc29a4fe6fd08b7f1f80cef5bdc097f Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 11 Mar 2010 18:04:03 +0200 Subject: glapi: exec_malloc for dispatch stubs --- src/mesa/SConscript | 1 + src/mesa/glapi/glapi_entrypoint.c | 4 +- src/mesa/glapi/glapi_execmem.c | 127 ++++++++++++++++++++++++++++++++++++++ src/mesa/glapi/glapi_getproc.c | 6 -- src/mesa/glapi/glapi_priv.h | 25 ++++++++ src/mesa/sources.mak | 1 + 6 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 src/mesa/glapi/glapi_execmem.c (limited to 'src/mesa') diff --git a/src/mesa/SConscript b/src/mesa/SConscript index e80ec5ee88..86da6f58bd 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -250,6 +250,7 @@ if env['platform'] != 'winddk': 'glapi/glapi.c', 'glapi/glapi_dispatch.c', 'glapi/glapi_entrypoint.c', + 'glapi/glapi_execmem.c', 'glapi/glapi_getproc.c', 'glapi/glapi_nop.c', 'glapi/glthread.c', diff --git a/src/mesa/glapi/glapi_entrypoint.c b/src/mesa/glapi/glapi_entrypoint.c index 3256867b16..c4f43f66a1 100644 --- a/src/mesa/glapi/glapi_entrypoint.c +++ b/src/mesa/glapi/glapi_entrypoint.c @@ -105,7 +105,7 @@ generate_entrypoint(GLuint functionOffset) */ const GLubyte * const template_func = gl_dispatch_functions_start + (DISPATCH_FUNCTION_SIZE * 32); - GLubyte * const code = (GLubyte *) malloc(DISPATCH_FUNCTION_SIZE); + GLubyte * const code = (GLubyte *) _glapi_exec_malloc(DISPATCH_FUNCTION_SIZE); if ( code != NULL ) { @@ -288,7 +288,7 @@ generate_entrypoint(GLuint functionOffset) extern unsigned int __glapi_sparc_pthread_stub; unsigned long call_dest = (unsigned long ) &__glapi_sparc_pthread_stub; #endif - unsigned int *code = (unsigned int *) malloc(sizeof(template)); + unsigned int *code = (unsigned int *) _glapi_exec_malloc(sizeof(template)); if (code) { code[0] = template[0] | (functionOffset & 0x3fffff); code[1] = template[1]; diff --git a/src/mesa/glapi/glapi_execmem.c b/src/mesa/glapi/glapi_execmem.c new file mode 100644 index 0000000000..6a1fac597f --- /dev/null +++ b/src/mesa/glapi/glapi_execmem.c @@ -0,0 +1,127 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file glapi_execmem.c + * + * Function for allocating executable memory for dispatch stubs. + * + * Copied from main/execmem.c and simplified for dispatch stubs. + */ + + +#ifdef HAVE_DIX_CONFIG_H +#include +#include "glapi/mesa.h" +#else +#include "main/compiler.h" +#endif + +#include "glapi/glthread.h" + + +#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) + +#include +#include + +#ifdef MESA_SELINUX +#include +#endif + + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + + +#define EXEC_MAP_SIZE (4*1024) + +_glthread_DECLARE_STATIC_MUTEX(exec_mutex); + +static unsigned int head = 0; + +static unsigned char *exec_mem = NULL; + + +/* + * Dispatch stubs are of fixed size and never freed. Thus, we do not need to + * overlay a heap, we just mmap a page and manage through an index. + */ + +static int +init_map(void) +{ +#ifdef MESA_SELINUX + if (is_selinux_enabled()) { + if (!security_get_boolean_active("allow_execmem") || + !security_get_boolean_pending("allow_execmem")) + return 0; + } +#endif + + if (!exec_mem) + exec_mem = mmap(NULL, EXEC_MAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + + return (exec_mem != MAP_FAILED); +} + + +void * +_glapi_exec_malloc(unsigned int size) +{ + void *addr = NULL; + + _glthread_LOCK_MUTEX(exec_mutex); + + if (!init_map()) + goto bail; + + /* free space check, assumes no integer overflow */ + if (head + size > EXEC_MAP_SIZE) + goto bail; + + /* allocation, assumes proper addr and size alignement */ + addr = exec_mem + head; + head += size; + +bail: + _glthread_UNLOCK_MUTEX(exec_mutex); + + return addr; +} + + +#else + +void * +_glapi_exec_malloc(unsigned int size) +{ + return malloc(size); +} + + +#endif diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index 295657875d..c73e8dd3b0 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -200,12 +200,6 @@ struct _glapi_function { }; -/* - * Number of extension functions which we can dynamically add at runtime. - */ -#define MAX_EXTENSION_FUNCS 300 - - static struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS]; static GLuint NumExtEntryPoints = 0; diff --git a/src/mesa/glapi/glapi_priv.h b/src/mesa/glapi/glapi_priv.h index a8516f71a3..0e2de460f2 100644 --- a/src/mesa/glapi/glapi_priv.h +++ b/src/mesa/glapi/glapi_priv.h @@ -28,6 +28,9 @@ #include "glthread.h" + +/* getproc */ + extern void _glapi_check_table_not_null(const struct _glapi_table *table); @@ -36,6 +39,14 @@ extern void _glapi_check_table(const struct _glapi_table *table); +/* execmem */ + +extern void * +_glapi_exec_malloc(GLuint size); + + +/* entrypoint */ + extern void init_glapi_relocs_once(void); @@ -52,6 +63,9 @@ extern _glapi_proc get_entrypoint_address(GLuint functionOffset); +/** + * Size (in bytes) of dispatch function (entrypoint). + */ #if defined(USE_X86_ASM) # if defined(GLX_USE_TLS) # define DISPATCH_FUNCTION_SIZE 16 @@ -69,4 +83,15 @@ get_entrypoint_address(GLuint functionOffset); #endif +/** + * Number of extension functions which we can dynamically add at runtime. + * + * Number of extension functions is also subject to the size of backing exec + * mem we allocate. For the common case of dispatch stubs with size 16 bytes, + * the two limits will be hit simultaneously. For larger dispatch function + * sizes, MAX_EXTENSION_FUNCS is effectively reduced. + */ +#define MAX_EXTENSION_FUNCS 256 + + #endif diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index 74885548e5..d59e24de1f 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -89,6 +89,7 @@ GLAPI_SOURCES = \ glapi/glapi.c \ glapi/glapi_dispatch.c \ glapi/glapi_entrypoint.c \ + glapi/glapi_execmem.c \ glapi/glapi_getproc.c \ glapi/glapi_nop.c \ glapi/glthread.c -- cgit v1.2.3 From 06ebc46e65d7dea6f146db85150021814d2439bf Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:45 +0200 Subject: dri: add dri_sw.c helper This is dri_util.c stripped from the drm-specific bits and will be used for both classic and gallium swrast_dri.so --- src/mesa/drivers/dri/common/dri_sw.c | 267 +++++++++++++++++++++++++++++++++++ src/mesa/drivers/dri/common/dri_sw.h | 115 +++++++++++++++ 2 files changed, 382 insertions(+) create mode 100644 src/mesa/drivers/dri/common/dri_sw.c create mode 100644 src/mesa/drivers/dri/common/dri_sw.h (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/common/dri_sw.c b/src/mesa/drivers/dri/common/dri_sw.c new file mode 100644 index 0000000000..4b87a7f32f --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_sw.c @@ -0,0 +1,267 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file dri_sw.c + * + * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits. + */ + +#include "dri_sw.h" +#include "utils.h" + + +/** + * Screen functions + */ + +static void +setupLoaderExtensions(__DRIscreen *psp, + const __DRIextension **extensions) +{ + int i; + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0) + psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i]; + } +} + +static __DRIscreen * +driCreateNewScreen(int scrn, const __DRIextension **extensions, + const __DRIconfig ***driver_configs, void *data) +{ + static const __DRIextension *emptyExtensionList[] = { NULL }; + __DRIscreen *psp; + + (void) data; + + psp = CALLOC_STRUCT(__DRIscreenRec); + if (!psp) + return NULL; + + setupLoaderExtensions(psp, extensions); + + psp->extensions = emptyExtensionList; + psp->myNum = scrn; + + *driver_configs = driDriverAPI.InitScreen(psp); + + if (*driver_configs == NULL) { + FREE(psp); + return NULL; + } + + return psp; +} + +static void driDestroyScreen(__DRIscreen *psp) +{ + if (psp) { + driDriverAPI.DestroyScreen(psp); + + FREE(psp); + } +} + +static const __DRIextension **driGetExtensions(__DRIscreen *psp) +{ + return psp->extensions; +} + + +/** + * Context functions + */ + +static __DRIcontext * +driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, + __DRIcontext *shared, void *data) +{ + __DRIcontext *pcp; + void * const shareCtx = (shared != NULL) ? &shared->Base : NULL; + + pcp = CALLOC_STRUCT(__DRIcontextRec); + if (!pcp) + return NULL; + + pcp->loaderPrivate = data; + + pcp->driScreenPriv = psp; + pcp->driDrawablePriv = NULL; + pcp->driReadablePriv = NULL; + + if (!driDriverAPI.CreateContext(&config->modes, pcp, shareCtx)) { + FREE(pcp); + return NULL; + } + + return pcp; +} + +static void +driDestroyContext(__DRIcontext *pcp) +{ + if (pcp) { + driDriverAPI.DestroyContext(pcp); + FREE(pcp); + } +} + +static int +driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask) +{ + return GL_FALSE; +} + +static void dri_get_drawable(__DRIdrawable *pdp); +static void dri_put_drawable(__DRIdrawable *pdp); + +static int driBindContext(__DRIcontext *pcp, + __DRIdrawable *pdp, + __DRIdrawable *prp) +{ + /* Bind the drawable to the context */ + if (pcp) { + pcp->driDrawablePriv = pdp; + pcp->driReadablePriv = prp; + if (pdp) { + dri_get_drawable(pdp); + } + if ( prp && pdp != prp ) { + dri_get_drawable(prp); + } + } + + return driDriverAPI.MakeCurrent(pcp, pdp, prp); +} + +static int driUnbindContext(__DRIcontext *pcp) +{ + __DRIdrawable *pdp; + __DRIdrawable *prp; + + if (pcp == NULL) + return GL_FALSE; + + pdp = pcp->driDrawablePriv; + prp = pcp->driReadablePriv; + + /* already unbound */ + if (!pdp && !prp) + return GL_TRUE; + + driDriverAPI.UnbindContext(pcp); + + dri_put_drawable(pdp); + + if (prp != pdp) { + dri_put_drawable(prp); + } + + pcp->driDrawablePriv = NULL; + pcp->driReadablePriv = NULL; + + return GL_TRUE; +} + + +/** + * Drawable functions + */ + +static void dri_get_drawable(__DRIdrawable *pdp) +{ + pdp->refcount++; +} + +static void dri_put_drawable(__DRIdrawable *pdp) +{ + if (pdp) { + pdp->refcount--; + if (pdp->refcount) + return; + + driDriverAPI.DestroyBuffer(pdp); + + FREE(pdp); + } +} + +static __DRIdrawable * +driCreateNewDrawable(__DRIscreen *psp, + const __DRIconfig *config, void *data) +{ + __DRIdrawable *pdp; + + pdp = CALLOC_STRUCT(__DRIdrawableRec); + if (!pdp) + return NULL; + + pdp->loaderPrivate = data; + + pdp->driScreenPriv = psp; + + dri_get_drawable(pdp); + + if (!driDriverAPI.CreateBuffer(psp, pdp, &config->modes, GL_FALSE)) { + FREE(pdp); + return NULL; + } + + return pdp; +} + +static void +driDestroyDrawable(__DRIdrawable *pdp) +{ + dri_put_drawable(pdp); +} + +static void driSwapBuffers(__DRIdrawable *pdp) +{ + driDriverAPI.SwapBuffers(pdp); +} + +const __DRIcoreExtension driCoreExtension = { + { __DRI_CORE, __DRI_CORE_VERSION }, + NULL, /* driCreateNewScreen */ + driDestroyScreen, + driGetExtensions, + driGetConfigAttrib, + driIndexConfigAttrib, + NULL, /* driCreateNewDrawable */ + driDestroyDrawable, + driSwapBuffers, + driCreateNewContext, + driCopyContext, + driDestroyContext, + driBindContext, + driUnbindContext +}; + +const __DRIswrastExtension driSWRastExtension = { + { __DRI_SWRAST, __DRI_SWRAST_VERSION }, + driCreateNewScreen, + driCreateNewDrawable +}; diff --git a/src/mesa/drivers/dri/common/dri_sw.h b/src/mesa/drivers/dri/common/dri_sw.h new file mode 100644 index 0000000000..b7257b14a2 --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_sw.h @@ -0,0 +1,115 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _DRI_SW_H +#define _DRI_SW_H + +#include +#include +#include "main/mtypes.h" + + +/** + * Extensions + */ +extern const __DRIcoreExtension driCoreExtension; +extern const __DRIswrastExtension driSWRastExtension; + + +/** + * Data types + */ +struct __DRIscreenRec { + int myNum; + + int fd; + + void *private; + + const __DRIextension **extensions; + + const __DRIswrastLoaderExtension *swrast_loader; +}; + +struct __DRIcontextRec { + + GLcontext Base; + + void *loaderPrivate; + + __DRIdrawable *driDrawablePriv; + + __DRIdrawable *driReadablePriv; + + __DRIscreen *driScreenPriv; +}; + +struct __DRIdrawableRec { + + GLframebuffer Base; + + void *loaderPrivate; + + __DRIscreen *driScreenPriv; + + int refcount; + + /* scratch row for optimized front-buffer rendering */ + char *row; +}; + + +/** + * Driver callback functions + */ +struct __DriverAPIRec { + const __DRIconfig **(*InitScreen) (__DRIscreen * priv); + + void (*DestroyScreen)(__DRIscreen *driScrnPriv); + + GLboolean (*CreateContext)(const __GLcontextModes *glVis, + __DRIcontext *driContextPriv, + void *sharedContextPrivate); + + void (*DestroyContext)(__DRIcontext *driContextPriv); + + GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, + __DRIdrawable *driDrawPriv, + const __GLcontextModes *glVis, + GLboolean pixmapBuffer); + + void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); + + void (*SwapBuffers)(__DRIdrawable *driDrawPriv); + + GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, + __DRIdrawable *driDrawPriv, + __DRIdrawable *driReadPriv); + + GLboolean (*UnbindContext)(__DRIcontext *driContextPriv); +}; + +extern const struct __DriverAPIRec driDriverAPI; + +#endif /* _DRI_SW_H */ -- cgit v1.2.3 From 6e376485c10896229f7bfaf5b0cce9c8b67f61b1 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:45 +0200 Subject: dri/swrast: port to dri_sw --- src/mesa/drivers/dri/swrast/Makefile | 3 +- src/mesa/drivers/dri/swrast/swrast.c | 249 ++++++++++++------------------ src/mesa/drivers/dri/swrast/swrast_priv.h | 28 +--- 3 files changed, 100 insertions(+), 180 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/swrast/Makefile b/src/mesa/drivers/dri/swrast/Makefile index 771169c1ff..cc59eefdb2 100644 --- a/src/mesa/drivers/dri/swrast/Makefile +++ b/src/mesa/drivers/dri/swrast/Makefile @@ -17,7 +17,8 @@ ASM_SOURCES = SWRAST_COMMON_SOURCES = \ ../../common/driverfuncs.c \ - ../common/utils.c + ../common/utils.c \ + ../common/dri_sw.c include ../Makefile.template diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 03c672ecf1..8c858ab2da 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -54,17 +54,9 @@ * Screen and config-related functions */ -static void -setupLoaderExtensions(__DRIscreen *psp, - const __DRIextension **extensions) -{ - int i; - - for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0) - psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i]; - } -} +static const __DRIextension *dri_screen_extensions[] = { + NULL +}; static __DRIconfig ** swrastFillInModes(__DRIscreen *psp, @@ -143,26 +135,14 @@ swrastFillInModes(__DRIscreen *psp, return configs; } -static __DRIscreen * -driCreateNewScreen(int scrn, const __DRIextension **extensions, - const __DRIconfig ***driver_configs, void *data) +static const __DRIconfig ** +dri_init_screen(__DRIscreen * psp) { - static const __DRIextension *emptyExtensionList[] = { NULL }; - __DRIscreen *psp; __DRIconfig **configs8, **configs16, **configs24, **configs32; - (void) data; - TRACE; - psp = calloc(1, sizeof(*psp)); - if (!psp) - return NULL; - - setupLoaderExtensions(psp, extensions); - - psp->num = scrn; - psp->extensions = emptyExtensionList; + psp->extensions = dri_screen_extensions; configs8 = swrastFillInModes(psp, 8, 8, 0, 1); configs16 = swrastFillInModes(psp, 16, 16, 0, 1); @@ -171,28 +151,15 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions, configs16 = driConcatConfigs(configs8, configs16); configs24 = driConcatConfigs(configs16, configs24); - *driver_configs = (const __DRIconfig **) - driConcatConfigs(configs24, configs32); - - driInitExtensions( NULL, NULL, GL_FALSE ); - - return psp; -} - -static void driDestroyScreen(__DRIscreen *psp) -{ - TRACE; + configs32 = driConcatConfigs(configs24, configs32); - if (psp) { - free(psp); - } + return (const __DRIconfig **)configs32; } -static const __DRIextension **driGetExtensions(__DRIscreen *psp) +static void +dri_destroy_screen(__DRIscreen * sPriv) { TRACE; - - return psp->extensions; } @@ -336,94 +303,95 @@ swrast_new_renderbuffer(const GLvisual *visual, GLboolean front) return xrb; } -static __DRIdrawable * -driCreateNewDrawable(__DRIscreen *screen, - const __DRIconfig *config, void *data) +static GLboolean +dri_create_buffer(__DRIscreen * sPriv, + __DRIdrawable * dPriv, + const __GLcontextModes * visual, GLboolean isPixmap) { - __DRIdrawable *buf; + GLframebuffer *fb; struct swrast_renderbuffer *frontrb, *backrb; TRACE; - buf = calloc(1, sizeof *buf); - if (!buf) - return NULL; - - buf->loaderPrivate = data; + fb = &dPriv->Base; - buf->driScreenPriv = screen; - - buf->row = malloc(MAX_WIDTH * 4); + dPriv->row = malloc(MAX_WIDTH * 4); /* basic framebuffer setup */ - _mesa_initialize_window_framebuffer(&buf->Base, &config->modes); + _mesa_initialize_window_framebuffer(fb, visual); /* add front renderbuffer */ - frontrb = swrast_new_renderbuffer(&config->modes, GL_TRUE); - _mesa_add_renderbuffer(&buf->Base, BUFFER_FRONT_LEFT, &frontrb->Base); + frontrb = swrast_new_renderbuffer(visual, GL_TRUE); + _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base); /* add back renderbuffer */ - if (config->modes.doubleBufferMode) { - backrb = swrast_new_renderbuffer(&config->modes, GL_FALSE); - _mesa_add_renderbuffer(&buf->Base, BUFFER_BACK_LEFT, &backrb->Base); + if (visual->doubleBufferMode) { + backrb = swrast_new_renderbuffer(visual, GL_FALSE); + _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base); } /* add software renderbuffers */ - _mesa_add_soft_renderbuffers(&buf->Base, + _mesa_add_soft_renderbuffers(fb, GL_FALSE, /* color */ - config->modes.haveDepthBuffer, - config->modes.haveStencilBuffer, - config->modes.haveAccumBuffer, + visual->haveDepthBuffer, + visual->haveStencilBuffer, + visual->haveAccumBuffer, GL_FALSE, /* alpha */ GL_FALSE /* aux bufs */); - return buf; + return GL_TRUE; } static void -driDestroyDrawable(__DRIdrawable *buf) +dri_destroy_buffer(__DRIdrawable * dPriv) { TRACE; - if (buf) { - struct gl_framebuffer *fb = &buf->Base; + if (dPriv) { + GLframebuffer *fb; + + free(dPriv->row); - free(buf->row); + fb = &dPriv->Base; fb->DeletePending = GL_TRUE; _mesa_reference_framebuffer(&fb, NULL); } } -static void driSwapBuffers(__DRIdrawable *buf) +static void +dri_swap_buffers(__DRIdrawable * dPriv) { - GET_CURRENT_CONTEXT(ctx); + __DRIscreen *sPriv = dPriv->driScreenPriv; - struct swrast_renderbuffer *frontrb = - swrast_renderbuffer(buf->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer); - struct swrast_renderbuffer *backrb = - swrast_renderbuffer(buf->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer); + GET_CURRENT_CONTEXT(ctx); - __DRIscreen *screen = buf->driScreenPriv; + GLframebuffer *fb; + struct swrast_renderbuffer *frontrb, *backrb; TRACE; + fb = &dPriv->Base; + + frontrb = swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + backrb = swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + /* check for signle-buffered */ if (backrb == NULL) return; /* check if swapping currently bound buffer */ - if (ctx && ctx->DrawBuffer == &(buf->Base)) { + if (ctx && ctx->DrawBuffer == fb) { /* flush pending rendering */ _mesa_notifySwapBuffers(ctx); } - screen->swrast_loader->putImage(buf, __DRI_SWRAST_IMAGE_OP_SWAP, - 0, 0, - frontrb->Base.Width, - frontrb->Base.Height, - backrb->Base.Data, - buf->loaderPrivate); + sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, + 0, 0, + frontrb->Base.Width, + frontrb->Base.Height, + backrb->Base.Data, + dPriv->loaderPrivate); } @@ -434,13 +402,13 @@ static void driSwapBuffers(__DRIdrawable *buf) static void get_window_size( GLframebuffer *fb, GLsizei *w, GLsizei *h ) { - __DRIdrawable *buf = swrast_drawable(fb); - __DRIscreen *screen = buf->driScreenPriv; + __DRIdrawable *dPriv = swrast_drawable(fb); + __DRIscreen *sPriv = dPriv->driScreenPriv; int x, y; - screen->swrast_loader->getDrawableInfo(buf, - &x, &y, w, h, - buf->loaderPrivate); + sPriv->swrast_loader->getDrawableInfo(dPriv, + &x, &y, w, h, + dPriv->loaderPrivate); } static void @@ -502,36 +470,28 @@ swrast_init_driver_functions(struct dd_function_table *driver) * Context-related functions. */ -static __DRIcontext * -driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config, - __DRIcontext *shared, void *data) +static GLboolean +dri_create_context(const __GLcontextModes * visual, + __DRIcontext * cPriv, void *sharedContextPrivate) { - __DRIcontext *ctx; GLcontext *mesaCtx; + GLcontext *sharedCtx; struct dd_function_table functions; TRACE; - ctx = calloc(1, sizeof *ctx); - if (!ctx) - return NULL; - - ctx->loaderPrivate = data; - - ctx->driScreenPriv = screen; - /* build table of device driver functions */ _mesa_init_driver_functions(&functions); swrast_init_driver_functions(&functions); - if (!_mesa_initialize_context(&ctx->Base, &config->modes, - shared ? &shared->Base : NULL, - &functions, (void *) ctx)) { - free(ctx); - return NULL; + sharedCtx = sharedContextPrivate; + + /* basic context setup */ + if (!_mesa_initialize_context(&cPriv->Base, visual, sharedCtx, &functions, (void *) cPriv)) { + return GL_FALSE; } - mesaCtx = &ctx->Base; + mesaCtx = &cPriv->Base; /* do bounds checking to prevent segfaults and server crashes! */ mesaCtx->Const.CheckArrayBounds = GL_TRUE; @@ -558,17 +518,20 @@ driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config, _mesa_meta_init(mesaCtx); - return ctx; + driInitExtensions( mesaCtx, NULL, GL_FALSE ); + + return GL_TRUE; } static void -driDestroyContext(__DRIcontext *ctx) +dri_destroy_context(__DRIcontext * cPriv) { GLcontext *mesaCtx; TRACE; - if (ctx) { - mesaCtx = &ctx->Base; + if (cPriv) { + mesaCtx = &cPriv->Base; + _mesa_meta_free(mesaCtx); _swsetup_DestroyContext( mesaCtx ); _swrast_DestroyContext( mesaCtx ); @@ -578,31 +541,23 @@ driDestroyContext(__DRIcontext *ctx) } } -static int -driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask) -{ - TRACE; - - _mesa_copy_context(&src->Base, &dst->Base, mask); - return GL_TRUE; -} - -static int driBindContext(__DRIcontext *ctx, - __DRIdrawable *draw, - __DRIdrawable *read) +static GLboolean +dri_make_current(__DRIcontext * cPriv, + __DRIdrawable * driDrawPriv, + __DRIdrawable * driReadPriv) { GLcontext *mesaCtx; GLframebuffer *mesaDraw; GLframebuffer *mesaRead; TRACE; - if (ctx) { - if (!draw || !read) + if (cPriv) { + if (!driDrawPriv || !driReadPriv) return GL_FALSE; - mesaCtx = &ctx->Base; - mesaDraw = &draw->Base; - mesaRead = &read->Base; + mesaCtx = &cPriv->Base; + mesaDraw = &driDrawPriv->Base; + mesaRead = &driReadPriv->Base; /* check for same context and buffer */ if (mesaCtx == _mesa_get_current_context() @@ -614,7 +569,7 @@ static int driBindContext(__DRIcontext *ctx, _glapi_check_multithread(); swrast_check_and_update_window_size(mesaCtx, mesaDraw); - if (read != draw) + if (mesaRead != mesaDraw) swrast_check_and_update_window_size(mesaCtx, mesaRead); _mesa_make_current( mesaCtx, @@ -629,35 +584,25 @@ static int driBindContext(__DRIcontext *ctx, return GL_TRUE; } -static int driUnbindContext(__DRIcontext *ctx) +static GLboolean +dri_unbind_context(__DRIcontext * cPriv) { TRACE; - (void) ctx; + (void) cPriv; return GL_TRUE; } -static const __DRIcoreExtension driCoreExtension = { - { __DRI_CORE, __DRI_CORE_VERSION }, - NULL, /* driCreateNewScreen */ - driDestroyScreen, - driGetExtensions, - driGetConfigAttrib, - driIndexConfigAttrib, - NULL, /* driCreateNewDrawable */ - driDestroyDrawable, - driSwapBuffers, - driCreateNewContext, - driCopyContext, - driDestroyContext, - driBindContext, - driUnbindContext -}; - -static const __DRIswrastExtension driSWRastExtension = { - { __DRI_SWRAST, __DRI_SWRAST_VERSION }, - driCreateNewScreen, - driCreateNewDrawable +const struct __DriverAPIRec driDriverAPI = { + .InitScreen = dri_init_screen, + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .SwapBuffers = dri_swap_buffers, + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, }; /* This is the table of extensions that the loader will dlsym() for. */ diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 4722007f95..c83c64b487 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -34,6 +34,7 @@ #include #include #include "main/mtypes.h" +#include "dri_sw.h" /** @@ -58,33 +59,6 @@ /** * Data types */ -struct __DRIscreenRec { - int num; - - const __DRIextension **extensions; - - const __DRIswrastLoaderExtension *swrast_loader; -}; - -struct __DRIcontextRec { - GLcontext Base; - - void *loaderPrivate; - - __DRIscreen *driScreenPriv; -}; - -struct __DRIdrawableRec { - GLframebuffer Base; - - void *loaderPrivate; - - __DRIscreen *driScreenPriv; - - /* scratch row for optimized front-buffer rendering */ - char *row; -}; - struct swrast_renderbuffer { struct gl_renderbuffer Base; -- cgit v1.2.3 From cf8a1caa231b748d3ba7c776ab076ad3de99e963 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:45 +0200 Subject: dri/swrast: port to dri_sw (context) --- src/mesa/drivers/dri/common/dri_sw.c | 2 +- src/mesa/drivers/dri/common/dri_sw.h | 2 +- src/mesa/drivers/dri/swrast/swrast.c | 41 ++++++++++++++++++++------- src/mesa/drivers/dri/swrast/swrast_priv.h | 27 ++++++++++++++---- src/mesa/drivers/dri/swrast/swrast_spantemp.h | 8 +++--- 5 files changed, 58 insertions(+), 22 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/common/dri_sw.c b/src/mesa/drivers/dri/common/dri_sw.c index 4b87a7f32f..b7f9036f47 100644 --- a/src/mesa/drivers/dri/common/dri_sw.c +++ b/src/mesa/drivers/dri/common/dri_sw.c @@ -99,7 +99,7 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, __DRIcontext *shared, void *data) { __DRIcontext *pcp; - void * const shareCtx = (shared != NULL) ? &shared->Base : NULL; + void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; pcp = CALLOC_STRUCT(__DRIcontextRec); if (!pcp) diff --git a/src/mesa/drivers/dri/common/dri_sw.h b/src/mesa/drivers/dri/common/dri_sw.h index b7257b14a2..93e9624654 100644 --- a/src/mesa/drivers/dri/common/dri_sw.h +++ b/src/mesa/drivers/dri/common/dri_sw.h @@ -54,7 +54,7 @@ struct __DRIscreenRec { struct __DRIcontextRec { - GLcontext Base; + void *driverPrivate; void *loaderPrivate; diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 8c858ab2da..8273439fef 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -474,25 +474,36 @@ static GLboolean dri_create_context(const __GLcontextModes * visual, __DRIcontext * cPriv, void *sharedContextPrivate) { - GLcontext *mesaCtx; - GLcontext *sharedCtx; + struct dri_context *ctx = NULL; + struct dri_context *share = (struct dri_context *)sharedContextPrivate; + GLcontext *mesaCtx = NULL; + GLcontext *sharedCtx = NULL; struct dd_function_table functions; TRACE; + ctx = CALLOC_STRUCT(dri_context); + if (ctx == NULL) + goto context_fail; + + cPriv->driverPrivate = ctx; + ctx->cPriv = cPriv; + /* build table of device driver functions */ _mesa_init_driver_functions(&functions); swrast_init_driver_functions(&functions); - sharedCtx = sharedContextPrivate; + if (share) { + sharedCtx = &share->Base; + } + + mesaCtx = &ctx->Base; /* basic context setup */ - if (!_mesa_initialize_context(&cPriv->Base, visual, sharedCtx, &functions, (void *) cPriv)) { - return GL_FALSE; + if (!_mesa_initialize_context(mesaCtx, visual, sharedCtx, &functions, (void *) cPriv)) { + goto context_fail; } - mesaCtx = &cPriv->Base; - /* do bounds checking to prevent segfaults and server crashes! */ mesaCtx->Const.CheckArrayBounds = GL_TRUE; @@ -521,16 +532,24 @@ dri_create_context(const __GLcontextModes * visual, driInitExtensions( mesaCtx, NULL, GL_FALSE ); return GL_TRUE; + +context_fail: + + FREE(ctx); + + return GL_FALSE; } static void dri_destroy_context(__DRIcontext * cPriv) { - GLcontext *mesaCtx; TRACE; if (cPriv) { - mesaCtx = &cPriv->Base; + struct dri_context *ctx = dri_context(cPriv); + GLcontext *mesaCtx; + + mesaCtx = &ctx->Base; _mesa_meta_free(mesaCtx); _swsetup_DestroyContext( mesaCtx ); @@ -552,10 +571,12 @@ dri_make_current(__DRIcontext * cPriv, TRACE; if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + if (!driDrawPriv || !driReadPriv) return GL_FALSE; - mesaCtx = &cPriv->Base; + mesaCtx = &ctx->Base; mesaDraw = &driDrawPriv->Base; mesaRead = &driReadPriv->Base; diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index c83c64b487..130598bbd8 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -59,6 +59,27 @@ /** * Data types */ +struct dri_context +{ + /* mesa */ + GLcontext Base; + + /* dri */ + __DRIcontext *cPriv; +}; + +static INLINE struct dri_context * +dri_context(__DRIcontext * driContextPriv) +{ + return (struct dri_context *)driContextPriv->driverPrivate; +} + +static INLINE struct dri_context * +swrast_context(GLcontext *ctx) +{ + return (struct dri_context *) ctx; +} + struct swrast_renderbuffer { struct gl_renderbuffer Base; @@ -68,12 +89,6 @@ struct swrast_renderbuffer { GLuint bpp; }; -static INLINE __DRIcontext * -swrast_context(GLcontext *ctx) -{ - return (__DRIcontext *) ctx; -} - static INLINE __DRIdrawable * swrast_drawable(GLframebuffer *fb) { diff --git a/src/mesa/drivers/dri/swrast/swrast_spantemp.h b/src/mesa/drivers/dri/swrast/swrast_spantemp.h index 879a0c12e7..c73b785683 100644 --- a/src/mesa/drivers/dri/swrast/swrast_spantemp.h +++ b/src/mesa/drivers/dri/swrast/swrast_spantemp.h @@ -39,7 +39,7 @@ static INLINE void PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) { - __DRIcontext *ctx = swrast_context(glCtx); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); __DRIscreen *screen = ctx->driScreenPriv; @@ -53,7 +53,7 @@ PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) static INLINE void GET_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) { - __DRIcontext *ctx = swrast_context(glCtx); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer); __DRIscreen *screen = ctx->driScreenPriv; @@ -65,7 +65,7 @@ GET_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) static INLINE void PUT_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) { - __DRIcontext *ctx = swrast_context(glCtx); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); __DRIscreen *screen = ctx->driScreenPriv; @@ -78,7 +78,7 @@ PUT_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) static INLINE void GET_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) { - __DRIcontext *ctx = swrast_context(glCtx); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer); __DRIscreen *screen = ctx->driScreenPriv; -- cgit v1.2.3 From c1bde793598bcb5d5f8744c290a66ea6586eb29f Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:46 +0200 Subject: dri/swrast: port to dri_sw (drawable) --- src/mesa/drivers/dri/common/dri_sw.h | 5 +--- src/mesa/drivers/dri/swrast/swrast.c | 39 +++++++++++++++++++++------ src/mesa/drivers/dri/swrast/swrast_priv.h | 30 ++++++++++++++++----- src/mesa/drivers/dri/swrast/swrast_spantemp.h | 8 +++--- 4 files changed, 60 insertions(+), 22 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/common/dri_sw.h b/src/mesa/drivers/dri/common/dri_sw.h index 93e9624654..89369a9d00 100644 --- a/src/mesa/drivers/dri/common/dri_sw.h +++ b/src/mesa/drivers/dri/common/dri_sw.h @@ -67,16 +67,13 @@ struct __DRIcontextRec { struct __DRIdrawableRec { - GLframebuffer Base; + void *driverPrivate; void *loaderPrivate; __DRIscreen *driScreenPriv; int refcount; - - /* scratch row for optimized front-buffer rendering */ - char *row; }; diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 8273439fef..4450e470c6 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -308,14 +308,24 @@ dri_create_buffer(__DRIscreen * sPriv, __DRIdrawable * dPriv, const __GLcontextModes * visual, GLboolean isPixmap) { + struct dri_drawable *drawable = NULL; GLframebuffer *fb; struct swrast_renderbuffer *frontrb, *backrb; TRACE; - fb = &dPriv->Base; + drawable = CALLOC_STRUCT(dri_drawable); + if (drawable == NULL) + goto drawable_fail; - dPriv->row = malloc(MAX_WIDTH * 4); + dPriv->driverPrivate = drawable; + drawable->dPriv = dPriv; + + drawable->row = malloc(MAX_WIDTH * 4); + if (drawable->row == NULL) + goto drawable_fail; + + fb = &drawable->Base; /* basic framebuffer setup */ _mesa_initialize_window_framebuffer(fb, visual); @@ -340,6 +350,15 @@ dri_create_buffer(__DRIscreen * sPriv, GL_FALSE /* aux bufs */); return GL_TRUE; + +drawable_fail: + + if (drawable) + free(drawable->row); + + FREE(drawable); + + return GL_FALSE; } static void @@ -348,11 +367,12 @@ dri_destroy_buffer(__DRIdrawable * dPriv) TRACE; if (dPriv) { + struct dri_drawable *drawable = dri_drawable(dPriv); GLframebuffer *fb; - free(dPriv->row); + free(drawable->row); - fb = &dPriv->Base; + fb = &drawable->Base; fb->DeletePending = GL_TRUE; _mesa_reference_framebuffer(&fb, NULL); @@ -366,12 +386,13 @@ dri_swap_buffers(__DRIdrawable * dPriv) GET_CURRENT_CONTEXT(ctx); + struct dri_drawable *drawable = dri_drawable(dPriv); GLframebuffer *fb; struct swrast_renderbuffer *frontrb, *backrb; TRACE; - fb = &dPriv->Base; + fb = &drawable->Base; frontrb = swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); backrb = swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); @@ -402,7 +423,7 @@ dri_swap_buffers(__DRIdrawable * dPriv) static void get_window_size( GLframebuffer *fb, GLsizei *w, GLsizei *h ) { - __DRIdrawable *dPriv = swrast_drawable(fb); + __DRIdrawable *dPriv = swrast_drawable(fb)->dPriv; __DRIscreen *sPriv = dPriv->driScreenPriv; int x, y; @@ -572,13 +593,15 @@ dri_make_current(__DRIcontext * cPriv, if (cPriv) { struct dri_context *ctx = dri_context(cPriv); + struct dri_drawable *draw = dri_drawable(driDrawPriv); + struct dri_drawable *read = dri_drawable(driReadPriv); if (!driDrawPriv || !driReadPriv) return GL_FALSE; mesaCtx = &ctx->Base; - mesaDraw = &driDrawPriv->Base; - mesaRead = &driReadPriv->Base; + mesaDraw = &draw->Base; + mesaRead = &read->Base; /* check for same context and buffer */ if (mesaCtx == _mesa_get_current_context() diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 130598bbd8..8e87f644c3 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -80,6 +80,30 @@ swrast_context(GLcontext *ctx) return (struct dri_context *) ctx; } +struct dri_drawable +{ + /* mesa */ + GLframebuffer Base; + + /* dri */ + __DRIdrawable *dPriv; + + /* scratch row for optimized front-buffer rendering */ + char *row; +}; + +static INLINE struct dri_drawable * +dri_drawable(__DRIdrawable * driDrawPriv) +{ + return (struct dri_drawable *)driDrawPriv->driverPrivate; +} + +static INLINE struct dri_drawable * +swrast_drawable(GLframebuffer *fb) +{ + return (struct dri_drawable *) fb; +} + struct swrast_renderbuffer { struct gl_renderbuffer Base; @@ -89,12 +113,6 @@ struct swrast_renderbuffer { GLuint bpp; }; -static INLINE __DRIdrawable * -swrast_drawable(GLframebuffer *fb) -{ - return (__DRIdrawable *) fb; -} - static INLINE struct swrast_renderbuffer * swrast_renderbuffer(struct gl_renderbuffer *rb) { diff --git a/src/mesa/drivers/dri/swrast/swrast_spantemp.h b/src/mesa/drivers/dri/swrast/swrast_spantemp.h index c73b785683..079726ae4a 100644 --- a/src/mesa/drivers/dri/swrast/swrast_spantemp.h +++ b/src/mesa/drivers/dri/swrast/swrast_spantemp.h @@ -40,7 +40,7 @@ static INLINE void PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) { __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); + __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; @@ -54,7 +54,7 @@ static INLINE void GET_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) { __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer); + __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; @@ -66,7 +66,7 @@ static INLINE void PUT_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) { __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); + __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; @@ -79,7 +79,7 @@ static INLINE void GET_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) { __DRIcontext *ctx = swrast_context(glCtx)->cPriv; - __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer); + __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; -- cgit v1.2.3 From e60693efda7826bf26ffb9993c6dfba3b8c8a812 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:46 +0200 Subject: dri/swrast: update copyright email --- src/mesa/drivers/dri/swrast/swrast.c | 2 +- src/mesa/drivers/dri/swrast/swrast_priv.h | 6 +----- src/mesa/drivers/dri/swrast/swrast_span.c | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 4450e470c6..e9ca99a86f 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 George Sapountzis + * Copyright 2008, 2010 George Sapountzis * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 8e87f644c3..57bd439425 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -3,6 +3,7 @@ * Version: 7.1 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright 2008, 2010 George Sapountzis * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,11 +23,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Authors: - * George Sapountzis - */ - #ifndef _SWRAST_PRIV_H #define _SWRAST_PRIV_H diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c b/src/mesa/drivers/dri/swrast/swrast_span.c index 5290dc82b9..c5681e34a9 100644 --- a/src/mesa/drivers/dri/swrast/swrast_span.c +++ b/src/mesa/drivers/dri/swrast/swrast_span.c @@ -3,6 +3,7 @@ * Version: 7.1 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright 2008, 2010 George Sapountzis * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,11 +23,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Authors: - * George Sapountzis - */ - #include "swrast_priv.h" #define YFLIP(_xrb, Y) ((_xrb)->Base.Height - (Y) - 1) -- cgit v1.2.3 From e557c2e14f1481abff75af912feb5dce79a65ab8 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:46 +0200 Subject: dri/swrast: drop mtypes.h from dri_sw --- src/mesa/drivers/dri/common/dri_sw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/common/dri_sw.h b/src/mesa/drivers/dri/common/dri_sw.h index 89369a9d00..e353e26b34 100644 --- a/src/mesa/drivers/dri/common/dri_sw.h +++ b/src/mesa/drivers/dri/common/dri_sw.h @@ -26,8 +26,8 @@ #define _DRI_SW_H #include +#include #include -#include "main/mtypes.h" /** -- cgit v1.2.3 From 7a62c60ca960b3a5b27b598a0c2036f38933c8fb Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:46 +0200 Subject: dri/swrast: add comment in case it's not clear --- src/mesa/drivers/dri/swrast/swrast_priv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 57bd439425..77670d89a5 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -57,7 +57,7 @@ */ struct dri_context { - /* mesa */ + /* mesa, base class, must be first */ GLcontext Base; /* dri */ @@ -78,7 +78,7 @@ swrast_context(GLcontext *ctx) struct dri_drawable { - /* mesa */ + /* mesa, base class, must be first */ GLframebuffer Base; /* dri */ -- cgit v1.2.3 From 631a1a9ac8b97dec172205e13e33ef51f28bb1c0 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:47 +0200 Subject: dri/common: mv __driUtilMessage to utils.c allows to link with xmlconfig without dri_util, and has nothing drm-specific. --- src/mesa/drivers/dri/common/dri_util.c | 22 ---------------------- src/mesa/drivers/dri/common/dri_util.h | 4 ---- src/mesa/drivers/dri/common/utils.c | 28 ++++++++++++++++++++++++---- src/mesa/drivers/dri/common/utils.h | 3 +++ src/mesa/drivers/dri/common/xmlconfig.c | 2 +- src/mesa/drivers/dri/mach64/mach64_context.c | 1 + 6 files changed, 29 insertions(+), 31 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 75c98825b7..badbb5ff82 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -47,28 +47,6 @@ const __DRIextension driReadDrawableExtension = { __DRI_READ_DRAWABLE, __DRI_READ_DRAWABLE_VERSION }; -/** - * Print message to \c stderr if the \c LIBGL_DEBUG environment variable - * is set. - * - * Is called from the drivers. - * - * \param f \c printf like format string. - */ -void -__driUtilMessage(const char *f, ...) -{ - va_list args; - - if (getenv("LIBGL_DEBUG")) { - fprintf(stderr, "libGL: "); - va_start(args, f); - vfprintf(stderr, f, args); - va_end(args); - fprintf(stderr, "\n"); - } -} - GLint driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 ) { diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 99c0f1e442..f63583cebc 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -551,10 +551,6 @@ struct __DRIscreenRec { drmLock *lock; }; -extern void -__driUtilMessage(const char *f, ...); - - extern void __driUtilUpdateDrawableInfo(__DRIdrawable *pdp); diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index b85b364c57..0dd879abc9 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -37,6 +37,29 @@ #include "utils.h" +/** + * Print message to \c stderr if the \c LIBGL_DEBUG environment variable + * is set. + * + * Is called from the drivers. + * + * \param f \c printf like format string. + */ +void +__driUtilMessage(const char *f, ...) +{ + va_list args; + + if (getenv("LIBGL_DEBUG")) { + fprintf(stderr, "libGL: "); + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); + fprintf(stderr, "\n"); + } +} + + unsigned driParseDebugString( const char * debug, const struct dri_debug_control * control ) @@ -230,9 +253,6 @@ void driInitSingleExtension( GLcontext * ctx, /** * Utility function used by drivers to test the verions of other components. * - * If one of the version requirements is not met, a message is logged using - * \c __driUtilMessage. - * * \param driver_name Name of the driver. Used in error messages. * \param driActual Actual DRI version supplied __driCreateNewScreen. * \param driExpected Minimum DRI version required by the driver. @@ -244,7 +264,7 @@ void driInitSingleExtension( GLcontext * ctx, * \returns \c GL_TRUE if all version requirements are met. Otherwise, * \c GL_FALSE is returned. * - * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2, __driUtilMessage + * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2 * * \todo * Now that the old \c driCheckDriDdxDrmVersions function is gone, this diff --git a/src/mesa/drivers/dri/common/utils.h b/src/mesa/drivers/dri/common/utils.h index 02ca3feb73..de6070c398 100644 --- a/src/mesa/drivers/dri/common/utils.h +++ b/src/mesa/drivers/dri/common/utils.h @@ -69,6 +69,9 @@ struct __DRIutilversionRec2 { int patch; /**< Patch-level. */ }; +extern void +__driUtilMessage(const char *f, ...); + extern unsigned driParseDebugString( const char * debug, const struct dri_debug_control * control ); diff --git a/src/mesa/drivers/dri/common/xmlconfig.c b/src/mesa/drivers/dri/common/xmlconfig.c index 477259ea7e..de4500a39b 100644 --- a/src/mesa/drivers/dri/common/xmlconfig.c +++ b/src/mesa/drivers/dri/common/xmlconfig.c @@ -36,7 +36,7 @@ #include #include #include "main/imports.h" -#include "dri_util.h" +#include "utils.h" #include "xmlconfig.h" #undef GET_PROGRAM_NAME diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c index 77e7e53ce0..73b1e08d4b 100644 --- a/src/mesa/drivers/dri/mach64/mach64_context.c +++ b/src/mesa/drivers/dri/mach64/mach64_context.c @@ -31,6 +31,7 @@ #include "main/glheader.h" #include "main/context.h" +#include "main/extensions.h" #include "main/simple_list.h" #include "main/imports.h" -- cgit v1.2.3