<div dir="ltr">On 22 August 2013 13:58, 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"><div class="HOEnZb"><div class="h5">On 08/20/2013 11:30 AM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Eric Anholt <<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>><br>
<br>
All but two of the piglit GLSL 1.50/uniform_buffer tests work, and<br>
maxuniformblocksize and referenced-by-shader work.<br>
<br>
v2 (Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>>): Account for Ken's recent<br>
binding table re-work. Use brw->vec4_gs.bind_bo_offset instead of<br>
brw->gs.bind_bo_offset.<br>
---<br>
src/mesa/drivers/dri/i965/<u></u>Makefile.sources | 1 +<br>
src/mesa/drivers/dri/i965/brw_<u></u>context.h | 17 ++-<br>
src/mesa/drivers/dri/i965/brw_<u></u>gs_emit.c | 2 +-<br>
src/mesa/drivers/dri/i965/brw_<u></u>gs_surface_state.c | 182 +++++++++++++++++++++++<br>
src/mesa/drivers/dri/i965/brw_<u></u>state.h | 3 +<br>
src/mesa/drivers/dri/i965/brw_<u></u>state_upload.c | 3 +<br>
src/mesa/drivers/dri/i965/<u></u>gen6_sol.c | 6 +-<br>
7 files changed, 208 insertions(+), 6 deletions(-)<br>
create mode 100644 src/mesa/drivers/dri/i965/brw_<u></u>gs_surface_state.c<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>Makefile.sources b/src/mesa/drivers/dri/i965/<u></u>Makefile.sources<br>
index 290cd93..81a16ff 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>Makefile.sources<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>Makefile.sources<br>
@@ -63,6 +63,7 @@ i965_FILES = \<br>
brw_gs.c \<br>
brw_gs_emit.c \<br>
brw_gs_state.c \<br>
+ brw_gs_surface_state.c \<br>
brw_interpolation_map.c \<br>
brw_lower_texture_gradients.<u></u>cpp \<br>
brw_misc_state.c \<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_context.h b/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
index 4f6c767..a6d0786 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
@@ -148,6 +148,7 @@ enum brw_state_id {<br>
BRW_STATE_BATCH,<br>
BRW_STATE_INDEX_BUFFER,<br>
BRW_STATE_VS_CONSTBUF,<br>
+ BRW_STATE_GS_CONSTBUF,<br>
BRW_STATE_PROGRAM_CACHE,<br>
BRW_STATE_STATE_BASE_ADDRESS,<br>
BRW_STATE_VUE_MAP_VS,<br>
@@ -184,6 +185,7 @@ enum brw_state_id {<br>
/** \see brw.state.depth_region */<br>
#define BRW_NEW_INDEX_BUFFER (1 << BRW_STATE_INDEX_BUFFER)<br>
#define BRW_NEW_VS_CONSTBUF (1 << BRW_STATE_VS_CONSTBUF)<br>
+#define BRW_NEW_GS_CONSTBUF (1 << BRW_STATE_GS_CONSTBUF)<br>
#define BRW_NEW_PROGRAM_CACHE (1 << BRW_STATE_PROGRAM_CACHE)<br>
#define BRW_NEW_STATE_BASE_ADDRESS (1 << BRW_STATE_STATE_BASE_ADDRESS)<br>
#define BRW_NEW_VUE_MAP_VS (1 << BRW_STATE_VUE_MAP_VS)<br>
@@ -654,8 +656,19 @@ struct brw_vec4_gs_prog_data<br>
#define SURF_INDEX_VS_SHADER_TIME (SURF_INDEX_VS_UBO(12))<br>
#define BRW_MAX_VS_SURFACES (SURF_INDEX_VS_SHADER_TIME + 1)<br>
<br>
-#define SURF_INDEX_SOL_BINDING(t) ((t))<br>
-#define BRW_MAX_GS_SURFACES SURF_INDEX_SOL_BINDING(BRW_<u></u>MAX_SOL_BINDINGS)<br>
+#define SURF_INDEX_GEN6_SOL_BINDING(t) (t)<br>
+#define BRW_MAX_GEN6_GS_SURFACES SURF_INDEX_GEN6_SOL_BINDING(<u></u>BRW_MAX_SOL_BINDINGS)<br>
</blockquote>
<br></div></div>
It's not a big deal, but it would be nice to do the SURF_INDEX_SOL_BINDING renames in a separate patch.</blockquote><div><br></div><div>Good point.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+#define SURF_INDEX_GS_GEN6_SOL_BUFFER 0<br>
+#define SURF_INDEX_GS_CONST_BUFFER (SURF_INDEX_GS_GEN6_SOL_<u></u>BUFFER)<br>
+<br>
+#define SURF_INDEX_GS_TEXTURE(t) (SURF_INDEX_GS_CONST_BUFFER + 1 + (t))<br>
+#define SURF_INDEX_GS_UBO(u) (SURF_INDEX_GS_TEXTURE(BRW_<u></u>MAX_TEX_UNIT) + u)<br>
+#define SURF_INDEX_GS_SHADER_TIME (SURF_INDEX_GS_UBO(12))<br>
+#define BRW_MAX_GEN7_GS_SURFACES (SURF_INDEX_GS_SHADER_TIME + 1)<br>
+<br>
+#define BRW_MAX_GS_SURFACES MAX2(BRW_MAX_GEN6_GS_SURFACES, \<br>
+ BRW_MAX_GEN7_GS_SURFACES)<br>
<br>
/**<br>
* Stride in bytes between shader_time entries.<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c b/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c<br>
index fff3585..f576a81 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c<br>
@@ -432,7 +432,7 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key,<br>
final_write ? c->reg.temp : brw_null_reg(), /* dest */<br>
1, /* msg_reg_nr */<br>
c->reg.header, /* src0 */<br>
- SURF_INDEX_SOL_BINDING(<u></u>binding), /* binding_table_index */<br>
+ SURF_INDEX_GEN6_SOL_BINDING(<u></u>binding), /* binding_table_index */<br>
final_write); /* send_commit_msg */<br>
}<br>
}<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/<u></u>brw_gs_surface_state.c<br>
new file mode 100644<br>
index 0000000..ed99d65<br>
--- /dev/null<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_gs_surface_state.c<br>
@@ -0,0 +1,182 @@<br>
+/*<br>
+ * Copyright © 2013 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include "main/mtypes.h"<br>
+#include "program/prog_parameter.h"<br>
+<br>
+#include "brw_context.h"<br>
+#include "brw_state.h"<br>
+<br>
+/* Creates a new GS constant buffer reflecting the current GS program's<br>
+ * constants, if needed by the GS program.<br>
+ *<br>
+ * Otherwise, constants go through the CURBEs using the brw_constant_buffer<br>
+ * state atom.<br>
+ */<br>
</blockquote>
<br></div></div>
This is a lot of code duplication, and I'd really like to avoid that. (Avoiding it should help even more when we add tesselation shaders.)<br>
<br>
Paul and I had talked briefly about creating a new structure type to hold some of the fields that are common between vs, gs, and wm:<br>
<br>
- scratch_bo<br>
- const_bo<br>
- prog_offset<br>
- state_offset<br>
- push_const_offset<br>
- push_const_size<br>
- bind_bo_offset<br>
- surf_offset<br>
(the size varies slightly, but we can probably take the largest)<br>
- sampler_count<br>
- sampler_offset<br>
- sdc_offset<br>
<br>
Then vs, gs, and wm could use instances of that structure, rather than containing those fields directly. This would allow us to pass around that "shader stage data" (pipeline stage data?) struct, rather than inspecting vs or gs directly.<br>
<br>
I think we could create a function for at least VS/GS binding tables that takes that struct, struct gl_program, and brw_vec4_prog_data, which would work for both.</blockquote><div><br></div><div>Very good point. I think you'll like how I've re-worked the series (I hope to publish it later today). I mostly took your advice, except that at the moment I've only consolidated the vs and gs code--wm is still separate (I figure merging the wm stuff can be done as follow-on work).<br>
</div></div></div></div>