Mesa (master): i965: avoid shader translation on window resize

Brian Paul brianp at kemper.freedesktop.org
Thu Oct 29 21:48:02 UTC 2009


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

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Oct 29 15:29:41 2009 -0600

i965: avoid shader translation on window resize

If the fragment shader doesn't use FRAG_ATTRIB_WPOS (gl_FragCoord) we
don't need to worry about the window size and origin in
brw_wm_populate_key().

This avoids re-generating the i965 shader code when a window is resized.

Issue spotted by Keith Whitwell.

---

 src/mesa/drivers/dri/i965/brw_wm.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index eeb2598..964ee10 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -308,6 +308,9 @@ static void brw_wm_populate_key( struct brw_context *brw,
     * from the incoming screen origin relative position we get as part of our
     * payload.
     *
+    * This is only needed for the WM_WPOSXY opcode when the fragment program
+    * uses the gl_FragCoord input.
+    *
     * We could avoid recompiling by including this as a constant referenced by
     * our program, but if we were to do that it would also be nice to handle
     * getting that constant updated at batchbuffer submit time (when we
@@ -316,13 +319,15 @@ static void brw_wm_populate_key( struct brw_context *brw,
     * just avoid using this as key data if the program doesn't use
     * fragment.position.
     *
-    * This pretty much becomes moot with DRI2 and redirected buffers anyway,
-    * as our origins will always be zero then.
+    * For DRI2 the origin_x/y will always be (0,0) but we still need the
+    * drawable height in order to invert the Y axis.
     */
-   if (brw->intel.driDrawable != NULL) {
-      key->origin_x = brw->intel.driDrawable->x;
-      key->origin_y = brw->intel.driDrawable->y;
-      key->drawable_height = brw->intel.driDrawable->h;
+   if (fp->program.Base.InputsRead & FRAG_BIT_WPOS) {
+      if (brw->intel.driDrawable != NULL) {
+         key->origin_x = brw->intel.driDrawable->x;
+         key->origin_y = brw->intel.driDrawable->y;
+         key->drawable_height = brw->intel.driDrawable->h;
+      }
    }
 
    key->nr_color_regions = brw->state.nr_color_regions;




More information about the mesa-commit mailing list