<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Jul 25, 2018 at 9:30 AM Dylan Baker <<a href="mailto:dylan@pnwbakers.com">dylan@pnwbakers.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Quoting Jason Ekstrand (2018-07-24 16:51:26)<br>
> On July 24, 2018 09:05:05 Dylan Baker <<a href="mailto:dylan@pnwbakers.com" target="_blank">dylan@pnwbakers.com</a>> wrote:<br>
> <br>
> > Quoting Jason Ekstrand (2018-07-23 10:46:31)<br>
> >> The original pass only looked for load_uniform intrinsics but there are<br>
> >> a number of other places that could end up loading a push constant. One<br>
> >> obvious omission was images which always implicitly use a push constant.<br>
> >> Legacy VS clip planes also get pushed into the shader.<br>
> >><br>
> >> Cc: <a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a><br>
> >> Cc: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><br>
> >> ---<br>
> >> src/intel/compiler/brw_nir.h | 1 +<br>
> >> .../compiler/brw_nir_analyze_ubo_ranges.c | 41 +++++++++++++++++--<br>
> >> src/intel/vulkan/anv_pipeline.c | 2 +-<br>
> >> src/mesa/drivers/dri/i965/brw_gs.c | 2 +-<br>
> >> src/mesa/drivers/dri/i965/brw_tcs.c | 2 +-<br>
> >> src/mesa/drivers/dri/i965/brw_tes.c | 2 +-<br>
> >> src/mesa/drivers/dri/i965/brw_vs.c | 2 +-<br>
> >> src/mesa/drivers/dri/i965/brw_wm.c | 2 +-<br>
> >> 8 files changed, 45 insertions(+), 9 deletions(-)<br>
> >><br>
> >> diff --git a/src/intel/compiler/brw_nir.h b/src/intel/compiler/brw_nir.h<br>
> >> index 19442b47eae..7d82edafe46 100644<br>
> >> --- a/src/intel/compiler/brw_nir.h<br>
> >> +++ b/src/intel/compiler/brw_nir.h<br>
> >> @@ -148,6 +148,7 @@ void <br>
> >> brw_nir_lower_patch_vertices_in_to_uniform(nir_shader *nir);<br>
> >><br>
> >> void brw_nir_analyze_ubo_ranges(const struct brw_compiler *compiler,<br>
> >> nir_shader *nir,<br>
> >> + const struct brw_vs_prog_key *vs_key,<br>
> >> struct brw_ubo_range out_ranges[4]);<br>
> >><br>
> >> bool brw_nir_opt_peephole_ffma(nir_shader *shader);<br>
> >> diff --git a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c <br>
> >> b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c<br>
> >> index cd5137da06e..cfa531675fc 100644<br>
> >> --- a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c<br>
> >> +++ b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c<br>
> >> @@ -124,12 +124,29 @@ analyze_ubos_block(struct ubo_analysis_state *state, <br>
> >> nir_block *block)<br>
> >> continue;<br>
> >><br>
> >> nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);<br>
> >> - if (intrin->intrinsic == nir_intrinsic_load_uniform)<br>
> >> + switch (intrin->intrinsic) {<br>
> >> + case nir_intrinsic_load_uniform:<br>
> >> + case nir_intrinsic_image_deref_load:<br>
> >> + case nir_intrinsic_image_deref_store:<br>
> >> + case nir_intrinsic_image_deref_atomic_add:<br>
> >> + case nir_intrinsic_image_deref_atomic_min:<br>
> >> + case nir_intrinsic_image_deref_atomic_max:<br>
> >> + case nir_intrinsic_image_deref_atomic_and:<br>
> >> + case nir_intrinsic_image_deref_atomic_or:<br>
> >> + case nir_intrinsic_image_deref_atomic_xor:<br>
> >> + case nir_intrinsic_image_deref_atomic_exchange:<br>
> >> + case nir_intrinsic_image_deref_atomic_comp_swap:<br>
> >> + case nir_intrinsic_image_deref_size:<br>
> >> state->uses_regular_uniforms = true;<br>
> >> -<br>
> >> - if (intrin->intrinsic != nir_intrinsic_load_ubo)<br>
> >> continue;<br>
> >><br>
> >> + case nir_intrinsic_load_ubo:<br>
> >> + break; /* Fall through to the analysis below */<br>
> >> +<br>
> >> + default:<br>
> >> + continue; /* Not a uniform or UBO intrinsic */<br>
> >> + }<br>
> >> +<br>
> >> nir_const_value *block_const = nir_src_as_const_value(intrin->src[0]);<br>
> >> nir_const_value *offset_const = nir_src_as_const_value(intrin->src[1]);<br>
> >><br>
> >> @@ -179,6 +196,7 @@ print_ubo_entry(FILE *file,<br>
> >> void<br>
> >> brw_nir_analyze_ubo_ranges(const struct brw_compiler *compiler,<br>
> >> nir_shader *nir,<br>
> >> + const struct brw_vs_prog_key *vs_key,<br>
> >> struct brw_ubo_range out_ranges[4])<br>
> >> {<br>
> >> const struct gen_device_info *devinfo = compiler->devinfo;<br>
> >> @@ -197,6 +215,23 @@ brw_nir_analyze_ubo_ranges(const struct brw_compiler <br>
> >> *compiler,<br>
> >> _mesa_hash_table_create(mem_ctx, NULL, _mesa_key_pointer_equal),<br>
> >> };<br>
> >><br>
> >> + switch (nir->info.stage) {<br>
> >> + case MESA_SHADER_VERTEX:<br>
> >> + if (vs_key && vs_key->nr_userclip_plane_consts > 0)<br>
> >> + state.uses_regular_uniforms = true;<br>
> >> + break;<br>
> >> +<br>
> >> + case MESA_SHADER_COMPUTE:<br>
> >> + /* Compute shaders use push constants to get the subgroup ID so it's<br>
> >> + * best to just assume some system values are pushed.<br>
> >> + */<br>
> >> + state.uses_regular_uniforms = true;<br>
> >> + break;<br>
> >> +<br>
> >> + default:<br>
> >> + break;<br>
> >> + }<br>
> >> +<br>
> >> /* Walk the IR, recording how many times each UBO block/offset is used. */<br>
> >> nir_foreach_function(function, nir) {<br>
> >> if (function->impl) {<br>
> >> diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c<br>
> >> index 211cee788b8..1e6bd12b87d 100644<br>
> >> --- a/src/intel/vulkan/anv_pipeline.c<br>
> >> +++ b/src/intel/vulkan/anv_pipeline.c<br>
> >> @@ -472,7 +472,7 @@ anv_pipeline_compile(struct anv_pipeline *pipeline,<br>
> >> anv_nir_apply_pipeline_layout(pipeline, layout, nir, prog_data, map);<br>
> >><br>
> >> if (stage != MESA_SHADER_COMPUTE)<br>
> >> - brw_nir_analyze_ubo_ranges(compiler, nir, prog_data->ubo_ranges);<br>
> >> + brw_nir_analyze_ubo_ranges(compiler, nir, NULL, prog_data->ubo_ranges);<br>
> >><br>
> >> assert(nir->num_uniforms == prog_data->nr_params * 4);<br>
> >><br>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_gs.c <br>
> >> b/src/mesa/drivers/dri/i965/brw_gs.c<br>
> >> index 9acb0337e20..7263f6351e9 100644<br>
> >> --- a/src/mesa/drivers/dri/i965/brw_gs.c<br>
> >> +++ b/src/mesa/drivers/dri/i965/brw_gs.c<br>
> >> @@ -94,7 +94,7 @@ brw_codegen_gs_prog(struct brw_context *brw,<br>
> >> brw_nir_setup_glsl_uniforms(mem_ctx, gp->program.nir, &gp->program,<br>
> >> &prog_data.base.base,<br>
> >> compiler->scalar_stage[MESA_SHADER_GEOMETRY]);<br>
> >> - brw_nir_analyze_ubo_ranges(compiler, gp->program.nir,<br>
> >> + brw_nir_analyze_ubo_ranges(compiler, gp->program.nir, NULL,<br>
> >> prog_data.base.base.ubo_ranges);<br>
> >><br>
> >> uint64_t outputs_written = gp->program.nir->info.outputs_written;<br>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c <br>
> >> b/src/mesa/drivers/dri/i965/brw_tcs.c<br>
> >> index 3b4642033fe..53611144ff5 100644<br>
> >> --- a/src/mesa/drivers/dri/i965/brw_tcs.c<br>
> >> +++ b/src/mesa/drivers/dri/i965/brw_tcs.c<br>
> >> @@ -185,7 +185,7 @@ brw_codegen_tcs_prog(struct brw_context *brw, struct <br>
> >> brw_program *tcp,<br>
> >> brw_nir_setup_glsl_uniforms(mem_ctx, nir, &tcp->program,<br>
> >> &prog_data.base.base,<br>
> >> compiler->scalar_stage[MESA_SHADER_TESS_CTRL]);<br>
> >> - brw_nir_analyze_ubo_ranges(compiler, tcp->program.nir,<br>
> >> + brw_nir_analyze_ubo_ranges(compiler, tcp->program.nir, NULL,<br>
> >> prog_data.base.base.ubo_ranges);<br>
> >> } else {<br>
> >> /* Upload the Patch URB Header as the first two uniforms.<br>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_tes.c <br>
> >> b/src/mesa/drivers/dri/i965/brw_tes.c<br>
> >> index 6f37dfabbf8..b3220a94741 100644<br>
> >> --- a/src/mesa/drivers/dri/i965/brw_tes.c<br>
> >> +++ b/src/mesa/drivers/dri/i965/brw_tes.c<br>
> >> @@ -85,7 +85,7 @@ brw_codegen_tes_prog(struct brw_context *brw,<br>
> >> brw_nir_setup_glsl_uniforms(mem_ctx, nir, &tep->program,<br>
> >> &prog_data.base.base,<br>
> >> compiler->scalar_stage[MESA_SHADER_TESS_EVAL]);<br>
> >> - brw_nir_analyze_ubo_ranges(compiler, tep->program.nir,<br>
> >> + brw_nir_analyze_ubo_ranges(compiler, tep->program.nir, NULL,<br>
> >> prog_data.base.base.ubo_ranges);<br>
> >><br>
> >> int st_index = -1;<br>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_vs.c <br>
> >> b/src/mesa/drivers/dri/i965/brw_vs.c<br>
> >> index f518649e751..69c0046bbb9 100644<br>
> >> --- a/src/mesa/drivers/dri/i965/brw_vs.c<br>
> >> +++ b/src/mesa/drivers/dri/i965/brw_vs.c<br>
> >> @@ -181,7 +181,7 @@ brw_codegen_vs_prog(struct brw_context *brw,<br>
> >> brw_nir_setup_glsl_uniforms(mem_ctx, vp->program.nir, &vp->program,<br>
> >> &prog_data.base.base,<br>
> >> compiler->scalar_stage[MESA_SHADER_VERTEX]);<br>
> >> - brw_nir_analyze_ubo_ranges(compiler, vp->program.nir,<br>
> >> + brw_nir_analyze_ubo_ranges(compiler, vp->program.nir, key,<br>
> >> prog_data.base.base.ubo_ranges);<br>
> >> } else {<br>
> >> brw_nir_setup_arb_uniforms(mem_ctx, vp->program.nir, &vp->program,<br>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_wm.c <br>
> >> b/src/mesa/drivers/dri/i965/brw_wm.c<br>
> >> index c65ca166286..70fe3844442 100644<br>
> >> --- a/src/mesa/drivers/dri/i965/brw_wm.c<br>
> >> +++ b/src/mesa/drivers/dri/i965/brw_wm.c<br>
> >> @@ -149,7 +149,7 @@ brw_codegen_wm_prog(struct brw_context *brw,<br>
> >> brw_nir_setup_glsl_uniforms(mem_ctx, fp->program.nir, &fp->program,<br>
> >> &prog_data.base, true);<br>
> >> brw_nir_analyze_ubo_ranges(brw->screen->compiler, fp->program.nir,<br>
> >> - prog_data.base.ubo_ranges);<br>
> >> + NULL, prog_data.base.ubo_ranges);<br>
> >> } else {<br>
> >> brw_nir_setup_arb_uniforms(mem_ctx, fp->program.nir, &fp->program,<br>
> >> &prog_data.base);<br>
> >> --<br>
> >> 2.17.1<br>
> >><br>
> >> _______________________________________________<br>
> >> mesa-stable mailing list<br>
> >> <a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a><br>
> >> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-stable" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-stable</a><br>
> ><br>
> > Hi Jason,<br>
> ><br>
> > This applies, but won't build on the stable branch, because none of the<br>
> > intriniscs actually exist in 18.1. Do you want to try to pull in some <br>
> > additional<br>
> > patches to make this work, or should we drop this patch?<br>
> <br>
> Just get rid of the _deref in the image intrinsic names.<br>
> <br>
> <br>
> <br>
<br>
I had to apply this diff, does this look right:<br>
<br>
diff --git a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c<br>
index da5ff4a3bbe..48bedabf31b 100644<br>
--- a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c<br>
+++ b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c<br>
@@ -126,17 +126,17 @@ analyze_ubos_block(struct ubo_analysis_state *state, nir_block *block)<br>
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);<br>
switch (intrin->intrinsic) {<br>
case nir_intrinsic_load_uniform:<br>
- case nir_intrinsic_image_deref_load:<br>
- case nir_intrinsic_image_deref_store:<br>
- case nir_intrinsic_image_deref_atomic_add:<br>
- case nir_intrinsic_image_deref_atomic_min:<br>
- case nir_intrinsic_image_deref_atomic_max:<br>
- case nir_intrinsic_image_deref_atomic_and:<br>
- case nir_intrinsic_image_deref_atomic_or:<br>
- case nir_intrinsic_image_deref_atomic_xor:<br>
- case nir_intrinsic_image_deref_atomic_exchange:<br>
- case nir_intrinsic_image_deref_atomic_comp_swap:<br>
- case nir_intrinsic_image_deref_size:<br>
+ case nir_intrinsic_image_var_load:<br>
+ case nir_intrinsic_image_var_store:<br>
+ case nir_intrinsic_image_var_atomic_add:<br>
+ case nir_intrinsic_image_var_atomic_min:<br>
+ case nir_intrinsic_image_var_atomic_max:<br>
+ case nir_intrinsic_image_var_atomic_and:<br>
+ case nir_intrinsic_image_var_atomic_or:<br>
+ case nir_intrinsic_image_var_atomic_xor:<br>
+ case nir_intrinsic_image_var_atomic_exchange:<br>
+ case nir_intrinsic_image_var_atomic_comp_swap:<br>
+ case nir_intrinsic_image_var_size:<br>
state->uses_regular_uniforms = true;<br>
continue;<br></blockquote><div><br></div><div>Looks good. I couldn't remember of the old ones had a _var or not and was on my phone. <br></div></div></div>