From a266d570def8b431bd724e1af1eb69bbd93a3a21 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 15 Jun 2021 18:34:14 +0200 Subject: [PATCH] dlist: always use merged primitive for drawing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit OpenGL 4.6 compatibility profile spec, Appendix B: 21. For any GL and framebuffer state, and for any group of GL commands and arguments, the resulting GL and framebuffer state is identical whether the GL commands and arguments are executed normally or from a display list. The only exception to this corollary is for built-in shader variables gl_VertexID and gl_PrimitiveID, which are not defined when drawing geometry within a display list. (thanks Ian Romanick for pointing this out in piglit !419 MR) Remove the code introduced in ebb228bec52a to determine if merged draws can be used. Reviewed-by: Marek Olšák Part-of: --- src/mesa/main/context.c | 1 - src/mesa/main/mtypes.h | 6 ------ src/mesa/main/pipelineobj.c | 1 - src/mesa/main/shaderapi.c | 1 - src/mesa/main/state.c | 38 ---------------------------------- src/mesa/main/state.h | 3 --- src/mesa/state_tracker/st_extensions.c | 1 - src/mesa/vbo/vbo_save_draw.c | 35 +++++++++++-------------------- 8 files changed, 12 insertions(+), 74 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b94a6d2..30f3633 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1205,7 +1205,6 @@ _mesa_initialize_context(struct gl_context *ctx, } ctx->FirstTimeCurrent = GL_TRUE; - ctx->_PrimitiveIDIsUnused = true; return GL_TRUE; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2fa1635..ad59701 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4278,10 +4278,6 @@ struct gl_constants /** Whether out-of-order draw (Begin/End) optimizations are allowed. */ bool AllowDrawOutOfOrder; - /** Whether draw merging optimizations are allowed (might cause - * incorrect results). */ - bool AllowIncorrectPrimitiveId; - /** Whether to allow the fast path for frequently updated VAOs. */ bool AllowDynamicVAOFastPath; @@ -5471,8 +5467,6 @@ struct gl_context GLboolean ViewportInitialized; /**< has viewport size been initialized? */ GLboolean _AllowDrawOutOfOrder; - /* Is gl_PrimitiveID unused by the current shaders? */ - bool _PrimitiveIDIsUnused; /** \name Derived state */ GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c index 58ea4cd..f0ca929 100644 --- a/src/mesa/main/pipelineobj.c +++ b/src/mesa/main/pipelineobj.c @@ -542,7 +542,6 @@ _mesa_bind_pipeline(struct gl_context *ctx, _mesa_update_vertex_processing_mode(ctx); _mesa_update_allow_draw_out_of_order(ctx); - _mesa_update_primitive_id_is_unused(ctx); _mesa_update_valid_to_render_state(ctx); } } diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index d6d42bd..0a19f62 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -2653,7 +2653,6 @@ _mesa_use_program(struct gl_context *ctx, gl_shader_stage stage, shProg); _mesa_reference_program(ctx, target, prog); _mesa_update_allow_draw_out_of_order(ctx); - _mesa_update_primitive_id_is_unused(ctx); _mesa_update_valid_to_render_state(ctx); if (stage == MESA_SHADER_VERTEX) _mesa_update_vertex_processing_mode(ctx); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 38fd54e..7ed93f9 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -147,44 +147,6 @@ _mesa_update_allow_draw_out_of_order(struct gl_context *ctx) } -void -_mesa_update_primitive_id_is_unused(struct gl_context *ctx) -{ - /* Only the compatibility profile with display lists needs this. */ - if (ctx->API != API_OPENGL_COMPAT || ctx->Const.AllowIncorrectPrimitiveId) - return; - - /* If all of these are NULL, GLSL is disabled. */ - struct gl_program *tcs = - ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]; - struct gl_program *tes = - ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]; - struct gl_program *gs = - ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; - struct gl_program *fs = - ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]; - - /* Update ctx->_PrimitiveIDIsUnused for display list if - * allow_incorrect_primitive_id isn't enabled. - * We can use merged primitives (see vbo_save) for drawing unless - * one program expects a correct primitive-ID value. - */ - /* TODO: it may be possible to relax the restriction in some cases. If the current - * geometry shader doesn't read gl_PrimitiveIDIn but does write gl_PrimitiveID, - * then the restriction on fragment shaders reading gl_PrimitiveID can be lifted. - */ - ctx->_PrimitiveIDIsUnused = !( - (tcs && (BITSET_TEST(tcs->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) || - tcs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) || - (tes && (BITSET_TEST(tes->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) || - tes->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) || - (gs && (BITSET_TEST(gs->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) || - gs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) || - (fs && (BITSET_TEST(fs->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) || - fs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID))); -} - - /** * Update the ctx->*Program._Current pointers to point to the * current/active programs. diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index 957fd37..d23a348 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -32,9 +32,6 @@ extern void _mesa_update_allow_draw_out_of_order(struct gl_context *ctx); extern void -_mesa_update_primitive_id_is_unused(struct gl_context *ctx); - -extern void _mesa_update_state(struct gl_context *ctx); /* As above but can only be called between _mesa_lock_context_textures() and diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index cd18ac9..fa6ecfe 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -1832,7 +1832,6 @@ void st_init_extensions(struct pipe_screen *screen, } consts->AllowDrawOutOfOrder = options->allow_draw_out_of_order; - consts->AllowIncorrectPrimitiveId = options->allow_incorrect_primitive_id; bool prefer_nir = PIPE_SHADER_IR_NIR == screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_PREFERRED_IR); diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 104b0bf..dfc2ed0 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -220,30 +220,19 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) assert(ctx->NewState == 0); - bool draw_using_merged_prim = (ctx->Const.AllowIncorrectPrimitiveId || - ctx->_PrimitiveIDIsUnused) && - node->merged.num_draws; - if (!draw_using_merged_prim) { - ctx->Driver.Draw(ctx, node->prims, node->prim_count, - NULL, true, - false, 0, node->min_index, node->max_index, 1, 0); - } else { - struct pipe_draw_info *info = (struct pipe_draw_info *) &node->merged.info; - info->vertices_per_patch = ctx->TessCtrlProgram.patch_vertices; - void *gl_bo = info->index.gl_bo; - if (node->merged.mode) { - assert(node->merged.mode); - ctx->Driver.DrawGalliumMultiMode(ctx, info, 0, - node->merged.start_counts, - node->merged.mode, - node->merged.num_draws); - } else if (node->merged.num_draws) { - /* If node->merged.mode is NULL then num_draws is 0 or 1 */ - assert (node->merged.num_draws == 1); - ctx->Driver.DrawGallium(ctx, info, 0, &node->merged.start_count, 1); - } - info->index.gl_bo = gl_bo; + struct pipe_draw_info *info = (struct pipe_draw_info *) &node->merged.info; + info->vertices_per_patch = ctx->TessCtrlProgram.patch_vertices; + void *gl_bo = info->index.gl_bo; + if (node->merged.mode) { + ctx->Driver.DrawGalliumMultiMode(ctx, info, 0, + node->merged.start_counts, + node->merged.mode, + node->merged.num_draws); + } else if (node->merged.num_draws) { + /* If node->merged.mode is NULL then num_draws is 0 or 1 */ + ctx->Driver.DrawGallium(ctx, info, 0, &node->merged.start_count, 1); } + info->index.gl_bo = gl_bo; /* Copy to current? */ -- 2.7.4