[Mesa-dev] [PATCH] st/osmesa: simplify osmesa_st_framebuffer_flush_front()

Brian Paul brianp at vmware.com
Tue Feb 3 14:51:29 PST 2015


The osmesa->textures[] array is indexed by ST_ATTACHMENT_* so
there's no need to search the array to find the depth/stencil buffer.
This is a follow-on improvement after bug 88930.
---
 src/gallium/state_trackers/osmesa/osmesa.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/src/gallium/state_trackers/osmesa/osmesa.c b/src/gallium/state_trackers/osmesa/osmesa.c
index 4e2b2e0..cbda267 100644
--- a/src/gallium/state_trackers/osmesa/osmesa.c
+++ b/src/gallium/state_trackers/osmesa/osmesa.c
@@ -319,21 +319,11 @@ osmesa_st_framebuffer_flush_front(struct st_context_iface *stctx,
    int dst_stride;
 
    if (osmesa->pp) {
-      struct pipe_resource *zsbuf = NULL;
-      unsigned i;
-
-      /* Find the z/stencil buffer if there is one */
-      for (i = 0; i < Elements(osbuffer->textures); i++) {
-         struct pipe_resource *res = osbuffer->textures[i];
-         if (res) {
-            const struct util_format_description *desc =
-               util_format_description(res->format);
-
-            if (util_format_has_depth(desc)) {
-               zsbuf = res;
-               break;
-            }
-         }
+      /* Get the z/stencil buffer if there is one */
+      struct pipe_resource *zsbuf =
+         osbuffer->textures[ST_ATTACHMENT_DEPTH_STENCIL];
+      if (zsbuf) {
+         assert(util_format_has_depth(util_format_description(zsbuf->format)));
       }
 
       /* run the postprocess stage(s) */
-- 
1.9.1



More information about the mesa-dev mailing list