Skip to content

Commit

Permalink
When cloning a NIR shader that was missing the FRAG0/COLOR output, av…
Browse files Browse the repository at this point in the history
…oid adding again the output variable if one is already present. This was causing DXIL validation to fail due to the duplicate SV_Target output parameter
  • Loading branch information
aerisarn committed Feb 12, 2024
1 parent 4054799 commit efcd556
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gallium/drivers/d3d12/d3d12_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,8 +1238,9 @@ select_shader_variant(struct d3d12_selection_context *sel_ctx, d3d12_shader_sele
}

if (key.fs.missing_dual_src_outputs) {
NIR_PASS_V(new_nir_variant, d3d12_add_missing_dual_src_target,
key.fs.missing_dual_src_outputs);
if (d3d12_is_missing_dual_src_target(new_nir_variant)) {
NIR_PASS_V(new_nir_variant, d3d12_add_missing_dual_src_target, key.fs.missing_dual_src_outputs);
}
} else if (key.fs.frag_result_color_lowering) {
NIR_PASS_V(new_nir_variant, nir_lower_fragcolor,
key.fs.frag_result_color_lowering);
Expand Down
10 changes: 10 additions & 0 deletions src/gallium/drivers/d3d12/d3d12_nir_passes.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,16 @@ d3d12_lower_state_vars(nir_shader *nir, struct d3d12_shader *shader)
return progress;
}

bool
d3d12_is_missing_dual_src_target(struct nir_shader *s)
{
nir_foreach_variable_with_modes (var, s, nir_var_shader_out) {
if (var->data.location == FRAG_RESULT_DATA0)
return false;
}
return true;
}

void
d3d12_add_missing_dual_src_target(struct nir_shader *s,
unsigned missing_mask)
Expand Down
3 changes: 3 additions & 0 deletions src/gallium/drivers/d3d12/d3d12_nir_passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ d3d12_lower_compute_state_vars(nir_shader *nir);
void
d3d12_lower_uint_cast(nir_shader *nir, bool is_signed);

bool
d3d12_is_missing_dual_src_target(struct nir_shader *s);

void
d3d12_add_missing_dual_src_target(struct nir_shader *s,
unsigned missing_mask);
Expand Down

0 comments on commit efcd556

Please sign in to comment.