[virglrenderer-devel] [PATCH 4/6] renderer: refactor/cleanup z/color surface binding.

Dave Airlie airlied at gmail.com
Fri Jun 8 01:18:53 UTC 2018


From: Dave Airlie <airlied at redhat.com>

This just makes the two functions look a lot more like each other,
since for texture views I have to add some more code to them.
---
 src/vrend_renderer.c | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index be597a2..80a469b 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -1506,45 +1506,39 @@ void vrend_fb_bind_texture(struct vrend_resource *res,
 
 static void vrend_hw_set_zsurf_texture(struct vrend_context *ctx)
 {
-   struct vrend_resource *tex;
-   int first_layer, last_layer;
-   if (!ctx->sub->zsurf) {
+   struct vrend_surface *surf = ctx->sub->zsurf;
+
+   if (!surf) {
       glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
                                 GL_TEXTURE_2D, 0, 0);
-      return;
-
-   }
-   tex = ctx->sub->zsurf->texture;
-   if (!tex)
-      return;
+   } else {
+      int first_layer = surf->val1 & 0xffff;
+      int last_layer = (surf->val1 >> 16) & 0xffff;
 
-   first_layer = ctx->sub->zsurf->val1 & 0xffff;
-   last_layer = (ctx->sub->zsurf->val1 >> 16) & 0xffff;
+      if (!surf->texture)
+         return;
 
-   vrend_fb_bind_texture(tex, 0, ctx->sub->zsurf->val0,
-                         first_layer != last_layer ? 0xffffffff : first_layer);
+      vrend_fb_bind_texture(surf->texture, 0, surf->val0,
+                            first_layer != last_layer ? 0xffffffff : first_layer);
+   }
 }
 
 static void vrend_hw_set_color_surface(struct vrend_context *ctx, int index)
 {
-   struct vrend_resource *tex;
+   struct vrend_surface *surf = ctx->sub->surf[index];
 
-   if (!ctx->sub->surf[index]) {
+   if (!surf) {
       GLenum attachment = GL_COLOR_ATTACHMENT0 + index;
 
       glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment,
                                 GL_TEXTURE_2D, 0, 0);
    } else {
-      int first_layer = ctx->sub->surf[index]->val1 & 0xffff;
-      int last_layer = (ctx->sub->surf[index]->val1 >> 16) & 0xffff;
-      tex = ctx->sub->surf[index]->texture;
+      int first_layer = surf->val1 & 0xffff;
+      int last_layer = (surf->val1 >> 16) & 0xffff;
 
-
-      vrend_fb_bind_texture(tex, index, ctx->sub->surf[index]->val0,
+      vrend_fb_bind_texture(surf->texture, index, surf->val0,
                             first_layer != last_layer ? 0xffffffff : first_layer);
    }
-
-
 }
 
 static void vrend_hw_emit_framebuffer_state(struct vrend_context *ctx)
-- 
2.14.3



More information about the virglrenderer-devel mailing list