radv: do not remove the PointSize built-in for polygon mode as points
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 12 Dec 2022 13:13:46 +0000 (14:13 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 13 Dec 2022 15:01:31 +0000 (15:01 +0000)
Determine if it can be removed when generating the graphics pipeline
key because of dynamic states.

Fixes new CTS dEQP-VK.rasterization.polygon_as_large_points.* and also
spec@!opengl 1.1@polygon-offset with Zink/RADV.

Cc: 22.3 mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20073>

src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_shader.h
src/gallium/drivers/zink/ci/zink-radv-fails.txt

index d25e0be17364b735ed8a87b92ba6d83961e5bc04..5b950aa861976121cf1520b6204dc8f2e0e3267d 100644 (file)
@@ -2179,16 +2179,9 @@ radv_remove_point_size(const struct radv_pipeline_key *pipeline_key,
    if (producer->xfb_info)
       return;
 
-   /* Do not remove PSIZ for vertex shaders when the topology is unknown. */
-   if (producer->info.stage == MESA_SHADER_VERTEX &&
-       pipeline_key->vs.topology == V_008958_DI_PT_NONE)
-      return;
-
    /* Do not remove PSIZ if the rasterization primitive uses points. */
    if (consumer->info.stage == MESA_SHADER_FRAGMENT &&
-       ((producer->info.stage == MESA_SHADER_VERTEX &&
-         pipeline_key->vs.topology == V_008958_DI_PT_POINTLIST) ||
-        (producer->info.stage == MESA_SHADER_TESS_EVAL && producer->info.tess.point_mode) ||
+       ((producer->info.stage == MESA_SHADER_TESS_EVAL && producer->info.tess.point_mode) ||
         (producer->info.stage == MESA_SHADER_GEOMETRY &&
          producer->info.gs.output_primitive == SHADER_PRIM_POINTS) ||
        (producer->info.stage == MESA_SHADER_MESH &&
@@ -2361,7 +2354,8 @@ radv_pipeline_link_shaders(const struct radv_device *device,
    /* Remove PSIZ from shaders when it's not needed.
     * This is typically produced by translation layers like Zink or D9VK.
     */
-   radv_remove_point_size(pipeline_key, producer, consumer);
+   if (pipeline_key->enable_remove_point_size)
+      radv_remove_point_size(pipeline_key, producer, consumer);
 
    if (nir_link_opt_varyings(producer, consumer)) {
       nir_validate_shader(producer, "after nir_link_opt_varyings");
@@ -2835,6 +2829,13 @@ radv_generate_graphics_pipeline_key(const struct radv_graphics_pipeline *pipelin
          (ngg_stage == VK_SHADER_STAGE_VERTEX_BIT || ngg_stage == VK_SHADER_STAGE_GEOMETRY_BIT);
    }
 
+   if (!(pipeline->dynamic_states & RADV_DYNAMIC_PRIMITIVE_TOPOLOGY) &&
+       state->ia && state->ia->primitive_topology != VK_PRIMITIVE_TOPOLOGY_POINT_LIST &&
+       !(pipeline->dynamic_states & RADV_DYNAMIC_POLYGON_MODE) &&
+       state->rs && state->rs->polygon_mode != VK_POLYGON_MODE_POINT) {
+      key.enable_remove_point_size = true;
+   }
+
    return key;
 }
 
index ad5de84154e89f1a8873aac14156626890c900c7..dc5d698325b4e6a3e3d208aabe66569421904381 100644 (file)
@@ -78,6 +78,7 @@ struct radv_pipeline_key {
    uint32_t dynamic_color_write_mask : 1;
    uint32_t dynamic_provoking_vtx_mode : 1;
    uint32_t tex_non_uniform : 1;
+   uint32_t enable_remove_point_size : 1;
 
    struct {
       uint32_t instance_rate_inputs;
index e448c025af9cc3e979b5ffc67e8b5f6df259eec9..909db7ef1705942359dd354f2f97137592598314 100644 (file)
@@ -380,7 +380,6 @@ spec@!opengl 1.1@polygon-mode-offset@config 6: Expected blue pixel in center,Fai
 spec@!opengl 1.1@polygon-mode-offset@config 6: Expected white pixel on right edge,Fail
 spec@!opengl 1.1@polygon-mode-offset@config 6: Expected white pixel on top edge,Fail
 spec@!opengl 1.1@polygon-mode-offset,Fail
-spec@!opengl 1.1@polygon-offset,Fail
 spec@!opengl 1.5@depth-tex-compare,Fail
 spec@!opengl 2.0@depth-tex-modes-glsl,Fail
 spec@!opengl 2.0@gl-2.0-edgeflag,Fail