diff options
Diffstat (limited to 'src/mesa/state_tracker/st_texture.c')
-rw-r--r-- | src/mesa/state_tracker/st_texture.c | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index d0d1c5c..dbdf1ea 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -29,7 +29,6 @@ #include "st_format.h" #include "st_texture.h" #include "st_cb_fbo.h" -#include "st_inlines.h" #include "main/enums.h" #undef Elements /* fix re-defined macro warning */ @@ -66,6 +65,9 @@ st_texture_create(struct st_context *st, struct pipe_screen *screen = st->pipe->screen; assert(target <= PIPE_TEXTURE_CUBE); + assert(width0 > 0); + assert(height0 > 0); + assert(depth0 > 0); DBG("%s target %s format %s last_level %d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(target), @@ -142,7 +144,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, DBG("%s \n", __FUNCTION__); - stImage->transfer = st_no_flush_get_tex_transfer(st, pt, stImage->face, + stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->face, stImage->level, zoffset, usage, x, y, w, h); @@ -217,7 +219,7 @@ st_texture_image_data(struct st_context *st, DBG("%s\n", __FUNCTION__); for (i = 0; i < depth; i++) { - dst_transfer = st_no_flush_get_tex_transfer(st, dst, face, level, i, + dst_transfer = pipe_get_transfer(st->pipe, dst, face, level, i, PIPE_TRANSFER_WRITE, 0, 0, u_minify(dst->width0, level), u_minify(dst->height0, level)); @@ -237,12 +239,47 @@ st_texture_image_data(struct st_context *st, } -/* Copy mipmap image between textures +/** + * For debug only: get/print center pixel in the src resource. + */ +static void +print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src) +{ + struct pipe_subresource rect; + struct pipe_transfer *xfer; + struct pipe_box region; + ubyte *map; + + rect.face = 0; + rect.level = 0; + + region.x = src->width0 / 2; + region.y = src->height0 / 2; + region.z = 0; + region.width = 1; + region.height = 1; + region.depth = 1; + + xfer = pipe->get_transfer(pipe, src, rect, PIPE_TRANSFER_READ, ®ion); + map = pipe->transfer_map(pipe, xfer); + + printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]); + + pipe->transfer_unmap(pipe, xfer); + pipe->transfer_destroy(pipe, xfer); +} + + +/** + * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'. + * This is used to copy mipmap images from one texture buffer to another. + * This typically happens when our initial guess at the total texture size + * is incorrect (see the guess_and_alloc_texture() function). */ void st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *dst, GLuint dstLevel, - struct pipe_resource *src, + struct pipe_resource *src, GLuint srcLevel, GLuint face) { GLuint width = u_minify(dst->width0, dstLevel); @@ -251,43 +288,20 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_subresource dstsub, srcsub; GLuint i; - assert(src->width0 == dst->width0); - assert(src->height0 == dst->height0); + assert(u_minify(src->width0, srcLevel) == width); + assert(u_minify(src->height0, srcLevel) == height); + assert(u_minify(src->depth0, srcLevel) == depth); dstsub.face = face; dstsub.level = dstLevel; srcsub.face = face; - + srcsub.level = srcLevel; + /* Loop over 3D image slices */ for (i = 0; i < depth; i++) { - GLuint srcLevel; - - /* find src texture level of needed size */ - for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) { - if (u_minify(src->width0, srcLevel) == width && - u_minify(src->height0, srcLevel) == height) { - break; - } - } - assert(u_minify(src->width0, srcLevel) == width); - assert(u_minify(src->height0, srcLevel) == height); - -#if 0 - { - struct pipe_screen *screen = pipe->screen; - src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, - PIPE_BUFFER_USAGE_CPU_READ); - ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ); - map += src_surface->width * src_surface->height * 4 / 2; - printf("%s center pixel: %d %d %d %d (pt %p[%d] -> %p[%d])\n", - __FUNCTION__, - map[0], map[1], map[2], map[3], - src, srcLevel, dst, dstLevel); - - screen->surface_unmap(screen, src_surface); - pipe_surface_reference(&src_surface, NULL); + + if (0) { + print_center_pixel(pipe, src); } -#endif - srcsub.level = srcLevel; pipe->resource_copy_region(pipe, dst, @@ -300,19 +314,3 @@ st_texture_image_copy(struct pipe_context *pipe, } } - -void -st_teximage_flush_before_map(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - enum pipe_transfer_usage usage) -{ - struct pipe_context *pipe = st->pipe; - unsigned referenced = - pipe->is_resource_referenced(pipe, pt, face, level); - - if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || - (usage & PIPE_TRANSFER_WRITE))) - st->pipe->flush(st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); -} |