This fixes KHR-GL45.shader_ballot_tests.ShaderBallotBitmasks.
This solution is better, because the IR isn't dependent on wave32.
ac_llvm_context_init(struct ac_llvm_context *ctx,
struct ac_llvm_compiler *compiler,
enum chip_class chip_class, enum radeon_family family,
- enum ac_float_mode float_mode, unsigned wave_size)
+ enum ac_float_mode float_mode, unsigned wave_size,
+ unsigned ballot_mask_bits)
{
LLVMValueRef args[1];
ctx->chip_class = chip_class;
ctx->family = family;
ctx->wave_size = wave_size;
+ ctx->ballot_mask_bits = ballot_mask_bits;
ctx->module = ac_create_module(wave_size == 32 ? compiler->tm_wave32
: compiler->tm,
ctx->context);
ctx->v4f32 = LLVMVectorType(ctx->f32, 4);
ctx->v8i32 = LLVMVectorType(ctx->i32, 8);
ctx->iN_wavemask = LLVMIntTypeInContext(ctx->context, ctx->wave_size);
+ ctx->iN_ballotmask = LLVMIntTypeInContext(ctx->context, ballot_mask_bits);
ctx->i8_0 = LLVMConstInt(ctx->i8, 0, false);
ctx->i8_1 = LLVMConstInt(ctx->i8, 1, false);
LLVMTypeRef v4f32;
LLVMTypeRef v8i32;
LLVMTypeRef iN_wavemask;
+ LLVMTypeRef iN_ballotmask;
LLVMValueRef i8_0;
LLVMValueRef i8_1;
enum chip_class chip_class;
enum radeon_family family;
+
unsigned wave_size;
+ unsigned ballot_mask_bits;
LLVMValueRef lds;
};
ac_llvm_context_init(struct ac_llvm_context *ctx,
struct ac_llvm_compiler *compiler,
enum chip_class chip_class, enum radeon_family family,
- enum ac_float_mode float_mode, unsigned wave_size);
+ enum ac_float_mode float_mode, unsigned wave_size,
+ unsigned ballot_mask_bits);
void
ac_llvm_context_dispose(struct ac_llvm_context *ctx);
switch (instr->intrinsic) {
case nir_intrinsic_ballot:
result = ac_build_ballot(&ctx->ac, get_src(ctx, instr->src[0]));
+ if (ctx->ac.ballot_mask_bits > ctx->ac.wave_size)
+ result = LLVMBuildZExt(ctx->ac.builder, result, ctx->ac.iN_ballotmask, "");
break;
case nir_intrinsic_read_invocation:
result = ac_build_readlane(&ctx->ac, get_src(ctx, instr->src[0]),
AC_FLOAT_MODE_DEFAULT;
ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class,
- options->family, float_mode, options->wave_size);
+ options->family, float_mode, options->wave_size,
+ options->wave_size);
ctx.context = ctx.ac.context;
radv_nir_shader_info_init(&shader_info->info);
AC_FLOAT_MODE_DEFAULT;
ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class,
- options->family, float_mode, 64);
+ options->family, float_mode, 64, 64);
ctx.context = ctx.ac.context;
ctx.is_gs_copy_shader = true;
si_nir_opts(sel->nir);
si_nir_scan_shader(sel->nir, &sel->info);
- si_lower_nir(sel, sscreen->compute_wave_size);
+ si_lower_nir(sel);
}
/* Store the declared LDS size into tgsi_shader_info for the shader
static void si_init_shader_ctx(struct si_shader_context *ctx,
struct si_screen *sscreen,
struct ac_llvm_compiler *compiler,
- unsigned wave_size);
+ unsigned wave_size,
+ bool nir);
static void si_llvm_emit_barrier(const struct lp_build_tgsi_action *action,
struct lp_build_tgsi_context *bld_base,
shader->is_gs_copy_shader = true;
si_init_shader_ctx(&ctx, sscreen, compiler,
- si_get_wave_size(sscreen, PIPE_SHADER_VERTEX, false, false));
+ si_get_wave_size(sscreen, PIPE_SHADER_VERTEX, false, false),
+ false);
ctx.shader = shader;
ctx.type = PIPE_SHADER_VERTEX;
static void si_init_shader_ctx(struct si_shader_context *ctx,
struct si_screen *sscreen,
struct ac_llvm_compiler *compiler,
- unsigned wave_size)
+ unsigned wave_size,
+ bool nir)
{
struct lp_build_tgsi_context *bld_base;
- si_llvm_context_init(ctx, sscreen, compiler, wave_size);
+ si_llvm_context_init(ctx, sscreen, compiler, wave_size,
+ nir ? 64 : wave_size);
bld_base = &ctx->bld_base;
bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
si_dump_streamout(&sel->so);
}
- si_init_shader_ctx(&ctx, sscreen, compiler, si_get_shader_wave_size(shader));
+ si_init_shader_ctx(&ctx, sscreen, compiler, si_get_shader_wave_size(shader),
+ sel->nir != NULL);
si_llvm_context_set_ir(&ctx, shader);
memset(shader->info.vs_output_param_offset, AC_EXP_PARAM_UNDEFINED,
struct si_shader_context ctx;
si_init_shader_ctx(&ctx, sscreen, compiler,
si_get_wave_size(sscreen, type, shader.key.as_ngg,
- shader.key.as_es));
+ shader.key.as_es),
+ false);
ctx.shader = &shader;
ctx.type = type;
void si_nir_scan_tess_ctrl(const struct nir_shader *nir,
struct tgsi_tessctrl_info *out);
void si_nir_lower_ps_inputs(struct nir_shader *nir);
-void si_lower_nir(struct si_shader_selector *sel, unsigned wave_size);
+void si_lower_nir(struct si_shader_selector *sel);
void si_nir_opts(struct nir_shader *nir);
/* si_state_shaders.c */
void si_llvm_context_init(struct si_shader_context *ctx,
struct si_screen *sscreen,
struct ac_llvm_compiler *compiler,
- unsigned wave_size);
+ unsigned wave_size,
+ unsigned ballot_mask_bits);
void si_llvm_context_set_ir(struct si_shader_context *ctx,
struct si_shader *shader);
* Perform "lowering" operations on the NIR that are run once when the shader
* selector is created.
*/
-void
-si_lower_nir(struct si_shader_selector* sel, unsigned wave_size)
+void si_lower_nir(struct si_shader_selector *sel)
{
/* Adjust the driver location of inputs and outputs. The state tracker
* interprets them as slots, while the ac/nir backend interprets them
NIR_PASS_V(sel->nir, nir_lower_tex, &lower_tex_options);
const nir_lower_subgroups_options subgroups_options = {
- .subgroup_size = wave_size,
- .ballot_bit_size = wave_size,
+ .subgroup_size = 64,
+ .ballot_bit_size = 64,
.lower_to_scalar = true,
.lower_subgroup_masks = true,
.lower_vote_trivial = false,
void si_llvm_context_init(struct si_shader_context *ctx,
struct si_screen *sscreen,
struct ac_llvm_compiler *compiler,
- unsigned wave_size)
+ unsigned wave_size,
+ unsigned ballot_mask_bits)
{
struct lp_type type;
ac_llvm_context_init(&ctx->ac, compiler, sscreen->info.chip_class,
sscreen->info.family,
AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH,
- wave_size);
+ wave_size, ballot_mask_bits);
ctx->gallivm.context = ctx->ac.context;
ctx->gallivm.module = ctx->ac.module;
assert(thread_index < ARRAY_SIZE(sscreen->compiler));
compiler = &sscreen->compiler[thread_index];
- if (sel->nir) {
- /* TODO: GS always sets wave size = default. Legacy GS will have
- * incorrect subgroup_size and ballot_bit_size. */
- si_lower_nir(sel, si_get_wave_size(sscreen, sel->type, true, false));
- }
+ if (sel->nir)
+ si_lower_nir(sel);
/* Compile the main shader part for use with a prolog and/or epilog.
* If this fails, the driver will try to compile a monolithic shader