mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2024-11-23 15:30:09 +00:00
zink: set primitive restart with extended dynamic state2
Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12585>
This commit is contained in:
parent
9c2fe8e621
commit
aab95f1bdf
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user