From 6d3863b41b16b4d71ce05b3701991c7bc2e56f76 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 10 Feb 2025 10:24:14 -0600 Subject: [PATCH] nvk: Fix scissor bounds This code is old, copied from the old nouveau GL driver. As of Pascal, we have have 32k images so we need 32k scissors as well. Use the max_image_dimension() helper instead of hard-coding it. Cc: mesa-stable Part-of: (cherry picked from commit 6f64962f273c901fd92ef1e012171e5fe2abbf7d) --- .pick_status.json | 2 +- src/nouveau/vulkan/nvk_cmd_draw.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 818290f11bd..62012118de6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -354,7 +354,7 @@ "description": "nvk: Fix scissor bounds", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 27945d97151..65f4dde14f6 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -1781,7 +1781,8 @@ nvk_flush_ts_state(struct nvk_cmd_buffer *cmd) static void nvk_flush_vp_state(struct nvk_cmd_buffer *cmd) { - const struct nvk_device *dev = nvk_cmd_buffer_device(cmd); + struct nvk_device *dev = nvk_cmd_buffer_device(cmd); + struct nvk_physical_device *pdev = nvk_device_physical(dev); const struct vk_dynamic_graphics_state *dyn = &cmd->vk.dynamic_graphics_state; @@ -1890,13 +1891,16 @@ nvk_flush_vp_state(struct nvk_cmd_buffer *cmd) } if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_SCISSORS)) { + const uint32_t sr_max = + nvk_image_max_dimension(&pdev->info, VK_IMAGE_TYPE_2D); + for (unsigned i = 0; i < dyn->vp.scissor_count; i++) { const VkRect2D *s = &dyn->vp.scissors[i]; - const uint32_t xmin = MIN2(16384, s->offset.x); - const uint32_t xmax = MIN2(16384, s->offset.x + s->extent.width); - const uint32_t ymin = MIN2(16384, s->offset.y); - const uint32_t ymax = MIN2(16384, s->offset.y + s->extent.height); + const uint32_t xmin = MIN2(sr_max, s->offset.x); + const uint32_t xmax = MIN2(sr_max, s->offset.x + s->extent.width); + const uint32_t ymin = MIN2(sr_max, s->offset.y); + const uint32_t ymax = MIN2(sr_max, s->offset.y + s->extent.height); P_MTHD(p, NV9097, SET_SCISSOR_ENABLE(i)); P_NV9097_SET_SCISSOR_ENABLE(p, i, V_TRUE);