Mesa (main): zink: set primitive restart with extended dynamic state2
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 03:51:13 UTC 2021
Module: Mesa
Branch: main
Commit: aab95f1bdf1f11738d985718558bb352e95fb68d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aab95f1bdf1f11738d985718558bb352e95fb68d
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri Jun 11 11:20:30 2021 -0400
zink: set primitive restart with extended dynamic state2
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12585>
---
src/gallium/drivers/zink/zink_context.c | 1 +
src/gallium/drivers/zink/zink_context.h | 1 +
src/gallium/drivers/zink/zink_draw.cpp | 13 ++++++++++---
src/gallium/drivers/zink/zink_pipeline.c | 30 +++++++++++++++++-------------
src/gallium/drivers/zink/zink_pipeline.h | 6 +++---
src/gallium/drivers/zink/zink_program.c | 6 ++++++
6 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 7f0c60cd738..eea5d72eaa3 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -3508,6 +3508,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
_mesa_hash_table_init(&ctx->batch_states, ctx, NULL, _mesa_key_pointer_equal);
ctx->gfx_pipeline_state.have_EXT_extended_dynamic_state = screen->info.have_EXT_extended_dynamic_state;
+ ctx->gfx_pipeline_state.have_EXT_extended_dynamic_state2 = screen->info.have_EXT_extended_dynamic_state2;
slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
slab_create_child(&ctx->transfer_pool_unsync, &screen->transfer_pool);
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index 1abf833faf3..4a58dadd945 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -317,6 +317,7 @@ struct zink_context {
bool gfx_dirty;
bool is_device_lost;
+ bool primitive_restart;
bool vertex_state_changed : 1;
bool blend_state_changed : 1;
bool rast_state_changed : 1;
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index 93f94e11a84..9a1ecb1cd26 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -455,9 +455,11 @@ zink_draw_vbo(struct pipe_context *pctx,
}
ctx->gfx_prim_mode = mode;
- if (ctx->gfx_pipeline_state.primitive_restart != dinfo->primitive_restart)
- ctx->gfx_pipeline_state.dirty = true;
- ctx->gfx_pipeline_state.primitive_restart = dinfo->primitive_restart;
+ if (!HAS_DYNAMIC_STATE2) {
+ if (ctx->gfx_pipeline_state.primitive_restart != dinfo->primitive_restart)
+ ctx->gfx_pipeline_state.dirty = true;
+ ctx->gfx_pipeline_state.primitive_restart = dinfo->primitive_restart;
+ }
unsigned index_offset = 0;
unsigned index_size = dinfo->index_size;
@@ -684,6 +686,11 @@ zink_draw_vbo(struct pipe_context *pctx,
screen->vk.CmdSetPrimitiveTopologyEXT(batch->state->cmdbuf, zink_primitive_topology(mode));
}
+ if (HAS_DYNAMIC_STATE2 && (BATCH_CHANGED || ctx->primitive_restart != dinfo->primitive_restart)) {
+ screen->vk.CmdSetPrimitiveRestartEnableEXT(batch->state->cmdbuf, dinfo->primitive_restart);
+ ctx->primitive_restart = dinfo->primitive_restart;
+ }
+
if (zink_program_has_descriptors(&ctx->curr_program->base))
screen->descriptors_update(ctx, false);
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index e7e4523497f..e0dd175a55f 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -73,19 +73,21 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
VkPipelineInputAssemblyStateCreateInfo primitive_state = {0};
primitive_state.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
primitive_state.topology = primitive_topology;
- switch (primitive_topology) {
- case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
- case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
- case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
- case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
- case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
- case VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
- if (state->primitive_restart)
- debug_printf("restart_index set with unsupported primitive topology %u\n", primitive_topology);
- primitive_state.primitiveRestartEnable = VK_FALSE;
- break;
- default:
- primitive_state.primitiveRestartEnable = state->primitive_restart ? VK_TRUE : VK_FALSE;
+ if (!screen->info.have_EXT_extended_dynamic_state2) {
+ switch (primitive_topology) {
+ case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+ case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+ case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+ case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+ case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+ case VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+ if (state->primitive_restart)
+ debug_printf("restart_index set with unsupported primitive topology %u\n", primitive_topology);
+ primitive_state.primitiveRestartEnable = VK_FALSE;
+ break;
+ default:
+ primitive_state.primitiveRestartEnable = state->primitive_restart ? VK_TRUE : VK_FALSE;
+ }
}
VkPipelineColorBlendAttachmentState blend_att[PIPE_MAX_COLOR_BUFS];
@@ -195,6 +197,8 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
if (screen->info.have_EXT_vertex_input_dynamic_state) {
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VERTEX_INPUT_EXT;
}
+ if (screen->info.have_EXT_extended_dynamic_state2)
+ dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT;
VkPipelineRasterizationLineStateCreateInfoEXT rast_line_state;
if (screen->info.have_EXT_line_rasterization) {
diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h
index 18784e9e9dc..1f619a179f2 100644
--- a/src/gallium/drivers/zink/zink_pipeline.h
+++ b/src/gallium/drivers/zink/zink_pipeline.h
@@ -51,8 +51,6 @@ struct zink_gfx_pipeline_state {
unsigned num_viewports;
- bool primitive_restart;
-
/* Pre-hashed value for table lookup, invalid when zero.
* Members after this point are not included in pipeline state hash key */
uint32_t hash;
@@ -60,6 +58,8 @@ struct zink_gfx_pipeline_state {
struct zink_depth_stencil_alpha_hw_state *depth_stencil_alpha_state; //non-dynamic state
VkFrontFace front_face;
+
+ bool primitive_restart; //dynamic state2
VkShaderModule modules[PIPE_SHADER_TYPES - 1];
uint32_t module_hash;
@@ -75,7 +75,7 @@ struct zink_gfx_pipeline_state {
uint32_t vertex_strides[PIPE_MAX_ATTRIBS];
bool sample_locations_enabled;
bool have_EXT_extended_dynamic_state;
-
+ bool have_EXT_extended_dynamic_state2;
VkPipeline pipeline;
uint8_t patch_vertices;
unsigned idx : 8;
diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c
index 748a6b419d3..597e325711a 100644
--- a/src/gallium/drivers/zink/zink_program.c
+++ b/src/gallium/drivers/zink/zink_program.c
@@ -309,6 +309,8 @@ hash_gfx_pipeline_state(const void *key)
{
const struct zink_gfx_pipeline_state *state = key;
uint32_t hash = _mesa_hash_data(key, offsetof(struct zink_gfx_pipeline_state, hash));
+ if (!state->have_EXT_extended_dynamic_state2)
+ hash = XXH32(&state->primitive_restart, 1, hash);
if (state->have_EXT_extended_dynamic_state)
return hash;
return XXH32(&state->depth_stencil_alpha_state, sizeof(void*), hash);
@@ -337,6 +339,10 @@ equals_gfx_pipeline_state(const void *a, const void *b)
memcmp(sa->depth_stencil_alpha_state, sb->depth_stencil_alpha_state, sizeof(struct zink_depth_stencil_alpha_hw_state)))
return false;
}
+ if (!sa->have_EXT_extended_dynamic_state2) {
+ if (sa->primitive_restart != sb->primitive_restart)
+ return false;
+ }
return !memcmp(sa->modules, sb->modules, sizeof(sa->modules)) &&
!memcmp(a, b, offsetof(struct zink_gfx_pipeline_state, hash));
}
More information about the mesa-commit
mailing list