svga: Don't unnecessarily reemit BindGBShader commands v2
authorThomas Hellstrom <thellstrom@vmware.com>
Fri, 13 Jun 2014 07:46:54 +0000 (09:46 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 3 Jul 2014 20:26:00 +0000 (22:26 +0200)
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@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
src/gallium/drivers/svga/svga_shader.c
src/gallium/drivers/svga/svga_state_fs.c
src/gallium/drivers/svga/svga_state_vs.c

index 6b6b441cb828e37ec06321146ff61bdc0918e1fc..46efa07df2db11cf7eea4b4950a4326f9494138d 100644 (file)
@@ -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;
index 8f419fa69ac8a320b3b979fe525a558113b6cbd8..e714c078405b59a5a58b02fe603fa18c9c33b634 100644 (file)
@@ -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)
index 125903b386acf6e15006ceda066c2a3260599f2e..545c9d7420fa897f55bc73f5014b37d86251b80d 100644 (file)
@@ -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;