llvmpipe: enable ARB_shader_group_vote.
authorDave Airlie <airlied@redhat.com>
Fri, 13 Dec 2019 04:44:59 +0000 (14:44 +1000)
committerDave Airlie <airlied@linux.ie>
Mon, 30 Dec 2019 05:30:30 +0000 (05:30 +0000)
This just adds the NIR paths for shader group vote.

v2: drop feq for now. (Roland)

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3213>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3213>

.gitlab-ci/piglit/glslparser.txt
.gitlab-ci/piglit/quick_shader.txt
docs/features.txt
src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/auxiliary/gallivm/lp_bld_nir.h
src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
src/gallium/drivers/llvmpipe/lp_screen.c

index 8c4681014c3ae9c25115358eda75b2309a4e9ccc..d01136abbdca740122568ff1474def4eb9da472e 100644 (file)
@@ -1288,18 +1288,24 @@ spec/arb_shader_draw_parameters/preprocessor/disabled-undefined-core.tese: skip
 spec/arb_shader_draw_parameters/preprocessor/disabled-undefined-core.vert: skip
 spec/arb_shader_draw_parameters/preprocessor/enabled-core.tesc: skip
 spec/arb_shader_draw_parameters/preprocessor/enabled-core.tese: skip
+spec/arb_shader_group_vote/preprocessor/disabled-defined-compat.frag: skip
+spec/arb_shader_group_vote/preprocessor/disabled-defined-compat.vert: skip
+spec/arb_shader_group_vote/preprocessor/disabled-defined-core.comp: skip
+spec/arb_shader_group_vote/preprocessor/disabled-defined-core.frag: skip
+spec/arb_shader_group_vote/preprocessor/disabled-defined-core.geom: skip
 spec/arb_shader_group_vote/preprocessor/disabled-defined-core.tesc: skip
 spec/arb_shader_group_vote/preprocessor/disabled-defined-core.tese: skip
+spec/arb_shader_group_vote/preprocessor/disabled-defined-core.vert: skip
+spec/arb_shader_group_vote/preprocessor/disabled-undefined-compat.frag: skip
+spec/arb_shader_group_vote/preprocessor/disabled-undefined-compat.vert: skip
+spec/arb_shader_group_vote/preprocessor/disabled-undefined-core.comp: skip
+spec/arb_shader_group_vote/preprocessor/disabled-undefined-core.frag: skip
+spec/arb_shader_group_vote/preprocessor/disabled-undefined-core.geom: skip
 spec/arb_shader_group_vote/preprocessor/disabled-undefined-core.tesc: skip
 spec/arb_shader_group_vote/preprocessor/disabled-undefined-core.tese: skip
-spec/arb_shader_group_vote/preprocessor/enabled-compat.frag: skip
-spec/arb_shader_group_vote/preprocessor/enabled-compat.vert: skip
-spec/arb_shader_group_vote/preprocessor/enabled-core.comp: skip
-spec/arb_shader_group_vote/preprocessor/enabled-core.frag: skip
-spec/arb_shader_group_vote/preprocessor/enabled-core.geom: skip
+spec/arb_shader_group_vote/preprocessor/disabled-undefined-core.vert: skip
 spec/arb_shader_group_vote/preprocessor/enabled-core.tesc: skip
 spec/arb_shader_group_vote/preprocessor/enabled-core.tese: skip
-spec/arb_shader_group_vote/preprocessor/enabled-core.vert: skip
 spec/arb_shader_image_load_store/preprocessor/disabled-defined-compat.frag: skip
 spec/arb_shader_image_load_store/preprocessor/disabled-defined-compat.vert: skip
 spec/arb_shader_image_load_store/preprocessor/disabled-defined-core.comp: skip
@@ -5092,10 +5098,10 @@ spec/oes_texture_storage_multisample_2d_array/preprocessor/enabled-es.tese: skip
 summary:
        name:  results
        ----  --------
-       pass:     9692
+       pass:     9686
        fail:        2
       crash:        0
-       skip:     5089
+       skip:     5095
     timeout:        0
        warn:        0
  incomplete:        0
index d678476241a5897211093deeb1a1b278d4c93f21..c6aa27b071a7502e0ed1c70e21ce74b0e3a141d5 100644 (file)
@@ -1352,15 +1352,6 @@ spec/arb_shader_ballot/execution/fs-readinvocation-uint: skip
 spec/arb_shader_ballot/execution/fs-readinvocation-uint-uniform: skip
 spec/arb_shader_clock/execution/clock: skip
 spec/arb_shader_clock/execution/clock2x32: skip
-spec/arb_shader_group_vote/cs-all: skip
-spec/arb_shader_group_vote/cs-any: skip
-spec/arb_shader_group_vote/cs-eq: skip
-spec/arb_shader_group_vote/vs-all-const: skip
-spec/arb_shader_group_vote/vs-all-uniform: skip
-spec/arb_shader_group_vote/vs-any-const: skip
-spec/arb_shader_group_vote/vs-any-uniform: skip
-spec/arb_shader_group_vote/vs-eq-const: skip
-spec/arb_shader_group_vote/vs-eq-uniform: skip
 spec/arb_shader_image_load_store/execution/gl45-imageatomicexchange-float: skip
 spec/arb_shader_precision/fs-degrees-float: skip
 spec/arb_shader_precision/fs-degrees-vec2: skip
@@ -6417,10 +6408,10 @@ spec/oes_viewport_array/viewport-gs-writes-out-of-range: skip
 summary:
        name:  results
        ----  --------
-       pass:     8930
+       pass:     8939
        fail:       55
       crash:        0
-       skip:     6361
+       skip:     6352
     timeout:        0
        warn:        0
  incomplete:        0
index 61c2a408624d01a8c0eeb443b2506249bcd5314f..055815f5394c309e75b80908aa952d2f87a6ecc7 100644 (file)
@@ -232,7 +232,7 @@ GL 4.6, GLSL 4.60 -- all DONE: radeonsi
   GL_ARB_polygon_offset_clamp                           DONE (freedreno, i965, nv50, nvc0, r600, llvmpipe, swr, virgl)
   GL_ARB_shader_atomic_counter_ops                      DONE (freedreno/a5xx+, i965/gen7+, nvc0, r600, llvmpipe, softpipe, virgl)
   GL_ARB_shader_draw_parameters                         DONE (i965, llvmpipe, nvc0)
-  GL_ARB_shader_group_vote                              DONE (i965, nvc0)
+  GL_ARB_shader_group_vote                              DONE (i965, nvc0, llvmpipe)
   GL_ARB_spirv_extensions                               DONE (i965/gen7+)
   GL_ARB_texture_filter_anisotropic                     DONE (freedreno, i965, nv50, nvc0, r600, softpipe (*), llvmpipe (*))
   GL_ARB_transform_feedback_overflow_query              DONE (i965/gen6+, nvc0, llvmpipe, softpipe, virgl)
index 7461e06c9a5a49617e03822bbbf2f677aff2d85d..290f64e3f2c83d0af434dd09b54711ce14942870 100644 (file)
@@ -1373,6 +1373,10 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base,
    case nir_intrinsic_global_atomic_exchange:
    case nir_intrinsic_global_atomic_comp_swap:
       visit_global_atomic(bld_base, instr, result);
+   case nir_intrinsic_vote_all:
+   case nir_intrinsic_vote_any:
+   case nir_intrinsic_vote_ieq:
+      bld_base->vote(bld_base, cast_type(bld_base, get_src(bld_base, instr->src[0]), nir_type_int, 32), instr, result);
       break;
    default:
       assert(0);
index 0f13477c8563668b0b4f97cb56ee16c78e34acc5..ad56fef44a0d4d5c569a2564d44076e340ab15d8 100644 (file)
@@ -168,6 +168,8 @@ struct lp_build_nir_context
 
    void (*emit_vertex)(struct lp_build_nir_context *bld_base, uint32_t stream_id);
    void (*end_primitive)(struct lp_build_nir_context *bld_base, uint32_t stream_id);
+
+   void (*vote)(struct lp_build_nir_context *bld_base, LLVMValueRef src, nir_intrinsic_instr *instr, LLVMValueRef dst[4]);
 //   LLVMValueRef main_function
 };
 
index dc2a7405ae3dfd12d61db10781c762d1b84fbb92..1457cb15f28c089b7be6186debaf24f238e71b57 100644 (file)
@@ -1400,6 +1400,63 @@ emit_prologue(struct lp_build_nir_soa_context *bld)
    }
 }
 
+static void emit_vote(struct lp_build_nir_context *bld_base, LLVMValueRef src, nir_intrinsic_instr *instr, LLVMValueRef result[4])
+{
+   struct gallivm_state * gallivm = bld_base->base.gallivm;
+   LLVMBuilderRef builder = gallivm->builder;
+
+   LLVMValueRef exec_mask = mask_vec(bld_base);
+   struct lp_build_loop_state loop_state;
+
+   LLVMValueRef outer_cond = LLVMBuildICmp(builder, LLVMIntNE, exec_mask, bld_base->uint_bld.zero, "");
+
+   LLVMValueRef res_store = lp_build_alloca(gallivm, bld_base->int_bld.elem_type, "");
+   LLVMValueRef init_val;
+   if (instr->intrinsic == nir_intrinsic_vote_ieq) {
+      /* for equal we unfortunately have to loop and find the first valid one. */
+      lp_build_loop_begin(&loop_state, gallivm, lp_build_const_int32(gallivm, 0));
+      LLVMValueRef if_cond = LLVMBuildExtractElement(gallivm->builder, outer_cond, loop_state.counter, "");
+
+      struct lp_build_if_state ifthen;
+      lp_build_if(&ifthen, gallivm, if_cond);
+      LLVMValueRef value_ptr = LLVMBuildExtractElement(gallivm->builder, src,
+                                                       loop_state.counter, "");
+      LLVMBuildStore(builder, value_ptr, res_store);
+      lp_build_endif(&ifthen);
+      lp_build_loop_end_cond(&loop_state, lp_build_const_int32(gallivm, bld_base->uint_bld.type.length),
+                            NULL, LLVMIntUGE);
+      lp_build_print_value(gallivm, "init_val is ", LLVMBuildLoad(builder, res_store, ""));
+      init_val = LLVMBuildLoad(builder, res_store, "");
+   } else {
+      LLVMBuildStore(builder, lp_build_const_int32(gallivm, instr->intrinsic == nir_intrinsic_vote_any ? 0 : -1), res_store);
+   }
+
+   LLVMValueRef res;
+   lp_build_loop_begin(&loop_state, gallivm, lp_build_const_int32(gallivm, 0));
+   LLVMValueRef value_ptr = LLVMBuildExtractElement(gallivm->builder, src,
+                                                       loop_state.counter, "");
+   struct lp_build_if_state ifthen;
+   LLVMValueRef if_cond;
+   if_cond = LLVMBuildExtractElement(gallivm->builder, outer_cond, loop_state.counter, "");
+
+   lp_build_if(&ifthen, gallivm, if_cond);
+   res = LLVMBuildLoad(builder, res_store, "");
+
+   if (instr->intrinsic == nir_intrinsic_vote_ieq) {
+      LLVMValueRef tmp = LLVMBuildICmp(builder, LLVMIntEQ, init_val, value_ptr, "");
+      tmp = LLVMBuildSExt(builder, tmp, bld_base->uint_bld.elem_type, "");
+      res = LLVMBuildOr(builder, res, tmp, "");
+   } else if (instr->intrinsic == nir_intrinsic_vote_any)
+      res = LLVMBuildOr(builder, res, value_ptr, "");
+   else
+      res = LLVMBuildAnd(builder, res, value_ptr, "");
+   LLVMBuildStore(builder, res, res_store);
+   lp_build_endif(&ifthen);
+   lp_build_loop_end_cond(&loop_state, lp_build_const_int32(gallivm, bld_base->uint_bld.type.length),
+                         NULL, LLVMIntUGE);
+   result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, LLVMBuildLoad(builder, res_store, ""));
+}
+
 void lp_build_nir_soa(struct gallivm_state *gallivm,
                       struct nir_shader *shader,
                       const struct lp_build_tgsi_params *params,
@@ -1494,6 +1551,7 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
    bld.bld_base.barrier = emit_barrier;
    bld.bld_base.image_op = emit_image_op;
    bld.bld_base.image_size = emit_image_size;
+   bld.bld_base.vote = emit_vote;
 
    bld.mask = params->mask;
    bld.inputs = params->inputs;
index 8258614aebeacf9ff6106845416e86beceba4482..8fa0f6902d26ecf1f5eeb7a95eec0c808e992bf5 100644 (file)
@@ -351,7 +351,6 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PCI_FUNCTION:
    case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
-   case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_MAX_WINDOW_RECTANGLES:
    case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
    case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
@@ -395,6 +394,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE:
    case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
       return 1;
+   case PIPE_CAP_TGSI_VOTE:
    case PIPE_CAP_LOAD_CONSTBUF:
    case PIPE_CAP_PACKED_UNIFORMS: {
       struct llvmpipe_screen *lscreen = llvmpipe_screen(screen);