mesa: inline {Create,Draw}GalliumVertexState callbacks

They are always constant.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27525>
This commit is contained in:
Marek Olšák 2022-12-31 13:01:17 -05:00 committed by Marge Bot
parent 8618062b3c
commit 9aa205668b
6 changed files with 42 additions and 68 deletions

View file

@ -1018,5 +1018,9 @@ struct gl_constants
/** Allow GLThread to convert glBuffer */
bool AllowGLThreadBufferSubDataOpt;
/** Whether pipe_context::draw_vertex_state is supported. */
bool HasDrawVertexState;
};
#endif

View file

@ -169,21 +169,8 @@ struct dd_function_table {
const struct pipe_draw_start_count_bias *draws,
const unsigned char *mode,
unsigned num_draws);
void (*DrawGalliumVertexState)(struct gl_context *ctx,
struct pipe_vertex_state *state,
struct pipe_draw_vertex_state_info info,
const struct pipe_draw_start_count_bias *draws,
const uint8_t *mode,
unsigned num_draws);
/*@}*/
struct pipe_vertex_state *
(*CreateGalliumVertexState)(struct gl_context *ctx,
const struct gl_vertex_array_object *vao,
struct gl_buffer_object *indexbuf,
uint32_t enabled_attribs);
/**
* \name Support for multiple T&L engines
*/

View file

@ -271,43 +271,6 @@ st_indirect_draw_vbo(struct gl_context *ctx,
_mesa_flush(ctx);
}
static void
st_draw_gallium_vertex_state(struct gl_context *ctx,
struct pipe_vertex_state *state,
struct pipe_draw_vertex_state_info info,
const struct pipe_draw_start_count_bias *draws,
const uint8_t *mode,
unsigned num_draws)
{
struct st_context *st = st_context(ctx);
st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS);
struct pipe_context *pipe = st->pipe;
uint32_t velem_mask = ctx->VertexProgram._Current->info.inputs_read;
if (!mode) {
pipe->draw_vertex_state(pipe, state, velem_mask, info, draws, num_draws);
} else {
/* Find consecutive draws where mode doesn't vary. */
for (unsigned i = 0, first = 0; i <= num_draws; i++) {
if (i == num_draws || mode[i] != mode[first]) {
unsigned current_num_draws = i - first;
/* Increase refcount to be able to use take_vertex_state_ownership
* with all draws.
*/
if (i != num_draws && info.take_vertex_state_ownership)
p_atomic_inc(&state->reference.count);
info.mode = mode[first];
pipe->draw_vertex_state(pipe, state, velem_mask, info, &draws[first],
current_num_draws);
first = i;
}
}
}
}
void
st_init_draw_functions(struct pipe_screen *screen,
@ -315,11 +278,6 @@ st_init_draw_functions(struct pipe_screen *screen,
{
functions->DrawGallium = st_draw_gallium;
functions->DrawGalliumMultiMode = st_draw_gallium_multimode;
if (screen->get_param(screen, PIPE_CAP_DRAW_VERTEX_STATE)) {
functions->DrawGalliumVertexState = st_draw_gallium_vertex_state;
functions->CreateGalliumVertexState = st_create_gallium_vertex_state;
}
}

View file

@ -626,6 +626,9 @@ void st_init_limits(struct pipe_screen *screen,
c->AllowGLThreadBufferSubDataOpt =
screen->get_param(screen, PIPE_CAP_ALLOW_GLTHREAD_BUFFER_SUBDATA_OPT);
c->HasDrawVertexState =
screen->get_param(screen, PIPE_CAP_DRAW_VERTEX_STATE);
}

View file

@ -953,16 +953,16 @@ end:
_mesa_reference_vao(ctx, &node->cold->VAO[vpm], save->VAO[vpm]);
}
/* Prepare for DrawGalliumVertexState */
if (node->num_draws && ctx->Driver.DrawGalliumVertexState) {
/* Prepare for draw_vertex_state. */
if (node->num_draws && ctx->Const.HasDrawVertexState) {
for (unsigned i = 0; i < VP_MODE_MAX; i++) {
uint32_t enabled_attribs = _vbo_get_vao_filter(i) &
node->cold->VAO[i]->_EnabledWithMapMode;
node->state[i] =
ctx->Driver.CreateGalliumVertexState(ctx, node->cold->VAO[i],
node->cold->ib.obj,
enabled_attribs);
st_create_gallium_vertex_state(ctx, node->cold->VAO[i],
node->cold->ib.obj,
enabled_attribs);
node->private_refcount[i] = 0;
node->enabled_attribs[i] = enabled_attribs;
}

View file

@ -39,6 +39,7 @@
#include "main/varray.h"
#include "util/bitscan.h"
#include "state_tracker/st_draw.h"
#include "pipe/p_context.h"
#include "vbo_private.h"
@ -199,7 +200,7 @@ vbo_save_playback_vertex_list_gallium(struct gl_context *ctx,
/* Don't use this if selection or feedback mode is enabled. st/mesa can't
* handle it.
*/
if (!ctx->Driver.DrawGalliumVertexState || ctx->RenderMode != GL_RENDER)
if (!ctx->Const.HasDrawVertexState || ctx->RenderMode != GL_RENDER)
return USE_SLOW_PATH;
const gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode;
@ -280,16 +281,37 @@ vbo_save_playback_vertex_list_gallium(struct gl_context *ctx,
/* Set edge flags. */
_mesa_update_edgeflag_state_explicit(ctx, enabled & VERT_BIT_EDGEFLAG);
st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS);
struct pipe_context *pipe = ctx->pipe;
uint32_t velem_mask = ctx->VertexProgram._Current->info.inputs_read;
/* Fast path using a pre-built gallium vertex buffer state. */
if (node->modes || node->num_draws > 1) {
ctx->Driver.DrawGalliumVertexState(ctx, state, info,
node->start_counts,
node->modes,
node->num_draws);
const struct pipe_draw_start_count_bias *draws = node->start_counts;
const uint8_t *mode = node->modes;
unsigned num_draws = node->num_draws;
/* Find consecutive draws where mode doesn't vary. */
for (unsigned i = 0, first = 0; i <= num_draws; i++) {
if (i == num_draws || mode[i] != mode[first]) {
unsigned current_num_draws = i - first;
/* Increase refcount to be able to use take_vertex_state_ownership
* with all draws.
*/
if (i != num_draws && info.take_vertex_state_ownership)
p_atomic_inc(&state->reference.count);
info.mode = mode[first];
pipe->draw_vertex_state(pipe, state, velem_mask, info, &draws[first],
current_num_draws);
first = i;
}
}
} else if (node->num_draws) {
ctx->Driver.DrawGalliumVertexState(ctx, state, info,
&node->start_count,
NULL, 1);
pipe->draw_vertex_state(pipe, state, velem_mask, info,
&node->start_count, 1);
}
/* Restore edge flag state and ctx->VertexProgram._VaryingInputs. */