diff options
author | Marek Olšák <[email protected]> | 2020-03-22 16:40:32 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2020-04-06 10:29:16 -0400 |
commit | e6bc1702f484be1ecb592295c4877281075798be (patch) | |
tree | 9f6482f91c3b22a30eb9d70ce573bd30d24f7df2 /src/mesa | |
parent | 10beee8a7757e956ab0e02ec8402ec1273d8edce (diff) |
mesa: precompute _mesa_primitive_restart_index during state changes
Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4466>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/genX_state_upload.c | 2 | ||||
-rw-r--r-- | src/mesa/main/attrib.c | 1 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 19 | ||||
-rw-r--r-- | src/mesa/main/enable.h | 3 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 1 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw.c | 3 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw_feedback.c | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_minmax_index.c | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_primitive_restart.c | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_save_api.c | 2 |
11 files changed, 22 insertions, 16 deletions
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c index e9d3b614ee3..898d5aa7a43 100644 --- a/src/mesa/drivers/dri/i965/genX_state_upload.c +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c @@ -904,7 +904,7 @@ genX(upload_cut_index)(struct brw_context *brw) brw_batch_emit(brw, GENX(3DSTATE_VF), vf) { if (ctx->Array._PrimitiveRestart && brw->ib.ib) { vf.IndexedDrawCutIndexEnable = true; - vf.CutIndex = _mesa_primitive_restart_index(ctx, brw->ib.index_size); + vf.CutIndex = ctx->Array._RestartIndex[brw->ib.index_size - 1]; } } } diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index f84844ccea2..5aa3f7bf067 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1607,6 +1607,7 @@ copy_array_attrib(struct gl_context *ctx, dest->PrimitiveRestartFixedIndex = src->PrimitiveRestartFixedIndex; dest->_PrimitiveRestart = src->_PrimitiveRestart; dest->RestartIndex = src->RestartIndex; + memcpy(dest->_RestartIndex, src->_RestartIndex, sizeof(src->_RestartIndex)); /* skip NewState */ /* skip RebindArrays */ diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 7410b0faddf..7e0162b0040 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -44,13 +44,14 @@ #include "varray.h" -static void -update_derived_primitive_restart_state(struct gl_context *ctx) +void +_mesa_update_derived_primitive_restart_state(struct gl_context *ctx) { - /* Update derived primitive restart state. - */ - ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart - || ctx->Array.PrimitiveRestartFixedIndex; + ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart || + ctx->Array.PrimitiveRestartFixedIndex; + ctx->Array._RestartIndex[0] = _mesa_primitive_restart_index(ctx, 1); + ctx->Array._RestartIndex[1] = _mesa_primitive_restart_index(ctx, 2); + ctx->Array._RestartIndex[3] = _mesa_primitive_restart_index(ctx, 4); } @@ -118,7 +119,7 @@ client_state(struct gl_context *ctx, struct gl_vertex_array_object* vao, FLUSH_VERTICES(ctx, 0); ctx->Array.PrimitiveRestart = state; - update_derived_primitive_restart_state(ctx); + _mesa_update_derived_primitive_restart_state(ctx); return; default: @@ -1200,7 +1201,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) if (ctx->Array.PrimitiveRestart != state) { FLUSH_VERTICES(ctx, 0); ctx->Array.PrimitiveRestart = state; - update_derived_primitive_restart_state(ctx); + _mesa_update_derived_primitive_restart_state(ctx); } break; @@ -1210,7 +1211,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) if (ctx->Array.PrimitiveRestartFixedIndex != state) { FLUSH_VERTICES(ctx, 0); ctx->Array.PrimitiveRestartFixedIndex = state; - update_derived_primitive_restart_state(ctx); + _mesa_update_derived_primitive_restart_state(ctx); } break; diff --git a/src/mesa/main/enable.h b/src/mesa/main/enable.h index 1cd8f675d33..78e31700548 100644 --- a/src/mesa/main/enable.h +++ b/src/mesa/main/enable.h @@ -38,6 +38,9 @@ struct gl_context; extern void +_mesa_update_derived_primitive_restart_state(struct gl_context *ctx); + +extern void _mesa_set_enable( struct gl_context* ctx, GLenum cap, GLboolean state ); extern void GLAPIENTRY diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 50380c05b14..86b1a7035b8 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1612,6 +1612,7 @@ struct gl_array_attrib GLboolean PrimitiveRestartFixedIndex; GLboolean _PrimitiveRestart; GLuint RestartIndex; + GLuint _RestartIndex[4]; /**< Restart indices for index_size - 1. */ /*@}*/ /* GL_ARB_vertex_buffer_object */ diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 2190687e108..140c84de2b1 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -2747,6 +2747,7 @@ static void primitive_restart_index(struct gl_context *ctx, GLuint index) { ctx->Array.RestartIndex = index; + _mesa_update_derived_primitive_restart_state(ctx); } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a8ff306e00a..10374746734 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -85,8 +85,7 @@ setup_primitive_restart(struct gl_context *ctx, struct pipe_draw_info *info) if (ctx->Array._PrimitiveRestart) { unsigned index_size = info->index_size; - info->restart_index = - _mesa_primitive_restart_index(ctx, index_size); + info->restart_index = ctx->Array._RestartIndex[index_size - 1]; /* Enable primitive restart only when the restart index can have an * effect. This is required for correctness in radeonsi GFX8 support. diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 8d82884ba8d..a4a38556199 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -216,7 +216,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, if (ctx->Array._PrimitiveRestart) { info.primitive_restart = true; - info.restart_index = _mesa_primitive_restart_index(ctx, info.index_size); + info.restart_index = ctx->Array._RestartIndex[index_size - 1]; } } else { info.index_size = 0; diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c index f66ed3dee39..34766642c6a 100644 --- a/src/mesa/vbo/vbo_minmax_index.c +++ b/src/mesa/vbo/vbo_minmax_index.c @@ -242,7 +242,7 @@ vbo_get_minmax_index(struct gl_context *ctx, { const GLboolean restart = ctx->Array._PrimitiveRestart; const GLuint restartIndex = - _mesa_primitive_restart_index(ctx, 1 << ib->index_size_shift); + ctx->Array._RestartIndex[(1 << ib->index_size_shift) - 1]; const char *indices; GLuint i; GLintptr offset = 0; diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c index 1349740249f..8dd059f165a 100644 --- a/src/mesa/vbo/vbo_primitive_restart.c +++ b/src/mesa/vbo/vbo_primitive_restart.c @@ -177,7 +177,7 @@ vbo_sw_primitive_restart(struct gl_context *ctx, GLuint sub_prim_num; GLuint end_index; GLuint sub_end_index; - GLuint restart_index = _mesa_primitive_restart_index(ctx, 1 << ib->index_size_shift); + GLuint restart_index = ctx->Array._RestartIndex[(1 << ib->index_size_shift) - 1]; struct _mesa_prim temp_prim; GLboolean map_ib = ib->obj && !ib->obj->Mappings[MAP_INTERNAL].Pointer; const void *ptr; diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 52ed86cf3b7..4e96fc79343 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1329,7 +1329,7 @@ array_element(struct gl_context *ctx, * then we call PrimitiveRestartNV and return. */ if (ctx->Array._PrimitiveRestart && - elt == _mesa_primitive_restart_index(ctx, index_size)) { + elt == ctx->Array._RestartIndex[index_size - 1]) { CALL_PrimitiveRestartNV(GET_DISPATCH(), ()); return; } |