diff options
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_framebuffer.c | 18 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_pixeltransfer.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_accum.c | 24 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 14 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_blit.c | 31 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 45 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_fbo.c | 32 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_readpixels.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 85 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.c | 35 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_manager.c | 23 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.c | 54 |
12 files changed, 196 insertions, 175 deletions
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 036bc60049a..2843b7b1764 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -51,7 +51,7 @@ static void update_renderbuffer_surface(struct st_context *st, struct st_renderbuffer *strb) { - struct pipe_screen *screen = st->pipe->screen; + struct pipe_context *pipe = st->pipe; struct pipe_resource *resource = strb->rtt->pt; int rtt_width = strb->Base.Width; int rtt_height = strb->Base.Height; @@ -65,15 +65,19 @@ update_renderbuffer_surface(struct st_context *st, for (level = 0; level <= resource->last_level; level++) { if (u_minify(resource->width0, level) == rtt_width && u_minify(resource->height0, level) == rtt_height) { + struct pipe_surface surf_tmpl; + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + surf_tmpl.format = resource->format; + surf_tmpl.usage = PIPE_BIND_RENDER_TARGET; + surf_tmpl.u.tex.level = level; + surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice; + surf_tmpl.u.tex.last_layer = strb->rtt_face + strb->rtt_slice; pipe_surface_reference(&strb->surface, NULL); - strb->surface = screen->get_tex_surface(screen, - resource, - strb->rtt_face, - level, - strb->rtt_slice, - PIPE_BIND_RENDER_TARGET); + strb->surface = pipe->create_surface(pipe, + resource, + &surf_tmpl); #if 0 printf("-- alloc new surface %d x %d into tex %p\n", strb->surface->width, strb->surface->height, diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 6be03376d01..378b30e57cc 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -122,8 +122,8 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt) uint i, j; transfer = pipe_get_transfer(st_context(ctx)->pipe, - pt, 0, 0, 0, PIPE_TRANSFER_WRITE, - 0, 0, texSize, texSize); + pt, 0, 0, PIPE_TRANSFER_WRITE, + 0, 0, texSize, texSize); dest = (uint *) pipe_transfer_map(pipe, transfer); /* Pack four 1D maps into a 2D texture: diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 6c5caf42e35..a76ae92dc3d 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -138,10 +138,10 @@ accum_accum(struct st_context *st, GLfloat value, debug_printf("%s: fallback processing\n", __FUNCTION__); color_trans = pipe_get_transfer(st->pipe, - color_strb->texture, - 0, 0, 0, - PIPE_TRANSFER_READ, xpos, ypos, - width, height); + color_strb->texture, + 0, 0, + PIPE_TRANSFER_READ, xpos, ypos, + width, height); buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); @@ -187,9 +187,9 @@ accum_load(struct st_context *st, GLfloat value, debug_printf("%s: fallback processing\n", __FUNCTION__); color_trans = pipe_get_transfer(st->pipe, color_strb->texture, - 0, 0, 0, - PIPE_TRANSFER_READ, xpos, ypos, - width, height); + 0, 0, + PIPE_TRANSFER_READ, xpos, ypos, + width, height); buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); @@ -241,12 +241,12 @@ accum_return(struct gl_context *ctx, GLfloat value, usage = PIPE_TRANSFER_READ_WRITE; else usage = PIPE_TRANSFER_WRITE; - + color_trans = pipe_get_transfer(st_context(ctx)->pipe, - color_strb->texture, 0, 0, 0, - usage, - xpos, ypos, - width, height); + color_strb->texture, 0, 0, + usage, + xpos, ypos, + width, height); if (usage & PIPE_TRANSFER_READ) pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf); diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 3c0ee6c2883..f08697fe23b 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -283,9 +283,9 @@ make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height, return NULL; } - transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0, - PIPE_TRANSFER_WRITE, - 0, 0, width, height); + transfer = pipe_get_transfer(st->pipe, pt, 0, 0, + PIPE_TRANSFER_WRITE, + 0, 0, width, height); dest = pipe_transfer_map(pipe, transfer); @@ -585,10 +585,10 @@ create_cache_trans(struct st_context *st) /* Map the texture transfer. * Subsequent glBitmap calls will write into the texture image. */ - cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0, 0, - PIPE_TRANSFER_WRITE, 0, 0, - BITMAP_CACHE_WIDTH, - BITMAP_CACHE_HEIGHT); + cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0, + PIPE_TRANSFER_WRITE, 0, 0, + BITMAP_CACHE_WIDTH, + BITMAP_CACHE_HEIGHT); cache->buffer = pipe_transfer_map(pipe, cache->trans); /* init image to all 0xff */ diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index af41835326a..06cee520b37 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -115,17 +115,14 @@ st_BlitFramebuffer(struct gl_context *ctx, st_texture_object(srcAtt->Texture); struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[0]); - struct pipe_subresource srcSub; struct pipe_surface *dstSurf = dstRb->surface; if (!srcObj->pt) return; - srcSub.face = srcAtt->CubeMapFace; - srcSub.level = srcAtt->TextureLevel; - - util_blit_pixels(st->blit, srcObj->pt, srcSub, - srcX0, srcY0, srcX1, srcY1, srcAtt->Zoffset, + util_blit_pixels(st->blit, srcObj->pt, srcAtt->TextureLevel, + srcX0, srcY0, srcX1, srcY1, + srcAtt->Zoffset + srcAtt->CubeMapFace, dstSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } @@ -136,14 +133,11 @@ st_BlitFramebuffer(struct gl_context *ctx, st_renderbuffer(drawFB->_ColorDrawBuffers[0]); struct pipe_surface *srcSurf = srcRb->surface; struct pipe_surface *dstSurf = dstRb->surface; - struct pipe_subresource srcSub; - - srcSub.face = srcSurf->face; - srcSub.level = srcSurf->level; util_blit_pixels(st->blit, - srcRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1, - srcSurf->zslice, + srcRb->texture, srcSurf->u.tex.level, + srcX0, srcY0, srcX1, srcY1, + srcSurf->u.tex.first_layer, dstSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } @@ -176,11 +170,11 @@ st_BlitFramebuffer(struct gl_context *ctx, /* Blitting depth and stencil values between combined * depth/stencil buffers. This is the ideal case for such buffers. */ - util_blit_pixels(st->blit, srcDepthRb->texture, - u_subresource(srcDepthRb->surface->face, - srcDepthRb->surface->level), + util_blit_pixels(st->blit, + srcDepthRb->texture, + srcDepthRb->surface->u.tex.level, srcX0, srcY0, srcX1, srcY1, - srcDepthRb->surface->zslice, + srcDepthRb->surface->u.tex.first_layer, dstDepthSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } @@ -189,10 +183,9 @@ st_BlitFramebuffer(struct gl_context *ctx, if (mask & GL_DEPTH_BUFFER_BIT) { util_blit_pixels(st->blit, srcDepthRb->texture, - u_subresource(srcDepthRb->surface->face, - srcDepthRb->surface->level), + srcDepthRb->surface->u.tex.level, srcX0, srcY0, srcX1, srcY1, - srcDepthRb->surface->zslice, + srcDepthRb->surface->u.tex.first_layer, dstDepthSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index d80c068ea81..c9786024575 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -427,9 +427,9 @@ make_texture(struct st_context *st, /* we'll do pixel transfer in a fragment shader */ ctx->_ImageTransferState = 0x0; - transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0, - PIPE_TRANSFER_WRITE, 0, 0, - width, height); + transfer = pipe_get_transfer(st->pipe, pt, 0, 0, + PIPE_TRANSFER_WRITE, 0, 0, + width, height); /* map texture transfer */ dest = pipe_transfer_map(pipe, transfer); @@ -763,9 +763,9 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, else usage = PIPE_TRANSFER_WRITE; - pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, - usage, x, y, - width, height); + pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, + usage, x, y, + width, height); stmap = pipe_transfer_map(pipe, pt); @@ -1025,15 +1025,15 @@ copy_stencil_pixels(struct gl_context *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 = pipe_get_transfer(st_context(ctx)->pipe, - rbDraw->texture, 0, 0, 0, - usage, dstx, dsty, - width, height); + rbDraw->texture, 0, 0, + usage, dstx, dsty, + width, height); assert(util_format_get_blockwidth(ptDraw->resource->format) == 1); assert(util_format_get_blockheight(ptDraw->resource->format) == 1); @@ -1209,27 +1209,24 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, /* Make temporary texture which is a copy of the src region. */ if (srcFormat == texFormat) { - struct pipe_subresource srcsub, dstsub; - srcsub.face = 0; - srcsub.level = 0; - dstsub.face = 0; - dstsub.level = 0; - /* copy source framebuffer surface into mipmap/texture */ + struct pipe_box src_box; + u_box_2d(readX, readY, readW, readH, &src_box); + /* copy source framebuffer surface into mipmap/texture */ pipe->resource_copy_region(pipe, pt, /* dest tex */ - dstsub, + 0, pack.SkipPixels, pack.SkipRows, 0, /* dest pos */ rbRead->texture, /* src tex */ - srcsub, - readX, readY, 0, readW, readH); /* src region */ + 0, + &src_box); } else { /* CPU-based fallback/conversion */ struct pipe_transfer *ptRead = - pipe_get_transfer(st->pipe, rbRead->texture, 0, 0, 0, - PIPE_TRANSFER_READ, - readX, readY, readW, readH); + pipe_get_transfer(st->pipe, rbRead->texture, 0, 0, + PIPE_TRANSFER_READ, + readX, readY, readW, readH); struct pipe_transfer *ptTex; enum pipe_transfer_usage transfer_usage; @@ -1241,8 +1238,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, else transfer_usage = PIPE_TRANSFER_WRITE; - ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, 0, transfer_usage, - 0, 0, width, height); + ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, transfer_usage, + 0, 0, width, height); /* copy image from ptRead surface to ptTex surface */ if (type == GL_COLOR) { diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 9425f07aee6..cd718a31a14 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -52,6 +52,7 @@ #include "util/u_format.h" #include "util/u_inlines.h" +#include "util/u_surface.h" /** @@ -65,9 +66,11 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *r GLuint width, GLuint height) { struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = st->pipe->screen; struct st_renderbuffer *strb = st_renderbuffer(rb); enum pipe_format format; + struct pipe_surface surf_tmpl; if (strb->format != PIPE_FORMAT_NONE) format = strb->format; @@ -113,6 +116,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *r template.width0 = width; template.height0 = height; template.depth0 = 1; + template.array_size = 1; template.last_level = 0; template.nr_samples = rb->NumSamples; if (util_format_is_depth_or_stencil(format)) { @@ -120,7 +124,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *r } else { template.bind = (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_RENDER_TARGET); + PIPE_BIND_RENDER_TARGET); } strb->texture = screen->resource_create(screen, &template); @@ -128,10 +132,11 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *r if (!strb->texture) return FALSE; - strb->surface = screen->get_tex_surface(screen, - strb->texture, - 0, 0, 0, - template.bind); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + u_surface_default_template(&surf_tmpl, strb->texture, template.bind); + strb->surface = pipe->create_surface(pipe, + strb->texture, + &surf_tmpl); if (strb->surface) { assert(strb->surface->texture); assert(strb->surface->format); @@ -327,12 +332,12 @@ st_render_texture(struct gl_context *ctx, { struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct st_renderbuffer *strb; struct gl_renderbuffer *rb; struct pipe_resource *pt = st_get_texobj_resource(att->Texture); struct st_texture_object *stObj; const struct gl_texture_image *texImage; + struct pipe_surface surf_tmpl; /* When would this fail? Perhaps assert? */ if (!pt) @@ -381,12 +386,15 @@ st_render_texture(struct gl_context *ctx, assert(strb->rtt_level <= strb->texture->last_level); /* new surface for rendering into the texture */ - strb->surface = screen->get_tex_surface(screen, - strb->texture, - strb->rtt_face, - strb->rtt_level, - strb->rtt_slice, - PIPE_BIND_RENDER_TARGET); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + surf_tmpl.format = strb->texture->format; + surf_tmpl.usage = PIPE_BIND_RENDER_TARGET; + surf_tmpl.u.tex.level = strb->rtt_level; + surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice; + surf_tmpl.u.tex.last_layer = strb->rtt_face + strb->rtt_slice; + strb->surface = pipe->create_surface(pipe, + strb->texture, + &surf_tmpl); strb->format = pt->format; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index bcd46ac9d54..620da07e3d1 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -80,7 +80,7 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, /* Create a read transfer from the renderbuffer's texture */ pt = pipe_get_transfer(pipe, strb->texture, - 0, 0, 0, /* face, level, zslice */ + 0, 0, PIPE_TRANSFER_READ, x, y, width, height); @@ -236,7 +236,7 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb, } trans = pipe_get_transfer(pipe, strb->texture, - 0, 0, 0, /* face, level, zslice */ + 0, 0, PIPE_TRANSFER_READ, x, y, width, height); if (!trans) { @@ -400,7 +400,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h /* Create a read transfer from the renderbuffer's texture */ trans = pipe_get_transfer(pipe, strb->texture, - 0, 0, 0, /* face, level, zslice */ + 0, 0, PIPE_TRANSFER_READ, x, y, width, height); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 15e69e1fa07..d0fb6301b08 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -63,7 +63,7 @@ #include "util/u_surface.h" #include "util/u_sampler.h" #include "util/u_math.h" - +#include "util/u_box.h" #define DBG if (0) printf @@ -431,7 +431,7 @@ compress_with_blit(struct gl_context * ctx, struct pipe_resource *src_tex; struct pipe_sampler_view view_templ; struct pipe_sampler_view *src_view; - struct pipe_surface *dst_surface; + struct pipe_surface *dst_surface, surf_tmpl; struct pipe_transfer *tex_xfer; void *map; @@ -441,9 +441,13 @@ compress_with_blit(struct gl_context * ctx, } /* get destination surface (in the compressed texture) */ - dst_surface = screen->get_tex_surface(screen, stImage->pt, - stImage->face, stImage->level, 0, - 0 /* flags */); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + surf_tmpl.format = stImage->pt->format; + surf_tmpl.usage = PIPE_BIND_RENDER_TARGET; + surf_tmpl.u.tex.level = stImage->level; + surf_tmpl.u.tex.first_layer = stImage->face; + surf_tmpl.u.tex.last_layer = stImage->face; + dst_surface = pipe->create_surface(pipe, stImage->pt, &surf_tmpl); if (!dst_surface) { /* can't render into this format (or other problem) */ return GL_FALSE; @@ -464,6 +468,7 @@ compress_with_blit(struct gl_context * ctx, templ.width0 = width; templ.height0 = height; templ.depth0 = 1; + templ.array_size = 1; templ.last_level = 0; templ.usage = PIPE_USAGE_DEFAULT; templ.bind = PIPE_BIND_SAMPLER_VIEW; @@ -475,9 +480,9 @@ compress_with_blit(struct gl_context * ctx, /* Put user's tex data into the temporary texture */ tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, src_tex, - 0, 0, 0, /* face, level are zero */ - PIPE_TRANSFER_WRITE, - 0, 0, width, height); /* x, y, w, h */ + 0, 0, /* layer, level are zero */ + PIPE_TRANSFER_WRITE, + 0, 0, width, height); /* x, y, w, h */ map = pipe_transfer_map(pipe, tex_xfer); _mesa_texstore(ctx, 2, GL_RGBA, mesa_format, @@ -857,7 +862,6 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level, { struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct st_texture_image *stImage = st_texture_image(texImage); struct st_texture_object *stObj = st_texture_object(texObj); struct pipe_sampler_view *src_view = @@ -871,7 +875,7 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level, PIPE_BIND_TRANSFER_READ); /* create temp / dest surface */ - if (!util_create_rgba_surface(screen, width, height, bind, + if (!util_create_rgba_surface(pipe, width, height, bind, &dst_texture, &dst_surface)) { _mesa_problem(ctx, "util_create_rgba_surface() failed " "in decompress_with_blit()"); @@ -891,9 +895,9 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level, /* map the dst_surface so we can read from it */ tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, - dst_texture, 0, 0, 0, - PIPE_TRANSFER_READ, - 0, 0, width, height); + dst_texture, 0, 0, + PIPE_TRANSFER_READ, + 0, 0, width, height); pixels = _mesa_map_pbo_dest(ctx, &ctx->Pack, pixels); @@ -1310,7 +1314,7 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level, struct pipe_transfer *src_trans; GLvoid *texDest; enum pipe_transfer_usage transfer_usage; - + if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); @@ -1321,11 +1325,11 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level, } src_trans = pipe_get_transfer(st_context(ctx)->pipe, - strb->texture, - 0, 0, 0, - PIPE_TRANSFER_READ, - srcX, srcY, - width, height); + strb->texture, + 0, 0, + PIPE_TRANSFER_READ, + srcX, srcY, + width, height); if ((baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) && @@ -1334,7 +1338,8 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level, else transfer_usage = PIPE_TRANSFER_WRITE; - texDest = st_texture_image_map(st, stImage, 0, transfer_usage, + /* XXX this used to ignore destZ param */ + texDest = st_texture_image_map(st, stImage, destZ, transfer_usage, destX, destY, width, height); if (baseFormat == GL_DEPTH_COMPONENT || @@ -1592,27 +1597,23 @@ st_copy_texsubimage(struct gl_context *ctx, if (matching_base_formats && src_format == dest_format && - !do_flip) + !do_flip) { /* use surface_copy() / blit */ - struct pipe_subresource subdst, subsrc; - subdst.face = stImage->face; - subdst.level = stImage->level; - subsrc.face = strb->surface->face; - subsrc.level = strb->surface->level; + struct pipe_box src_box; + u_box_2d_zslice(srcX, srcY, strb->surface->u.tex.first_layer, + width, height, &src_box); /* for resource_copy_region(), y=0=top, always */ pipe->resource_copy_region(pipe, /* dest */ stImage->pt, - subdst, - destX, destY, destZ, + stImage->level, + destX, destY, destZ + stImage->face, /* src */ strb->texture, - subsrc, - srcX, srcY, strb->surface->zslice, - /* size */ - width, height); + strb->surface->u.tex.level, + &src_box); use_fallback = GL_FALSE; } else if (format_writemask && @@ -1628,12 +1629,16 @@ st_copy_texsubimage(struct gl_context *ctx, 0)) { /* draw textured quad to do the copy */ GLint srcY0, srcY1; - struct pipe_subresource subsrc; + struct pipe_surface surf_tmpl; + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + surf_tmpl.format = stImage->pt->format; + surf_tmpl.usage = PIPE_BIND_RENDER_TARGET; + surf_tmpl.u.tex.level = stImage->level; + surf_tmpl.u.tex.first_layer = stImage->face + destZ; + surf_tmpl.u.tex.last_layer = stImage->face + destZ; - dest_surface = screen->get_tex_surface(screen, stImage->pt, - stImage->face, stImage->level, - destZ, - PIPE_BIND_RENDER_TARGET); + dest_surface = pipe->create_surface(pipe, stImage->pt, + &surf_tmpl); if (do_flip) { srcY1 = strb->Base.Height - srcY - height; @@ -1643,15 +1648,13 @@ st_copy_texsubimage(struct gl_context *ctx, srcY0 = srcY; srcY1 = srcY0 + height; } - subsrc.face = strb->surface->face; - subsrc.level = strb->surface->level; util_blit_pixels_writemask(st->blit, strb->texture, - subsrc, + strb->surface->u.tex.level, srcX, srcY0, srcX + width, srcY1, - strb->surface->zslice, + strb->surface->u.tex.first_layer, dest_surface, destX, destY, destX + width, destY + height, diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 1fc4f40488f..2472c0bcf11 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -79,11 +79,15 @@ st_render_mipmap(struct st_context *st, const uint face = _mesa_tex_target_to_face(target); assert(psv->texture == stObj->pt); - assert(target != GL_TEXTURE_3D); /* not done yet */ +#if 0 + assert(target != GL_TEXTURE_3D); /* implemented but untested */ +#endif /* check if we can render in the texture's format */ - if (!screen->is_format_supported(screen, psv->format, psv->texture->target, 0, - PIPE_BIND_RENDER_TARGET, 0)) { + /* XXX should probably kill this and always use util_gen_mipmap + since this implements a sw fallback as well */ + if (!screen->is_format_supported(screen, psv->format, psv->texture->target, + 0, PIPE_BIND_RENDER_TARGET, 0)) { return FALSE; } @@ -161,12 +165,12 @@ fallback_generate_mipmap(struct gl_context *ctx, GLenum target, struct pipe_resource *pt = st_get_texobj_resource(texObj); const uint baseLevel = texObj->BaseLevel; const uint lastLevel = pt->last_level; - const uint face = _mesa_tex_target_to_face(target), zslice = 0; + const uint face = _mesa_tex_target_to_face(target); uint dstLevel; GLenum datatype; GLuint comps; GLboolean compressed; - + if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); @@ -198,16 +202,15 @@ fallback_generate_mipmap(struct gl_context *ctx, GLenum target, ubyte *dstData; int srcStride, dstStride; - srcTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face, - srcLevel, zslice, - PIPE_TRANSFER_READ, 0, 0, - srcWidth, srcHeight); - + srcTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, srcLevel, + face, + PIPE_TRANSFER_READ, 0, 0, + srcWidth, srcHeight); - dstTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face, - dstLevel, zslice, - PIPE_TRANSFER_WRITE, 0, 0, - dstWidth, dstHeight); + dstTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, dstLevel, + face, + PIPE_TRANSFER_WRITE, 0, 0, + dstWidth, dstHeight); srcData = (ubyte *) pipe_transfer_map(pipe, srcTrans); dstData = (ubyte *) pipe_transfer_map(pipe, dstTrans); @@ -215,6 +218,8 @@ fallback_generate_mipmap(struct gl_context *ctx, GLenum target, srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->resource->format); dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->resource->format); + /* this cannot work correctly for 3d since it does + not respect layerStride. */ if (compressed) { const enum pipe_format format = pt->format; const uint bw = util_format_get_blockwidth(format); @@ -372,6 +377,8 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, * use the software fallback. */ if (!st_render_mipmap(st, target, stObj, baseLevel, lastLevel)) { + /* since the util code actually also has a fallback, should + probably make it never fail and kill this */ fallback_generate_mipmap(ctx, target, texObj); } diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 05733e818ea..0307b48978b 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -34,6 +34,7 @@ #include "util/u_pointer.h" #include "util/u_inlines.h" #include "util/u_atomic.h" +#include "util/u_surface.h" #include "main/mtypes.h" #include "main/context.h" @@ -142,7 +143,7 @@ buffer_index_to_attachment(gl_buffer_index index) static void st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) { - struct pipe_screen *screen = st->pipe->screen; + struct pipe_context *pipe = st->pipe; struct pipe_resource *textures[ST_ATTACHMENT_COUNT]; uint width, height; unsigned i; @@ -160,7 +161,7 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) for (i = 0; i < stfb->num_statts; i++) { struct st_renderbuffer *strb; - struct pipe_surface *ps; + struct pipe_surface *ps, surf_tmpl; gl_buffer_index idx; if (!textures[i]) @@ -179,8 +180,10 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) continue; } - ps = screen->get_tex_surface(screen, textures[i], 0, 0, 0, - PIPE_BIND_RENDER_TARGET); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + u_surface_default_template(&surf_tmpl, textures[i], + PIPE_BIND_RENDER_TARGET); + ps = pipe->create_surface(pipe, textures[i], &surf_tmpl); if (ps) { pipe_surface_reference(&strb->surface, ps); pipe_resource_reference(&strb->texture, ps->texture); @@ -813,6 +816,7 @@ st_manager_flush_frontbuffer(struct st_context *st) /** * Return the surface of an EGLImage. + * FIXME: I think this should operate on resources, not surfaces */ struct pipe_surface * st_manager_get_egl_image_surface(struct st_context *st, @@ -821,7 +825,7 @@ st_manager_get_egl_image_surface(struct st_context *st, struct st_manager *smapi = (struct st_manager *) st->iface.st_context_private; struct st_egl_image stimg; - struct pipe_surface *ps; + struct pipe_surface *ps, surf_tmpl; if (!smapi || !smapi->get_egl_image) return NULL; @@ -830,8 +834,13 @@ st_manager_get_egl_image_surface(struct st_context *st, if (!smapi->get_egl_image(smapi, eglimg, &stimg)) return NULL; - ps = smapi->screen->get_tex_surface(smapi->screen, - stimg.texture, stimg.face, stimg.level, stimg.zslice, usage); + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + surf_tmpl.format = stimg.texture->format; + surf_tmpl.usage = usage; + surf_tmpl.u.tex.level = stimg.level; + surf_tmpl.u.tex.first_layer = stimg.layer; + surf_tmpl.u.tex.last_layer = stimg.layer; + ps = st->pipe->create_surface(st->pipe, stimg.texture, &surf_tmpl); pipe_resource_reference(&stimg.texture, NULL); return ps; diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index c6cf2ba061b..155ea39f18c 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -84,6 +84,7 @@ st_texture_create(struct st_context *st, pt.width0 = width0; pt.height0 = height0; pt.depth0 = depth0; + pt.array_size = (target == PIPE_TEXTURE_CUBE ? 6 : 1); pt.usage = PIPE_USAGE_DEFAULT; pt.bind = bind; pt.flags = 0; @@ -136,7 +137,7 @@ st_texture_match_image(const struct pipe_resource *pt, */ GLubyte * st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, - GLuint zoffset, enum pipe_transfer_usage usage, + GLuint zoffset, enum pipe_transfer_usage usage, GLuint x, GLuint y, GLuint w, GLuint h) { struct pipe_context *pipe = st->pipe; @@ -144,9 +145,9 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, DBG("%s \n", __FUNCTION__); - stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->face, - stImage->level, zoffset, - usage, x, y, w, h); + stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->level, + stImage->face + zoffset, + usage, x, y, w, h); if (stImage->transfer) return pipe_transfer_map(pipe, stImage->transfer); @@ -219,10 +220,10 @@ st_texture_image_data(struct st_context *st, DBG("%s\n", __FUNCTION__); for (i = 0; i < depth; 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)); + dst_transfer = pipe_get_transfer(st->pipe, dst, level, face + i, + PIPE_TRANSFER_WRITE, 0, 0, + u_minify(dst->width0, level), + u_minify(dst->height0, level)); st_surface_data(pipe, dst_transfer, 0, 0, /* dstx, dsty */ @@ -230,7 +231,7 @@ st_texture_image_data(struct st_context *st, src_row_stride, 0, 0, /* source x, y */ u_minify(dst->width0, level), - u_minify(dst->height0, level)); /* width, height */ + u_minify(dst->height0, level)); /* width, height */ pipe->transfer_destroy(pipe, dst_transfer); @@ -245,14 +246,10 @@ st_texture_image_data(struct st_context *st, 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; @@ -260,7 +257,7 @@ print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src) region.height = 1; region.depth = 1; - xfer = pipe->get_transfer(pipe, src, rect, PIPE_TRANSFER_READ, ®ion); + xfer = pipe->get_transfer(pipe, src, 0, 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]); @@ -282,22 +279,26 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *src, GLuint srcLevel, GLuint face) { - GLuint width = u_minify(dst->width0, dstLevel); - GLuint height = u_minify(dst->height0, dstLevel); - GLuint depth = u_minify(dst->depth0, dstLevel); - struct pipe_subresource dstsub, srcsub; + GLuint width = u_minify(dst->width0, dstLevel); + GLuint height = u_minify(dst->height0, dstLevel); + GLuint depth = u_minify(dst->depth0, dstLevel); + struct pipe_box src_box; GLuint i; 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; + src_box.x = 0; + src_box.y = 0; + src_box.width = width; + src_box.height = height; + src_box.depth = 1; /* Loop over 3D image slices */ - for (i = 0; i < depth; i++) { + /* could (and probably should) use "true" 3d box here - + but drivers can't quite handle it yet */ + for (i = face; i < face + depth; i++) { + src_box.z = i; if (0) { print_center_pixel(pipe, src); @@ -305,12 +306,11 @@ st_texture_image_copy(struct pipe_context *pipe, pipe->resource_copy_region(pipe, dst, - dstsub, + dstLevel, 0, 0, i,/* destX, Y, Z */ src, - srcsub, - 0, 0, i,/* srcX, Y, Z */ - width, height); + srcLevel, + &src_box); } } |