diff options
Diffstat (limited to 'src/mesa/state_tracker/st_cb_texture.c')
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 135 |
1 files changed, 126 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index b7b791d9a4..0a72784ce0 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -335,7 +335,9 @@ guess_and_alloc_texture(struct st_context *st, * pagetable arrangements. */ if ((stObj->base.MinFilter == GL_NEAREST || - stObj->base.MinFilter == GL_LINEAR) && + stObj->base.MinFilter == GL_LINEAR || + stImage->base._BaseFormat == GL_DEPTH_COMPONENT || + stImage->base._BaseFormat == GL_DEPTH_STENCIL_EXT) && stImage->level == firstLevel) { lastLevel = firstLevel; } @@ -673,7 +675,7 @@ st_TexImage(GLcontext * ctx, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { if (compress_with_blit(ctx, target, level, 0, 0, 0, width, height, depth, format, type, pixels, unpack, texImage)) { - return; + goto done; } } @@ -750,6 +752,7 @@ st_TexImage(GLcontext * ctx, _mesa_unmap_teximage_pbo(ctx, unpack); +done: if (stImage->pt && texImage->Data) { st_texture_image_unmap(ctx->st, stImage); texImage->Data = NULL; @@ -1061,7 +1064,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, packing, texImage)) { - return; + goto done; } } @@ -1110,16 +1113,17 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, } } - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } - _mesa_unmap_teximage_pbo(ctx, packing); +done: if (stImage->pt) { st_texture_image_unmap(ctx->st, stImage); texImage->Data = NULL; } + + if (level == texObj->BaseLevel && texObj->GenerateMipmap) { + ctx->Driver.GenerateMipmap(ctx, target, texObj); + } } @@ -1167,6 +1171,88 @@ st_TexSubImage1D(GLcontext *ctx, GLenum target, GLint level, } +static void +st_CompressedTexSubImage1D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + assert(0); +} + + +static void +st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLint height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + struct st_texture_image *stImage = st_texture_image(texImage); + struct pipe_format_block block; + int srcBlockStride; + int dstBlockStride; + int y; + + if (stImage->pt) { + st_teximage_flush_before_map(ctx->st, stImage->pt, 0, level, + PIPE_TRANSFER_WRITE); + texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + PIPE_TRANSFER_WRITE, + xoffset, yoffset, + width, height); + + block = stImage->pt->block; + srcBlockStride = pf_get_stride(&block, width); + dstBlockStride = stImage->transfer->stride; + } else { + assert(stImage->pt); + /* TODO find good values for block and strides */ + /* TODO also adjust texImage->data for yoffset/xoffset */ + return; + } + + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage"); + return; + } + + assert(xoffset % block.width == 0); + assert(yoffset % block.height == 0); + assert(width % block.width == 0); + assert(height % block.height == 0); + + for (y = 0; y < height; y += block.height) { + /* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */ + const char *src = (const char*)data + srcBlockStride * pf_get_nblocksy(&block, y); + char *dst = (char*)texImage->Data + dstBlockStride * pf_get_nblocksy(&block, y); + memcpy(dst, src, pf_get_stride(&block, width)); + } + + if (stImage->pt) { + st_texture_image_unmap(ctx->st, stImage); + texImage->Data = NULL; + } +} + + +static void +st_CompressedTexSubImage3D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + assert(0); +} + + /** * Do a CopyTexSubImage operation using a read transfer from the source, @@ -1315,8 +1401,8 @@ 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); + /* any rendering in progress must flushed before we grab the fb image */ + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); /* make sure finalize_textures has been called? */ @@ -1340,6 +1426,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); @@ -1788,6 +1902,9 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TexSubImage1D = st_TexSubImage1D; functions->TexSubImage2D = st_TexSubImage2D; functions->TexSubImage3D = st_TexSubImage3D; + functions->CompressedTexSubImage1D = st_CompressedTexSubImage1D; + functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D; + functions->CompressedTexSubImage3D = st_CompressedTexSubImage3D; functions->CopyTexImage1D = st_CopyTexImage1D; functions->CopyTexImage2D = st_CopyTexImage2D; functions->CopyTexSubImage1D = st_CopyTexSubImage1D; |