[Mesa-dev] [PATCH] svga: Don't unnecessarily reemit BindGBShader commands v2

Thomas Hellstrom thellstrom at vmware.com
Thu Jul 3 13:19:08 PDT 2014


The Linux winsys can no longer relocate shader code, so avoid
reemitting BindGBShader commands. They are costly.

v2: Correctly handle errors from SVGA3D_BindGBShader()

Reported-by: Michael Banack <banackm at vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
Tested-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob at vmware.com>
---
 src/gallium/drivers/svga/svga_shader.c   |  9 ++++++++-
 src/gallium/drivers/svga/svga_state_fs.c |  8 --------
 src/gallium/drivers/svga/svga_state_vs.c | 11 -----------
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c
index 6b6b441..46efa07 100644
--- a/src/gallium/drivers/svga/svga_shader.c
+++ b/src/gallium/drivers/svga/svga_shader.c
@@ -45,13 +45,20 @@ svga_define_shader(struct svga_context *svga,
 
    if (svga_have_gb_objects(svga)) {
       struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws;
+      enum pipe_error ret;
 
       variant->gb_shader = sws->shader_create(sws, type,
                                               variant->tokens, codeLen);
       if (!variant->gb_shader)
          return PIPE_ERROR_OUT_OF_MEMORY;
 
-      return PIPE_OK;
+      ret = SVGA3D_BindGBShader(svga->swc, variant->gb_shader);
+      if (ret != PIPE_OK) {
+         sws->shader_destroy(sws, variant->gb_shader);
+         variant->gb_shader = NULL;
+      }
+
+      return ret;
    }
    else {
       enum pipe_error ret;
diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c
index 8f419fa..e714c07 100644
--- a/src/gallium/drivers/svga/svga_state_fs.c
+++ b/src/gallium/drivers/svga/svga_state_fs.c
@@ -402,14 +402,6 @@ emit_hw_fs(struct svga_context *svga, unsigned dirty)
 
    if (variant != svga->state.hw_draw.fs) {
       if (svga_have_gb_objects(svga)) {
-         /*
-          * Bind is necessary here only because pipebuffer_fenced may move
-          * the shader contents around....
-          */
-         ret = SVGA3D_BindGBShader(svga->swc, variant->gb_shader);
-         if (ret != PIPE_OK)
-            return ret;
-
          ret = SVGA3D_SetGBShader(svga->swc, SVGA3D_SHADERTYPE_PS,
                                   variant->gb_shader);
          if (ret != PIPE_OK)
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
index 125903b..545c9d7 100644
--- a/src/gallium/drivers/svga/svga_state_vs.c
+++ b/src/gallium/drivers/svga/svga_state_vs.c
@@ -243,17 +243,6 @@ emit_hw_vs(struct svga_context *svga, unsigned dirty)
       if (svga_have_gb_objects(svga)) {
          struct svga_winsys_gb_shader *gbshader =
             variant ? variant->gb_shader : NULL;
-
-         /*
-          * Bind is necessary here only because pipebuffer_fenced may move
-          * the shader contents around....
-          */
-         if (gbshader) {
-            ret = SVGA3D_BindGBShader(svga->swc, gbshader);
-            if (ret != PIPE_OK)
-               return ret;
-         }
-
          ret = SVGA3D_SetGBShader(svga->swc, SVGA3D_SHADERTYPE_VS, gbshader);
          if (ret != PIPE_OK)
             return ret;
-- 
1.8.3.2


More information about the mesa-dev mailing list