mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-31 22:50:08 +01:00
gallium/draw: Enable polygon stipple NIR helpers to generate bool1 or bool32 Booleans
It appears that only softpipe, llvmpipe, and d3d12 hit any of this code. If some NIR-to-TGSI driver that doesn't have native integers (e.g., i915 or r300) wants to use this path in the future, it should be easy to add float32 support. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20869>
This commit is contained in:
parent
d3a95f0f71
commit
2f467fb154
4 changed files with 25 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue