<div dir="ltr">On 14 August 2013 21:07, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This allows us to determine how small we can make the binding table.<br>
<br>
Since it depends entirely on the shader program, we can just compute<br>
it once at compile time, rather than at binding table emit time (which<br>
happens during drawing).<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_context.h | 2 ++<br>
src/mesa/drivers/dri/i965/brw_fs.h | 2 ++<br>
src/mesa/drivers/dri/i965/brw_fs_emit.cpp | 23 +++++++++++++++++++++++<br>
3 files changed, 27 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 ff0a65c..380fe08 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -305,6 +305,8 @@ struct brw_wm_prog_data {<br>
GLuint reg_blocks_16;<br>
GLuint total_scratch;<br>
<br>
+ unsigned max_surface_index;<br>
+<br></blockquote><div><br></div><div>I'm bothered by the off-by-one inconsistency of using max_surface_index here, but using binding_table_size over in brw_vec4_prog_data (see patch 5). Could we change this to binding_table_size, and update fs_generator::mark_surface_used() to do:<br>
<br>prog_data->binding_table_size = MAX2(prog_data->binding_table_size, surf_index + 1);<br><br></div><div>Then it would be consistent with vec4_generator::mark_surface_used().<br><br></div><div>With that changed, this patch is:<br>
<br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
GLuint nr_params; /**< number of float params/constants */<br>
GLuint nr_pull_params;<br>
bool dual_src_blend;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h<br>
index 7feb2b6..9d240b5 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.h<br>
@@ -569,6 +569,8 @@ private:<br>
struct brw_reg offset,<br>
struct brw_reg value);<br>
<br>
+ void mark_surface_used(unsigned surf_index);<br>
+<br>
void patch_discard_jumps_to_fb_writes();<br>
<br>
struct brw_context *brw;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp<br>
index b90cf0f..41dacff 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp<br>
@@ -59,6 +59,15 @@ fs_generator::~fs_generator()<br>
}<br>
<br>
void<br>
+fs_generator::mark_surface_used(unsigned surf_index)<br>
+{<br>
+ assert(surf_index < BRW_MAX_WM_SURFACES);<br>
+<br>
+ if (surf_index > c->prog_data.max_surface_index)<br>
+ c->prog_data.max_surface_index = surf_index;<br>
+}<br>
+<br>
+void<br>
fs_generator::patch_discard_jumps_to_fb_writes()<br>
{<br>
if (brw->gen < 6 || this->discard_halt_patches.is_empty())<br>
@@ -175,6 +184,8 @@ fs_generator::generate_fb_write(fs_inst *inst)<br>
0,<br>
eot,<br>
inst->header_present);<br>
+<br>
+ mark_surface_used(SURF_INDEX_DRAW(inst->target));<br>
}<br>
<br>
/* Computes the integer pixel x,y values from the origin.<br>
@@ -519,6 +530,8 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src<br>
inst->header_present,<br>
simd_mode,<br>
return_format);<br>
+<br>
+ mark_surface_used(SURF_INDEX_TEXTURE(inst->sampler));<br>
}<br>
<br>
<br>
@@ -648,6 +661,8 @@ fs_generator::generate_uniform_pull_constant_load(fs_inst *inst,<br>
<br>
brw_oword_block_read(p, dst, brw_message_reg(inst->base_mrf),<br>
read_offset, surf_index);<br>
+<br>
+ mark_surface_used(surf_index);<br>
}<br>
<br>
void<br>
@@ -688,6 +703,8 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst,<br>
false, /* no header */<br>
BRW_SAMPLER_SIMD_MODE_SIMD4X2,<br>
0);<br>
+<br>
+ mark_surface_used(surf_index);<br>
}<br>
<br>
void<br>
@@ -753,6 +770,8 @@ fs_generator::generate_varying_pull_constant_load(fs_inst *inst,<br>
inst->header_present,<br>
simd_mode,<br>
return_format);<br>
+<br>
+ mark_surface_used(surf_index);<br>
}<br>
<br>
void<br>
@@ -795,6 +814,8 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst,<br>
false, /* no header */<br>
simd_mode,<br>
0);<br>
+<br>
+ mark_surface_used(surf_index);<br>
}<br>
<br>
/**<br>
@@ -1040,6 +1061,8 @@ fs_generator::generate_shader_time_add(fs_inst *inst,<br>
brw_MOV(p, payload_value, value);<br>
brw_shader_time_add(p, payload, SURF_INDEX_WM_SHADER_TIME);<br>
brw_pop_insn_state(p);<br>
+<br>
+ mark_surface_used(SURF_INDEX_WM_SHADER_TIME);<br>
}<br>
<br>
void<br>
<span><font color="#888888">--<br>
1.8.3.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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></span></blockquote></div><br></div></div>