Hi,<br><br>Sorry that I am asking this but if a patch appears to be ignored on ML, should I push it to master anyway or should I ping you?<br><br>The reason I&#39;d like to add this CAP is to leverage what has already been implemented in GLSL2.<br>


<br>Ideally I&#39;d like to use GLSL2 IR in gallium drivers directly without messing with TGSI that has no compiler infrastructure, but I can&#39;t. TGSI takes so much away (e.g. the ability to use GLSL2 lowering passes and generate code directly from that IR) and gives nothing in return. GLSL doesn&#39;t have to be just a shading language in OpenGL, it can even be a very good, API-agnostic high-level language, something that Gallium lacks. And the GLSL2 compiler is self-contained anyway, so I don&#39;t see why Gallium drivers couldn&#39;t use it. Just some thoughts FWIW.<br>


<br>Best regards,<br>Marek<br><br><div class="gmail_quote">On Sun, Nov 14, 2010 at 3:48 PM, Marek Olšák <span dir="ltr">&lt;<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


This fixes piglit/glsl-vs-main-return for the drivers which don&#39;t<br>
support RET (i915g, r300g, r600g, svga).<br>
<br>
ir_to_mesa does not currently generate subroutines, but it&#39;s a matter of time<br>
till it&#39;s added. It would then break all the drivers which don&#39;t implement<br>
them, so this CAP makes sense.<br>
<br>
Signed-off-by: Marek Olšák &lt;<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>&gt;<br>
---<br>
 src/gallium/auxiliary/tgsi/tgsi_exec.h |    2 ++<br>
 src/gallium/drivers/i915/i915_screen.c |    2 ++<br>
 src/gallium/drivers/i965/brw_screen.c  |    2 ++<br>
 src/gallium/drivers/nv50/nv50_screen.c |    2 ++<br>
 src/gallium/drivers/nvfx/nvfx_screen.c |    4 ++++<br>
 src/gallium/drivers/r300/r300_screen.c |    4 ++++<br>
 src/gallium/drivers/r600/r600_pipe.c   |    2 ++<br>
 src/gallium/drivers/svga/svga_screen.c |    4 ++++<br>
 src/gallium/include/pipe/p_defines.h   |    1 +<br>
 src/mesa/state_tracker/st_extensions.c |    4 ++--<br>
 10 files changed, 25 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h<br>
index 7b07778..b5ebbfb 100644<br>
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h<br>
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h<br>
@@ -388,6 +388,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)<br>
    case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
    case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
       return 1;<br>
+   case PIPE_SHADER_CAP_SUBROUTINES:<br>
+      return 1;<br>
    default:<br>
       return 0;<br>
    }<br>
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c<br>
index 312847f..b9e5fc3 100644<br>
--- a/src/gallium/drivers/i915/i915_screen.c<br>
+++ b/src/gallium/drivers/i915/i915_screen.c<br>
@@ -183,6 +183,8 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha<br>
       case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
       case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
          return 1;<br>
+      case PIPE_SHADER_CAP_SUBROUTINES:<br>
+         return 0;<br>
       default:<br>
          assert(0);<br>
          return 0;<br>
diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c<br>
index 57160eb..29486f5 100644<br>
--- a/src/gallium/drivers/i965/brw_screen.c<br>
+++ b/src/gallium/drivers/i965/brw_screen.c<br>
@@ -240,6 +240,8 @@ brw_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_shad<br>
       case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
       case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
           return 1;<br>
+      case PIPE_SHADER_CAP_SUBROUTINES:<br>
+          return 1;<br>
       default:<br>
          assert(0);<br>
          return 0;<br>
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c<br>
index 51eab3a..49522b7 100644<br>
--- a/src/gallium/drivers/nv50/nv50_screen.c<br>
+++ b/src/gallium/drivers/nv50/nv50_screen.c<br>
@@ -176,6 +176,8 @@ nv50_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,<br>
        case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
        case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
                return 1;<br>
+       case PIPE_SHADER_CAP_SUBROUTINES:<br>
+               return 0;<br>
        default:<br>
                return 0;<br>
        }<br>
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c<br>
index 8bf0907..33ed654 100644<br>
--- a/src/gallium/drivers/nvfx/nvfx_screen.c<br>
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c<br>
@@ -123,6 +123,8 @@ nvfx_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, enum<br>
                case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
                case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
                        return 0;<br>
+               case PIPE_SHADER_CAP_SUBROUTINES:<br>
+                       return screen-&gt;use_nv4x ? 1 : 0;<br>
                default:<br>
                        break;<br>
                }<br>
@@ -161,6 +163,8 @@ nvfx_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, enum<br>
                        return 0;<br>
                case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
                        return 1;<br>
+               case PIPE_SHADER_CAP_SUBROUTINES:<br>
+                       return 1;<br>
                default:<br>
                        break;<br>
                }<br>
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c<br>
index 37563b5..b4b112e 100644<br>
--- a/src/gallium/drivers/r300/r300_screen.c<br>
+++ b/src/gallium/drivers/r300/r300_screen.c<br>
@@ -212,6 +212,8 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e<br>
         case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
         case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
             return 0;<br>
+        case PIPE_SHADER_CAP_SUBROUTINES:<br>
+            return 0;<br>
         }<br>
         break;<br>
     case PIPE_SHADER_VERTEX:<br>
@@ -245,6 +247,8 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e<br>
             return 0;<br>
         case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
             return 1;<br>
+        case PIPE_SHADER_CAP_SUBROUTINES:<br>
+            return 0;<br>
         default:<br>
             break;<br>
         }<br>
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c<br>
index 2a113f0..f46fac0 100644<br>
--- a/src/gallium/drivers/r600/r600_pipe.c<br>
+++ b/src/gallium/drivers/r600/r600_pipe.c<br>
@@ -375,6 +375,8 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e<br>
        case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
        case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
                return 1;<br>
+       case PIPE_SHADER_CAP_SUBROUTINES:<br>
+               return 0;<br>
        default:<br>
                return 0;<br>
        }<br>
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c<br>
index af99c41..666b498 100644<br>
--- a/src/gallium/drivers/svga/svga_screen.c<br>
+++ b/src/gallium/drivers/svga/svga_screen.c<br>
@@ -237,6 +237,8 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en<br>
       case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
       case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
          return 0;<br>
+      case PIPE_SHADER_CAP_SUBROUTINES:<br>
+         return 0;<br>
       }<br>
       break;<br>
    case PIPE_SHADER_VERTEX:<br>
@@ -276,6 +278,8 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en<br>
          return 0;<br>
       case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
          return 1;<br>
+      case PIPE_SHADER_CAP_SUBROUTINES:<br>
+         return 0;<br>
       default:<br>
          break;<br>
       }<br>
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h<br>
index 6cca301..dacabed 100644<br>
--- a/src/gallium/include/pipe/p_defines.h<br>
+++ b/src/gallium/include/pipe/p_defines.h<br>
@@ -489,6 +489,7 @@ enum pipe_shader_cap<br>
    PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR,<br>
    PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR,<br>
    PIPE_SHADER_CAP_INDIRECT_CONST_ADDR,<br>
+   PIPE_SHADER_CAP_SUBROUTINES, /* BGNSUB, ENDSUB, CAL, RET */<br>
 };<br>
<br>
 /**<br>
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c<br>
index 1327491..d4f0df8 100644<br>
--- a/src/mesa/state_tracker/st_extensions.c<br>
+++ b/src/mesa/state_tracker/st_extensions.c<br>
@@ -169,9 +169,9 @@ void st_init_limits(struct st_context *st)<br>
<br>
       /* TODO: make these more fine-grained if anyone needs it */<br>
       options-&gt;EmitNoIfs = !screen-&gt;get_shader_param(screen, i, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);<br>
-      options-&gt;EmitNoFunctions = !screen-&gt;get_shader_param(screen, i, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);<br>
       options-&gt;EmitNoLoops = !screen-&gt;get_shader_param(screen, i, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);<br>
-      options-&gt;EmitNoMainReturn = !screen-&gt;get_shader_param(screen, i, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);<br>
+      options-&gt;EmitNoFunctions = !screen-&gt;get_shader_param(screen, i, PIPE_SHADER_CAP_SUBROUTINES);<br>
+      options-&gt;EmitNoMainReturn = !screen-&gt;get_shader_param(screen, i, PIPE_SHADER_CAP_SUBROUTINES);<br>
<br>
       options-&gt;EmitNoCont = !screen-&gt;get_shader_param(screen, i, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED);<br>
<font color="#888888"><br>
--<br>
1.7.0.4<br>
<br>
</font></blockquote></div><br>