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 <marek.olsak@amd.com>
This commit is contained in:
Dave Airlie 2019-12-02 10:05:12 +10:00
parent f52cdaa517
commit 502548a09c
6 changed files with 14 additions and 1 deletions

View file

@ -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:

View file

@ -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;
}

View file

@ -173,6 +173,7 @@ struct lp_bld_tgsi_system_values {
LLVMValueRef thread_id;
LLVMValueRef block_id;
LLVMValueRef grid_size;
LLVMValueRef front_facing;
};

View file

@ -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;

View file

@ -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:

View file

@ -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) {