r600g: do proper tracking of views/samplers.
authorDave Airlie <airlied@redhat.com>
Mon, 18 Oct 2010 02:04:57 +0000 (12:04 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 18 Oct 2010 03:39:54 +0000 (13:39 +1000)
we need to do pretty much what r300g does in for this, this fixes some
issues seen while working on tiling.

src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c

index 935496c04af076d2f6c9e4a29d02eff97d790b99..ce34ed4ad3c76c712d67c2c59614edd187de9b55 100644 (file)
@@ -500,15 +500,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;
-
-       rctx->ps_samplers.views = resource;
-       rctx->ps_samplers.n_views = count;
-
-       for (int i = 0; i < count; i++) {
-               if (resource[i]) {
-                       evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state, i);
+       int i;
+
+       for (i = 0; i < count; i++) {
+               if (&rctx->ps_samplers.views[i]->base != views[i]) {
+                       if (resource[i])
+                               evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state, i);
+                       else
+                               evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, NULL, i);
+
+                       pipe_sampler_view_reference(
+                               (struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
+                               views[i]);
                }
        }
+       for (i = count; i < NUM_TEX_UNITS; i++) {
+               if (rctx->ps_samplers.views[i]) {
+                       evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, NULL, i);
+                       pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
+               }
+       }
+       rctx->ps_samplers.n_views = count;
 }
 
 static void evergreen_bind_state(struct pipe_context *ctx, void *state)
@@ -527,7 +539,8 @@ static void evergreen_bind_ps_sampler(struct pipe_context *ctx, unsigned count,
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state **rstates = (struct r600_pipe_state **)states;
 
-       rctx->ps_samplers.samplers = states;
+
+       memcpy(rctx->ps_samplers.samplers, states, sizeof(void*) * count);
        rctx->ps_samplers.n_samplers = count;
 
        for (int i = 0; i < count; i++) {
index 35548329e469c4d6e77a3b193e8e8f8632497d63..e7c4b60d00c437902d74ce03b3cf8c381ad02b32 100644 (file)
@@ -94,10 +94,12 @@ struct r600_pipe_shader {
 };
 
 /* needed for blitter save */
+#define NUM_TEX_UNITS 16
+
 struct r600_textures_info {
-       struct r600_pipe_sampler_view   **views;
+       struct r600_pipe_sampler_view   *views[NUM_TEX_UNITS];
        unsigned                        n_views;
-       void                            **samplers;
+       void                            *samplers[NUM_TEX_UNITS];
        unsigned                        n_samplers;
 };
 
index 00234f956aadf714ed5ceaf849be864e4541e9ca..a95e2c6590c2d92a52f6ff5ad40336f0ab27f1b8 100644 (file)
@@ -710,15 +710,28 @@ 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;
 
-       rctx->ps_samplers.views = resource;
-       rctx->ps_samplers.n_views = count;
+       for (i = 0; i < count; i++) {
+               if (&rctx->ps_samplers.views[i]->base != views[i]) {
+                       if (resource[i])
+                               r600_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state, i);
+                       else
+                               r600_context_pipe_state_set_ps_resource(&rctx->ctx, NULL, i);
+
+                       pipe_sampler_view_reference(
+                               (struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
+                               views[i]);
 
-       for (int i = 0; i < count; i++) {
-               if (resource[i]) {
-                       r600_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state, i);
                }
        }
+       for (i = count; i < NUM_TEX_UNITS; i++) {
+               if (rctx->ps_samplers.views[i]) {
+                       r600_context_pipe_state_set_ps_resource(&rctx->ctx, NULL, i);
+                       pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
+               }
+       }
+       rctx->ps_samplers.n_views = count;
 }
 
 static void r600_bind_state(struct pipe_context *ctx, void *state)
@@ -737,7 +750,7 @@ static void r600_bind_ps_sampler(struct pipe_context *ctx, unsigned count, void
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state **rstates = (struct r600_pipe_state **)states;
 
-       rctx->ps_samplers.samplers = states;
+       memcpy(rctx->ps_samplers.samplers, states, sizeof(void*) * count);
        rctx->ps_samplers.n_samplers = count;
 
        for (int i = 0; i < count; i++) {