<div dir="ltr">On 28 August 2013 18:06, 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="im">On 08/26/2013 03:12 PM, Paul Berry wrote:<br>
<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_<u></u>state.h | 8 +++<br>
src/mesa/drivers/dri/i965/brw_<u></u>vs_surface_state.c | 66 +++++++++++++++---------<br>
2 files changed, 50 insertions(+), 24 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_state.h b/src/mesa/drivers/dri/i965/<u></u>brw_state.h<br>
index 4814639..e7a1b40 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_state.h<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_state.h<br>
@@ -221,6 +221,14 @@ uint32_t<br>
get_attr_override(const struct brw_vue_map *vue_map, int urb_entry_read_offset,<br>
int fs_attr, bool two_side_color, uint32_t *max_source_attr);<br>
<br>
+/* brw_vs_surface_state.c */<br>
+void<br>
+brw_upload_vec4_pull_<u></u>constants(struct brw_context *brw,<br>
+ GLbitfield64 brw_new_constbuf,<br>
</blockquote>
<br></div>
FWIW, brw->state.dirty.brw is only 32-bits currently. That said, it's probably going to change in the not-too-distant future, so using GLbitfield64 preemptively isn't crazy.</blockquote><div><br></div><div>Oops, I didn't even realize I did that. I think I'll change it back to GLbitfield, just so that it doesn't cause any confusion for people.<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">
+ const struct gl_program *prog,<br>
+ struct brw_vec4_context_base *vec4_ctx,<br>
+ const struct brw_vec4_prog_data *prog_data);<br>
+<br>
#ifdef __cplusplus<br>
}<br>
#endif<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/<u></u>brw_vs_surface_state.c<br>
index 629eb96..48124bf 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_vs_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_vs_surface_state.c<br>
@@ -35,56 +35,50 @@<br>
#include "brw_context.h"<br>
#include "brw_state.h"<br>
<br>
-/* Creates a new VS constant buffer reflecting the current VS program's<br>
- * constants, if needed by the VS program.<br>
- *<br>
- * Otherwise, constants go through the CURBEs using the brw_constant_buffer<br>
- * state atom.<br>
- */<br>
-static void<br>
-brw_upload_vs_pull_constants(<u></u>struct brw_context *brw)<br>
-{<br>
- struct brw_vec4_context_base *vec4_ctx = &brw->vs.base;<br>
<br>
- /* BRW_NEW_VERTEX_PROGRAM */<br>
- struct brw_vertex_program *vp =<br>
- (struct brw_vertex_program *) brw->vertex_program;<br>
+void<br>
+brw_upload_vec4_pull_<u></u>constants(struct brw_context *brw,<br>
+ GLbitfield64 brw_new_constbuf,<br>
+ const struct gl_program *prog,<br>
+ struct brw_vec4_context_base *vec4_ctx,<br>
+ const struct brw_vec4_prog_data *prog_data)<br>
+{<br>
int i;<br>
<br>
/* Updates the ParamaterValues[i] pointers for all parameters of the<br>
* basic type of PROGRAM_STATE_VAR.<br>
*/<br>
- _mesa_load_state_parameters(&<u></u>brw->ctx, vp->program.Base.Parameters);<br>
+ _mesa_load_state_parameters(&<u></u>brw->ctx, prog->Parameters);<br>
<br>
- /* CACHE_NEW_VS_PROG */<br>
- if (!brw->vs.prog_data->base.nr_<u></u>pull_params) {<br>
+ if (!prog_data->nr_pull_params) {<br>
if (vec4_ctx->const_bo) {<br>
drm_intel_bo_unreference(vec4_<u></u>ctx->const_bo);<br>
vec4_ctx->const_bo = NULL;<br>
vec4_ctx->surf_offset[SURF_<u></u>INDEX_VEC4_CONST_BUFFER] = 0;<br>
- brw->state.dirty.brw |= BRW_NEW_VS_CONSTBUF;<br>
+ brw->state.dirty.brw |= brw_new_constbuf;<br>
}<br>
return;<br>
}<br>
<br>
/* _NEW_PROGRAM_CONSTANTS */<br>
drm_intel_bo_unreference(vec4_<u></u>ctx->const_bo);<br>
- uint32_t size = brw->vs.prog_data->base.nr_<u></u>pull_params * 4;<br>
- vec4_ctx->const_bo = drm_intel_bo_alloc(brw-><u></u>bufmgr, "vp_const_buffer",<br>
+ uint32_t size = prog_data->nr_pull_params * 4;<br>
+ vec4_ctx->const_bo = drm_intel_bo_alloc(brw-><u></u>bufmgr, "vec4_const_buffer",<br>
size, 64);<br>
<br>
drm_intel_gem_bo_map_gtt(vec4_<u></u>ctx->const_bo);<br>
- for (i = 0; i < brw->vs.prog_data->base.nr_<u></u>pull_params; i++) {<br>
+<br>
+ for (i = 0; i < prog_data->nr_pull_params; i++) {<br>
memcpy(vec4_ctx->const_bo-><u></u>virtual + i * 4,<br>
- brw->vs.prog_data->base.pull_<u></u>param[i],<br>
+ prog_data->pull_param[i],<br>
4);<br>
}<br>
<br>
if (0) {<br>
- for (i = 0; i < ALIGN(brw->vs.prog_data->base.<u></u>nr_pull_params, 4) / 4;<br>
+ for (i = 0; i < ALIGN(prog_data->nr_pull_<u></u>params, 4) / 4;<br>
i++) {<br>
</blockquote>
<br></div></div>
You could probably move the i++ up a line since it's shorter now.<br></blockquote><div><br></div><div>Done.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This patch is great.<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
float *row = (float *)vec4_ctx->const_bo->virtual + i * 4;<br>
- printf("vs const surface %3d: %4.3f %4.3f %4.3f %4.3f\n",<br>
+ printf("const surface %3d: %4.3f %4.3f %4.3f %4.3f\n",<br>
i, row[0], row[1], row[2], row[3]);<br>
}<br>
}<br>
@@ -95,7 +89,31 @@ brw_upload_vs_pull_constants(<u></u>struct brw_context *brw)<br>
brw->vtbl.create_constant_<u></u>surface(brw, vec4_ctx->const_bo, 0, size,<br>
&vec4_ctx->surf_offset[surf], false);<br>
<br>
- brw->state.dirty.brw |= BRW_NEW_VS_CONSTBUF;<br>
+ brw->state.dirty.brw |= brw_new_constbuf;<br>
+}<br>
+<br>
+<br>
+/* Creates a new VS constant buffer reflecting the current VS program's<br>
+ * constants, if needed by the VS program.<br>
+ *<br>
+ * Otherwise, constants go through the CURBEs using the brw_constant_buffer<br>
+ * state atom.<br>
+ */<br>
+static void<br>
+brw_upload_vs_pull_constants(<u></u>struct brw_context *brw)<br>
+{<br>
+ struct brw_vec4_context_base *vec4_ctx = &brw->vs.base;<br>
+<br>
+ /* BRW_NEW_VERTEX_PROGRAM */<br>
+ struct brw_vertex_program *vp =<br>
+ (struct brw_vertex_program *) brw->vertex_program;<br>
+<br>
+ /* CACHE_NEW_VS_PROG */<br>
+ const struct brw_vec4_prog_data *prog_data = &brw->vs.prog_data->base;<br>
+<br>
+ /* _NEW_PROGRAM_CONSTANTS */<br>
+ brw_upload_vec4_pull_<u></u>constants(brw, BRW_NEW_VS_CONSTBUF, &vp->program.Base,<br>
+ vec4_ctx, prog_data);<br>
}<br>
<br>
const struct brw_tracked_state brw_vs_pull_constants = {<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div></div>