On 24 October 2011 14:17, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net">eric@anholt.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
These produce BRW_NEW_SURFACES (used by binding table emit()) and<br>
BRW_NEW_NR_WM_SURFACES (used by WM unit emit()). Fixes a bug where<br>
with no texturing and no color buffer, we wouldn't consider the null<br>
renderbuffer in nr_surfaces. This was harmless because nr_surfaces is<br>
only used for the prefetch info in the unit state.<br>
---<br>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 54 +++++++--------------<br>
1 files changed, 18 insertions(+), 36 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
index bb7fd2e..782efd5 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
@@ -541,47 +541,16 @@ brw_update_renderbuffer_surface(struct brw_context *brw,<br>
I915_GEM_DOMAIN_RENDER);<br>
}<br>
<br>
-static void<br>
-prepare_wm_surfaces(struct brw_context *brw)<br>
-{<br>
- struct gl_context *ctx = &brw->intel.ctx;<br>
- int i;<br>
- int nr_surfaces = 0;<br>
-<br>
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {<br>
- nr_surfaces = SURF_INDEX_DRAW(i) + 1;<br>
- }<br>
-<br>
- if (brw->wm.const_bo) {<br>
- nr_surfaces = SURF_INDEX_FRAG_CONST_BUFFER + 1;<br>
- }<br>
-<br>
- for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {<br>
- const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];<br>
-<br>
- if (texUnit->_ReallyEnabled) {<br>
- nr_surfaces = SURF_INDEX_TEXTURE(i) + 1;<br>
- }<br>
- }<br>
-<br>
- /* Have to update this in our prepare, since the unit's prepare<br>
- * relies on it.<br>
- */<br>
- if (brw->wm.nr_surfaces != nr_surfaces) {<br>
- brw->wm.nr_surfaces = nr_surfaces;<br>
- brw->state.dirty.brw |= BRW_NEW_NR_WM_SURFACES;<br>
- }<br>
-}<br>
-<br>
/**<br>
* Constructs the set of surface state objects pointed to by the<br>
* binding table.<br>
*/<br>
static void<br>
-upload_wm_surfaces(struct brw_context *brw)<br>
+brw_upload_wm_surfaces(struct brw_context *brw)<br>
{<br>
struct gl_context *ctx = &brw->intel.ctx;<br>
GLuint i;<br>
+ int nr_surfaces = 0;<br>
<br>
/* _NEW_BUFFERS | _NEW_COLOR */<br>
/* Update surfaces for drawing buffers */<br>
@@ -595,8 +564,15 @@ upload_wm_surfaces(struct brw_context *brw)<br>
brw_update_null_renderbuffer_surface(brw, i);<br>
}<br>
}<br>
+ nr_surfaces = SURF_INDEX_DRAW(ctx->DrawBuffer->_NumColorDrawBuffers);<br>
} else {<br>
brw_update_null_renderbuffer_surface(brw, 0);<br>
+ nr_surfaces = SURF_INDEX_DRAW(0) + 1;<br></blockquote><div><br>This looks like a behavioral change to me. The old prepare_wm_surfaces() code would have left nr_surfaces = 0 in this case. Was this an intentional change? Was the old code buggy?<br>
<br>I have similar questions about patch 15/33.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
+ }<br>
+<br>
+ /* BRW_NEW_WM_CONSTBUF */<br>
+ if (brw->wm.const_bo) {<br>
+ nr_surfaces = SURF_INDEX_FRAG_CONST_BUFFER + 1;<br>
}<br>
<br>
/* Update surfaces for textures */<br>
@@ -607,11 +583,17 @@ upload_wm_surfaces(struct brw_context *brw)<br>
/* _NEW_TEXTURE */<br>
if (texUnit->_ReallyEnabled) {<br>
brw_update_texture_surface(ctx, i);<br>
+ nr_surfaces = SURF_INDEX_TEXTURE(i) + 1;<br>
} else {<br>
brw->wm.surf_offset[surf] = 0;<br>
}<br>
}<br>
<br>
+ if (brw->wm.nr_surfaces != nr_surfaces) {<br>
+ brw->wm.nr_surfaces = nr_surfaces;<br>
+ brw->state.dirty.brw |= BRW_NEW_NR_WM_SURFACES;<br>
+ }<br>
+<br>
brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;<br>
}<br>
<br>
@@ -620,11 +602,11 @@ const struct brw_tracked_state brw_wm_surfaces = {<br>
.mesa = (_NEW_COLOR |<br>
_NEW_TEXTURE |<br>
_NEW_BUFFERS),<br>
- .brw = (BRW_NEW_BATCH),<br>
+ .brw = (BRW_NEW_BATCH |<br>
+ BRW_NEW_WM_CONSTBUF),<br>
.cache = 0<br>
},<br>
- .prepare = prepare_wm_surfaces,<br>
- .emit = upload_wm_surfaces,<br>
+ .emit = brw_upload_wm_surfaces,<br>
};<br>
<br>
/**<br>
<font color="#888888">--<br>
1.7.7<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br>