From: Dave Airlie Date: Mon, 17 Feb 2020 06:21:21 +0000 (+1000) Subject: gallivm/nir: add support for tess system values X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7898e37fb4201b4b8c761a6d131d2bdd7b7ef119;p=mesa.git gallivm/nir: add support for tess system values hooks up the tessellation specific system values in the NIR paths Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 5e47aaaadca..b8d804e827f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1316,6 +1316,10 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base, case nir_intrinsic_load_draw_id: case nir_intrinsic_load_local_group_size: case nir_intrinsic_load_work_dim: + case nir_intrinsic_load_tess_coord: + case nir_intrinsic_load_tess_level_outer: + case nir_intrinsic_load_tess_level_inner: + case nir_intrinsic_load_patch_vertices_in: bld_base->sysval_intrin(bld_base, instr, result); break; case nir_intrinsic_discard_if: diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 9d79358b33b..637ec36ba50 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -1193,7 +1193,10 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base, result[i] = lp_build_broadcast_scalar(&bld_base->uint_bld, LLVMBuildExtractElement(gallivm->builder, bld->system_values.grid_size, lp_build_const_int32(gallivm, i), "")); break; case nir_intrinsic_load_invocation_id: - result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.invocation_id); + if (bld_base->shader->info.stage == MESA_SHADER_TESS_CTRL) + result[0] = bld->system_values.invocation_id; + else + result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.invocation_id); break; case nir_intrinsic_load_front_face: result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.front_facing); @@ -1210,6 +1213,22 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base, case nir_intrinsic_load_work_dim: result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.work_dim); break; + case nir_intrinsic_load_tess_coord: + for (unsigned i = 0; i < 3; i++) { + result[i] = LLVMBuildExtractValue(gallivm->builder, bld->system_values.tess_coord, i, ""); + } + break; + case nir_intrinsic_load_tess_level_outer: + for (unsigned i = 0; i < 4; i++) + result[i] = lp_build_broadcast_scalar(&bld_base->base, LLVMBuildExtractValue(gallivm->builder, bld->system_values.tess_outer, i, "")); + break; + case nir_intrinsic_load_tess_level_inner: + for (unsigned i = 0; i < 2; i++) + result[i] = lp_build_broadcast_scalar(&bld_base->base, LLVMBuildExtractValue(gallivm->builder, bld->system_values.tess_inner, i, "")); + break; + case nir_intrinsic_load_patch_vertices_in: + result[0] = bld->system_values.vertices_in; + break; } }