From ad2e80ee534ee5067a28c63aa538c8e07ed2669d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Sun, 4 Sep 2022 19:12:21 +0300 Subject: [PATCH] anv: dynamic line rasterization mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This affects following packets: 3DSTATE_RASTER Signed-off-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_pipeline.c | 8 -------- src/intel/vulkan/anv_private.h | 15 ++++++++++++++- src/intel/vulkan/gfx8_cmd_buffer.c | 11 ++++++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 02bc258..0e1da28 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -2305,14 +2305,6 @@ anv_graphics_pipeline_init(struct anv_graphics_pipeline *pipeline, */ pipeline->rasterization_samples = state->ms != NULL ? state->ms->rasterization_samples : 1; - pipeline->line_mode = state->rs->line.mode; - if (pipeline->line_mode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT) { - if (pipeline->rasterization_samples > 1) { - pipeline->line_mode = VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT; - } else { - pipeline->line_mode = VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT; - } - } pipeline->patch_control_points = state->ts != NULL ? state->ts->patch_control_points : 0; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 700d06c..d1bcb1a 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2951,7 +2951,6 @@ struct anv_graphics_pipeline { /* These fields are required with dynamic primitive topology, * rasterization_samples used only with gen < 8. */ - VkLineRasterizationModeEXT line_mode; uint32_t patch_control_points; uint32_t rasterization_samples; @@ -3853,6 +3852,20 @@ anv_rasterization_aa_mode(VkPolygonMode raster_mode, return false; } +static inline VkLineRasterizationModeEXT +anv_line_rasterization_mode(VkLineRasterizationModeEXT line_mode, + unsigned rasterization_samples) +{ + if (line_mode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT) { + if (rasterization_samples > 1) { + return VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT; + } else { + return VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT; + } + } + return line_mode; +} + VkFormatFeatureFlags2 anv_get_image_format_features2(const struct intel_device_info *devinfo, VkFormat vk_format, diff --git a/src/intel/vulkan/gfx8_cmd_buffer.c b/src/intel/vulkan/gfx8_cmd_buffer.c index 3f0ecca..7ecf5cb 100644 --- a/src/intel/vulkan/gfx8_cmd_buffer.c +++ b/src/intel/vulkan/gfx8_cmd_buffer.c @@ -290,7 +290,8 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_FRONT_FACE) || BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_DEPTH_BIAS_ENABLE) || BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS) || - BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_POLYGON_MODE)) { + BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_POLYGON_MODE) || + BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_LINE_MODE)) { /* Take dynamic primitive topology in to account with * 3DSTATE_RASTER::APIMode * 3DSTATE_RASTER::DXMultisampleRasterizationEnable @@ -299,17 +300,21 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) uint32_t api_mode = 0; bool msaa_raster_enable = false; + VkLineRasterizationModeEXT line_mode = + anv_line_rasterization_mode(dyn->rs.line.mode, + pipeline->rasterization_samples); + VkPolygonMode dynamic_raster_mode = genX(raster_polygon_mode)(cmd_buffer->state.gfx.pipeline, dyn->rs.polygon_mode, dyn->ia.primitive_topology); genX(rasterization_mode)(dynamic_raster_mode, - pipeline->line_mode, dyn->rs.line.width, + line_mode, dyn->rs.line.width, &api_mode, &msaa_raster_enable); bool aa_enable = anv_rasterization_aa_mode(dynamic_raster_mode, - pipeline->line_mode); + line_mode); uint32_t raster_dw[GENX(3DSTATE_RASTER_length)]; struct GENX(3DSTATE_RASTER) raster = { -- 2.7.4