[virglrenderer-devel] [PATCH 4/4] get rid of yet another bind-flag set

Erik Faye-Lund erik.faye-lund at collabora.com
Mon Jul 16 15:43:44 UTC 2018


These VREND_BIND_*-flags here are basically a subset of the
VIRGL_BIND_*-flags, with one custom flag added. So let's just use
those, and use an unused big from the others for the swizzle-flag.

Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
---
 src/vrend_blitter.c  |  4 ++--
 src/vrend_formats.c  |  6 +++---
 src/vrend_renderer.c | 12 ++++++------
 src/vrend_renderer.h |  7 +------
 4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/src/vrend_blitter.c b/src/vrend_blitter.c
index 68b5bab..2411e99 100644
--- a/src/vrend_blitter.c
+++ b/src/vrend_blitter.c
@@ -393,7 +393,7 @@ static GLuint blit_get_frag_tex_col(struct vrend_blitter_ctx *blit_ctx,
 {
    assert(pipe_tex_target < PIPE_MAX_TEXTURE_TYPES);
 
-   bool needs_swizzle = dst_entry->flags & VREND_BIND_NEED_SWIZZLE;
+   bool needs_swizzle = dst_entry->flags & VIRGL_BIND_NEED_SWIZZLE;
 
    if (needs_swizzle || nr_samples > 1) {
       const uint8_t *swizzle = needs_swizzle ? dst_entry->swizzle : NULL;
@@ -776,7 +776,7 @@ void vrend_renderer_blit_gl(UNUSED struct vrend_context *ctx,
 
    glBindTexture(src_res->target, src_res->id);
 
-   if (src_entry->flags & VREND_BIND_NEED_SWIZZLE) {
+   if (src_entry->flags & VIRGL_BIND_NEED_SWIZZLE) {
       glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_R,
                       to_gl_swizzle(src_entry->swizzle[0]));
       glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_G,
diff --git a/src/vrend_formats.c b/src/vrend_formats.c
index 82a1b5c..00ec5d2 100644
--- a/src/vrend_formats.c
+++ b/src/vrend_formats.c
@@ -313,7 +313,7 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
     if (status == GL_INVALID_VALUE || status == GL_INVALID_ENUM) {
       struct vrend_format_table *entry = NULL;
       uint8_t swizzle[4];
-      binding = VREND_BIND_SAMPLER | VREND_BIND_RENDER | VREND_BIND_NEED_SWIZZLE;
+      binding = VIRGL_BIND_SAMPLER_VIEW | VIRGL_BIND_RENDER_TARGET | VIRGL_BIND_NEED_SWIZZLE;
 
       switch (table[i].format) {
       case PIPE_FORMAT_A8_UNORM:
@@ -359,9 +359,9 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
     }
 
     status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
-    binding = VREND_BIND_SAMPLER;
+    binding = VIRGL_BIND_SAMPLER_VIEW;
     if (status == GL_FRAMEBUFFER_COMPLETE)
-      binding |= (is_depth ? VREND_BIND_DEPTHSTENCIL : VREND_BIND_RENDER);
+      binding |= (is_depth ? VIRGL_BIND_DEPTH_STENCIL : VIRGL_BIND_RENDER_TARGET);
 
     glDeleteTextures(1, &tex_id);
     glDeleteFramebuffers(1, &fb_id);
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 3eab13f..2c801c1 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -434,16 +434,16 @@ static struct vrend_format_table tex_conv_table[VIRGL_FORMAT_MAX];
 
 static inline bool vrend_format_can_sample(enum virgl_formats format)
 {
-   return tex_conv_table[format].bindings & VREND_BIND_SAMPLER;
+   return tex_conv_table[format].bindings & VIRGL_BIND_SAMPLER_VIEW;
 }
 static inline bool vrend_format_can_render(enum virgl_formats format)
 {
-   return tex_conv_table[format].bindings & VREND_BIND_RENDER;
+   return tex_conv_table[format].bindings & VIRGL_BIND_RENDER_TARGET;
 }
 
 static inline bool vrend_format_is_ds(enum virgl_formats format)
 {
-   return tex_conv_table[format].bindings & VREND_BIND_DEPTHSTENCIL;
+   return tex_conv_table[format].bindings & VIRGL_BIND_DEPTH_STENCIL;
 }
 
 bool vrend_is_ds_format(enum virgl_formats format)
@@ -461,7 +461,7 @@ bool vrend_format_is_emulated_alpha(enum virgl_formats format)
 
 static bool vrend_format_needs_swizzle(enum virgl_formats format)
 {
-   return tex_conv_table[format].flags & VREND_BIND_NEED_SWIZZLE;
+   return tex_conv_table[format].flags & VIRGL_BIND_NEED_SWIZZLE;
 }
 
 static inline const char *pipe_shader_to_prefix(int shader_type)
@@ -676,7 +676,7 @@ vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entr
    int i;
    tex_conv_table[override_format] = *entry;
    tex_conv_table[override_format].bindings = bindings;
-   tex_conv_table[override_format].flags = VREND_BIND_NEED_SWIZZLE;
+   tex_conv_table[override_format].flags = VIRGL_BIND_NEED_SWIZZLE;
    for (i = 0; i < 4; i++)
       tex_conv_table[override_format].swizzle[i] = swizzle[i];
 }
@@ -1524,7 +1524,7 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
           swizzle[3] = PIPE_SWIZZLE_ONE;
    }
 
-   if (tex_conv_table[view->format].flags & VREND_BIND_NEED_SWIZZLE) {
+   if (tex_conv_table[view->format].flags & VIRGL_BIND_NEED_SWIZZLE) {
       if (swizzle[0] <= PIPE_SWIZZLE_ALPHA)
          swizzle[0] = tex_conv_table[view->format].swizzle[swizzle[0]];
       if (swizzle[1] <= PIPE_SWIZZLE_ALPHA)
diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h
index 84933a0..43a0909 100644
--- a/src/vrend_renderer.h
+++ b/src/vrend_renderer.h
@@ -70,12 +70,7 @@ struct vrend_resource {
    uint64_t mipmap_offsets[VR_MAX_TEXTURE_2D_LEVELS];
 };
 
-/* assume every format is sampler friendly */
-#define VREND_BIND_SAMPLER (1 << 0)
-#define VREND_BIND_RENDER (1 << 1)
-#define VREND_BIND_DEPTHSTENCIL (1 << 2)
-
-#define VREND_BIND_NEED_SWIZZLE (1 << 28)
+#define VIRGL_BIND_NEED_SWIZZLE (1 << 28)
 
 struct vrend_format_table {
    enum virgl_formats format;
-- 
2.18.0.rc2



More information about the virglrenderer-devel mailing list