From 606a5476131059b012bb2522b204ed8b868db122 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 28 Apr 2009 17:07:01 +0100 Subject: pb: Dump the fenced buffer sizes. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 044e8e1dd3..4698efa69c 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -531,16 +531,17 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) pipe_mutex_lock(fenced_list->mutex); - debug_printf("%10s %7s %10s %s\n", - "buffer", "reference.count", "fence", "signalled"); + debug_printf("%10s %7s %7s %10s %s\n", + "buffer", "size", "refcount", "fence", "signalled"); curr = fenced_list->unfenced.next; next = curr->next; while(curr != &fenced_list->unfenced) { fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); assert(!fenced_buf->fence); - debug_printf("%10p %7u\n", + debug_printf("%10p %7u %7u\n", fenced_buf, + fenced_buf->base.base.size, fenced_buf->base.base.reference.count); curr = next; next = curr->next; @@ -552,8 +553,9 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) int signaled; fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - debug_printf("%10p %7u %10p %s\n", + debug_printf("%10p %7u %7u %10p %s\n", fenced_buf, + fenced_buf->base.base.size, fenced_buf->base.base.reference.count, fenced_buf->fence, signaled == 0 ? "y" : "n"); -- cgit v1.2.3 From 1248ff7d45ce4b78af8c7a091cb64f1f992f88dd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 28 Apr 2009 18:53:52 +0100 Subject: pb: Save the stack backtrace when creating/mapping a debug buffer. --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 102 ++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index f1a05be46e..cedf745bda 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -40,6 +40,7 @@ #include "util/u_memory.h" #include "util/u_double_list.h" #include "util/u_time.h" +#include "util/u_debug_stack.h" #include "pb_buffer.h" #include "pb_bufmgr.h" @@ -48,6 +49,10 @@ #ifdef DEBUG +#define PB_DEBUG_CREATE_BACKTRACE 8 +#define PB_DEBUG_MAP_BACKTRACE 8 + + /** * Convenience macro (type safe). */ @@ -69,6 +74,14 @@ struct pb_debug_buffer size_t underflow_size; size_t overflow_size; + + struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE]; + + pipe_mutex mutex; + unsigned map_count; + struct debug_stack_frame map_backtrace[PB_DEBUG_MAP_BACKTRACE]; + + struct list_head head; }; @@ -80,6 +93,9 @@ struct pb_debug_manager size_t underflow_size; size_t overflow_size; + + pipe_mutex mutex; + struct list_head list; }; @@ -189,6 +205,9 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf) max_ofs == buf->overflow_size - 1 ? "+" : ""); } + if(underflow || overflow) + debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE); + debug_assert(!underflow && !overflow); /* re-fill if not aborted */ @@ -207,11 +226,18 @@ static void pb_debug_buffer_destroy(struct pb_buffer *_buf) { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); + struct pb_debug_manager *mgr = buf->mgr; assert(!pipe_is_referenced(&buf->base.base.reference)); pb_debug_buffer_check(buf); + pipe_mutex_lock(mgr->mutex); + LIST_DEL(&buf->head); + pipe_mutex_unlock(mgr->mutex); + + pipe_mutex_destroy(buf->mutex); + pb_reference(&buf->buffer, NULL); FREE(buf); } @@ -230,6 +256,13 @@ pb_debug_buffer_map(struct pb_buffer *_buf, if(!map) return NULL; + if(map) { + pipe_mutex_lock(buf->mutex); + ++buf->map_count; + debug_backtrace_capture(buf->map_backtrace, 1, PB_DEBUG_MAP_BACKTRACE); + pipe_mutex_unlock(buf->mutex); + } + return (uint8_t *)map + buf->underflow_size; } @@ -238,6 +271,13 @@ static void pb_debug_buffer_unmap(struct pb_buffer *_buf) { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); + + pipe_mutex_lock(buf->mutex); + assert(buf->map_count); + if(buf->map_count) + --buf->map_count; + pipe_mutex_unlock(buf->mutex); + pb_unmap(buf->buffer); pb_debug_buffer_check(buf); @@ -262,6 +302,14 @@ pb_debug_buffer_validate(struct pb_buffer *_buf, { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); + pipe_mutex_lock(buf->mutex); + if(buf->map_count) { + debug_printf("%s: attempting to validate a mapped buffer\n", __FUNCTION__); + debug_printf("last map backtrace is\n"); + debug_backtrace_dump(buf->map_backtrace, PB_DEBUG_MAP_BACKTRACE); + } + pipe_mutex_unlock(buf->mutex); + pb_debug_buffer_check(buf); return pb_validate(buf->buffer, vl, flags); @@ -288,6 +336,31 @@ pb_debug_buffer_vtbl = { }; +static void +pb_debug_manager_dump(struct pb_debug_manager *mgr) +{ + struct list_head *curr, *next; + struct pb_debug_buffer *buf; + + pipe_mutex_lock(mgr->mutex); + + curr = mgr->list.next; + next = curr->next; + while(curr != &mgr->list) { + buf = LIST_ENTRY(struct pb_debug_buffer, curr, head); + + debug_printf("buffer = %p\n", buf); + debug_printf(" .size = %p\n", buf->base.base.size); + debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE); + + curr = next; + next = curr->next; + } + + pipe_mutex_unlock(mgr->mutex); +} + + static struct pb_buffer * pb_debug_manager_create_buffer(struct pb_manager *_mgr, size_t size, @@ -312,6 +385,13 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, &real_desc); if(!buf->buffer) { FREE(buf); +#if 0 + pipe_mutex_lock(mgr->mutex); + debug_printf("%s: failed to create buffer\n", __FUNCTION__); + if(!LIST_IS_EMPTY(&mgr->list)) + pb_debug_manager_dump(mgr); + pipe_mutex_unlock(mgr->mutex); +#endif return NULL; } @@ -331,8 +411,16 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, buf->underflow_size = mgr->underflow_size; buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size; + debug_backtrace_capture(buf->create_backtrace, 1, PB_DEBUG_CREATE_BACKTRACE); + pb_debug_buffer_fill(buf); + pipe_mutex_init(buf->mutex); + + pipe_mutex_lock(mgr->mutex); + LIST_ADDTAIL(&buf->head, &mgr->list); + pipe_mutex_unlock(mgr->mutex); + return &buf->base; } @@ -351,6 +439,15 @@ static void pb_debug_manager_destroy(struct pb_manager *_mgr) { struct pb_debug_manager *mgr = pb_debug_manager(_mgr); + + pipe_mutex_lock(mgr->mutex); + if(!LIST_IS_EMPTY(&mgr->list)) { + debug_printf("%s: unfreed buffers\n", __FUNCTION__); + pb_debug_manager_dump(mgr); + } + pipe_mutex_unlock(mgr->mutex); + + pipe_mutex_destroy(mgr->mutex); mgr->provider->destroy(mgr->provider); FREE(mgr); } @@ -375,7 +472,10 @@ pb_debug_manager_create(struct pb_manager *provider, mgr->provider = provider; mgr->underflow_size = underflow_size; mgr->overflow_size = overflow_size; - + + pipe_mutex_init(mgr->mutex); + LIST_INITHEAD(&mgr->list); + return &mgr->base; } -- cgit v1.2.3 From bb9ea58f9502c7e54d03e3c2c21d20749f796c7c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 28 Apr 2009 19:46:56 +0100 Subject: wgl: UINT_PTR null value is an integral type, so return 0 instead of NULL. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 0b5dd78ec6..473e3308c6 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -276,12 +276,12 @@ stw_get_current_context( void ) struct stw_context *ctx; if(!glcurctx) - return NULL; + return 0; ctx = (struct stw_context *)glcurctx->DriverCtx; assert(ctx); if(!ctx) - return NULL; + return 0; return ctx->hglrc; } -- cgit v1.2.3 From af09ba96e9e2d783fb0538a82513716c1c9aed3b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 10:59:19 +0100 Subject: gallium/draw: cope with unused vertex_elements --- src/gallium/auxiliary/draw/draw_pt.h | 1 + src/gallium/auxiliary/draw/draw_pt_fetch.c | 8 +++++++- src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index 6f3e1e0289..8ef0ea8011 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -187,6 +187,7 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw ); struct pt_fetch; void draw_pt_fetch_prepare( struct pt_fetch *fetch, + unsigned vertex_input_count, unsigned vertex_size ); void draw_pt_fetch_run( struct pt_fetch *fetch, diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 505d32f2c3..65c3a34c34 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -26,6 +26,7 @@ **************************************************************************/ #include "util/u_memory.h" +#include "util/u_math.h" #include "draw/draw_context.h" #include "draw/draw_private.h" #include "draw/draw_vbuf.h" @@ -56,9 +57,11 @@ struct pt_fetch { * */ void draw_pt_fetch_prepare( struct pt_fetch *fetch, + unsigned vs_input_count, unsigned vertex_size ) { struct draw_context *draw = fetch->draw; + unsigned nr_inputs; unsigned i, nr = 0; unsigned dst_offset = 0; struct translate_key key; @@ -89,8 +92,11 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, dst_offset += 4 * sizeof(float); } + assert( draw->pt.nr_vertex_elements >= vs_input_count ); - for (i = 0; i < draw->pt.nr_vertex_elements; i++) { + nr_inputs = MIN2( vs_input_count, draw->pt.nr_vertex_elements ); + + for (i = 0; i < nr_inputs; i++) { key.element[nr].input_format = draw->pt.vertex_element[i].src_format; key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index; key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index 11ac90fc56..df6c265b7e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -77,8 +77,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle, draw_pt_fetch_prepare( fpme->fetch, + vs->info.num_inputs, fpme->vertex_size ); - /* XXX: it's not really gl rasterization rules we care about here, * but gl vs dx9 clip spaces. */ -- cgit v1.2.3 From d075cb4fc8c130f2e8f40356e7872fcc7ce3dcd1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 30 Apr 2009 12:24:08 +0100 Subject: wgl: Include alpha bits in pixel format's cColorBits field. --- src/gallium/state_trackers/wgl/shared/stw_pixelformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c index 9e642cbdd4..8d6955f390 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c @@ -158,7 +158,7 @@ stw_pixelformat_add( pfi->pfd.iPixelType = PFD_TYPE_RGBA; - pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue; + pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue + color->bits.alpha; pfi->pfd.cRedBits = color->bits.red; pfi->pfd.cRedShift = color->shift.red; pfi->pfd.cGreenBits = color->bits.green; -- cgit v1.2.3 From f628d7f5eebe9743f85ea8edf7c09b32cf393e4a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 13:09:34 +0100 Subject: gallium/tgsi: hack around linker/archiver breakage Add a dummy function which exists only so that tgsi_text_translate() doesn't get magic-ed out of the libtgsi.a archive by the build system. Don't remove unless you know this has been fixed - check on mingw/scons builds as well. --- src/gallium/auxiliary/tgsi/tgsi_transform.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src') diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c index 062c1be938..bc9c18fd4a 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_transform.c +++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c @@ -198,3 +198,30 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in, return ctx->ti; } + + +#include "tgsi_text.h" + +extern int tgsi_transform_foo( struct tgsi_token *tokens_out, + uint max_tokens_out ); + +/* This function exists only so that tgsi_text_translate() doesn't get + * magic-ed out of the libtgsi.a archive by the build system. Don't + * remove unless you know this has been fixed - check on mingw/scons + * builds as well. + */ +int +tgsi_transform_foo( struct tgsi_token *tokens_out, + uint max_tokens_out ) +{ + const char *text = + "FRAG1.1\n" + "DCL IN[0], COLOR, CONSTANT\n" + "DCL OUT[0], COLOR\n" + " 0: MOV OUT[0], IN[0]\n" + " 1: END"; + + return tgsi_text_translate( text, + tokens_out, + max_tokens_out ); +} -- cgit v1.2.3 From be3f9dd26cf59cadc21e4d5cc27dd199c9752b1c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 30 Apr 2009 13:10:58 +0100 Subject: util: Limit the stack walk to avoid referencing undefined memory. --- src/gallium/auxiliary/util/u_debug_stack.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c index e9891fde8a..528a1c394b 100644 --- a/src/gallium/auxiliary/util/u_debug_stack.c +++ b/src/gallium/auxiliary/util/u_debug_stack.c @@ -62,6 +62,8 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace, #ifdef PIPE_ARCH_X86 while(nr_frames) { + const void **next_frame_pointer; + if(!frame_pointer) break; @@ -72,7 +74,14 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace, --nr_frames; } - frame_pointer = (const void **)frame_pointer[0]; + next_frame_pointer = (const void **)frame_pointer[0]; + + /* Limit the stack walk to avoid referencing undefined memory */ + if((uintptr_t)next_frame_pointer <= (uintptr_t)frame_pointer || + (uintptr_t)next_frame_pointer > (uintptr_t)frame_pointer + 64*1024) + break; + + frame_pointer = next_frame_pointer; } #endif -- cgit v1.2.3 From 1ed90091be0a79977eb6c055ba1da56114d52f53 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 1 May 2009 16:30:08 +0100 Subject: wgl: Implemente SwapLayerBuffers. --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 2 +- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 12 ++++++++++++ src/gallium/state_trackers/wgl/shared/stw_public.h | 3 +++ src/gallium/state_trackers/wgl/wgl/stw_wgl.c | 5 +---- 4 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 3711982fd2..b259ea91f5 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -583,7 +583,7 @@ DrvSwapLayerBuffers( if (DBG) debug_printf( "%s\n", __FUNCTION__ ); - return FALSE; + return stw_swap_layer_buffers( hdc, fuPlanes ); } BOOL APIENTRY diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 4348b8f326..f66f429542 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -237,6 +237,18 @@ stw_swap_buffers( } +BOOL +stw_swap_layer_buffers( + HDC hdc, + UINT fuPlanes ) +{ + if(fuPlanes & WGL_SWAP_MAIN_PLANE) + return stw_swap_buffers(hdc); + + return FALSE; +} + + boolean stw_framebuffer_init_thread(void) { diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h index 39d377c16b..59d709a6d4 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_public.h +++ b/src/gallium/state_trackers/wgl/shared/stw_public.h @@ -50,6 +50,9 @@ BOOL stw_make_current( HDC hdc, UINT_PTR hglrc ); BOOL stw_swap_buffers( HDC hdc ); +BOOL +stw_swap_layer_buffers( HDC hdc, UINT fuPlanes ); + PROC stw_get_proc_address( LPCSTR lpszProc ); int stw_pixelformat_describe( HDC hdc, diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index e06d2640b4..30e42e0ec5 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -100,10 +100,7 @@ wglSwapLayerBuffers( HDC hdc, UINT fuPlanes ) { - (void) hdc; - (void) fuPlanes; - - return FALSE; + return stw_swap_layer_buffers( hdc, fuPlanes ); } WINGDIAPI PROC APIENTRY -- cgit v1.2.3 From 751f73e2812cf8185c775a91c16cf8565b85536d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 1 May 2009 18:20:42 +0100 Subject: mesa/main: set PREFER_DP4 to match position_invarient code This is a quick fix for z fighting in quake4 caused by the mismatch between vertex transformation here and in the position_invarient code. Full fix would be to make this driver-tunable and adjust both position_invarient and ffvertex_prog.c code to respect driver preferences. --- src/mesa/main/ffvertex_prog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 1ce5685af4..82e1c4af66 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -319,7 +319,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) * multiplications with DP4's or with MUL/MAD's? SSE works better * with the latter, drivers may differ. */ -#define PREFER_DP4 0 +#define PREFER_DP4 1 /* Use uregs to represent registers internally, translate to Mesa's -- cgit v1.2.3 From b6e8256899a9a93c665c34e10efcc918f2fcc095 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 5 May 2009 12:12:28 +0100 Subject: mesa: more complete fix for transform_invarient glitches Add a new flag mvp_with_dp4 in the context, and use that to switch both ffvertex.c and programopt.c vertex transformation code to either DP4 or MUL/MAD implementations. --- src/mesa/main/context.c | 13 ++++ src/mesa/main/context.h | 4 ++ src/mesa/main/ffvertex_prog.c | 16 +++-- src/mesa/main/mtypes.h | 6 ++ src/mesa/shader/programopt.c | 119 +++++++++++++++++++++++++++++++++++- src/mesa/state_tracker/st_context.c | 6 ++ 6 files changed, 153 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 016284de9a..d780f91f04 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1522,4 +1522,17 @@ _mesa_Flush(void) } +/** + * Set mvp_with_dp4 flag. If a driver has a preference for DP4 over + * MUL/MAD, or vice versa, call this function to register that. + * Otherwise we default to MUL/MAD. + */ +void +_mesa_set_mvp_with_dp4( GLcontext *ctx, + GLboolean flag ) +{ + ctx->mvp_with_dp4 = flag; +} + + /*@}*/ diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index ecc1cec779..5b57d88029 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -151,6 +151,10 @@ extern struct _glapi_table * _mesa_get_dispatch(GLcontext *ctx); +void +_mesa_set_mvp_with_dp4( GLcontext *ctx, + GLboolean flag ); + /** \name Miscellaneous */ /*@{*/ diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 82e1c4af66..43325b1352 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -315,12 +315,6 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) */ #define DISASSEM 0 -/* Should be tunable by the driver - do we want to do matrix - * multiplications with DP4's or with MUL/MAD's? SSE works better - * with the latter, drivers may differ. - */ -#define PREFER_DP4 1 - /* Use uregs to represent registers internally, translate to Mesa's * expected formats on emit. @@ -348,6 +342,7 @@ struct tnl_program { const struct state_key *state; struct gl_vertex_program *program; GLint max_inst; /** number of instructions allocated for program */ + GLboolean mvp_with_dp4; GLuint temp_in_use; GLuint temp_reserved; @@ -775,7 +770,7 @@ static struct ureg get_eye_position( struct tnl_program *p ) p->eye_position = reserve_temp(p); - if (PREFER_DP4) { + if (p->mvp_with_dp4) { register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, 0, modelview ); @@ -881,7 +876,7 @@ static void build_hpos( struct tnl_program *p ) struct ureg hpos = register_output( p, VERT_RESULT_HPOS ); struct ureg mvp[4]; - if (PREFER_DP4) { + if (p->mvp_with_dp4) { register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, 0, mvp ); emit_matrix_transform_vec4( p, hpos, mvp, pos ); @@ -1574,7 +1569,7 @@ static void build_texture_transform( struct tnl_program *p ) struct ureg in = (!is_undef(out_texgen) ? out_texgen : register_input(p, VERT_ATTRIB_TEX0+i)); - if (PREFER_DP4) { + if (p->mvp_with_dp4) { register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, 0, texmat ); emit_matrix_transform_vec4( p, out, texmat, in ); @@ -1708,6 +1703,7 @@ static void build_tnl_program( struct tnl_program *p ) static void create_new_program( const struct state_key *key, struct gl_vertex_program *program, + GLboolean mvp_with_dp4, GLuint max_temps) { struct tnl_program p; @@ -1721,6 +1717,7 @@ create_new_program( const struct state_key *key, p.transformed_normal = undef; p.identity = undef; p.temp_in_use = 0; + p.mvp_with_dp4 = mvp_with_dp4; if (max_temps >= sizeof(int) * 8) p.temp_reserved = 0; @@ -1776,6 +1773,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx) return NULL; create_new_program( &key, prog, + ctx->mvp_with_dp4, ctx->Const.VertexProgram.MaxTemps ); #if 0 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 30c7cca3b5..ed6b1062bd 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2977,6 +2977,12 @@ struct __GLcontextRec /** software compression/decompression supported or not */ GLboolean Mesa_DXTn; + /** + * Use dp4 (rather than mul/mad) instructions for position + * transformation? + */ + GLboolean mvp_with_dp4; + /** Core tnl module support */ struct gl_tnl_module TnlModule; diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index ecd98dc85c..f70c75cec8 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -45,8 +45,8 @@ * into a vertex program. * May be used to implement the position_invariant option. */ -void -_mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) +static void +_mesa_insert_mvp_dp4_code(GLcontext *ctx, struct gl_vertex_program *vprog) { struct prog_instruction *newInst; const GLuint origLen = vprog->Base.NumInstructions; @@ -113,6 +113,121 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) } +static void +_mesa_insert_mvp_mad_code(GLcontext *ctx, struct gl_vertex_program *vprog) +{ + struct prog_instruction *newInst; + const GLuint origLen = vprog->Base.NumInstructions; + const GLuint newLen = origLen + 4; + GLuint hposTemp; + GLuint i; + + /* + * Setup state references for the modelview/projection matrix. + * XXX we should check if these state vars are already declared. + */ + static const gl_state_index mvpState[4][STATE_LENGTH] = { + { STATE_MVP_MATRIX, 0, 0, 0, STATE_MATRIX_TRANSPOSE }, + { STATE_MVP_MATRIX, 0, 1, 1, STATE_MATRIX_TRANSPOSE }, + { STATE_MVP_MATRIX, 0, 2, 2, STATE_MATRIX_TRANSPOSE }, + { STATE_MVP_MATRIX, 0, 3, 3, STATE_MATRIX_TRANSPOSE }, + }; + GLint mvpRef[4]; + + for (i = 0; i < 4; i++) { + mvpRef[i] = _mesa_add_state_reference(vprog->Base.Parameters, + mvpState[i]); + } + + /* Alloc storage for new instructions */ + newInst = _mesa_alloc_instructions(newLen); + if (!newInst) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glProgramString(inserting position_invariant code)"); + return; + } + + /* TEMP hposTemp; */ + hposTemp = vprog->Base.NumTemporaries++; + + /* + * Generated instructions: + * emit_op2(p, OPCODE_MUL, tmp, 0, swizzle1(src,X), mat[0]); + * emit_op3(p, OPCODE_MAD, tmp, 0, swizzle1(src,Y), mat[1], tmp); + * emit_op3(p, OPCODE_MAD, tmp, 0, swizzle1(src,Z), mat[2], tmp); + * emit_op3(p, OPCODE_MAD, dest, 0, swizzle1(src,W), mat[3], tmp); + */ + _mesa_init_instructions(newInst, 4); + + newInst[0].Opcode = OPCODE_MUL; + newInst[0].DstReg.File = PROGRAM_TEMPORARY; + newInst[0].DstReg.Index = hposTemp; + newInst[0].DstReg.WriteMask = WRITEMASK_XYZW; + newInst[0].SrcReg[0].File = PROGRAM_INPUT; + newInst[0].SrcReg[0].Index = VERT_ATTRIB_POS; + newInst[0].SrcReg[0].Swizzle = SWIZZLE_XXXX; + newInst[0].SrcReg[1].File = PROGRAM_STATE_VAR; + newInst[0].SrcReg[1].Index = mvpRef[0]; + newInst[0].SrcReg[1].Swizzle = SWIZZLE_NOOP; + + for (i = 1; i <= 2; i++) { + newInst[i].Opcode = OPCODE_MAD; + newInst[i].DstReg.File = PROGRAM_TEMPORARY; + newInst[i].DstReg.Index = hposTemp; + newInst[i].DstReg.WriteMask = WRITEMASK_XYZW; + newInst[i].SrcReg[0].File = PROGRAM_INPUT; + newInst[i].SrcReg[0].Index = VERT_ATTRIB_POS; + newInst[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(i,i,i,i); + newInst[i].SrcReg[1].File = PROGRAM_STATE_VAR; + newInst[i].SrcReg[1].Index = mvpRef[i]; + newInst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; + newInst[i].SrcReg[2].File = PROGRAM_TEMPORARY; + newInst[i].SrcReg[2].Index = hposTemp; + newInst[1].SrcReg[2].Swizzle = SWIZZLE_NOOP; + } + + newInst[3].Opcode = OPCODE_MAD; + newInst[3].DstReg.File = PROGRAM_OUTPUT; + newInst[3].DstReg.Index = VERT_RESULT_HPOS; + newInst[3].DstReg.WriteMask = WRITEMASK_XYZW; + newInst[3].SrcReg[0].File = PROGRAM_INPUT; + newInst[3].SrcReg[0].Index = VERT_ATTRIB_POS; + newInst[3].SrcReg[0].Swizzle = SWIZZLE_WWWW; + newInst[3].SrcReg[1].File = PROGRAM_STATE_VAR; + newInst[3].SrcReg[1].Index = mvpRef[3]; + newInst[3].SrcReg[1].Swizzle = SWIZZLE_NOOP; + newInst[3].SrcReg[2].File = PROGRAM_TEMPORARY; + newInst[3].SrcReg[2].Index = hposTemp; + newInst[3].SrcReg[2].Swizzle = SWIZZLE_NOOP; + + + /* Append original instructions after new instructions */ + _mesa_copy_instructions (newInst + 4, vprog->Base.Instructions, origLen); + + /* free old instructions */ + _mesa_free_instructions(vprog->Base.Instructions, origLen); + + /* install new instructions */ + vprog->Base.Instructions = newInst; + vprog->Base.NumInstructions = newLen; + vprog->Base.InputsRead |= VERT_BIT_POS; + vprog->Base.OutputsWritten |= (1 << VERT_RESULT_HPOS); +} + + +void +_mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) +{ + if (ctx->mvp_with_dp4) + _mesa_insert_mvp_dp4_code( ctx, vprog ); + else + _mesa_insert_mvp_mad_code( ctx, vprog ); +} + + + + + /** * Append extra instructions onto the given fragment program to implement diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 92a630eff9..2a1f21c51c 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -177,6 +177,12 @@ struct st_context *st_create_context(struct pipe_context *pipe, ctx = _mesa_create_context(visual, shareCtx, &funcs, NULL); + /* XXX: need a capability bit in gallium to query if the pipe + * driver prefers DP4 or MUL/MAD for vertex transformation. + */ + if (debug_get_bool_option("MESA_MVP_DP4", FALSE)) + _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); + return st_create_context_priv(ctx, pipe); } -- cgit v1.2.3 From 4d28fcfeaa6be438f6739fddcb0661ae97a68919 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 1 May 2009 18:49:22 +0100 Subject: wgl: Implement ShareLists. --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 2 +- .../state_trackers/wgl/shared/stw_context.c | 24 ++++++++++++++++++++++ src/gallium/state_trackers/wgl/shared/stw_public.h | 2 ++ src/gallium/state_trackers/wgl/wgl/stw_wgl.c | 7 +------ 4 files changed, 28 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index b259ea91f5..62af765211 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -562,7 +562,7 @@ DrvShareLists( if (DBG) debug_printf( "%s\n", __FUNCTION__ ); - return FALSE; + return stw_share_lists(dhglrc1, dhglrc2); } BOOL APIENTRY diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 473e3308c6..e172f09bdf 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -74,6 +74,30 @@ stw_copy_context( return ret; } +BOOL +stw_share_lists( + UINT_PTR hglrc1, + UINT_PTR hglrc2 ) +{ + struct stw_context *ctx1; + struct stw_context *ctx2; + BOOL ret = FALSE; + + pipe_mutex_lock( stw_dev->mutex ); + + ctx1 = stw_lookup_context_locked( hglrc1 ); + ctx2 = stw_lookup_context_locked( hglrc2 ); + + if (ctx1 && ctx2 && + ctx1->pfi == ctx2->pfi) { + ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx); + } + + pipe_mutex_unlock( stw_dev->mutex ); + + return ret; +} + UINT_PTR stw_create_layer_context( HDC hdc, diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h index 59d709a6d4..7fe9cfb356 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_public.h +++ b/src/gallium/state_trackers/wgl/shared/stw_public.h @@ -37,6 +37,8 @@ BOOL stw_copy_context( UINT_PTR hglrcSrc, UINT_PTR stw_create_layer_context( HDC hdc, int iLayerPlane ); +BOOL stw_share_lists( UINT_PTR hglrc1, UINT_PTR hglrc2 ); + BOOL stw_delete_context( UINT_PTR hglrc ); BOOL diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index 30e42e0ec5..a131292f7a 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -186,12 +186,7 @@ wglShareLists( HGLRC hglrc1, HGLRC hglrc2 ) { - (void) hglrc1; - (void) hglrc2; - - assert( 0 ); - - return FALSE; + return stw_share_lists( (UINT_PTR)hglrc1, (UINT_PTR)hglrc2);; } WINGDIAPI BOOL APIENTRY -- cgit v1.2.3 From d88faf91e9fe222636b33540298ee64bc6f4416c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 1 May 2009 18:52:54 +0100 Subject: mesa: Make _mesa_share_state thread safe. --- src/mesa/main/context.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index d780f91f04..60c48289e4 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1397,14 +1397,21 @@ _mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare) { if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) { struct gl_shared_state *oldSharedState = ctx->Shared; + GLint RefCount; ctx->Shared = ctxToShare->Shared; + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); ctx->Shared->RefCount++; + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); update_default_objects(ctx); - oldSharedState->RefCount--; - if (oldSharedState->RefCount == 0) { + _glthread_LOCK_MUTEX(oldSharedState->Mutex); + RefCount = --oldSharedState->RefCount; + _glthread_UNLOCK_MUTEX(oldSharedState->Mutex); + + if (RefCount == 0) { _mesa_free_shared_state(ctx, oldSharedState); } -- cgit v1.2.3 From 692263aad695c66669a0001fb3ac6d7a0bd84c94 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 1 May 2009 18:53:17 +0100 Subject: wgl: Remove unused variable. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index e172f09bdf..336eccef71 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -109,7 +109,6 @@ stw_create_layer_context( GLvisual *visual = NULL; struct pipe_screen *screen = NULL; struct pipe_context *pipe = NULL; - UINT_PTR hglrc = 0; if(!stw_dev) return 0; -- cgit v1.2.3 From d78b5952c10d5c65cd7d679b291c217ebd30cc4a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 1 May 2009 18:53:51 +0100 Subject: wgl: Add assertion for missing function. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 336eccef71..d532b1563b 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -64,6 +64,7 @@ stw_copy_context( if (src && dst) { /* FIXME */ + assert(0); (void) src; (void) dst; (void) mask; -- cgit v1.2.3 From d5eac43a2e06ff30f9e6f74e49493ef5d64cd309 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 6 May 2009 19:58:08 +0100 Subject: wgl: Enforce a minimum 1x1 framebuffer size. --- .../state_trackers/wgl/shared/stw_context.c | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index d532b1563b..b61f74f69b 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -278,19 +278,30 @@ stw_release_context( /* Find the width and height of the window named by hdc. */ static void -stw_get_window_size( HDC hdc, GLuint *width, GLuint *height ) +stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight ) { - if (WindowFromDC( hdc )) { - RECT rect; + GLuint width, height; + HWND hwnd; - GetClientRect( WindowFromDC( hdc ), &rect ); - *width = rect.right - rect.left; - *height = rect.bottom - rect.top; + hwnd = WindowFromDC( hdc ); + if (hwnd) { + RECT rect; + GetClientRect( hwnd, &rect ); + width = rect.right - rect.left; + height = rect.bottom - rect.top; } else { - *width = GetDeviceCaps( hdc, HORZRES ); - *height = GetDeviceCaps( hdc, VERTRES ); + width = GetDeviceCaps( hdc, HORZRES ); + height = GetDeviceCaps( hdc, VERTRES ); } + + if(width < 1) + width = 1; + if(height < 1) + height = 1; + + *pwidth = width; + *pheight = height; } UINT_PTR -- cgit v1.2.3 From ee7982718685cd2398a895caf5e7cd90b6ee12f9 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 6 May 2009 20:41:17 +0100 Subject: stw: fix potential uninitialized use of curctx --- src/gallium/state_trackers/wgl/shared/stw_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index b61f74f69b..dd97e48b14 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -348,7 +348,7 @@ stw_make_current( struct stw_framebuffer *fb; GLuint width = 0; GLuint height = 0; - struct stw_context *curctx; + struct stw_context *curctx = NULL; if (!stw_dev) return FALSE; -- cgit v1.2.3 From e6a3801f3daaaf7e7e048ad0c43e838bac6a2d9a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 May 2009 09:24:37 +0100 Subject: util/upload: catch failures to map_range and return error Caller may be able to do something about this - eg flush and retry. --- src/gallium/auxiliary/util/u_upload_mgr.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index d9c0d7afa8..2eb98068c8 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -70,7 +70,7 @@ struct u_upload_mgr *u_upload_create( struct pipe_screen *screen, } -static INLINE void +static INLINE enum pipe_error my_buffer_write(struct pipe_screen *screen, struct pipe_buffer *buf, unsigned offset, unsigned size, unsigned dirty_size, @@ -84,12 +84,14 @@ my_buffer_write(struct pipe_screen *screen, assert(size); map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE); - assert(map); - if(map) { - memcpy(map + offset, data, size); - pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size); - pipe_buffer_unmap(screen, buf); - } + if (map == NULL) + return PIPE_ERROR_OUT_OF_MEMORY; + + memcpy(map + offset, data, size); + pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size); + pipe_buffer_unmap(screen, buf); + + return PIPE_OK; } /* Release old buffer. @@ -162,12 +164,14 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, /* Copy the data, using map_range if available: */ - my_buffer_write( upload->screen, - upload->buffer, - upload->offset, - size, - alloc_size, - data ); + ret = my_buffer_write( upload->screen, + upload->buffer, + upload->offset, + size, + alloc_size, + data ); + if (ret) + return ret; /* Emit the return values: */ -- cgit v1.2.3 From 33d2ca7624968fc972c917f15fa947df36916296 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 May 2009 11:46:08 +0100 Subject: mesa/st: cope with non-ibo index data in st_draw_feedback.c Previously only non-indexed or indicies-in-a-vbo cases were handled in this code. This change adds the missing regular indices-in-memory case. --- src/mesa/state_tracker/st_draw_feedback.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index e533afd051..32502a9cda 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -196,13 +196,10 @@ st_feedback_draw_vbo(GLcontext *ctx, draw_set_vertex_elements(draw, vp->num_inputs, velements); if (ib) { - unsigned indexSize; struct gl_buffer_object *bufobj = ib->obj; - struct st_buffer_object *stobj = st_buffer_object(bufobj); + unsigned indexSize; void *map; - index_buffer_handle = stobj->buffer; - switch (ib->type) { case GL_UNSIGNED_INT: indexSize = 4; @@ -215,9 +212,19 @@ st_feedback_draw_vbo(GLcontext *ctx, return; } - map = pipe_buffer_map(pipe->screen, index_buffer_handle, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_element_buffer(draw, indexSize, map); + if (bufobj && bufobj->Name) { + struct st_buffer_object *stobj = st_buffer_object(bufobj); + + index_buffer_handle = stobj->buffer; + + map = pipe_buffer_map(pipe->screen, index_buffer_handle, + PIPE_BUFFER_USAGE_CPU_READ); + + draw_set_mapped_element_buffer(draw, indexSize, map); + } + else { + draw_set_mapped_element_buffer(draw, indexSize, (void *) ib->ptr); + } } else { /* no index/element buffer */ @@ -252,7 +259,7 @@ st_feedback_draw_vbo(GLcontext *ctx, draw_set_mapped_vertex_buffer(draw, i, NULL); } } - if (ib) { + if (index_buffer_handle) { pipe_buffer_unmap(pipe->screen, index_buffer_handle); draw_set_mapped_element_buffer(draw, 0, NULL); } -- cgit v1.2.3 From 44a996b185c446eab7038a10153db7e7496bf2c9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 7 May 2009 18:21:56 +0100 Subject: wgl: Export pixelformats with accumulation bits. --- src/gallium/state_trackers/wgl/shared/stw_pixelformat.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c index 8d6955f390..b81d2b59a4 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c @@ -119,6 +119,7 @@ stw_pixelformat_add( struct stw_device *stw_dev, const struct stw_pf_color_info *color, const struct stw_pf_depth_info *depth, + unsigned accum, boolean doublebuffer, unsigned samples ) { @@ -167,11 +168,11 @@ stw_pixelformat_add( pfi->pfd.cBlueShift = color->shift.blue; pfi->pfd.cAlphaBits = color->bits.alpha; pfi->pfd.cAlphaShift = color->shift.alpha; - pfi->pfd.cAccumBits = 0; - pfi->pfd.cAccumRedBits = 0; - pfi->pfd.cAccumGreenBits = 0; - pfi->pfd.cAccumBlueBits = 0; - pfi->pfd.cAccumAlphaBits = 0; + pfi->pfd.cAccumBits = 4*accum; + pfi->pfd.cAccumRedBits = accum; + pfi->pfd.cAccumGreenBits = accum; + pfi->pfd.cAccumBlueBits = accum; + pfi->pfd.cAccumAlphaBits = accum; pfi->pfd.cDepthBits = depth->bits.depth; pfi->pfd.cStencilBits = depth->bits.stencil; pfi->pfd.cAuxBuffers = 0; @@ -228,7 +229,8 @@ stw_pixelformat_init( void ) PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) continue; - stw_pixelformat_add( stw_dev, color, depth, doublebuffer, samples ); + stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples ); + stw_pixelformat_add( stw_dev, color, depth, 16, doublebuffer, samples ); } } } -- cgit v1.2.3 From 507f4e7a7448fb246febefe8819b7b3ac70a35b4 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 May 2009 19:27:30 +0100 Subject: mesa/st: remove redundant call to st_finish in CopyTexSubImage Rendering should already have been flushed, any synchronization will be done by the driver or memory manager. --- src/mesa/state_tracker/st_cb_texture.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index b7b791d9a4..98f109fc65 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1315,9 +1315,6 @@ st_copy_texsubimage(GLcontext *ctx, GLboolean use_fallback = GL_TRUE; GLboolean matching_base_formats; - /* any rendering in progress must complete before we grab the fb image */ - st_finish(ctx->st); - /* make sure finalize_textures has been called? */ if (0) st_validate_state(ctx->st); -- cgit v1.2.3 From e90beb93a89f77bffce8ab3d54457ea65868e93c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 May 2009 19:48:06 +0100 Subject: mesa/st: keep surface_copy arguments positive The src/dest x,y, and w,h arguments of the pipe->surface_copy function are unsigned and the drivers aren't expecting negative (or extremly-large unsigned) values as inputs. Trim the requests at the state-tracker level before passing down. --- src/mesa/state_tracker/st_cb_drawpixels.c | 43 ++++++++++++++++++++++++++++--- src/mesa/state_tracker/st_cb_texture.c | 28 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 08dc7c930e..89725cfe8d 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -910,6 +910,34 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, st_validate_state(st); + if (srcx < 0) { + width -= -srcx; + dstx += -srcx; + srcx = 0; + } + + if (srcy < 0) { + height -= -srcy; + dsty += -srcy; + srcy = 0; + } + + if (dstx < 0) { + width -= -dstx; + srcx += -dstx; + dstx = 0; + } + + if (dsty < 0) { + height -= -dsty; + srcy += -dsty; + dsty = 0; + } + + if (width < 0 || height < 0) + return; + + if (type == GL_STENCIL) { /* can't use texturing to do stencil */ copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty); @@ -951,15 +979,24 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, } } + if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { + srcy = ctx->DrawBuffer->Height - srcy - height; + + if (srcy < 0) { + height -= -srcy; + srcy = 0; + } + + if (height < 0) + return; + } + pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, texFormat, 0, width, height, 1, PIPE_TEXTURE_USAGE_SAMPLER); if (!pt) return; - if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - srcy = ctx->DrawBuffer->Height - srcy - height; - } if (srcFormat == texFormat) { /* copy source framebuffer surface into mipmap/texture */ diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 98f109fc65..b182106fd5 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1337,6 +1337,34 @@ st_copy_texsubimage(GLcontext *ctx, return; } + if (srcX < 0) { + width -= -srcX; + destX += -srcX; + srcX = 0; + } + + if (srcY < 0) { + height -= -srcY; + destY += -srcY; + srcY = 0; + } + + if (destX < 0) { + width -= -destX; + srcX += -destX; + destX = 0; + } + + if (destY < 0) { + height -= -destY; + srcY += -destY; + destY = 0; + } + + if (width < 0 || height < 0) + return; + + assert(strb); assert(strb->surface); assert(stImage->pt); -- cgit v1.2.3 From b6e226109612057762eb7d0bf73f39a93c69e6c3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 8 May 2009 14:23:45 +0100 Subject: wgl: Grow the maximum number of pixel formats to cope with the new accum pixel formats. Fix a segfault when using softpipe. --- src/gallium/state_trackers/wgl/shared/stw_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h index 969e3843e7..e097f1f71e 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.h +++ b/src/gallium/state_trackers/wgl/shared/stw_device.h @@ -37,7 +37,7 @@ #include "stw_pixelformat.h" -#define STW_MAX_PIXELFORMATS 128 +#define STW_MAX_PIXELFORMATS 256 struct pipe_screen; -- cgit v1.2.3 From 6fec2eb1433c8d533b0a9afb73a2162db8dd9a7b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 8 May 2009 15:04:12 -0600 Subject: mesa: set version to 7.5-rc1 --- Makefile | 2 +- src/mesa/main/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/Makefile b/Makefile index a77825e8f9..4282b78f49 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.5-devel +VERSION=7.5-rc1 DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index ba027465d4..072037bbd7 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -31,7 +31,7 @@ #define MESA_MAJOR 7 #define MESA_MINOR 5 #define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.5" +#define MESA_VERSION_STRING "7.5-rc1" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -- cgit v1.2.3 From c8c0953294daf9176bc89c28484410e9b7de2b93 Mon Sep 17 00:00:00 2001 From: Hanno Böck Date: Sat, 9 May 2009 16:17:37 -0600 Subject: gallium: replace lib with $(LIB_DIR) --- src/gallium/winsys/drm/intel/dri/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile index a4704bc050..ac0891a646 100644 --- a/src/gallium/winsys/drm/intel/dri/Makefile +++ b/src/gallium/winsys/drm/intel/dri/Makefile @@ -21,5 +21,5 @@ include ../../Makefile.template DRI_LIB_DEPS += -ldrm_intel symlinks: $(TOP)/$(LIB_DIR)/gallium - @rm -f $(TOP)/lib/gallium/i965_dri.so - ln -s i915_dri.so $(TOP)/lib/gallium/i965_dri.so + @rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so + ln -s i915_dri.so $(TOP)/$(LIB_DIR)/gallium/i965_dri.so -- cgit v1.2.3 From 2223615e0a897434b41f86d22c41cb5dc9f8d67a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 11 May 2009 09:46:56 -0600 Subject: mesa: Fixed a texture memory leak The current texture for any particular texture unit is given an additional reference in update_texture_state(); but if the context is closed before that texture can be released (which is quite frequent in normal use, unless a program unbinds and deletes the texture and renders without it to force a call to update_texture_state(), the memory is lost. This affects general Mesa; but the i965 is particularly affected because it allocates a considerable amount of additional memory for each allocated texture. (cherry picked from master, commit c230767d6956b63a2b101acb48f98823bb5dd31a) --- src/mesa/main/texstate.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 73f8a5339e..cef58d7a49 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -780,6 +780,9 @@ _mesa_free_texture_data(GLcontext *ctx) /* unreference current textures */ for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { + /* The _Current texture could account for another reference */ + _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL); } -- cgit v1.2.3 From f104e4d666dfccda6f5ad817693216733ddede44 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 11 May 2009 16:09:39 -0600 Subject: st: do proper refcounting for framebuffer surfaces --- src/mesa/state_tracker/st_atom_framebuffer.c | 16 ++++++++++------ src/mesa/state_tracker/st_context.c | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index df0f0931ea..536293683e 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -98,8 +98,6 @@ update_framebuffer_state( struct st_context *st ) struct st_renderbuffer *strb; GLuint i; - memset(framebuffer, 0, sizeof(*framebuffer)); - framebuffer->width = fb->Width; framebuffer->height = fb->Height; @@ -120,12 +118,19 @@ update_framebuffer_state( struct st_context *st ) } if (strb->surface) { - framebuffer->cbufs[framebuffer->nr_cbufs] = strb->surface; + pipe_surface_reference(&framebuffer->cbufs[framebuffer->nr_cbufs], + strb->surface); framebuffer->nr_cbufs++; } } } + for (i = framebuffer->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; i++) { + pipe_surface_reference(&framebuffer->cbufs[i], NULL); + } + /* + * Depth/Stencil renderbuffer/surface. + */ strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer); if (strb) { strb = st_renderbuffer(strb->Base.Wrapped); @@ -133,15 +138,14 @@ update_framebuffer_state( struct st_context *st ) /* rendering to a GL texture, may have to update surface */ update_renderbuffer_surface(st, strb); } - - framebuffer->zsbuf = strb->surface; + pipe_surface_reference(&framebuffer->zsbuf, strb->surface); } else { strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer); if (strb) { strb = st_renderbuffer(strb->Base.Wrapped); assert(strb->surface); - framebuffer->zsbuf = strb->surface; + pipe_surface_reference(&framebuffer->zsbuf, strb->surface); } } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 2a1f21c51c..e536029e86 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -233,6 +233,7 @@ void st_destroy_context( struct st_context *st ) struct pipe_context *pipe = st->pipe; struct cso_context *cso = st->cso_context; GLcontext *ctx = st->ctx; + GLuint i; /* need to unbind and destroy CSO objects before anything else */ cso_release_all(st->cso_context); @@ -240,6 +241,12 @@ void st_destroy_context( struct st_context *st ) st_reference_fragprog(st, &st->fp, NULL); st_reference_vertprog(st, &st->vp, NULL); + /* release framebuffer surfaces */ + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL); + } + pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL); + _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); _vbo_DestroyContext(st->ctx); -- cgit v1.2.3