nv50,nvc0: Remove duplicate logic from nvc0_set_framebuffer_state()
authorEdward O'Callaghan <eocallaghan@alterapraxis.com>
Sun, 14 Feb 2016 21:54:30 +0000 (08:54 +1100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 14 Feb 2016 22:56:54 +0000 (23:56 +0100)
We already have this logic in the gallium/util functions so
lets reduce some entropy while here.

V.2:
  Apply change to nv50 also as suggested by Samuel Pitoiset.

Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/gallium/drivers/nouveau/nv50/nv50_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c

index cb04043913904acec05c9c7cbf27c2026ba8446b..438f41385f0dcefc77de21a885f094ba0178df8d 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "pipe/p_defines.h"
+#include "util/u_framebuffer.h"
 #include "util/u_helpers.h"
 #include "util/u_inlines.h"
 #include "util/u_transfer.h"
@@ -936,21 +937,10 @@ nv50_set_framebuffer_state(struct pipe_context *pipe,
                            const struct pipe_framebuffer_state *fb)
 {
    struct nv50_context *nv50 = nv50_context(pipe);
-   unsigned i;
 
    nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_FB);
 
-   for (i = 0; i < fb->nr_cbufs; ++i)
-      pipe_surface_reference(&nv50->framebuffer.cbufs[i], fb->cbufs[i]);
-   for (; i < nv50->framebuffer.nr_cbufs; ++i)
-      pipe_surface_reference(&nv50->framebuffer.cbufs[i], NULL);
-
-   nv50->framebuffer.nr_cbufs = fb->nr_cbufs;
-
-   nv50->framebuffer.width = fb->width;
-   nv50->framebuffer.height = fb->height;
-
-   pipe_surface_reference(&nv50->framebuffer.zsbuf, fb->zsbuf);
+   util_copy_framebuffer_state(&nv50->framebuffer, fb);
 
    nv50->dirty |= NV50_NEW_FRAMEBUFFER;
 }
index cf3d3497c789365865a50a65182064674cc88303..cd3f1ff18d12fad33fe76527a5a438b43e1d498a 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "pipe/p_defines.h"
+#include "util/u_framebuffer.h"
 #include "util/u_helpers.h"
 #include "util/u_inlines.h"
 #include "util/u_transfer.h"
@@ -940,21 +941,10 @@ nvc0_set_framebuffer_state(struct pipe_context *pipe,
                            const struct pipe_framebuffer_state *fb)
 {
     struct nvc0_context *nvc0 = nvc0_context(pipe);
-    unsigned i;
 
     nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_FB);
 
-    for (i = 0; i < fb->nr_cbufs; ++i)
-       pipe_surface_reference(&nvc0->framebuffer.cbufs[i], fb->cbufs[i]);
-    for (; i < nvc0->framebuffer.nr_cbufs; ++i)
-       pipe_surface_reference(&nvc0->framebuffer.cbufs[i], NULL);
-
-    nvc0->framebuffer.nr_cbufs = fb->nr_cbufs;
-
-    nvc0->framebuffer.width = fb->width;
-    nvc0->framebuffer.height = fb->height;
-
-    pipe_surface_reference(&nvc0->framebuffer.zsbuf, fb->zsbuf);
+    util_copy_framebuffer_state(&nvc0->framebuffer, fb);
 
     nvc0->dirty |= NVC0_NEW_FRAMEBUFFER;
 }