r600g: move depth texture flushing out of line.
authorDave Airlie <airlied@redhat.com>
Tue, 7 Jun 2011 05:41:30 +0000 (15:41 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 13 Jun 2011 23:17:16 +0000 (09:17 +1000)
this needs a piglit run.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600.h
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c

index 9ebfe54c76d97b1a536287dafae2dde6db428f2d..f86e4d4e3af03c91fd649d1536ae5fbf9780667c 100644 (file)
@@ -482,19 +482,27 @@ static void evergreen_set_ps_sampler_view(struct pipe_context *ctx, unsigned cou
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
        int i;
+       int has_depth = 0;
 
        for (i = 0; i < count; i++) {
                if (&rctx->ps_samplers.views[i]->base != views[i]) {
-                       if (resource[i])
+                       if (resource[i]) {
+                               if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+                                       has_depth = 1;
                                evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state,
                                                                             i + R600_MAX_CONST_BUFFERS);
-                       else
+                       else
                                evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, NULL,
                                                                             i + R600_MAX_CONST_BUFFERS);
 
                        pipe_sampler_view_reference(
                                (struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
                                views[i]);
+               } else {
+                       if (resource[i]) {
+                               if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+                                       has_depth = 1;
+                       }
                }
        }
        for (i = count; i < NUM_TEX_UNITS; i++) {
@@ -504,6 +512,7 @@ static void evergreen_set_ps_sampler_view(struct pipe_context *ctx, unsigned cou
                        pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
                }
        }
+       rctx->have_depth_texture = has_depth;
        rctx->ps_samplers.n_views = count;
 }
 
@@ -689,6 +698,9 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
        surf = (struct r600_surface *)state->cbufs[cb];
        rtex = (struct r600_resource_texture*)state->cbufs[cb]->texture;
 
+       if (rtex->depth)
+               rctx->have_depth_fb = TRUE;
+
        if (rtex->depth && !rtex->is_flushing_texture) {
                r600_texture_depth_flush(&rctx->context, state->cbufs[cb]->texture, TRUE);
                rtex = rtex->flushed_depth_texture;
@@ -870,6 +882,7 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
        util_copy_framebuffer_state(&rctx->framebuffer, state);
 
        /* build states */
+       rctx->have_depth_fb = 0;
        for (int i = 0; i < state->nr_cbufs; i++) {
                evergreen_cb(rctx, rstate, state, i);
        }
index bf7138d9e4e845a700cf80e05875f1df8b20e575..225c17c2540b186d296bd9cf07a99b13da5a1619 100644 (file)
@@ -261,6 +261,7 @@ struct r600_context {
        struct r600_range vs_resources;
        struct r600_range fs_resources;
        int num_ps_resources, num_vs_resources, num_fs_resources;
+       boolean                 have_depth_texture, have_depth_fb;
 };
 
 struct r600_draw {
index 151f48a8bf8b1f70e4403ac62b26645104251581..e9f35c10ac16188a15016bfb7c0cdf479806614d 100644 (file)
@@ -121,8 +121,6 @@ void r600_flush_depth_textures(struct r600_pipe_context *rctx)
 {
        unsigned int i;
 
-       if (rctx->blit) return;
-
        /* FIXME: This handles fragment shader textures only. */
 
        for (i = 0; i < rctx->ps_samplers.n_views; ++i) {
index 332f932013a27ae4db4ede65c3e5d3f1f4f43932..5e534ca905cf15ad91fef668da425dc805b8fab1 100644 (file)
@@ -204,6 +204,7 @@ struct r600_pipe_context {
        struct u_vbuf_mgr               *vbuf_mgr;
        struct util_slab_mempool        pool_transfers;
        boolean                         blit;
+       boolean                         have_depth_texture, have_depth_fb;
 
        unsigned default_ps_gprs, default_vs_gprs;
 };
index 98f5c511f5b7b57e0d14a203599f33464f57a95d..3b6e2dc99a5683b24b4a8ae0a6bbfca062f02cc9 100644 (file)
@@ -518,13 +518,16 @@ static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
        int i;
+       int has_depth = 0;
 
        for (i = 0; i < count; i++) {
                if (&rctx->ps_samplers.views[i]->base != views[i]) {
-                       if (resource[i])
+                       if (resource[i]) {
+                               if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+                                       has_depth = 1;
                                r600_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state,
                                                                        i + R600_MAX_CONST_BUFFERS);
-                       else
+                       else
                                r600_context_pipe_state_set_ps_resource(&rctx->ctx, NULL,
                                                                        i + R600_MAX_CONST_BUFFERS);
 
@@ -532,6 +535,11 @@ static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
                                (struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
                                views[i]);
 
+               } else {
+                       if (resource[i]) {
+                               if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+                                       has_depth = 1;
+                       }
                }
        }
        for (i = count; i < NUM_TEX_UNITS; i++) {
@@ -541,6 +549,7 @@ static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
                        pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
                }
        }
+       rctx->have_depth_texture = has_depth;
        rctx->ps_samplers.n_views = count;
 }
 
@@ -724,6 +733,9 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
        surf = (struct r600_surface *)state->cbufs[cb];
        rtex = (struct r600_resource_texture*)state->cbufs[cb]->texture;
 
+       if (rtex->depth)
+               rctx->have_depth_fb = TRUE;
+
        if (rtex->depth && !rtex->is_flushing_texture) {
                r600_texture_depth_flush(&rctx->context, state->cbufs[cb]->texture, TRUE);
                rtex = rtex->flushed_depth_texture;
@@ -886,6 +898,7 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
        util_copy_framebuffer_state(&rctx->framebuffer, state);
 
        /* build states */
+       rctx->have_depth_fb = 0;
        for (int i = 0; i < state->nr_cbufs; i++) {
                r600_cb(rctx, rstate, state, i);
        }
index 1eb9389badef09828f5885f65a66888d381c304c..d58c1f0656ca79767cd29a9509713b78a664fccf 100644 (file)
@@ -530,7 +530,10 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
        struct r600_drawl draw = {};
        unsigned prim;
 
-       r600_flush_depth_textures(rctx);
+       if (!rctx->blit) {
+               if (rctx->have_depth_fb || rctx->have_depth_texture)
+                       r600_flush_depth_textures(rctx);
+       }
        u_vbuf_mgr_draw_begin(rctx->vbuf_mgr, info, NULL, NULL);
        r600_vertex_buffer_update(rctx);