[Mesa-dev] [PATCH 02/13] nir: add load_param
Rob Clark
robdclark at gmail.com
Wed Feb 28 19:51:32 UTC 2018
From: Karol Herbst <kherbst at redhat.com>
OpenCL kernels have parameters (see pipe_grid_info::input), and so we
need a way to access them.
Signed-off-by: Rob Clark <robdclark at gmail.com>
---
src/compiler/nir/nir_intrinsics.h | 2 ++
src/compiler/nir/nir_lower_io.c | 13 ++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
index ede29277876..0915c5e809f 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -435,6 +435,8 @@ LOAD(ubo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REOR
LOAD(input, 1, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
/* src[] = { vertex, offset }. const_index[] = { base, component } */
LOAD(per_vertex_input, 2, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+/* src[] = { }. const_index[] = { base } */
+LOAD(param, 0, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
/* src[] = { barycoord, offset }. const_index[] = { base, component } */
INTRINSIC(load_interpolated_input, 2, ARR(2, 1), true, 0, 0,
2, BASE, COMPONENT, xx,
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index df91febd68d..febd28b560e 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -199,6 +199,9 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
case nir_var_shared:
op = nir_intrinsic_load_shared;
break;
+ case nir_var_param:
+ op = nir_intrinsic_load_param;
+ break;
default:
unreachable("Unknown variable mode");
}
@@ -207,7 +210,10 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
nir_intrinsic_instr_create(state->builder.shader, op);
load->num_components = intrin->num_components;
- nir_intrinsic_set_base(load, var->data.driver_location);
+ if (mode == nir_var_param)
+ nir_intrinsic_set_base(load, var->data.location);
+ else
+ nir_intrinsic_set_base(load, var->data.driver_location);
if (mode == nir_var_shader_in || mode == nir_var_shader_out)
nir_intrinsic_set_component(load, component);
@@ -220,7 +226,7 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
} else if (barycentric) {
load->src[0] = nir_src_for_ssa(barycentric);
load->src[1] = nir_src_for_ssa(offset);
- } else {
+ } else if (mode != nir_var_param) {
load->src[0] = nir_src_for_ssa(offset);
}
@@ -407,7 +413,8 @@ nir_lower_io_block(nir_block *block,
if (mode != nir_var_shader_in &&
mode != nir_var_shader_out &&
mode != nir_var_shared &&
- mode != nir_var_uniform)
+ mode != nir_var_uniform &&
+ mode != nir_var_param)
continue;
b->cursor = nir_before_instr(instr);
--
2.14.3
More information about the mesa-dev
mailing list