<div dir="ltr">On 2 December 2013 11:39, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 src/mesa/drivers/dri/i965/brw_context.h          |  2 +<br>
 src/mesa/drivers/dri/i965/brw_gs_surface_state.c | 24 ++++++++++++<br>
 src/mesa/drivers/dri/i965/brw_state.h            |  3 ++<br>
 src/mesa/drivers/dri/i965/brw_state_upload.c     |  6 +++<br>
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 24 ++++++++++++<br>
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 50 ++++++++++++++++++++++++<br>
 6 files changed, 109 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
index dc606c0f..4586005 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -181,6 +181,7 @@ enum brw_state_id {<br>
    BRW_STATE_STATS_WM,<br>
    BRW_STATE_UNIFORM_BUFFER,<br>
    BRW_STATE_ATOMIC_BUFFER,<br>
+   BRW_STATE_IMAGE_UNITS,<br>
    BRW_STATE_META_IN_PROGRESS,<br>
    BRW_STATE_INTERPOLATION_MAP,<br>
    BRW_STATE_PUSH_CONSTANT_ALLOCATION,<br>
@@ -220,6 +221,7 @@ enum brw_state_id {<br>
 #define BRW_NEW_STATS_WM               (1 << BRW_STATE_STATS_WM)<br>
 #define BRW_NEW_UNIFORM_BUFFER          (1 << BRW_STATE_UNIFORM_BUFFER)<br>
 #define BRW_NEW_ATOMIC_BUFFER           (1 << BRW_STATE_ATOMIC_BUFFER)<br>
+#define BRW_NEW_IMAGE_UNITS             (1 << BRW_STATE_IMAGE_UNITS)<br>
 #define BRW_NEW_META_IN_PROGRESS        (1 << BRW_STATE_META_IN_PROGRESS)<br>
 #define BRW_NEW_INTERPOLATION_MAP       (1 << BRW_STATE_INTERPOLATION_MAP)<br>
 #define BRW_NEW_PUSH_CONSTANT_ALLOCATION (1 << BRW_STATE_PUSH_CONSTANT_ALLOCATION)<br>
diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c<br>
index 5661941..6db061d 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c<br>
@@ -110,3 +110,27 @@ const struct brw_tracked_state brw_gs_abo_surfaces = {<br>
    },<br>
    .emit = brw_upload_gs_abo_surfaces,<br>
 };<br>
+<br>
+static void<br>
+brw_upload_gs_image_surfaces(struct brw_context *brw)<br>
+{<br>
+   struct gl_context *ctx = &brw->ctx;<br>
+   /* _NEW_PROGRAM */<br>
+   struct gl_shader_program *prog = ctx->Shader.CurrentGeometryProgram;<br></blockquote><div><br></div><div>Since you only need the geometry program here, you can depend on BRW_NEW_GEOMETRY_PROGRAM instead of _NEW_PROGRAM, and avoid this function getting called unnecessarily when the geometry shader doesn't change (e.g. when switching between two programs that don't contain a geometry shader).<br>
<br></div><div>A similar improvement cound be made in the vs and fs cases, but the benefit is less (since nearly all programs contain a vertex and a fragment shader).<br><br></div><div>It's not a huge deal, though.  Either way, the patch is:<br>
<br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div></div></div></div>