zink: move viewport count to zink_gfx_pipeline_state
this is part of the pipeline state (there's an extension for setting it
dynamically but we don't supprot that atm
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6349>
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 6ef4e8f..a0eaddf 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -348,7 +348,9 @@
ctx->viewport_states[start_slot + i] = state[i];
ctx->viewports[start_slot + i] = viewport;
}
- ctx->num_viewports = start_slot + num_viewports;
+ if (ctx->gfx_pipeline_state.num_viewports != start_slot + num_viewports)
+ ctx->gfx_pipeline_state.hash = 0;
+ ctx->gfx_pipeline_state.num_viewports = start_slot + num_viewports;
}
static void
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index a9c3b71..314aa5f 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -107,8 +107,6 @@
struct pipe_scissor_state scissor_states[PIPE_MAX_VIEWPORTS];
VkViewport viewports[PIPE_MAX_VIEWPORTS];
VkRect2D scissors[PIPE_MAX_VIEWPORTS];
- unsigned num_viewports;
-
struct pipe_vertex_buffer buffers[PIPE_MAX_ATTRIBS];
uint32_t buffers_enabled_mask;
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index b103d08..50db38f 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -393,9 +393,9 @@
}
}
- vkCmdSetViewport(batch->cmdbuf, 0, ctx->num_viewports, ctx->viewports);
+ vkCmdSetViewport(batch->cmdbuf, 0, ctx->gfx_pipeline_state.num_viewports, ctx->viewports);
if (ctx->rast_state->base.scissor)
- vkCmdSetScissor(batch->cmdbuf, 0, ctx->num_viewports, ctx->scissors);
+ vkCmdSetScissor(batch->cmdbuf, 0, ctx->gfx_pipeline_state.num_viewports, ctx->scissors);
else if (ctx->fb_state.width && ctx->fb_state.height) {
VkRect2D fb_scissor = {};
fb_scissor.extent.width = ctx->fb_state.width;
diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h
index 25c9db3..4b14f00 100644
--- a/src/gallium/drivers/zink/zink_pipeline.h
+++ b/src/gallium/drivers/zink/zink_pipeline.h
@@ -54,6 +54,8 @@
VkSampleMask sample_mask;
uint8_t rast_samples;
+ unsigned num_viewports;
+
bool primitive_restart;
/* Pre-hashed value for table lookup, invalid when zero.