<div dir="ltr">On 17 May 2013 10:17, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</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">Hardware contexts are necessary to reasonably support OpenGL 3.2.<br>
In particular, we currently maintain software counters for transform<br>
feedback buffer offsets and counters, which relies on knowing the number<br>
of primitives generated. Geometry shaders violate that assumption.<br>
<br>
At the time of writing, Debian has moved to Kernel 3.8, which means most<br>
people probably have a newer kernel by now. It's also worth noting that<br>
this patch won't land until Mesa 10 which is currently targeted for<br>
September. By that point, even more people will have a newer kernel.<br>
<br>
This patch leaves the code for flagging BRW_NEW_CONTEXT on new<br>
batchbuffers if hw_ctx == NULL since that still occurs pre-Gen6.<br></blockquote><div><br></div><div>There's a slight change here that I'd like to see documented more clearly in the commit message:<br><br>Previously, Mesa would *try* to allocate a hardware context regardless of intel->gen. That would always fail for gen<6 (since the kernel doesn't support hardware contexts prior to gen6), and would sometimes fail and sometimes succeed on gen6+, depending on kernel version. Now, Mesa doesn't even try to allocate a hardware context if gen<6.<br>
<br></div><div>With that changed, this is:<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cc: Eric Anholt <<a href="mailto:eric@anholt.net">eric@anholt.net</a>><br>
Cc: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_context.c | 18 +++++++++++++++++-<br>
1 file changed, 17 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c<br>
index 69b7e4d..2f5fedb 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.c<br>
@@ -143,6 +143,23 @@ brwCreateContext(int api,<br>
return false;<br>
}<br>
<br>
+ if (intel->gen >= 6) {<br>
+ /* Create a new hardware context. Using a hardware context means that<br>
+ * our GPU state will be saved/restored on context switch, allowing us<br>
+ * to assume that the GPU is in the same state we left it in.<br>
+ *<br>
+ * This is required for transform feedback buffer offsets, query objects,<br>
+ * and also allows us to reduce how much state we have to emit.<br>
+ */<br>
+ intel->hw_ctx = drm_intel_gem_context_create(intel->bufmgr);<br>
+<br>
+ if (!intel->hw_ctx) {<br>
+ fprintf(stderr, "Gen6+ requires Kernel 3.6 or later.\n");<br>
+ ralloc_free(brw);<br>
+ return false;<br>
+ }<br>
+ }<br>
+<br>
brw_init_surface_formats(brw);<br>
<br>
/* Initialize swrast, tnl driver tables: */<br>
@@ -374,7 +391,6 @@ brwCreateContext(int api,<br>
<br>
brw->prim_restart.in_progress = false;<br>
brw->prim_restart.enable_cut_index = false;<br>
- intel->hw_ctx = drm_intel_gem_context_create(intel->bufmgr);<br>
<br>
brw_init_state( brw );<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.8.2.3<br>
<br>
</font></span></blockquote></div><br></div></div>