Mesa (main): anv,nir: Use sample_pos_or_center in lower_wpos_center
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Dec 17 16:32:41 UTC 2021
Module: Mesa
Branch: main
Commit: deec7a590b32d374032c4039e1b14e9a09a5e67d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=deec7a590b32d374032c4039e1b14e9a09a5e67d
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Thu Dec 2 14:41:41 2021 -0600
anv,nir: Use sample_pos_or_center in lower_wpos_center
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14198>
---
src/compiler/nir/nir.h | 2 +-
src/compiler/nir/nir_lower_wpos_center.c | 32 +++++++++++++-------------------
src/intel/vulkan/anv_pipeline.c | 3 +--
3 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f3aba96a0c7..44d62e8a228 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -5016,7 +5016,7 @@ typedef struct nir_lower_wpos_ytransform_options {
bool nir_lower_wpos_ytransform(nir_shader *shader,
const nir_lower_wpos_ytransform_options *options);
-bool nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading);
+bool nir_lower_wpos_center(nir_shader *shader);
bool nir_lower_pntc_ytransform(nir_shader *shader,
const gl_state_index16 clipplane_state_tokens[][STATE_LENGTH]);
diff --git a/src/compiler/nir/nir_lower_wpos_center.c b/src/compiler/nir/nir_lower_wpos_center.c
index a9a6161a2a8..4e541afb805 100644
--- a/src/compiler/nir/nir_lower_wpos_center.c
+++ b/src/compiler/nir/nir_lower_wpos_center.c
@@ -45,8 +45,7 @@
*/
static void
-update_fragcoord(nir_builder *b, nir_intrinsic_instr *intr,
- const bool for_sample_shading)
+update_fragcoord(nir_builder *b, nir_intrinsic_instr *intr)
{
nir_ssa_def *wpos = &intr->dest.ssa;
@@ -54,26 +53,21 @@ update_fragcoord(nir_builder *b, nir_intrinsic_instr *intr,
b->cursor = nir_after_instr(&intr->instr);
- if (!for_sample_shading) {
- wpos = nir_fadd(b, wpos, nir_imm_vec4(b, 0.5f, 0.5f, 0.0f, 0.0f));
- } else {
- nir_ssa_def *spos = nir_load_sample_pos(b);
-
- wpos = nir_fadd(b, wpos,
- nir_vec4(b,
- nir_channel(b, spos, 0),
- nir_channel(b, spos, 1),
- nir_imm_float(b, 0.0f),
- nir_imm_float(b, 0.0f)));
- }
+ nir_ssa_def *spos = nir_load_sample_pos_or_center(b);
+
+ wpos = nir_fadd(b, wpos,
+ nir_vec4(b,
+ nir_channel(b, spos, 0),
+ nir_channel(b, spos, 1),
+ nir_imm_float(b, 0.0f),
+ nir_imm_float(b, 0.0f)));
nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, wpos,
wpos->parent_instr);
}
static bool
-lower_wpos_center_block(nir_builder *b, nir_block *block,
- const bool for_sample_shading)
+lower_wpos_center_block(nir_builder *b, nir_block *block)
{
bool progress = false;
@@ -81,7 +75,7 @@ lower_wpos_center_block(nir_builder *b, nir_block *block,
if (instr->type == nir_instr_type_intrinsic) {
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
if (intr->intrinsic == nir_intrinsic_load_frag_coord) {
- update_fragcoord(b, intr, for_sample_shading);
+ update_fragcoord(b, intr);
progress = true;
}
}
@@ -91,7 +85,7 @@ lower_wpos_center_block(nir_builder *b, nir_block *block,
}
bool
-nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading)
+nir_lower_wpos_center(nir_shader *shader)
{
bool progress = false;
nir_builder b;
@@ -103,7 +97,7 @@ nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading)
nir_builder_init(&b, function->impl);
nir_foreach_block(block, function->impl) {
- progress = lower_wpos_center_block(&b, block, for_sample_shading) ||
+ progress = lower_wpos_center_block(&b, block) ||
progress;
}
nir_metadata_preserve(function->impl, nir_metadata_block_index |
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index b9db1c06d6a..0ece06c92d8 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -802,8 +802,7 @@ anv_pipeline_lower_nir(struct anv_pipeline *pipeline,
if (nir->info.fs.uses_sample_shading)
anv_pipeline_to_graphics(pipeline)->sample_shading_enable = true;
- NIR_PASS_V(nir, nir_lower_wpos_center,
- anv_pipeline_to_graphics(pipeline)->sample_shading_enable);
+ NIR_PASS_V(nir, nir_lower_wpos_center);
NIR_PASS_V(nir, nir_lower_input_attachments,
&(nir_input_attachment_options) {
.use_fragcoord_sysval = true,
More information about the mesa-commit
mailing list