[Mesa-dev] [PATCH] Add virgl cap for invariant attrib in tgsi

Joe M. Kniss djmk at chromium.org
Mon Apr 9 22:01:20 UTC 2018


While some support for invariant shader attribute exisits in
tgsi, it was never fully implemented.  This patch adds a virgl
cap for this feature in advance of the tgsi invariant implementation
to insure backward compatibility.  Current virglrenderer tgsi
deserialization will error if invariant apprears in tgsi text stream.

Signed-off-by: Joe M. Kniss <djmk at google.com>
---
 src/gallium/drivers/virgl/virgl_hw.h     | 1 +
 src/gallium/drivers/virgl/virgl_tgsi.c   | 5 +++++
 src/gallium/drivers/virgl/virgl_winsys.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/src/gallium/drivers/virgl/virgl_hw.h b/src/gallium/drivers/virgl/virgl_hw.h
index 93849c03dd..aaa4704b2a 100644
--- a/src/gallium/drivers/virgl/virgl_hw.h
+++ b/src/gallium/drivers/virgl/virgl_hw.h
@@ -286,6 +286,7 @@ struct virgl_caps_v2 {
         int32_t max_texture_gather_offset;
         uint32_t texture_buffer_offset_alignment;
         uint32_t uniform_buffer_offset_alignment;
+        uint32_t tgsi_invariant;
 };
 
 union virgl_caps {
diff --git a/src/gallium/drivers/virgl/virgl_tgsi.c b/src/gallium/drivers/virgl/virgl_tgsi.c
index ff5abf6ddb..b0f9a73850 100644
--- a/src/gallium/drivers/virgl/virgl_tgsi.c
+++ b/src/gallium/drivers/virgl/virgl_tgsi.c
@@ -31,12 +31,14 @@
 struct virgl_transform_context {
    struct tgsi_transform_context base;
    bool cull_enabled;
+   bool invariant_enabled;
 };
 
 static void
 virgl_tgsi_transform_declaration(struct tgsi_transform_context *ctx,
                                  struct tgsi_full_declaration *decl)
 {
+   struct virgl_transform_context *vtctx = (struct virgl_transform_context *)ctx;
    switch (decl->Declaration.File) {
    case TGSI_FILE_CONSTANT:
       if (decl->Declaration.Dimension) {
@@ -47,6 +49,8 @@ virgl_tgsi_transform_declaration(struct tgsi_transform_context *ctx,
    default:
       break;
    }
+   if (!vtctx->invariant_enabled)
+      decl->Declaration.Invariant = 0;
    ctx->emit_declaration(ctx, decl);
 
 }
@@ -104,6 +108,7 @@ struct tgsi_token *virgl_tgsi_transform(struct virgl_context *vctx, const struct
    transform.base.transform_property = virgl_tgsi_transform_property;
    transform.base.transform_instruction = virgl_tgsi_transform_instruction;
    transform.cull_enabled = vscreen->caps.caps.v1.bset.has_cull;
+   transform.invariant_enabled = vscreen->caps.caps.v2.tgsi_invariant;
    tgsi_transform_shader(tokens_in, new_tokens, newLen, &transform.base);
 
    return new_tokens;
diff --git a/src/gallium/drivers/virgl/virgl_winsys.h b/src/gallium/drivers/virgl/virgl_winsys.h
index 99e98ad9c9..6ca2641e7a 100644
--- a/src/gallium/drivers/virgl/virgl_winsys.h
+++ b/src/gallium/drivers/virgl/virgl_winsys.h
@@ -134,5 +134,6 @@ static inline void virgl_ws_fill_new_caps_defaults(struct virgl_drm_caps *caps)
    caps->caps.v2.max_texture_gather_offset = 7;
    caps->caps.v2.texture_buffer_offset_alignment = 32;
    caps->caps.v2.uniform_buffer_offset_alignment = 256;
+   caps->caps.v2.tgsi_invariant = 0;
 }
 #endif
-- 
2.17.0.484.g0c8726318c-goog



More information about the mesa-dev mailing list