v3dv: PrimitiveTopology is now dynamic

Note that although the topology affects the final shader, and it is
part of the v3d_fs_key (through is_points and is_lines), changing
dynamically the topology would not trigger a shader recompilation as
that would only needed if there was a topology class change. From
spec:

  "VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500

   If the bound graphics pipeline state was created with the
   VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the
   dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the
   primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of
   the same topology class as the pipeline
   VkPipelineInputAssemblyStateCreateInfo::topology state"

dynamicPrimitiveTopologyUnrestricted is defined at
VK_EXT_extended_dynamic_state3, so for now it is false. And even if in
the future we support that extension, it is really likely that we
would return False there.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27609>
This commit is contained in:
Alejandro Piñeiro 2024-03-31 13:40:55 +02:00 committed by Marge Bot
parent fbfb99cbc3
commit 2526f74ade
3 changed files with 14 additions and 8 deletions

View File

@ -1076,6 +1076,12 @@ static const enum mesa_prim vk_to_mesa_prim[] = {
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY] = MESA_PRIM_TRIANGLE_STRIP_ADJACENCY,
};
uint32_t
v3dv_pipeline_primitive(VkPrimitiveTopology vk_prim)
{
return v3d_hw_prim_type(vk_to_mesa_prim[vk_prim]);
}
static const enum pipe_logicop vk_to_pipe_logicop[] = {
[VK_LOGIC_OP_CLEAR] = PIPE_LOGICOP_CLEAR,
[VK_LOGIC_OP_AND] = PIPE_LOGICOP_AND,

View File

@ -2705,6 +2705,8 @@ v3dv_compute_ez_state(struct vk_dynamic_graphics_state *dyn,
enum v3dv_ez_state *ez_state,
bool *incompatible_ez_test);
uint32_t v3dv_pipeline_primitive(VkPrimitiveTopology vk_prim);
#if DETECT_OS_ANDROID
VkResult
v3dv_gralloc_to_drm_explicit_layout(struct u_gralloc *gralloc,

View File

@ -2612,13 +2612,9 @@ v3dX(cmd_buffer_emit_draw)(struct v3dv_cmd_buffer *cmd_buffer,
{
struct v3dv_job *job = cmd_buffer->state.job;
assert(job);
struct v3dv_cmd_buffer_state *state = &cmd_buffer->state;
struct v3dv_pipeline *pipeline = state->gfx.pipeline;
assert(pipeline);
uint32_t hw_prim_type = v3d_hw_prim_type(pipeline->topology);
const struct vk_dynamic_graphics_state *dyn =
&cmd_buffer->vk.dynamic_graphics_state;
uint32_t hw_prim_type = v3dv_pipeline_primitive(dyn->ia.primitive_topology);
if (info->first_instance > 0) {
v3dv_cl_ensure_space_with_branch(
@ -2773,7 +2769,9 @@ v3dX(cmd_buffer_emit_indexed_indirect)(struct v3dv_cmd_buffer *cmd_buffer,
assert(job);
const struct v3dv_pipeline *pipeline = cmd_buffer->state.gfx.pipeline;
uint32_t hw_prim_type = v3d_hw_prim_type(pipeline->topology);
const struct vk_dynamic_graphics_state *dyn =
&cmd_buffer->vk.dynamic_graphics_state;
uint32_t hw_prim_type = v3dv_pipeline_primitive(dyn->ia.primitive_topology);
uint8_t index_type = ffs(cmd_buffer->state.index_buffer.index_size) - 1;
v3dv_cl_ensure_space_with_branch(