Mesa (master): swrast: Use fixed-function processing instead _TexEnvProgram for DrawPixels

Ian Romanick idr at kemper.freedesktop.org
Tue Jan 24 20:35:17 UTC 2012


Module: Mesa
Branch: master
Commit: 9be3be3c6654da18466626c2d45ff4d06b5fb953
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9be3be3c6654da18466626c2d45ff4d06b5fb953

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Jan 19 17:29:37 2012 -0800

swrast: Use fixed-function processing instead _TexEnvProgram for DrawPixels

This is a hack to work around drivers such as i965 that:

    - Set _MaintainTexEnvProgram to generate GLSL IR for
      fixed-function fragment processing.
    - Don't call _mesa_ir_link_shader to generate Mesa IR from the
      GLSL IR.
    - May use swrast to handle glDrawPixels.

Since _mesa_ir_link_shader is never called, there is no Mesa IR to
execute.  Instead do regular fixed-function processing.

Even on platforms that don't need this, the software fixed-function
code is much faster than the software shader code.

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44749

---

 src/mesa/swrast/s_span.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index e899303..8d9f10d 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -50,6 +50,7 @@
 #include "s_stencil.h"
 #include "s_texcombine.h"
 
+#include <stdbool.h>
 
 /**
  * Set default fragment attributes for the span using the
@@ -968,7 +969,25 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output)
 static inline void
 shade_texture_span(struct gl_context *ctx, SWspan *span)
 {
-   if (ctx->FragmentProgram._Current ||
+   /* This is a hack to work around drivers such as i965 that:
+    *
+    *     - Set _MaintainTexEnvProgram to generate GLSL IR for
+    *       fixed-function fragment processing.
+    *     - Don't call _mesa_ir_link_shader to generate Mesa IR from
+    *       the GLSL IR.
+    *     - May use swrast to handle glDrawPixels.
+    *
+    * Since _mesa_ir_link_shader is never called, there is no Mesa IR
+    * to execute.  Instead do regular fixed-function processing.
+    *
+    * It is also worth noting that the software fixed-function path is
+    * much faster than the software shader path.
+    */
+   const bool use_fragment_program =
+      ctx->FragmentProgram._Current
+      && ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram;
+
+   if (use_fragment_program ||
        ctx->ATIFragmentShader._Enabled) {
       /* programmable shading */
       if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
@@ -997,7 +1016,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span)
          interpolate_wpos(ctx, span);
 
       /* Run fragment program/shader now */
-      if (ctx->FragmentProgram._Current) {
+      if (use_fragment_program) {
          _swrast_exec_fragment_program(ctx, span);
       }
       else {




More information about the mesa-commit mailing list