llvmpipe: enable ARB_shader_group_vote.

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>
This commit is contained in:
Dave Airlie 2019-12-13 14:44:59 +10:00 committed by Dave Airlie
parent 88f567b5ce
commit 26c5ae80f0
7 changed files with 82 additions and 21 deletions

View 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

View 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

View 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)

View 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);

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

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

View 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);