<div dir="ltr">Seems a little unfortunate to add a random bool to this interface which is otherwise fairly descriptive, but OK.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 19, 2016 at 8:26 AM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">While my intention is that the new intrinsics should be usable by all<br>
drivers, we need to make them optional until all drivers switch.<br>
<br>
This doesn't do anything yet, but I added it as a separate patch to<br>
keep the interface churn separate for easier review.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/compiler/nir/nir.h | 3 ++-<br>
src/compiler/nir/nir_lower_io.c | 15 +++++++++++----<br>
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 2 +-<br>
src/mesa/drivers/dri/i965/brw_blorp.c | 2 +-<br>
src/mesa/drivers/dri/i965/brw_nir.c | 18 +++++++++---------<br>
src/mesa/drivers/dri/i965/brw_program.c | 4 ++--<br>
src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 +-<br>
7 files changed, 27 insertions(+), 19 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index ac11998..e996e0e 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -2324,7 +2324,8 @@ void nir_assign_var_locations(struct exec_list *var_list, unsigned *size,<br>
<br>
void nir_lower_io(nir_shader *shader,<br>
nir_variable_mode modes,<br>
- int (*type_size)(const struct glsl_type *));<br>
+ int (*type_size)(const struct glsl_type *),<br>
+ bool use_load_interpolated_input_intrinsics);<br>
nir_src *nir_get_io_offset_src(nir_intrinsic_instr *instr);<br>
nir_src *nir_get_io_vertex_index_src(nir_intrinsic_instr *instr);<br>
<br>
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c<br>
index b05a73f..aa8a517 100644<br>
--- a/src/compiler/nir/nir_lower_io.c<br>
+++ b/src/compiler/nir/nir_lower_io.c<br>
@@ -39,6 +39,7 @@ struct lower_io_state {<br>
void *mem_ctx;<br>
int (*type_size)(const struct glsl_type *type);<br>
nir_variable_mode modes;<br>
+ bool use_interpolated_input;<br>
};<br>
<br>
void<br>
@@ -394,7 +395,8 @@ nir_lower_io_block(nir_block *block,<br>
static void<br>
nir_lower_io_impl(nir_function_impl *impl,<br>
nir_variable_mode modes,<br>
- int (*type_size)(const struct glsl_type *))<br>
+ int (*type_size)(const struct glsl_type *),<br>
+ bool use_interpolated_input)<br>
{<br>
struct lower_io_state state;<br>
<br>
@@ -402,6 +404,7 @@ nir_lower_io_impl(nir_function_impl *impl,<br>
state.mem_ctx = ralloc_parent(impl);<br>
state.modes = modes;<br>
state.type_size = type_size;<br>
+ state.use_interpolated_input = use_interpolated_input;<br>
<br>
nir_foreach_block(block, impl) {<br>
nir_lower_io_block(block, &state);<br>
@@ -413,11 +416,15 @@ nir_lower_io_impl(nir_function_impl *impl,<br>
<br>
void<br>
nir_lower_io(nir_shader *shader, nir_variable_mode modes,<br>
- int (*type_size)(const struct glsl_type *))<br>
+ int (*type_size)(const struct glsl_type *),<br>
+ bool use_interpolated_input)<br>
{<br>
nir_foreach_function(function, shader) {<br>
- if (function->impl)<br>
- nir_lower_io_impl(function->impl, modes, type_size);<br>
+ if (function->impl) {<br>
+ nir_lower_io_impl(function->impl, modes, type_size,<br>
+ use_interpolated_input &&<br>
+ shader->stage == MESA_SHADER_FRAGMENT);<br>
+ }<br>
}<br>
}<br>
<br>
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c<br>
index 41532fc..a8a8c1b 100644<br>
--- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c<br>
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c<br>
@@ -93,7 +93,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)<br>
// TODO nir_assign_var_locations??<br>
<br>
NIR_PASS_V(nir, nir_lower_system_values);<br>
- NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size);<br>
+ NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size, false);<br>
NIR_PASS_V(nir, nir_lower_samplers, prog);<br>
<br>
return nir;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c<br>
index 282a5b2..0473cfe 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c<br>
@@ -209,7 +209,7 @@ brw_blorp_compile_nir_shader(struct brw_context *brw, struct nir_shader *nir,<br>
unsigned end = var->data.location + nir_uniform_type_size(var->type);<br>
nir->num_uniforms = MAX2(nir->num_uniforms, end);<br>
}<br>
- nir_lower_io(nir, nir_var_uniform, nir_uniform_type_size);<br>
+ nir_lower_io(nir, nir_var_uniform, nir_uniform_type_size, false);<br>
<br>
const unsigned *program =<br>
brw_compile_fs(compiler, brw, mem_ctx, wm_key, &wm_prog_data, nir,<br>
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c<br>
index 6c3e1d1..caf9fe0 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_nir.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_nir.c<br>
@@ -204,7 +204,7 @@ brw_nir_lower_vs_inputs(nir_shader *nir,<br>
* loaded as one vec4 or dvec4 per element (or matrix column), depending on<br>
* whether it is a double-precision type or not.<br>
*/<br>
- nir_lower_io(nir, nir_var_shader_in, type_size_vs_input);<br>
+ nir_lower_io(nir, nir_var_shader_in, type_size_vs_input, false);<br>
<br>
/* This pass needs actual constants */<br>
nir_opt_constant_folding(nir);<br>
@@ -236,7 +236,7 @@ brw_nir_lower_vue_inputs(nir_shader *nir, bool is_scalar,<br>
}<br>
<br>
/* Inputs are stored in vec4 slots, so use type_size_vec4(). */<br>
- nir_lower_io(nir, nir_var_shader_in, type_size_vec4);<br>
+ nir_lower_io(nir, nir_var_shader_in, type_size_vec4, false);<br>
<br>
if (is_scalar || nir->stage != MESA_SHADER_GEOMETRY) {<br>
/* This pass needs actual constants */<br>
@@ -261,7 +261,7 @@ brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map)<br>
var->data.driver_location = var->data.location;<br>
}<br>
<br>
- nir_lower_io(nir, nir_var_shader_in, type_size_vec4);<br>
+ nir_lower_io(nir, nir_var_shader_in, type_size_vec4, false);<br>
<br>
/* This pass needs actual constants */<br>
nir_opt_constant_folding(nir);<br>
@@ -284,7 +284,7 @@ brw_nir_lower_fs_inputs(nir_shader *nir)<br>
{<br>
nir_assign_var_locations(&nir->inputs, &nir->num_inputs, VARYING_SLOT_VAR0,<br>
type_size_scalar);<br>
- nir_lower_io(nir, nir_var_shader_in, type_size_scalar);<br>
+ nir_lower_io(nir, nir_var_shader_in, type_size_scalar, false);<br>
}<br>
<br>
void<br>
@@ -295,11 +295,11 @@ brw_nir_lower_vue_outputs(nir_shader *nir,<br>
nir_assign_var_locations(&nir->outputs, &nir->num_outputs,<br>
VARYING_SLOT_VAR0,<br>
type_size_scalar);<br>
- nir_lower_io(nir, nir_var_shader_out, type_size_scalar);<br>
+ nir_lower_io(nir, nir_var_shader_out, type_size_scalar, false);<br>
} else {<br>
nir_foreach_variable(var, &nir->outputs)<br>
var->data.driver_location = var->data.location;<br>
- nir_lower_io(nir, nir_var_shader_out, type_size_vec4);<br>
+ nir_lower_io(nir, nir_var_shader_out, type_size_vec4, false);<br>
}<br>
}<br>
<br>
@@ -310,7 +310,7 @@ brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map)<br>
var->data.driver_location = var->data.location;<br>
}<br>
<br>
- nir_lower_io(nir, nir_var_shader_out, type_size_vec4);<br>
+ nir_lower_io(nir, nir_var_shader_out, type_size_vec4, false);<br>
<br>
/* This pass needs actual constants */<br>
nir_opt_constant_folding(nir);<br>
@@ -333,7 +333,7 @@ brw_nir_lower_fs_outputs(nir_shader *nir)<br>
{<br>
nir_assign_var_locations(&nir->outputs, &nir->num_outputs,<br>
FRAG_RESULT_DATA0, type_size_scalar);<br>
- nir_lower_io(nir, nir_var_shader_out, type_size_scalar);<br>
+ nir_lower_io(nir, nir_var_shader_out, type_size_scalar, false);<br>
}<br>
<br>
void<br>
@@ -341,7 +341,7 @@ brw_nir_lower_cs_shared(nir_shader *nir)<br>
{<br>
nir_assign_var_locations(&nir->shared, &nir->num_shared, 0,<br>
type_size_scalar_bytes);<br>
- nir_lower_io(nir, nir_var_shared, type_size_scalar_bytes);<br>
+ nir_lower_io(nir, nir_var_shared, type_size_scalar_bytes, false);<br>
}<br>
<br>
#define OPT(pass, ...) ({ \<br>
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c<br>
index 7785490..1899d79 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_program.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_program.c<br>
@@ -53,11 +53,11 @@ brw_nir_lower_uniforms(nir_shader *nir, bool is_scalar)<br>
if (is_scalar) {<br>
nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms, 0,<br>
type_size_scalar_bytes);<br>
- nir_lower_io(nir, nir_var_uniform, type_size_scalar_bytes);<br>
+ nir_lower_io(nir, nir_var_uniform, type_size_scalar_bytes, false);<br>
} else {<br>
nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms, 0,<br>
type_size_vec4_bytes);<br>
- nir_lower_io(nir, nir_var_uniform, type_size_vec4_bytes);<br>
+ nir_lower_io(nir, nir_var_uniform, type_size_vec4_bytes, false);<br>
}<br>
}<br>
<br>
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp<br>
index 73a692a..18a524d 100644<br>
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp<br>
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp<br>
@@ -343,7 +343,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)<br>
&nir->uniforms, &nir->num_uniforms);<br>
<br>
NIR_PASS_V(nir, nir_lower_system_values);<br>
- NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size);<br>
+ NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size, false);<br>
NIR_PASS_V(nir, nir_lower_samplers, shader_program);<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.9.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>