gallivm/llvmpipe: add support for front facing in sysval.
authorDave Airlie <airlied@redhat.com>
Mon, 2 Dec 2019 00:05:12 +0000 (10:05 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 3 Dec 2019 05:29:04 +0000 (15:29 +1000)
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>
src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_state_fs.c

index d69a5a4fb26d1d6e8bca5b7af818bf82628fda25..e13ec4e1a192c70f59891604790ec2ecf7f7b4ab 100644 (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:
index 7ac9697011694834bfbe09745d42c061b13cc43c..5c3a40cdfea67328fd3e7312c7a4d6fe81f0dc28 100644 (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;
    }
index 6a67d90f8a505e0acd2dab5cfba17ef0d8fadf81..7048fbc3325e6e3ba8f90f292ed685216d35a683 100644 (file)
@@ -173,6 +173,7 @@ struct lp_bld_tgsi_system_values {
    LLVMValueRef thread_id;
    LLVMValueRef block_id;
    LLVMValueRef grid_size;
+   LLVMValueRef front_facing;
 };
 
 
index ca70a96302e57412aaa1cbcf9026879a3ff56436..5ae3d51d9861c5264b11455a1bf57b70e7d600b0 100644 (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;
index 080b0635c64c0ce43b8a67b016f27666a5718b1d..0814145512c1b34fbca7b398f9502df79b2c7364 100644 (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:
index d72c1a7498ce36aca994c8b2be075089799062af..695ccb8968218e6e5c87507c6123767a9310e06f 100644 (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) {