diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 1aff54afa95..e708c8adebb 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -147,7 +147,8 @@ generate_pstip_fs(struct pstip_stage *pstip) } else { pstip_fs.ir.nir = nir_shader_clone(NULL, orig_fs->ir.nir); nir_lower_pstipple_fs(pstip_fs.ir.nir, - &pstip->fs->sampler_unit, 0, wincoord_file == TGSI_FILE_SYSTEM_VALUE); + &pstip->fs->sampler_unit, 0, wincoord_file == TGSI_FILE_SYSTEM_VALUE, + nir_type_bool32); } assert(pstip->fs->sampler_unit < PIPE_MAX_SAMPLERS); diff --git a/src/gallium/auxiliary/nir/nir_draw_helpers.c b/src/gallium/auxiliary/nir/nir_draw_helpers.c index 96cd395d44d..60fcf7dd941 100644 --- a/src/gallium/auxiliary/nir/nir_draw_helpers.c +++ b/src/gallium/auxiliary/nir/nir_draw_helpers.c @@ -44,6 +44,7 @@ typedef struct { bool fs_pos_is_sysval; nir_variable *stip_tex; nir_ssa_def *fragcoord; + nir_alu_type bool_type; } lower_pstipple; static nir_ssa_def * @@ -90,6 +91,18 @@ nir_lower_pstipple_block(nir_block *block, nir_builder_instr_insert(b, &tex->instr); nir_ssa_def *condition = nir_f2b32(b, nir_channel(b, &tex->dest.ssa, 3)); + + switch (state->bool_type) { + case nir_type_bool1: + condition = nir_f2b(b, nir_channel(b, &tex->dest.ssa, 3)); + break; + case nir_type_bool32: + condition = nir_f2b32(b, nir_channel(b, &tex->dest.ssa, 3)); + break; + default: + unreachable("Invalid Boolean type."); + } + nir_discard_if(b, condition); b->shader->info.fs.uses_discard = true; } @@ -110,12 +123,18 @@ void nir_lower_pstipple_fs(struct nir_shader *shader, unsigned *samplerUnitOut, unsigned fixedUnit, - bool fs_pos_is_sysval) + bool fs_pos_is_sysval, + nir_alu_type bool_type) { lower_pstipple state = { .shader = shader, .fs_pos_is_sysval = fs_pos_is_sysval, + .bool_type = bool_type, }; + + assert(bool_type == nir_type_bool1 || + bool_type == nir_type_bool32); + if (shader->info.stage != MESA_SHADER_FRAGMENT) return; diff --git a/src/gallium/auxiliary/nir/nir_draw_helpers.h b/src/gallium/auxiliary/nir/nir_draw_helpers.h index ef6ffd79b20..966789c8803 100644 --- a/src/gallium/auxiliary/nir/nir_draw_helpers.h +++ b/src/gallium/auxiliary/nir/nir_draw_helpers.h @@ -35,7 +35,8 @@ void nir_lower_pstipple_fs(struct nir_shader *shader, unsigned *samplerUnitOut, unsigned fixedUnit, - bool fs_pos_is_sysval); + bool fs_pos_is_sysval, + nir_alu_type bool_type); void nir_lower_aaline_fs(struct nir_shader *shader, int *varying, diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp index 75681797225..78228e45f5d 100644 --- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp +++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp @@ -1112,7 +1112,7 @@ select_shader_variant(struct d3d12_selection_context *sel_ctx, d3d12_shader_sele { if (key.fs.polygon_stipple) { NIR_PASS_V(new_nir_variant, nir_lower_pstipple_fs, - &pstipple_binding, 0, false); + &pstipple_binding, 0, false, nir_type_bool1); nir_function_impl *impl = nir_shader_get_entrypoint(new_nir_variant); nir_shader_gather_info(new_nir_variant, impl);