nir: Add gpu_shader5 interpolation intrinsics
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
This commit is contained in:
@@ -46,6 +46,21 @@ INTRINSIC(load_var, 0, ARR(), true, 0, 1, 0, NIR_INTRINSIC_CAN_ELIMINATE)
|
|||||||
INTRINSIC(store_var, 1, ARR(0), false, 0, 1, 0, 0)
|
INTRINSIC(store_var, 1, ARR(0), false, 0, 1, 0, 0)
|
||||||
INTRINSIC(copy_var, 0, ARR(), false, 0, 2, 0, 0)
|
INTRINSIC(copy_var, 0, ARR(), false, 0, 2, 0, 0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Interpolation of input. The interp_var_at* intrinsics are similar to the
|
||||||
|
* load_var intrinsic acting an a shader input except that they interpolate
|
||||||
|
* the input differently. The at_sample and at_offset intrinsics take an
|
||||||
|
* aditional source that is a integer sample id or a vec2 position offset
|
||||||
|
* respectively.
|
||||||
|
*/
|
||||||
|
|
||||||
|
INTRINSIC(interp_var_at_centroid, 0, ARR(0), true, 0, 1, 0,
|
||||||
|
NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
|
||||||
|
INTRINSIC(interp_var_at_sample, 1, ARR(1), true, 0, 1, 0,
|
||||||
|
NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
|
||||||
|
INTRINSIC(interp_var_at_offset, 1, ARR(2), true, 0, 1, 0,
|
||||||
|
NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* a barrier is an intrinsic with no inputs/outputs but which can't be moved
|
* a barrier is an intrinsic with no inputs/outputs but which can't be moved
|
||||||
* around/optimized in general
|
* around/optimized in general
|
||||||
@@ -109,23 +124,6 @@ LOAD(ubo, 3, NIR_INTRINSIC_CAN_REORDER)
|
|||||||
LOAD(input, 2, NIR_INTRINSIC_CAN_REORDER)
|
LOAD(input, 2, NIR_INTRINSIC_CAN_REORDER)
|
||||||
/* LOAD(ssbo, 2, 0) */
|
/* LOAD(ssbo, 2, 0) */
|
||||||
|
|
||||||
/*
|
|
||||||
* Interpolation of input. These are similar to the load_input* intrinsics
|
|
||||||
* except they interpolate differently. The interp_at_offset* and
|
|
||||||
* interp_at_offset* intrinsics take a second source that is either a
|
|
||||||
* sample id or a vec2 position offset.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define INTERP(name, num_srcs, src_comps) \
|
|
||||||
INTRINSIC(interp_##name, num_srcs, ARR(src_comps), true, \
|
|
||||||
0, 0, 2, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER) \
|
|
||||||
INTRINSIC(interp_##name##_indirect, 1 + num_srcs, ARR(1, src_comps), true, \
|
|
||||||
0, 0, 2, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
|
|
||||||
|
|
||||||
INTERP(at_centroid, 0, 0)
|
|
||||||
INTERP(at_sample, 1, 1)
|
|
||||||
INTERP(at_offset, 1, 1)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stores work the same way as loads, except now the first register input is
|
* Stores work the same way as loads, except now the first register input is
|
||||||
* the value or array to store and the optional second input is the indirect
|
* the value or array to store and the optional second input is the indirect
|
||||||
|
@@ -208,25 +208,21 @@ nir_lower_io_block(nir_block *block, void *void_state)
|
|||||||
|
|
||||||
bool has_indirect = deref_has_indirect(intrin->variables[0]);
|
bool has_indirect = deref_has_indirect(intrin->variables[0]);
|
||||||
|
|
||||||
|
/* Figure out the opcode */
|
||||||
nir_intrinsic_op load_op;
|
nir_intrinsic_op load_op;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case nir_var_shader_in:
|
case nir_var_shader_in:
|
||||||
if (has_indirect) {
|
load_op = has_indirect ? nir_intrinsic_load_input_indirect :
|
||||||
load_op = nir_intrinsic_load_input_indirect;
|
nir_intrinsic_load_input;
|
||||||
} else {
|
|
||||||
load_op = nir_intrinsic_load_input;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case nir_var_uniform:
|
case nir_var_uniform:
|
||||||
if (has_indirect) {
|
load_op = has_indirect ? nir_intrinsic_load_uniform_indirect :
|
||||||
load_op = nir_intrinsic_load_uniform_indirect;
|
nir_intrinsic_load_uniform;
|
||||||
} else {
|
|
||||||
load_op = nir_intrinsic_load_uniform;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
unreachable("Unknown variable mode");
|
unreachable("Unknown variable mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_intrinsic_instr *load = nir_intrinsic_instr_create(state->mem_ctx,
|
nir_intrinsic_instr *load = nir_intrinsic_instr_create(state->mem_ctx,
|
||||||
load_op);
|
load_op);
|
||||||
load->num_components = intrin->num_components;
|
load->num_components = intrin->num_components;
|
||||||
|
Reference in New Issue
Block a user