diff options
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 67 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bufferobjects.c | 9 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 14 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_readpixels.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 73 |
5 files changed, 79 insertions, 90 deletions
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index ccf972f805..902fb38d1a 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -241,7 +241,7 @@ combined_bitmap_fragment_program(GLcontext *ctx) /** * Copy user-provide bitmap bits into texture buffer, expanding * bits into texels. - * "On" bits will set texels to 0xff. + * "On" bits will set texels to 0x0. * "Off" bits will not modify texels. * Note that the image is actually going to be upside down in * the texture. We deal with that with texcoords. @@ -253,63 +253,10 @@ unpack_bitmap(struct st_context *st, const GLubyte *bitmap, ubyte *destBuffer, uint destStride) { - GLint row, col; - -#define SET_PIXEL(COL, ROW) \ - destBuffer[(py + (ROW)) * destStride + px + (COL)] = 0x0; - - for (row = 0; row < height; row++) { - const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack, - bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); - - if (unpack->LsbFirst) { - /* Lsb first */ - GLubyte mask = 1U << (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - - if (*src & mask) { - SET_PIXEL(col, row); - } - - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - - /* get ready for next row */ - if (mask != 1) - src++; - } - else { - /* Msb first */ - GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - - if (*src & mask) { - SET_PIXEL(col, row); - } - - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - - /* get ready for next row */ - if (mask != 128) - src++; - } - - } /* row */ + destBuffer += py * destStride + px; -#undef SET_PIXEL + _mesa_expand_bitmap(width, height, unpack, bitmap, + destBuffer, destStride, 0x0); } @@ -328,7 +275,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, struct pipe_texture *pt; /* PBO source... */ - bitmap = _mesa_map_bitmap_pbo(ctx, unpack, bitmap); + bitmap = _mesa_map_pbo_source(ctx, unpack, bitmap); if (!bitmap) { return NULL; } @@ -340,7 +287,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, 0, width, height, 1, PIPE_TEXTURE_USAGE_SAMPLER); if (!pt) { - _mesa_unmap_bitmap_pbo(ctx, unpack); + _mesa_unmap_pbo_source(ctx, unpack); return NULL; } @@ -355,7 +302,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap, dest, transfer->stride); - _mesa_unmap_bitmap_pbo(ctx, unpack); + _mesa_unmap_pbo_source(ctx, unpack); /* Release transfer */ screen->transfer_unmap(screen, transfer); diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 69dd76d083..8e09d0b932 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -134,9 +134,10 @@ st_bufferobj_get_subdata(GLcontext *ctx, * Allocate space for and store data in a buffer object. Any data that was * previously stored in the buffer object is lost. If data is NULL, * memory will be allocated, but no copy will occur. - * Called via glBufferDataARB(). + * Called via ctx->Driver.BufferData(). + * \return GL_TRUE for success, GL_FALSE if out of memory */ -static void +static GLboolean st_bufferobj_data(GLcontext *ctx, GLenum target, GLsizeiptrARB size, @@ -172,13 +173,13 @@ st_bufferobj_data(GLcontext *ctx, st_obj->buffer = pipe_buffer_create( pipe->screen, 32, buffer_usage, size ); if (!st_obj->buffer) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB"); - return; + return GL_FALSE; } if (data) st_no_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, 0, size, data); + return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index d19a88fa7c..a9cafbf8cd 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -353,7 +353,7 @@ make_texture(struct st_context *st, assert(pipeFormat); cpp = st_sizeof_format(pipeFormat); - pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels); + pixels = _mesa_map_pbo_source(ctx, unpack, pixels); if (!pixels) return NULL; @@ -381,7 +381,7 @@ make_texture(struct st_context *st, pt = st_texture_create(st, PIPE_TEXTURE_2D, pipeFormat, 0, ptw, pth, 1, PIPE_TEXTURE_USAGE_SAMPLER); if (!pt) { - _mesa_unmap_drawpix_pbo(ctx, unpack); + _mesa_unmap_pbo_source(ctx, unpack); return NULL; } @@ -428,7 +428,7 @@ make_texture(struct st_context *st, ctx->_ImageTransferState = imageTransferStateSave; } - _mesa_unmap_drawpix_pbo(ctx, unpack); + _mesa_unmap_pbo_source(ctx, unpack); return pt; } @@ -681,7 +681,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, stmap = screen->transfer_map(screen, pt); - pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels); + pixels = _mesa_map_pbo_source(ctx, unpack, pixels); assert(pixels); /* if width > MAX_WIDTH, have to process image in chunks */ @@ -775,7 +775,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, skipPixels += spanWidth; } - _mesa_unmap_drawpix_pbo(ctx, unpack); + _mesa_unmap_pbo_source(ctx, unpack); /* unmap the stencil buffer */ screen->transfer_unmap(screen, pt); @@ -865,6 +865,10 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, usage = PIPE_TRANSFER_READ_WRITE; else usage = PIPE_TRANSFER_WRITE; + + if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { + dsty = rbDraw->Base.Height - dsty - height; + } ptDraw = st_cond_flush_get_tex_transfer(st_context(ctx), rbDraw->texture, 0, 0, 0, diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index ccf1a0b563..75424aa2e7 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -353,7 +353,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, return; } - dest = _mesa_map_readpix_pbo(ctx, &clippedPacking, dest); + dest = _mesa_map_pbo_dest(ctx, &clippedPacking, dest); if (!dest) return; @@ -380,7 +380,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, if (st_fast_readpixels(ctx, strb, x, y, width, height, format, type, pack, dest)) { /* success! */ - _mesa_unmap_readpix_pbo(ctx, &clippedPacking); + _mesa_unmap_pbo_dest(ctx, &clippedPacking); return; } @@ -534,7 +534,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, screen->tex_transfer_destroy(trans); - _mesa_unmap_readpix_pbo(ctx, &clippedPacking); + _mesa_unmap_pbo_dest(ctx, &clippedPacking); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 90a059ca69..abaf9d2c35 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -56,6 +56,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" +#include "pipe/p_shader_tokens.h" #include "util/u_tile.h" #include "util/u_blit.h" #include "util/u_surface.h" @@ -516,9 +517,9 @@ st_TexImage(GLcontext * ctx, struct st_texture_image *stImage = st_texture_image(texImage); GLint postConvWidth, postConvHeight; GLint texelBytes, sizeInBytes; - GLuint dstRowStride; + GLuint dstRowStride = 0; struct gl_pixelstore_attrib unpackNB; - enum pipe_transfer_usage transfer_usage; + enum pipe_transfer_usage transfer_usage = 0; DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(target), level, width, height, depth, border); @@ -870,7 +871,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, PIPE_TRANSFER_READ, 0, 0, width, height); - pixels = _mesa_map_readpix_pbo(ctx, &ctx->Pack, pixels); + pixels = _mesa_map_pbo_dest(ctx, &ctx->Pack, pixels); /* copy/pack data into user buffer */ if (st_equal_formats(stImage->pt->format, format, type)) { @@ -903,7 +904,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, } } - _mesa_unmap_readpix_pbo(ctx, &ctx->Pack); + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); /* destroy the temp / dest surface */ util_destroy_rgba_surface(dst_texture, dst_surface); @@ -1393,6 +1394,36 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, } +static unsigned +compatible_src_dst_formats(const struct gl_renderbuffer *src, + const struct gl_texture_image *dst) +{ + const GLenum srcFormat = src->_BaseFormat; + const GLenum dstLogicalFormat = dst->_BaseFormat; + + if (srcFormat == dstLogicalFormat) { + /* This is the same as matching_base_formats, which should + * always pass, as it did previously. + */ + return TGSI_WRITEMASK_XYZW; + } + else if (srcFormat == GL_RGBA && + dstLogicalFormat == GL_RGB) { + /* Add a single special case to cope with RGBA->RGB transfers, + * setting A to 1.0 to cope with situations where the RGB + * destination is actually stored as RGBA. + */ + return TGSI_WRITEMASK_XYZ; /* A ==> 1.0 */ + } + else { + /* Otherwise fail. + */ + return 0; + } +} + + + /** * Do a CopyTex[Sub]Image1/2/3D() using a hardware (blit) path if possible. * Note that the region to copy has already been clipped so we know we @@ -1422,6 +1453,9 @@ st_copy_texsubimage(GLcontext *ctx, enum pipe_format dest_format, src_format; GLboolean use_fallback = GL_TRUE; GLboolean matching_base_formats; + GLuint format_writemask; + struct pipe_surface *dest_surface = NULL; + GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); /* any rendering in progress must flushed before we grab the fb image */ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); @@ -1492,13 +1526,14 @@ st_copy_texsubimage(GLcontext *ctx, * textured-quad paths. */ matching_base_formats = (strb->Base._BaseFormat == texImage->_BaseFormat); + format_writemask = compatible_src_dst_formats(&strb->Base, texImage); - if (matching_base_formats && ctx->_ImageTransferState == 0x0) { - /* try potential hardware path */ - struct pipe_surface *dest_surface = NULL; - boolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); + if (ctx->_ImageTransferState == 0x0) { - if (src_format == dest_format && !do_flip) { + if (matching_base_formats && + src_format == dest_format && + !do_flip) + { /* use surface_copy() / blit */ dest_surface = screen->get_tex_surface(screen, stImage->pt, @@ -1518,7 +1553,8 @@ st_copy_texsubimage(GLcontext *ctx, width, height); use_fallback = GL_FALSE; } - else if (screen->is_format_supported(screen, src_format, + else if (format_writemask && + screen->is_format_supported(screen, src_format, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0) && @@ -1542,14 +1578,15 @@ st_copy_texsubimage(GLcontext *ctx, srcY0 = srcY; srcY1 = srcY0 + height; } - util_blit_pixels(ctx->st->blit, - strb->surface, - srcX, srcY0, - srcX + width, srcY1, - dest_surface, - destX, destY, - destX + width, destY + height, - 0.0, PIPE_TEX_MIPFILTER_NEAREST); + util_blit_pixels_writemask(ctx->st->blit, + strb->surface, + srcX, srcY0, + srcX + width, srcY1, + dest_surface, + destX, destY, + destX + width, destY + height, + 0.0, PIPE_TEX_MIPFILTER_NEAREST, + format_writemask); use_fallback = GL_FALSE; } |