From: Dave Airlie Date: Mon, 2 Dec 2019 00:05:12 +0000 (+1000) Subject: gallivm/llvmpipe: add support for front facing in sysval. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=502548a09c5a87d06da97be45a2386bb1e5e800e;p=mesa.git gallivm/llvmpipe: add support for front facing in sysval. This wires up the front facing value as a sysval, I'd like to remove the other facing code but I'd need to confirm VMware don't use it first. Reviewed-by: Marek Olšák --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index d69a5a4fb26..e13ec4e1a19 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1149,6 +1149,7 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base, case nir_intrinsic_load_local_invocation_id: case nir_intrinsic_load_num_work_groups: case nir_intrinsic_load_invocation_id: + case nir_intrinsic_load_front_face: 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 7ac96970116..5c3a40cdfea 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -943,6 +943,9 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base, case nir_intrinsic_load_invocation_id: 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); + break; default: break; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 6a67d90f8a5..7048fbc3325 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -173,6 +173,7 @@ struct lp_bld_tgsi_system_values { LLVMValueRef thread_id; LLVMValueRef block_id; LLVMValueRef grid_size; + LLVMValueRef front_facing; }; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index ca70a96302e..5ae3d51d986 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1336,6 +1336,10 @@ emit_fetch_system_value( atype = TGSI_TYPE_UNSIGNED; break; + case TGSI_SEMANTIC_FACE: + res = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.front_facing); + break; + default: assert(!"unexpected semantic in emit_fetch_system_value"); res = bld_base->base.zero; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 080b0635c64..0814145512c 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -337,7 +337,6 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_MULTI_DRAW_INDIRECT: case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: - case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_INVALIDATE_BUFFER: case PIPE_CAP_GENERATE_MIPMAP: case PIPE_CAP_STRING_MARKER: @@ -392,6 +391,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) return LP_MAX_TGSI_SHADER_BUFFER_SIZE; case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: case PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE: + case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: return 1; case PIPE_CAP_LOAD_CONSTBUF: case PIPE_CAP_PACKED_UNIFORMS: diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index d72c1a7498c..695ccb89682 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -342,6 +342,10 @@ generate_fs_loop(struct gallivm_state *gallivm, memset(&system_values, 0, sizeof(system_values)); + /* truncate then sign extend. */ + system_values.front_facing = LLVMBuildTrunc(gallivm->builder, facing, LLVMInt1TypeInContext(gallivm->context), ""); + system_values.front_facing = LLVMBuildSExt(gallivm->builder, system_values.front_facing, LLVMInt32TypeInContext(gallivm->context), ""); + if (key->depth.enabled || key->stencil[0].enabled) {