d3d12: Lower load_sample_pos to load_sample_pos_at_id
D3D doesn't have an intrinsic for loading the current sample's position, only for loading a specific sample's intrinsic. Fortunately, we can also just get the current sample. So do that. Reviewed-by: Sil Vilerino <sivileri@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
This commit is contained in:
@@ -1160,6 +1160,7 @@ d3d12_create_shader(struct d3d12_context *ctx,
|
||||
next ? next->current->nir->info.inputs_read : 0);
|
||||
} else {
|
||||
NIR_PASS_V(nir, nir_lower_fragcoord_wtrans);
|
||||
NIR_PASS_V(nir, d3d12_lower_sample_pos);
|
||||
dxil_sort_ps_outputs(nir);
|
||||
}
|
||||
|
||||
|
||||
@@ -857,3 +857,24 @@ d3d12_lower_triangle_strip(nir_shader *shader)
|
||||
nir_metadata_preserve(impl, nir_metadata_none);
|
||||
NIR_PASS_V(shader, nir_lower_var_copies);
|
||||
}
|
||||
|
||||
static bool
|
||||
is_sample_pos(const nir_instr *instr, const void *_data)
|
||||
{
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
return false;
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
return intr->intrinsic == nir_intrinsic_load_sample_pos;
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
lower_sample_pos(nir_builder *b, nir_instr *instr, void *_data)
|
||||
{
|
||||
return nir_load_sample_pos_from_id(b, 32, nir_load_sample_id(b));
|
||||
}
|
||||
|
||||
bool
|
||||
d3d12_lower_sample_pos(nir_shader *s)
|
||||
{
|
||||
return nir_shader_lower_instructions(s, is_sample_pos, lower_sample_pos, NULL);
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ d3d12_lower_triangle_strip(nir_shader *shader);
|
||||
bool
|
||||
d3d12_lower_image_casts(nir_shader *s, struct d3d12_image_format_conversion_info *info);
|
||||
|
||||
bool
|
||||
d3d12_lower_sample_pos(nir_shader *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user