diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/SConscript | 3 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.c | 141 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.h | 33 | ||||
-rw-r--r-- | src/mesa/main/context.c | 4 | ||||
-rw-r--r-- | src/mesa/main/drawpix.c | 62 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 3 | ||||
-rw-r--r-- | src/mesa/shader/program.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_constbuf.c | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_shader.c | 43 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_shader.h | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 21 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 20 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_program.c | 57 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_readpixels.c | 17 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 15 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_bitmap.c | 32 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 29 | ||||
-rw-r--r-- | src/mesa/swrast/s_readpix.c | 28 |
20 files changed, 354 insertions, 185 deletions
diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 678e4ad0e82..b816a21b38d 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -142,6 +142,8 @@ STATETRACKER_SOURCES = [ 'state_tracker/st_atom_texture.c', 'state_tracker/st_atom_viewport.c', 'state_tracker/st_cb_accum.c', + 'state_tracker/st_cb_bitmap.c', + 'state_tracker/st_cb_blit.c', 'state_tracker/st_cb_bufferobjects.c', 'state_tracker/st_cb_clear.c', 'state_tracker/st_cb_flush.c', @@ -154,7 +156,6 @@ STATETRACKER_SOURCES = [ 'state_tracker/st_cb_readpixels.c', 'state_tracker/st_cb_strings.c', 'state_tracker/st_cb_texture.c', - 'state_tracker/st_cache.c', 'state_tracker/st_context.c', 'state_tracker/st_debug.c', 'state_tracker/st_draw.c', diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 009055a6ab6..e762eb3b634 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -470,6 +470,143 @@ _mesa_validate_pbo_access(GLuint dimensions, /** + * If the source of glBitmap data is a PBO, check that we won't read out + * of buffer bounds, then map the buffer. + * If not sourcing from a PBO, just return the bitmap pointer. + * This is a helper function for (some) drivers. + * Return NULL if error. + * If non-null return, must call _mesa_unmap_bitmap_pbo() when done. + */ +const GLubyte * +_mesa_map_bitmap_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap) +{ + const GLubyte *buf; + + if (unpack->BufferObj->Name) { + /* unpack from PBO */ + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, + unpack->BufferObj); + if (!buf) + return NULL; + + buf = ADD_POINTERS(buf, bitmap); + } + else { + /* unpack from normal memory */ + buf = bitmap; + } + + return buf; +} + + +/** + * Counterpart to _mesa_map_bitmap_pbo() + * This is a helper function for (some) drivers. + */ +void +_mesa_unmap_bitmap_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + if (unpack->BufferObj->Name) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + } +} + + +/** + * \sa _mesa_map_bitmap_pbo + */ +const GLvoid * +_mesa_map_drawpix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *pixels) +{ + const GLvoid *buf; + + if (unpack->BufferObj->Name) { + /* unpack from PBO */ + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, + unpack->BufferObj); + if (!buf) + return NULL; + + buf = ADD_POINTERS(buf, pixels); + } + else { + /* unpack from normal memory */ + buf = pixels; + } + + return buf; +} + + +/** + * \sa _mesa_unmap_bitmap_pbo + */ +void +_mesa_unmap_drapix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + if (unpack->BufferObj->Name) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + } +} + + +/** + * If PBO is bound, map the buffer, return dest pointer in mapped buffer. + * Call _mesa_unmap_readpix_pbo() when finished + * \return NULL if error + */ +void * +_mesa_map_readpix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *pack, + GLvoid *dest) +{ + void *buf; + + if (pack->BufferObj->Name) { + /* pack into PBO */ + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + GL_WRITE_ONLY_ARB, + pack->BufferObj); + if (!buf) + return NULL; + + buf = ADD_POINTERS(buf, dest); + } + else { + /* pack to normal memory */ + buf = dest; + } + + return buf; +} + + +/** + * Counterpart to _mesa_map_readpix_pbo() + */ +void +_mesa_unmap_readpix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *pack) +{ + if (pack->BufferObj->Name) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, pack->BufferObj); + } +} + + + +/** * Return the gl_buffer_object for the given ID. * Always return NULL for ID 0. */ diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index f54f9e9ff00..46525f08ae3 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 7.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -86,6 +86,35 @@ _mesa_validate_pbo_access(GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *ptr); +extern const GLubyte * +_mesa_map_bitmap_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap); + +extern void +_mesa_unmap_bitmap_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack); + +extern const GLvoid * +_mesa_map_drawpix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *pixels); + +extern void +_mesa_unmap_drapix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *unpack); + + +extern void * +_mesa_map_readpix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *pack, + GLvoid *dest); + +extern void +_mesa_unmap_readpix_pbo(GLcontext *ctx, + const struct gl_pixelstore_attrib *pack); + + extern void _mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index a9f9bd9da44..d06644f65dd 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -695,10 +695,10 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) _mesa_DeleteHashTable(ss->Programs); #endif #if FEATURE_ARB_vertex_program - _mesa_delete_program(ctx, ss->DefaultVertexProgram); + ctx->Driver.DeleteProgram(ctx, ss->DefaultVertexProgram); #endif #if FEATURE_ARB_fragment_program - _mesa_delete_program(ctx, ss->DefaultFragmentProgram); + ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentProgram); #endif #if FEATURE_ATI_fragment_shader diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index ae9c7e29a15..0f64f1c1c0c 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -24,6 +24,7 @@ #include "glheader.h" #include "imports.h" +#include "bufferobj.h" #include "context.h" #include "drawpix.h" #include "feedback.h" @@ -183,6 +184,23 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, /* Round, to satisfy conformance tests (matches SGI's OpenGL) */ GLint x = IROUND(ctx->Current.RasterPos[0]); GLint y = IROUND(ctx->Current.RasterPos[1]); + + if (ctx->Unpack.BufferObj->Name) { + /* unpack from PBO */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(invalid PBO access)"); + return; + } + if (ctx->Unpack.BufferObj->Pointer) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(PBO is mapped)"); + return; + } + } + ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type, &ctx->Unpack, pixels); } @@ -303,6 +321,21 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, return; } + if (ctx->Pack.BufferObj->Name) { + if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(invalid PBO access)"); + return; + } + + if (ctx->Pack.BufferObj->Pointer) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)"); + return; + } + } + ctx->Driver.ReadPixels(ctx, x, y, width, height, format, type, &ctx->Pack, pixels); } @@ -343,12 +376,27 @@ _mesa_Bitmap( GLsizei width, GLsizei height, } if (ctx->RenderMode == GL_RENDER) { - if (bitmap && width && height) { - /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ - GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig); - GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig); - ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); + /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ + GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig); + GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig); + + if (ctx->Unpack.BufferObj->Name) { + /* unpack from PBO */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, + GL_COLOR_INDEX, GL_BITMAP, + (GLvoid *) bitmap)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBitmap(invalid PBO access)"); + return; + } + if (ctx->Unpack.BufferObj->Pointer) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)"); + return; + } } + + ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); } #if _HAVE_FULL_GL else if (ctx->RenderMode == GL_FEEDBACK) { diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index f15e4045278..384e1455203 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2323,9 +2323,6 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, return; } - if (!pixels) - return; - _mesa_lock_texture(ctx, texObj); { texImage = _mesa_select_tex_image(ctx, texObj, target, level); diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 3869e317147..39c4ca1dd5d 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -354,7 +354,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog) clone->Format = prog->Format; clone->Instructions = _mesa_alloc_instructions(prog->NumInstructions); if (!clone->Instructions) { - _mesa_delete_program(ctx, clone); + ctx->Driver.DeleteProgram(ctx, clone); return NULL; } _mesa_copy_instructions(clone->Instructions, prog->Instructions, diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 4470a87af0a..4cb8bb8ed1f 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -79,7 +79,7 @@ _mesa_clear_shader_program_data(GLcontext *ctx, /* to prevent a double-free in the next call */ shProg->VertexProgram->Base.Parameters = NULL; } - _mesa_delete_program(ctx, &shProg->VertexProgram->Base); + ctx->Driver.DeleteProgram(ctx, &shProg->VertexProgram->Base); shProg->VertexProgram = NULL; } @@ -88,7 +88,7 @@ _mesa_clear_shader_program_data(GLcontext *ctx, /* to prevent a double-free in the next call */ shProg->FragmentProgram->Base.Parameters = NULL; } - _mesa_delete_program(ctx, &shProg->FragmentProgram->Base); + ctx->Driver.DeleteProgram(ctx, &shProg->FragmentProgram->Base); shProg->FragmentProgram = NULL; } @@ -246,7 +246,7 @@ _mesa_free_shader(GLcontext *ctx, struct gl_shader *sh) _mesa_free(sh->InfoLog); for (i = 0; i < sh->NumPrograms; i++) { assert(sh->Programs[i]); - _mesa_delete_program(ctx, sh->Programs[i]); + ctx->Driver.DeleteProgram(ctx, sh->Programs[i]); } if (sh->Programs) _mesa_free(sh->Programs); diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 21416da2e01..cd7372902b8 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -66,7 +66,8 @@ void st_upload_constants( struct st_context *st, /* Update our own dependency flags. This works because this * function will also be called whenever the program changes. */ - st->constants.tracked_state[id].dirty.mesa = params->StateFlags; + st->constants.tracked_state[id].dirty.mesa = + (params->StateFlags | _NEW_PROGRAM); _mesa_load_state_parameters(st->ctx, params); @@ -115,7 +116,7 @@ static void update_vs_constants(struct st_context *st ) const struct st_tracked_state st_update_vs_constants = { .name = "st_update_vs_constants", .dirty = { - .mesa = 0, + .mesa = 0, /* set dynamically above */ .st = ST_NEW_VERTEX_PROGRAM, }, .update = update_vs_constants @@ -134,7 +135,7 @@ static void update_fs_constants(struct st_context *st ) const struct st_tracked_state st_update_fs_constants = { .name = "st_update_fs_constants", .dirty = { - .mesa = 0, + .mesa = 0, /* set dynamically above */ .st = ST_NEW_FRAGMENT_PROGRAM, }, .update = update_fs_constants diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 07266884930..ec39026eb32 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -78,34 +78,6 @@ struct translated_vertex_program /** - * Free data hanging off the st vert prog. - */ -void -st_remove_vertex_program(struct st_context *st, struct st_vertex_program *stvp) -{ - /* no-op, for now? */ -} - - -/** - * Free data hanging off the st frag prog. - */ -void -st_remove_fragment_program(struct st_context *st, - struct st_fragment_program *stfp) -{ - struct translated_vertex_program *xvp, *next; - - for (xvp = stfp->vertex_programs; xvp; xvp = next) { - next = xvp->next; - /* XXX free xvp->vs */ - free(xvp); - } -} - - - -/** * Given a vertex program output attribute, return the corresponding * fragment program input attribute. * \return -1 for vertex outputs that have no corresponding fragment input @@ -265,6 +237,21 @@ find_translated_vp(struct st_context *st, } +void +st_free_translated_vertex_programs(struct st_context *st, + struct translated_vertex_program *xvp) +{ + struct translated_vertex_program *next; + + while (xvp) { + next = xvp->next; + free(xvp); + xvp = next; + } +} + + + static void update_linkage( struct st_context *st ) { diff --git a/src/mesa/state_tracker/st_atom_shader.h b/src/mesa/state_tracker/st_atom_shader.h index f3124d87c01..8403bc66c92 100644 --- a/src/mesa/state_tracker/st_atom_shader.h +++ b/src/mesa/state_tracker/st_atom_shader.h @@ -31,10 +31,8 @@ extern void -st_remove_vertex_program(struct st_context *, struct st_vertex_program *); - -extern void -st_remove_fragment_program(struct st_context *, struct st_fragment_program *); +st_free_translated_vertex_programs(struct st_context *st, + struct translated_vertex_program *xvp); #endif /* ST_ATOM_SHADER_H */ diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 33256196bb5..acc22d4323c 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -32,6 +32,7 @@ #include "main/imports.h" #include "main/image.h" +#include "main/bufferobj.h" #include "main/macros.h" #include "main/texformat.h" #include "shader/program.h" @@ -191,7 +192,6 @@ combined_bitmap_fragment_program(GLcontext *ctx) } - /** * Create a texture which represents a bitmap image. */ @@ -224,19 +224,20 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, assert( 0 ); } + /* PBO source... */ + bitmap = _mesa_map_bitmap_pbo(ctx, unpack, bitmap); + if (!bitmap) { + return NULL; + } + /** - * Create a texture. + * Create texture to hold bitmap pattern. */ pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, width, height, 1, 0); - if (!pt) + if (!pt) { + _mesa_unmap_bitmap_pbo(ctx, unpack); return NULL; - - if (unpack->BufferObj && unpack->BufferObj->Name) { - /* - pt->region = buffer_object_region(unpack->BufferObj); - */ - printf("st_Bitmap (sourcing from PBO not implemented yet)\n"); } surface = screen->get_tex_surface(screen, pt, 0, 0, 0); @@ -301,6 +302,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, } /* row */ + _mesa_unmap_bitmap_pbo(ctx, unpack); + /* Release surface */ pipe_surface_unmap(surface); pipe_surface_reference(&surface, NULL); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index b4cd93cd548..2ebaf8a2c31 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -32,6 +32,7 @@ #include "main/imports.h" #include "main/image.h" +#include "main/bufferobj.h" #include "main/macros.h" #include "main/texformat.h" #include "shader/program.h" @@ -334,16 +335,15 @@ make_texture(struct st_context *st, assert(pipeFormat); cpp = st_sizeof_format(pipeFormat); + pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels); + if (!pixels) + return NULL; + pt = st_texture_create(st, PIPE_TEXTURE_2D, pipeFormat, 0, width, height, 1, 0); - if (!pt) + if (!pt) { + _mesa_unmap_drapix_pbo(ctx, unpack); return NULL; - - if (unpack->BufferObj && unpack->BufferObj->Name) { - /* - pt->region = buffer_object_region(unpack->BufferObj); - */ - printf("st_DrawPixels (sourcing from PBO not implemented yet)\n"); } { @@ -388,6 +388,8 @@ make_texture(struct st_context *st, ctx->_ImageTransferState = imageTransferStateSave; } + _mesa_unmap_drapix_pbo(ctx, unpack); + return pt; } @@ -836,9 +838,9 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, bufferFormat = ps->format; - if (any_fragment_ops(st) || + if (1/*any_fragment_ops(st) || any_pixel_transfer_ops(st) || - !compatible_formats(format, type, ps->format)) { + !compatible_formats(format, type, ps->format)*/) { /* textured quad */ struct pipe_texture *pt = make_texture(ctx->st, width, height, format, type, unpack, pixels); diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 0a62e20e0c6..a739fcd3362 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -126,19 +126,39 @@ static void st_delete_program( GLcontext *ctx, struct gl_program *prog ) { struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; switch( prog->Target ) { case GL_VERTEX_PROGRAM_ARB: { struct st_vertex_program *stvp = (struct st_vertex_program *) prog; - st_remove_vertex_program(st, stvp); + + if (stvp->driver_shader) { + pipe->delete_vs_state(pipe, stvp->driver_shader); + stvp->driver_shader = NULL; + } + + if (stvp->state.tokens) { + FREE((void *) stvp->state.tokens); + stvp->state.tokens = NULL; + } } break; case GL_FRAGMENT_PROGRAM_ARB: { - struct st_fragment_program *stfp - = (struct st_fragment_program *) prog; - st_remove_fragment_program(st, stfp); + struct st_fragment_program *stfp = (struct st_fragment_program *) prog; + + if (stfp->driver_shader) { + pipe->delete_fs_state(pipe, stfp->driver_shader); + stfp->driver_shader = NULL; + } + + if (stfp->state.tokens) { + FREE((void *) stfp->state.tokens); + stfp->state.tokens = NULL; + } + + st_free_translated_vertex_programs(st, stfp->vertex_programs); } break; default: @@ -162,27 +182,25 @@ static void st_program_string_notify( GLcontext *ctx, struct gl_program *prog ) { struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; if (target == GL_FRAGMENT_PROGRAM_ARB) { struct st_fragment_program *stfp = (struct st_fragment_program *) prog; stfp->serialNo++; -#if 0 - if (stfp->cso) { - /* free the TGSI code */ - // cso_delete(stfp->vs); - stfp->cso = NULL; + if (stfp->driver_shader) { + pipe->delete_fs_state(pipe, stfp->driver_shader); + stfp->driver_shader = NULL; } -#endif - - stfp->param_state = stfp->Base.Base.Parameters->StateFlags; if (stfp->state.tokens) { FREE((void *) stfp->state.tokens); stfp->state.tokens = NULL; } + stfp->param_state = stfp->Base.Base.Parameters->StateFlags; + if (st->fp == stfp) st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; } @@ -191,26 +209,23 @@ static void st_program_string_notify( GLcontext *ctx, stvp->serialNo++; -#if 0 - if (stvp->cso) { - /* free the CSO data */ - st->pipe->delete_vs_state(st->pipe, stvp->cso->data); - FREE((void *) stvp->cso); - stvp->cso = NULL; + if (stvp->driver_shader) { + pipe->delete_vs_state(pipe, stvp->driver_shader); + stvp->driver_shader = NULL; } -#endif + if (stvp->draw_shader) { draw_delete_vertex_shader(st->draw, stvp->draw_shader); stvp->draw_shader = NULL; } - stvp->param_state = stvp->Base.Base.Parameters->StateFlags; - if (stvp->state.tokens) { FREE((void *) stvp->state.tokens); stvp->state.tokens = NULL; } + stvp->param_state = stvp->Base.Base.Parameters->StateFlags; + if (st->vp == stvp) st->dirty.st |= ST_NEW_VERTEX_PROGRAM; } diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index c89c74229e5..4cf9adcd28a 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -34,6 +34,7 @@ #include "main/imports.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/image.h" @@ -126,7 +127,6 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } - /** * Do glReadPixels by getting rows from the framebuffer surface with * get_tile(). Convert to requested format/type with Mesa image routines. @@ -155,18 +155,13 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, return; } + dest = _mesa_map_readpix_pbo(ctx, &clippedPacking, dest); + if (!dest) + return; + /* make sure rendering has completed */ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE); - if (pack->BufferObj && pack->BufferObj->Name) { - /* reading into a PBO */ - - } - else { - /* reading into user memory/buffer */ - - } - if (format == GL_STENCIL_INDEX) { st_read_stencil_pixels(ctx, x, y, width, height, type, pack, dest); return; @@ -285,6 +280,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } + + _mesa_unmap_readpix_pbo(ctx, &clippedPacking); } diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 0962b5f74c5..7fab4d041d0 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -155,7 +155,6 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_texture_env_combine = GL_TRUE; ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; - ctx->Extensions.EXT_texture_sRGB = GL_TRUE; /* XXX temp */ ctx->Extensions.NV_blend_square = GL_TRUE; ctx->Extensions.NV_texgen_reflection = GL_TRUE; @@ -190,10 +189,6 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.ATI_separate_stencil = GL_TRUE; } - if (screen->get_param(screen, PIPE_CAP_S3TC)) { - ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; - } - if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) { ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE; } @@ -214,4 +209,14 @@ void st_init_extensions(struct st_context *st) /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/ } + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB, + PIPE_TEXTURE)) { + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; + } + + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, + PIPE_TEXTURE)) { + ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; + } + } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index d9d11ee0e84..101a6a48afd 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -260,6 +260,16 @@ st_translate_vertex_program(struct st_context *st, outputMapping = defaultOutputMapping; } + /* free old shader state, if any */ + if (stvp->state.tokens) { + FREE((void *) stvp->state.tokens); + stvp->state.tokens = NULL; + } + if (stvp->driver_shader) { + pipe->delete_vs_state(pipe, stvp->driver_shader); + stvp->driver_shader = NULL; + } + /* XXX: fix static allocation of tokens: */ num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX, diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index 1e7f6c18e6a..f3dda12e252 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -57,25 +57,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, ASSERT(ctx->RenderMode == GL_RENDER); - if (unpack->BufferObj->Name) { - /* unpack from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, - GL_COLOR_INDEX, GL_BITMAP, - (GLvoid *) bitmap)) { - _mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - unpack->BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)"); - return; - } - bitmap = ADD_POINTERS(buf, bitmap); - } + bitmap = _mesa_map_bitmap_pbo(ctx, unpack, bitmap); + if (!bitmap) + return; RENDER_START(swrast,ctx); @@ -150,11 +134,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, RENDER_FINISH(swrast,ctx); - if (unpack->BufferObj->Name) { - /* done with PBO so unmap it now */ - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - } + _mesa_unmap_bitmap_pbo(ctx, unpack); } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 0cf425e1c62..fb04d9f746a 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -812,7 +812,6 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } - /** * Execute software-based glDrawPixels. * By time we get here, all error checking will have been done. @@ -835,25 +834,9 @@ _swrast_DrawPixels( GLcontext *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - if (unpack->BufferObj->Name) { - /* unpack from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(invalid PBO access)"); - goto end; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - unpack->BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(PBO is mapped)"); - goto end; - } - pixels = ADD_POINTERS(buf, pixels); - } + pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels); + if (!pixels) + return; switch (format) { case GL_STENCIL_INDEX: @@ -894,11 +877,7 @@ end: RENDER_FINISH(swrast,ctx); - if (unpack->BufferObj->Name) { - /* done with PBO so unmap it now */ - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - } + _mesa_unmap_drapix_pbo(ctx, unpack); } diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index fe9a70f4eae..2f155d0b705 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -572,25 +572,9 @@ _swrast_ReadPixels( GLcontext *ctx, goto end; } - if (clippedPacking.BufferObj->Name) { - /* pack into PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &clippedPacking, width, height, 1, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(invalid PBO access)"); - goto end; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - clippedPacking.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)"); - goto end; - } - pixels = ADD_POINTERS(buf, pixels); - } + pixels = _mesa_map_readpix_pbo(ctx, &clippedPacking, pixels); + if (!pixels) + return; switch (format) { case GL_COLOR_INDEX: @@ -632,9 +616,5 @@ _swrast_ReadPixels( GLcontext *ctx, end: RENDER_FINISH(swrast, ctx); - if (clippedPacking.BufferObj->Name) { - /* done with PBO so unmap it now */ - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - clippedPacking.BufferObj); - } + _mesa_unmap_readpix_pbo(ctx, &clippedPacking); } |