It's the easiest approach and it's pretty much what Intel does. There's a lot of fallbacks which map textures and this makes them trivially work. Note that this is mainly for the window-system multi-sample framebuffer, which must implemented the same features as a single-sample one has. That means ReadPixels, CopyTex*Image and CopyPixels are allowed, unlike a multisample FBO which generates INVALID_OPERATION in those functions.
Also radeons cannot map MSAA textures directly. r300 cannot map them at all, r600 can map only one sample at a time (or it would have to copy each sample to a separate layer). Marek On Tue, Dec 4, 2012 at 12:35 PM, Christoph Bumiller <e0425...@student.tuwien.ac.at> wrote: > On 04.12.2012 01:07, Marek Olšák wrote: >> so that ReadPixels and various fallbacks work. > > Err, shouldn't the state tracker do the resolve ? What if someone wants > to read back the individual samples ? > > Yes, I know this adds a few complications, like how they are stored for > the transfer (maybe read them with separate transfers ? - yes, slow), > and that you get an extra copy because you won't be able to directly > write to a staging resource, but I really dislike this implicit resolve ... > >> --- >> src/gallium/drivers/r600/r600_texture.c | 37 >> ++++++++++++++++++++++++++----- >> 1 file changed, 32 insertions(+), 5 deletions(-) >> >> diff --git a/src/gallium/drivers/r600/r600_texture.c >> b/src/gallium/drivers/r600/r600_texture.c >> index 0054c5b..d6d1b3d 100644 >> --- a/src/gallium/drivers/r600/r600_texture.c >> +++ b/src/gallium/drivers/r600/r600_texture.c >> @@ -31,18 +31,38 @@ >> #include "util/u_format_s3tc.h" >> #include "util/u_memory.h" >> >> + >> /* Copy from a full GPU texture to a transfer's staging one. */ >> static void r600_copy_to_staging_texture(struct pipe_context *ctx, struct >> r600_transfer *rtransfer) >> { >> struct pipe_transfer *transfer = (struct pipe_transfer*)rtransfer; >> - struct pipe_resource *texture = transfer->resource; >> + struct pipe_resource *dst = &rtransfer->staging->b.b; >> + struct pipe_resource *src = transfer->resource; >> >> - ctx->resource_copy_region(ctx, &rtransfer->staging->b.b, >> - 0, 0, 0, 0, texture, transfer->level, >> - &transfer->box); >> + if (src->nr_samples <= 1) { >> + ctx->resource_copy_region(ctx, dst, 0, 0, 0, 0, >> + src, transfer->level, >> &transfer->box); >> + } else { >> + /* Resolve the resource. */ >> + struct pipe_blit_info blit; >> + >> + memset(&blit, 0, sizeof(blit)); >> + blit.src.resource = src; >> + blit.src.format = src->format; >> + blit.src.level = transfer->level; >> + blit.src.box = transfer->box; >> + blit.dst.resource = dst; >> + blit.dst.format = dst->format; >> + blit.dst.box.width = transfer->box.width; >> + blit.dst.box.height = transfer->box.height; >> + blit.dst.box.depth = transfer->box.depth; >> + blit.mask = PIPE_MASK_RGBA; >> + blit.filter = PIPE_TEX_FILTER_NEAREST; >> + >> + ctx->blit(ctx, &blit); >> + } >> } >> >> - >> /* Copy from a transfer's staging texture to a full GPU one. */ >> static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct >> r600_transfer *rtransfer) >> { >> @@ -715,6 +735,13 @@ static void *r600_texture_transfer_map(struct >> pipe_context *ctx, >> */ >> struct r600_texture *staging_depth; >> >> + assert(rtex->resource.b.b.nr_samples <= 1); >> + if (rtex->resource.b.b.nr_samples > 1) { >> + R600_ERR("mapping MSAA zbuffer unimplemented\n"); >> + FREE(trans); >> + return NULL; >> + } >> + >> if (!r600_init_flushed_depth_texture(ctx, texture, >> &staging_depth)) { >> R600_ERR("failed to create temporary texture to hold >> untiled copy\n"); >> FREE(trans); > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev