Commit f99f7c06 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz 🏋 Committed by Marge Bot
Browse files

lavapipe: implement multidraw ext


Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Part-of: <mesa/mesa!11533>
parent be0e3445
......@@ -498,6 +498,36 @@ VKAPI_ATTR void VKAPI_CALL lvp_CmdDraw(
cmd_buf_queue(cmd_buffer, cmd);
}
VKAPI_ATTR void VKAPI_CALL lvp_CmdDrawMultiEXT(
VkCommandBuffer commandBuffer,
uint32_t drawCount,
const VkMultiDrawInfoEXT *pVertexInfo,
uint32_t instanceCount,
uint32_t firstInstance,
uint32_t stride)
{
LVP_FROM_HANDLE(lvp_cmd_buffer, cmd_buffer, commandBuffer);
struct lvp_cmd_buffer_entry *cmd;
uint32_t cmd_size = drawCount * sizeof(struct pipe_draw_start_count_bias);
cmd = cmd_buf_entry_alloc_size(cmd_buffer, cmd_size, LVP_CMD_DRAW);
if (!cmd)
return;
cmd->u.draw.instance_count = instanceCount;
cmd->u.draw.first_instance = firstInstance;
cmd->u.draw.draw_count = drawCount;
if (stride == sizeof(struct pipe_draw_start_count_bias))
memcpy(cmd->u.draw.draws, pVertexInfo, cmd_size);
else {
unsigned i = 0;
vk_foreach_multi_draw(draw, i, pVertexInfo, drawCount, stride)
memcpy(cmd->u.draw.draws, draw, sizeof(struct pipe_draw_start_count_bias));
}
cmd_buf_queue(cmd_buffer, cmd);
}
VKAPI_ATTR void VKAPI_CALL lvp_CmdEndRenderPass2(
VkCommandBuffer commandBuffer,
const VkSubpassEndInfo* pSubpassEndInfo)
......@@ -752,6 +782,42 @@ VKAPI_ATTR void VKAPI_CALL lvp_CmdDrawIndexed(
cmd_buf_queue(cmd_buffer, cmd);
}
VKAPI_ATTR void VKAPI_CALL lvp_CmdDrawMultiIndexedEXT(
VkCommandBuffer commandBuffer,
uint32_t drawCount,
const VkMultiDrawIndexedInfoEXT *pIndexInfo,
uint32_t instanceCount,
uint32_t firstInstance,
uint32_t stride,
const int32_t *pVertexOffset)
{
LVP_FROM_HANDLE(lvp_cmd_buffer, cmd_buffer, commandBuffer);
struct lvp_cmd_buffer_entry *cmd;
uint32_t cmd_size = drawCount * sizeof(struct pipe_draw_start_count_bias);
cmd = cmd_buf_entry_alloc_size(cmd_buffer, cmd_size, LVP_CMD_DRAW_INDEXED);
if (!cmd)
return;
cmd->u.draw_indexed.instance_count = instanceCount;
cmd->u.draw_indexed.first_instance = firstInstance;
cmd->u.draw_indexed.draw_count = drawCount;
cmd->u.draw_indexed.vertex_offset_changes = !pVertexOffset;
if (stride == sizeof(struct pipe_draw_start_count_bias))
memcpy(cmd->u.draw_indexed.draws, pIndexInfo, cmd_size);
else {
unsigned i = 0;
vk_foreach_multi_draw_indexed(draw, i, pIndexInfo, drawCount, stride)
memcpy(cmd->u.draw_indexed.draws, draw, sizeof(struct pipe_draw_start_count_bias));
}
/* only the first member is read if vertex_offset_changes is true */
if (pVertexOffset)
cmd->u.draw_indexed.draws[0].index_bias = *pVertexOffset;
cmd->u.draw_indexed.calc_start = true;
cmd_buf_queue(cmd_buffer, cmd);
}
VKAPI_ATTR void VKAPI_CALL lvp_CmdDrawIndirect(
VkCommandBuffer commandBuffer,
VkBuffer _buffer,
......
......@@ -128,6 +128,7 @@ static const struct vk_device_extension_table lvp_device_extensions_supported =
.EXT_extended_dynamic_state = true,
.EXT_host_query_reset = true,
.EXT_index_type_uint8 = true,
.EXT_multi_draw = true,
.EXT_post_depth_coverage = true,
.EXT_private_data = true,
.EXT_sampler_filter_minmax = true,
......@@ -644,6 +645,11 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceFeatures2(
features->transformFeedbackPreservesProvokingVertex = true;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT: {
VkPhysicalDeviceMultiDrawFeaturesEXT *features = (VkPhysicalDeviceMultiDrawFeaturesEXT *)ext;
features->multiDraw = true;
break;
}
default:
break;
}
......@@ -968,6 +974,11 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceProperties2(
properties->transformFeedbackPreservesTriangleFanProvokingVertex = true;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT: {
VkPhysicalDeviceMultiDrawPropertiesEXT *props = (VkPhysicalDeviceMultiDrawPropertiesEXT *)ext;
props->maxMultiDrawCount = 2048;
break;
}
default:
break;
}
......
......@@ -2127,6 +2127,7 @@ static void handle_draw_indexed(struct lvp_cmd_buffer_entry *cmd,
cmd->u.draw_indexed.draws[i].start = (state->index_offset / state->index_size) + cmd->u.draw_indexed.draws[i].start;
cmd->u.draw_indexed.calc_start = false;
}
state->info.index_bias_varies = cmd->u.draw_indexed.vertex_offset_changes;
state->pctx->draw_vbo(state->pctx, &state->info, 0, NULL, cmd->u.draw_indexed.draws, cmd->u.draw_indexed.draw_count);
}
......
......@@ -755,6 +755,7 @@ struct lvp_cmd_draw_indexed {
uint32_t first_instance;
bool calc_start;
uint32_t draw_count;
bool vertex_offset_changes;
struct pipe_draw_start_count_bias draws[0];
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment