svga: track which textures are rendered to

Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Cc: "10.1" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
Brian Paul 2014-02-08 09:51:14 -08:00
parent c1e60a61e8
commit d0c22a6d53
2 changed files with 38 additions and 18 deletions

View File

@ -25,11 +25,13 @@
#include "svga_cmd.h"
#include "util/u_framebuffer.h"
#include "util/u_inlines.h"
#include "svga_context.h"
#include "svga_screen.h"
#include "svga_surface.h"
#include "svga_resource_texture.h"
static void svga_set_scissor_states( struct pipe_context *pipe,
@ -86,19 +88,25 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe,
dst->nr_cbufs = fb->nr_cbufs;
/* check if we need to propagate any of the target surfaces */
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
if (dst->cbufs[i] && dst->cbufs[i] != fb->cbufs[i])
if (svga_surface_needs_propagation(dst->cbufs[i]))
for (i = 0; i < dst->nr_cbufs; i++) {
struct pipe_surface *s = i < fb->nr_cbufs ? fb->cbufs[i] : NULL;
if (dst->cbufs[i] && dst->cbufs[i] != s) {
if (svga_surface_needs_propagation(dst->cbufs[i])) {
propagate = TRUE;
break;
}
}
}
if (propagate) {
/* make sure that drawing calls comes before propagation calls */
svga_hwtnl_flush_retry( svga );
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
if (dst->cbufs[i] && dst->cbufs[i] != fb->cbufs[i])
for (i = 0; i < dst->nr_cbufs; i++) {
struct pipe_surface *s = i < fb->nr_cbufs ? fb->cbufs[i] : NULL;
if (dst->cbufs[i] && dst->cbufs[i] != s)
svga_propagate_surface(svga, dst->cbufs[i]);
}
}
/* XXX: Actually the virtual hardware may support rendertargets with
@ -111,12 +119,16 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe,
}
}
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
pipe_surface_reference(&dst->cbufs[i],
(i < fb->nr_cbufs) ? fb->cbufs[i] : NULL);
}
pipe_surface_reference(&dst->zsbuf, fb->zsbuf);
util_copy_framebuffer_state(dst, fb);
/* Set the rendered-to flags */
for (i = 0; i < dst->nr_cbufs; i++) {
struct pipe_surface *s = dst->cbufs[i];
if (s) {
struct svga_texture *t = svga_texture(s->texture);
svga_set_texture_rendered_to(t, s->u.tex.first_layer, s->u.tex.level);
}
}
if (svga->curr.framebuffer.zsbuf)
{
@ -140,6 +152,13 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe,
svga->curr.depthscale = 0.0f;
break;
}
/* Set rendered-to flag */
{
struct pipe_surface *s = dst->zsbuf;
struct svga_texture *t = svga_texture(s->texture);
svga_set_texture_rendered_to(t, s->u.tex.first_layer, s->u.tex.level);
}
}
else {
svga->curr.depthscale = 0.0f;

View File

@ -158,7 +158,7 @@ svga_texture_view_surface(struct svga_context *svga,
for (i = 0; i < key->numMipLevels; i++) {
for (j = 0; j < key->numFaces; j++) {
if (tex->defined[j + face_pick][i + start_mip]) {
if (svga_is_texture_level_defined(tex, j + face_pick, i + start_mip)) {
unsigned depth = (zslice_pick < 0 ?
u_minify(tex->b.b.depth0, i + start_mip) :
1);
@ -304,18 +304,19 @@ svga_mark_surface_dirty(struct pipe_surface *surf)
if (s->handle == tex->handle) {
/* hmm so 3d textures always have all their slices marked ? */
if (surf->texture->target == PIPE_TEXTURE_CUBE)
tex->defined[surf->u.tex.first_layer][surf->u.tex.level] = TRUE;
svga_define_texture_level(tex, surf->u.tex.first_layer,
surf->u.tex.level);
else
tex->defined[0][surf->u.tex.level] = TRUE;
svga_define_texture_level(tex, 0, surf->u.tex.level);
}
else {
/* this will happen later in svga_propagate_surface */
}
/* Increment the view_age and texture age for this surface's slice
* so that any sampler views into the texture are re-validated too.
/* Increment the view_age and texture age for this surface's mipmap
* level so that any sampler views into the texture are re-validated too.
*/
svga_age_texture_view(tex, surf->u.tex.first_layer);
svga_age_texture_view(tex, surf->u.tex.level);
}
}
@ -361,7 +362,7 @@ svga_propagate_surface(struct svga_context *svga, struct pipe_surface *surf)
s->dirty = FALSE;
ss->texture_timestamp++;
tex->view_age[surf->u.tex.level] = ++(tex->age);
svga_age_texture_view(tex, surf->u.tex.level);
if (s->handle != tex->handle) {
SVGA_DBG(DEBUG_VIEWS,
@ -372,7 +373,7 @@ svga_propagate_surface(struct svga_context *svga, struct pipe_surface *surf)
tex->handle, 0, 0, zslice, surf->u.tex.level, face,
u_minify(tex->b.b.width0, surf->u.tex.level),
u_minify(tex->b.b.height0, surf->u.tex.level), 1);
tex->defined[face][surf->u.tex.level] = TRUE;
svga_define_texture_level(tex, face, surf->u.tex.level);
}
}