Commit 068a3bf0 authored by Marek Olšák's avatar Marek Olšák
Browse files

util: move and adjust the vertex upload heuristic equation from u_vbuf



This will also be used by glthread.

The new equation is optimized for glthread.
Reviewed-by: Pierre-Eric Pelloux-Prayer's avatarPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tested-by: Marge Bot <mesa/mesa!4466>
Part-of: <mesa/mesa!4466>
parent d9cb0ec5
...@@ -1433,8 +1433,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info) ...@@ -1433,8 +1433,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
* performance. */ * performance. */
if (!info->indirect && if (!info->indirect &&
!new_info.primitive_restart && !new_info.primitive_restart &&
num_vertices > new_info.count * 4 && util_is_vbo_upload_ratio_too_large(new_info.count, num_vertices) &&
new_info.count > 32 &&
!u_vbuf_mapping_vertex_buffer_blocks(mgr)) { !u_vbuf_mapping_vertex_buffer_blocks(mgr)) {
unroll_indices = TRUE; unroll_indices = TRUE;
user_vb_mask &= ~(mgr->nonzero_stride_vb_mask & user_vb_mask &= ~(mgr->nonzero_stride_vb_mask &
......
...@@ -783,7 +783,25 @@ util_fpstate_set_denorms_to_zero(unsigned current_fpstate); ...@@ -783,7 +783,25 @@ util_fpstate_set_denorms_to_zero(unsigned current_fpstate);
void void
util_fpstate_set(unsigned fpstate); util_fpstate_set(unsigned fpstate);
/**
* For indexed draw calls, return true if the vertex count to be drawn is
* much lower than the vertex count that has to be uploaded, meaning
* that the driver should flatten indices instead of trying to upload
* a too big range.
*
* This is used by vertex upload code in u_vbuf and glthread.
*/
static inline bool
util_is_vbo_upload_ratio_too_large(unsigned draw_vertex_count,
unsigned upload_vertex_count)
{
if (draw_vertex_count > 1024)
return upload_vertex_count > draw_vertex_count * 4;
else if (draw_vertex_count > 32)
return upload_vertex_count > draw_vertex_count * 8;
else
return upload_vertex_count > draw_vertex_count * 16;
}
#ifdef __cplusplus #ifdef __cplusplus
} }
......
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