Mesa (main): radv: allow to force per-vertex VRS if the config file is present

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 16 08:49:13 UTC 2022


Module: Mesa
Branch: main
Commit: 103699677bdb50d667d63890da53df814dfceca3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=103699677bdb50d667d63890da53df814dfceca3

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Fri Feb 11 09:30:39 2022 +0100

radv: allow to force per-vertex VRS if the config file is present

This is needed to add the primitive shading rate output to the vertex
or geometry shaders, even if the default value is 1x1.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14713>

---

 src/amd/vulkan/radv_device.c   | 8 +++++---
 src/amd/vulkan/radv_pipeline.c | 5 +++--
 src/amd/vulkan/radv_private.h  | 3 +++
 src/amd/vulkan/radv_shader.h   | 2 +-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 26fed37adac..a85c7db68a0 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -3359,19 +3359,21 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr
 
          device->force_vrs = radv_parse_force_vrs_config_file(file);
 
-         if (!radv_device_init_notifier(device)) {
+         if (radv_device_init_notifier(device)) {
+            device->force_vrs_enabled = true;
+         } else {
             fprintf(stderr, "radv: Failed to initialize the notifier for RADV_FORCE_VRS_CONFIG_FILE!\n");
          }
       } else if (getenv("RADV_FORCE_VRS")) {
          const char *vrs_rates = getenv("RADV_FORCE_VRS");
 
          device->force_vrs = radv_parse_vrs_rates(vrs_rates);
+         device->force_vrs_enabled = device->force_vrs != RADV_FORCE_VRS_1x1;
       }
    }
 
    device->adjust_frag_coord_z =
-      (device->vk.enabled_extensions.KHR_fragment_shading_rate ||
-       device->force_vrs != RADV_FORCE_VRS_1x1) &&
+      (device->vk.enabled_extensions.KHR_fragment_shading_rate || device->force_vrs_enabled) &&
       (device->physical_device->rad_info.family == CHIP_SIENNA_CICHLID ||
        device->physical_device->rad_info.family == CHIP_NAVY_FLOUNDER ||
        device->physical_device->rad_info.family == CHIP_VANGOGH);
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index a7de117e9b5..f9973b8ea9f 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -2984,7 +2984,8 @@ radv_generate_graphics_pipeline_key(const struct radv_pipeline *pipeline,
    if (pipeline->device->instance->enable_mrt_output_nan_fixup)
       key.ps.enable_mrt_output_nan_fixup = true;
 
-   key.ps.force_vrs = pipeline->device->force_vrs;
+
+   key.ps.force_vrs_enabled = pipeline->device->force_vrs_enabled;
 
    if (pipeline->device->instance->debug_flags & RADV_DEBUG_INVARIANT_GEOM)
       key.invariant_geom = true;
@@ -3664,7 +3665,7 @@ radv_consider_force_vrs(const struct radv_pipeline *pipeline, bool noop_fs, nir_
 {
    struct radv_device *device = pipeline->device;
 
-   if (device->force_vrs == RADV_FORCE_VRS_1x1)
+   if (!device->force_vrs_enabled)
       return false;
 
    /* Only VS and GS are supported for now. */
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 39b006ed838..22c202fab63 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -877,6 +877,9 @@ struct radv_device {
    struct radv_shader_prolog *instance_rate_vs_prologs[816];
 
    simple_mtx_t trace_mtx;
+
+   /* Whether per-vertex VRS is forced. */
+   bool force_vrs_enabled;
 };
 
 struct radv_device_memory {
diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h
index 61323641b67..d34781e729f 100644
--- a/src/amd/vulkan/radv_shader.h
+++ b/src/amd/vulkan/radv_shader.h
@@ -89,7 +89,7 @@ struct radv_pipeline_key {
 
       bool lower_discard_to_demote;
       bool enable_mrt_output_nan_fixup;
-      uint8_t force_vrs;
+      bool force_vrs_enabled;
    } ps;
 
    struct {



More information about the mesa-commit mailing list