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

Erik Faye-Lund erik.faye-lund at collabora.com
Tue Jul 24 08:54:47 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 0254bf7..338577d 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 8f92903..4647c43 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 794cfe0..81348c3 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -466,16 +466,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)
@@ -493,7 +493,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)
@@ -708,7 +708,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];
 }
@@ -1579,7 +1579,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 43f991a..e49486c 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



More information about the virglrenderer-devel mailing list