summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-10-20 12:25:31 -0500
committerJason Ekstrand <[email protected]>2018-11-08 10:09:25 -0600
commitbcc6aab065a9a4f7fc089065227c36c6c8efd52b (patch)
tree5424f78fb4c2824e34858fc3bc18f8dd1985d3cb
parent52145070c096883959975c8b1767af2da32f9f11 (diff)
anv: Use nir_src_is_const and friends in lowering code
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/intel/vulkan/anv_nir_apply_pipeline_layout.c15
-rw-r--r--src/intel/vulkan/anv_nir_lower_ycbcr_textures.c6
2 files changed, 9 insertions, 12 deletions
diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
index 6868288e486..fa967c217e7 100644
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
@@ -144,11 +144,9 @@ lower_res_index_intrinsic(nir_intrinsic_instr *intrin,
uint32_t array_size =
state->layout->set[set].layout->binding[binding].array_size;
- nir_const_value *const_array_index = nir_src_as_const_value(intrin->src[0]);
-
nir_ssa_def *block_index;
- if (const_array_index) {
- unsigned array_index = const_array_index->u32[0];
+ if (nir_src_is_const(intrin->src[0])) {
+ unsigned array_index = nir_src_as_uint(intrin->src[0]);
array_index = MIN2(array_index, array_size - 1);
block_index = nir_imm_int(b, surface_index + array_index);
} else {
@@ -299,9 +297,9 @@ lower_tex_deref(nir_tex_instr *tex, nir_tex_src_type deref_src_type,
if (deref->deref_type != nir_deref_type_var) {
assert(deref->deref_type == nir_deref_type_array);
- nir_const_value *const_index = nir_src_as_const_value(deref->arr.index);
- if (const_index) {
- *base_index += MIN2(const_index->u32[0], array_size - 1);
+ if (nir_src_is_const(deref->arr.index)) {
+ unsigned arr_index = nir_src_as_uint(deref->arr.index);
+ *base_index += MIN2(arr_index, array_size - 1);
} else {
nir_builder *b = &state->builder;
@@ -337,8 +335,7 @@ tex_instr_get_and_remove_plane_src(nir_tex_instr *tex)
if (plane_src_idx < 0)
return 0;
- unsigned plane =
- nir_src_as_const_value(tex->src[plane_src_idx].src)->u32[0];
+ unsigned plane = nir_src_as_uint(tex->src[plane_src_idx].src);
nir_tex_instr_remove_src(tex, plane_src_idx);
diff --git a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
index 71e511f34b7..3962356708b 100644
--- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
+++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
@@ -344,10 +344,10 @@ try_lower_tex_ycbcr(struct anv_pipeline_layout *layout,
unsigned array_index = 0;
if (deref->deref_type != nir_deref_type_var) {
assert(deref->deref_type == nir_deref_type_array);
- nir_const_value *const_index = nir_src_as_const_value(deref->arr.index);
- if (!const_index)
+ if (!nir_src_is_const(deref->arr.index))
return false;
- array_index = MIN2(const_index->u32[0], binding->array_size - 1);
+ array_index = nir_src_as_uint(deref->arr.index);
+ array_index = MIN2(array_index, binding->array_size - 1);
}
const struct anv_sampler *sampler = binding->immutable_samplers[array_index];