From 6f64962f273c901fd92ef1e012171e5fe2abbf7d 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: --- src/nouveau/vulkan/nvk_cmd_draw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index a92f11a2787..2363485f521 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -1782,7 +1782,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; @@ -1891,13 +1892,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);