mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
microsoft/spirv_to_dxil: Make sure the SampleMask is a uint
DXIL doesn't like when SV_Coverage (AKA SampleMask in DXIL) is a signed integer. Fix the type while we're in the NIR domain. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14765>
This commit is contained in:
parent
7e56d8c393
commit
ef47a6800b
2 changed files with 43 additions and 24 deletions
|
|
@ -420,30 +420,9 @@ Test:SpvModuleScopeVarParserTest_SampleMask_In_U32_AccessChain.spvasm:main|Fragm
|
|||
Test:SpvModuleScopeVarParserTest_SampleMask_In_U32_CopyObject.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_In_U32_Direct.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_In_WithStride.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_I32_AccessChain.spvasm:main|Fragment: Fail
|
||||
DXIL: SV_Coverage must be uint
|
||||
|
||||
Validation failed.
|
||||
|
||||
Failed to validate DXIL
|
||||
|
||||
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_I32_CopyObject.spvasm:main|Fragment: Fail
|
||||
DXIL: SV_Coverage must be uint
|
||||
|
||||
Validation failed.
|
||||
|
||||
Failed to validate DXIL
|
||||
|
||||
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_I32_Direct.spvasm:main|Fragment: Fail
|
||||
DXIL: SV_Coverage must be uint
|
||||
|
||||
Validation failed.
|
||||
|
||||
Failed to validate DXIL
|
||||
|
||||
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_I32_AccessChain.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_I32_CopyObject.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_I32_Direct.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_U32_AccessChain.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_U32_CopyObject.spvasm:main|Fragment: Pass
|
||||
Test:SpvModuleScopeVarParserTest_SampleMask_Out_U32_Direct.spvasm:main|Fragment: Pass
|
||||
|
|
|
|||
|
|
@ -475,6 +475,45 @@ dxil_spirv_nir_discard_point_size_var(nir_shader *shader)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
fix_sample_mask_type(struct nir_builder *builder, nir_instr *instr,
|
||||
void *cb_data)
|
||||
{
|
||||
struct dxil_spirv_runtime_conf *conf =
|
||||
(struct dxil_spirv_runtime_conf *)cb_data;
|
||||
|
||||
if (instr->type != nir_instr_type_deref)
|
||||
return false;
|
||||
|
||||
nir_deref_instr *deref = nir_instr_as_deref(instr);
|
||||
nir_variable *var =
|
||||
deref->deref_type == nir_deref_type_var ? deref->var : NULL;
|
||||
|
||||
if (!var || var->data.mode != nir_var_shader_out ||
|
||||
var->data.location != FRAG_RESULT_SAMPLE_MASK ||
|
||||
deref->type == glsl_uint_type())
|
||||
return false;
|
||||
|
||||
assert(glsl_without_array(deref->type) == glsl_int_type());
|
||||
deref->type = glsl_uint_type();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
dxil_spirv_nir_fix_sample_mask_type(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_variable_with_modes(var, shader, nir_var_shader_out) {
|
||||
if (var->data.location == FRAG_RESULT_SAMPLE_MASK &&
|
||||
var->type != glsl_uint_type()) {
|
||||
var->type = glsl_uint_type();
|
||||
}
|
||||
}
|
||||
|
||||
return nir_shader_instructions_pass(shader, fix_sample_mask_type,
|
||||
nir_metadata_all, NULL);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
spirv_to_dxil(const uint32_t *words, size_t word_count,
|
||||
struct dxil_spirv_specialization *specializations,
|
||||
|
|
@ -669,6 +708,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count,
|
|||
nir_lower_tex_options lower_tex_options = {0};
|
||||
NIR_PASS_V(nir, nir_lower_tex, &lower_tex_options);
|
||||
|
||||
NIR_PASS_V(nir, dxil_spirv_nir_fix_sample_mask_type);
|
||||
NIR_PASS_V(nir, dxil_nir_lower_atomics_to_dxil);
|
||||
NIR_PASS_V(nir, dxil_nir_split_clip_cull_distance);
|
||||
NIR_PASS_V(nir, dxil_nir_lower_loads_stores_to_dxil);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue