diff options
author | Karol Herbst <[email protected]> | 2019-03-28 16:53:47 +0100 |
---|---|---|
committer | Karol Herbst <[email protected]> | 2019-04-14 22:25:56 +0200 |
commit | 2a36699ed36f753cccaee211a0da4f1b162ff281 (patch) | |
tree | aad9446d3d174173a64574192edae0a313452975 /src/amd | |
parent | adb22630147fa1837e59ac4fe87da95a5e399115 (diff) |
radv: use nir constant helpers
Signed-off-by: Karol Herbst <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/vulkan/radv_meta_resolve_cs.c | 16 | ||||
-rw-r--r-- | src/amd/vulkan/radv_shader_info.c | 14 |
2 files changed, 10 insertions, 20 deletions
diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c index e56df7f8a59..1b786526cf2 100644 --- a/src/amd/vulkan/radv_meta_resolve_cs.c +++ b/src/amd/vulkan/radv_meta_resolve_cs.c @@ -34,33 +34,27 @@ static nir_ssa_def *radv_meta_build_resolve_srgb_conversion(nir_builder *b, nir_ssa_def *input) { - nir_const_value v; unsigned i; - v.u32[0] = 0x3b4d2e1c; // 0.00313080009 nir_ssa_def *cmp[3]; for (i = 0; i < 3; i++) cmp[i] = nir_flt(b, nir_channel(b, input, i), - nir_build_imm(b, 1, 32, v)); + nir_imm_int(b, 0x3b4d2e1c)); nir_ssa_def *ltvals[3]; - v.f32[0] = 12.92; for (i = 0; i < 3; i++) ltvals[i] = nir_fmul(b, nir_channel(b, input, i), - nir_build_imm(b, 1, 32, v)); + nir_imm_float(b, 12.92)); nir_ssa_def *gtvals[3]; for (i = 0; i < 3; i++) { - v.f32[0] = 1.0/2.4; gtvals[i] = nir_fpow(b, nir_channel(b, input, i), - nir_build_imm(b, 1, 32, v)); - v.f32[0] = 1.055; + nir_imm_float(b, 1.0/2.4)); gtvals[i] = nir_fmul(b, gtvals[i], - nir_build_imm(b, 1, 32, v)); - v.f32[0] = 0.055; + nir_imm_float(b, 1.055)); gtvals[i] = nir_fsub(b, gtvals[i], - nir_build_imm(b, 1, 32, v)); + nir_imm_float(b, 0.055)); } nir_ssa_def *comp[4]; diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index 002475953d9..932a1852266 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -59,9 +59,7 @@ get_deref_offset(nir_deref_instr *instr, if (var->data.compact) { assert(instr->deref_type == nir_deref_type_array); - nir_const_value *v = nir_src_as_const_value(instr->arr.index); - assert(v); - *const_out = v->u32[0]; + *const_out = nir_src_as_uint(instr->arr.index); return; } @@ -80,9 +78,8 @@ get_deref_offset(nir_deref_instr *instr, } } else if(path.path[idx_lvl]->deref_type == nir_deref_type_array) { unsigned size = glsl_count_attribute_slots(path.path[idx_lvl]->type, false); - nir_const_value *v = nir_src_as_const_value(path.path[idx_lvl]->arr.index); - if (v) - const_offset += v->u32[0] * size; + if (nir_src_is_const(path.path[idx_lvl]->arr.index)) + const_offset += nir_src_as_uint(path.path[idx_lvl]->arr.index) * size; } else unreachable("Uhandled deref type in get_deref_instr_offset"); } @@ -189,13 +186,12 @@ gather_push_constant_info(const nir_shader *nir, const nir_intrinsic_instr *instr, struct radv_shader_info *info) { - nir_const_value *cval = nir_src_as_const_value(instr->src[0]); int base = nir_intrinsic_base(instr); - if (!cval) { + if (!nir_src_is_const(instr->src[0])) { info->has_indirect_push_constants = true; } else { - uint32_t min = base + cval->u32[0]; + uint32_t min = base + nir_src_as_uint(instr->src[0]); uint32_t max = min + instr->num_components * 4; info->max_push_constant_used = |