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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33478>
(cherry picked from commit 6f64962f27)
This commit is contained in:
Faith Ekstrand 2025-02-10 10:24:14 -06:00 committed by Eric Engestrom
parent 6285eefd88
commit 6d3863b41b
2 changed files with 10 additions and 6 deletions

View file

@ -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

View file

@ -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);