X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_atom_framebuffer.c;h=a8907c1577a4650a341bdf65a7dd4c3d10e3d6ac;hb=07b9b3c37b33e4994ff71930aed77821e758f0c9;hp=1cd55463379b16d44610b43afb7c0b9cfce41bab;hpb=35489ef285f1fde234b2b9bbb91fdc41fddefc02;p=mesa.git diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 1cd55463379..a8907c1577a 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -39,7 +39,7 @@ #include "cso_cache/cso_context.h" #include "util/u_math.h" #include "util/u_inlines.h" - +#include "util/u_format.h" /** @@ -51,12 +51,14 @@ 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; + enum pipe_format format = st->ctx->Color.sRGBEnabled ? resource->format : util_format_linear(resource->format); if (!strb->surface || + strb->surface->format != format || strb->surface->texture != resource || strb->surface->width != rtt_width || strb->surface->height != rtt_height) { @@ -65,17 +67,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 = 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 | - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION ); + 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, @@ -135,7 +139,6 @@ update_framebuffer_state( struct st_context *st ) */ strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer); if (strb) { - strb = st_renderbuffer(strb->Base.Wrapped); if (strb->rtt) { /* rendering to a GL texture, may have to update surface */ update_renderbuffer_surface(st, strb); @@ -145,7 +148,6 @@ update_framebuffer_state( struct st_context *st ) else { strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer); if (strb) { - strb = st_renderbuffer(strb->Base.Wrapped); assert(strb->surface); pipe_surface_reference(&framebuffer->zsbuf, strb->surface); } @@ -153,6 +155,16 @@ update_framebuffer_state( struct st_context *st ) pipe_surface_reference(&framebuffer->zsbuf, NULL); } +#ifdef DEBUG + /* Make sure the resource binding flags were set properly */ + for (i = 0; i < framebuffer->nr_cbufs; i++) { + assert(framebuffer->cbufs[i]->texture->bind & PIPE_BIND_RENDER_TARGET); + } + if (framebuffer->zsbuf) { + assert(framebuffer->zsbuf->texture->bind & PIPE_BIND_DEPTH_STENCIL); + } +#endif + cso_set_framebuffer(st->cso_context, framebuffer); }