hasvk: add restrictions for 3DSTATE_RASTER::AntiAliasingEnable
authorTapani Pälli <tapani.palli@intel.com>
Fri, 13 Jan 2023 13:52:00 +0000 (15:52 +0200)
committerEric Engestrom <eric@engestrom.ch>
Thu, 26 Jan 2023 15:40:33 +0000 (15:40 +0000)
Field must be disabled if any render targets have integer format.

Cc: mesa-stable
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20671>
(cherry picked from commit 58dd9d5134e280302cc5270d7cc5ecdbc49791de)

.pick_status.json
src/intel/vulkan_hasvk/anv_private.h
src/intel/vulkan_hasvk/genX_cmd_buffer.c
src/intel/vulkan_hasvk/gfx7_cmd_buffer.c
src/intel/vulkan_hasvk/gfx8_cmd_buffer.c

index 5822c87..2d96fc2 100644 (file)
         "description": "hasvk: add restrictions for 3DSTATE_RASTER::AntiAliasingEnable",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
index ba81eb6..0367cef 100644 (file)
@@ -74,6 +74,7 @@
 #include "vk_device.h"
 #include "vk_drm_syncobj.h"
 #include "vk_enum_defines.h"
+#include "vk_format.h"
 #include "vk_framebuffer.h"
 #include "vk_graphics_state.h"
 #include "vk_image.h"
@@ -2568,6 +2569,8 @@ struct anv_cmd_graphics_state {
    uint32_t index_offset;
 
    struct vk_sample_locations_state sample_locations;
+
+   bool has_uint_rt;
 };
 
 enum anv_depth_reg_mode {
@@ -3076,6 +3079,18 @@ anv_cmd_buffer_all_color_write_masked(const struct anv_cmd_buffer *cmd_buffer)
    return true;
 }
 
+static inline void
+anv_cmd_graphic_state_update_has_uint_rt(struct anv_cmd_graphics_state *state)
+{
+   state->has_uint_rt = false;
+   for (unsigned a = 0; a < state->color_att_count; a++) {
+      if (vk_format_is_int(state->color_att[a].vk_format)) {
+         state->has_uint_rt = true;
+         break;
+      }
+   }
+}
+
 #define ANV_DECL_GET_GRAPHICS_PROG_DATA_FUNC(prefix, stage)             \
 static inline const struct brw_##prefix##_prog_data *                   \
 get_##prefix##_prog_data(const struct anv_graphics_pipeline *pipeline)  \
index bd8df92..df815c5 100644 (file)
@@ -1723,6 +1723,8 @@ genX(BeginCommandBuffer)(
             inheritance_info->stencilAttachmentFormat;
 
          cmd_buffer->state.gfx.dirty |= ANV_CMD_DIRTY_RENDER_TARGETS;
+
+         anv_cmd_graphic_state_update_has_uint_rt(gfx);
       }
    }
 
@@ -6202,6 +6204,8 @@ void genX(CmdBeginRendering)(
       }
    }
 
+   anv_cmd_graphic_state_update_has_uint_rt(gfx);
+
    const struct anv_image_view *fsr_iview = NULL;
    const VkRenderingFragmentShadingRateAttachmentInfoKHR *fsr_att =
       vk_find_struct_const(pRenderingInfo->pNext,
index 5522179..45fe9e9 100644 (file)
@@ -80,8 +80,15 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
       uint32_t ms_rast_mode =
          genX(ms_rasterization_mode)(pipeline, dynamic_raster_mode);
 
+     /* From the Haswell PRM, Volume 2b, documentation for
+      * 3DSTATE_SF, "Antialiasing Enable":
+      *
+      * "This field must be disabled if any of the render targets
+      * have integer (UINT or SINT) surface format."
+      */
       bool aa_enable = anv_rasterization_aa_mode(dynamic_raster_mode,
-                                                 pipeline->line_mode);
+                                                 pipeline->line_mode) &&
+                       !cmd_buffer->state.gfx.has_uint_rt;
 
       uint32_t sf_dw[GENX(3DSTATE_SF_length)];
       struct GENX(3DSTATE_SF) sf = {
index 8972a0c..f0d28ac 100644 (file)
@@ -366,8 +366,20 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
                                pipeline->line_mode, dyn->rs.line.width,
                                &api_mode, &msaa_raster_enable);
 
-      bool aa_enable = anv_rasterization_aa_mode(dynamic_raster_mode,
-                                                 pipeline->line_mode);
+     /* From the Browadwell PRM, Volume 2, documentation for
+      * 3DSTATE_RASTER, "Antialiasing Enable":
+      *
+      * "This field must be disabled if any of the render targets
+      * have integer (UINT or SINT) surface format."
+      *
+      * Additionally internal documentation for Gfx12+ states:
+      *
+      * "This bit MUST not be set when NUM_MULTISAMPLES > 1 OR
+      *  FORCED_SAMPLE_COUNT > 1."
+      */
+      bool aa_enable =
+         anv_rasterization_aa_mode(dynamic_raster_mode, pipeline->line_mode) &&
+         !cmd_buffer->state.gfx.has_uint_rt;
 
       uint32_t raster_dw[GENX(3DSTATE_RASTER_length)];
       struct GENX(3DSTATE_RASTER) raster = {