mesa: add HWSelectModeBeginEnd dispatch table

Used when in glBegin/End section and HW GL_RENDER mode.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15765>
This commit is contained in:
Qiang Yu 2022-05-13 17:34:14 +08:00 committed by Marge Bot
parent 8373248cf0
commit c41ac0682e
6 changed files with 60 additions and 3 deletions

View File

@ -1168,6 +1168,7 @@ _mesa_free_context_data(struct gl_context *ctx, bool destroy_debug_output)
free(ctx->Save);
free(ctx->ContextLost);
free(ctx->MarshalExec);
free(ctx->HWSelectModeBeginEnd);
/* Shared context state (display lists, textures, etc) */
_mesa_reference_shared_state(ctx, &ctx->Shared, NULL);

View File

@ -230,6 +230,15 @@ alloc_select_resource(struct gl_context *ctx)
if (!ctx->Const.HardwareAcceleratedSelect)
return;
if (!ctx->HWSelectModeBeginEnd) {
ctx->HWSelectModeBeginEnd = _mesa_alloc_dispatch_table(false);
if (!ctx->HWSelectModeBeginEnd) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Cannot allocate HWSelectModeBeginEnd");
return;
}
vbo_install_hw_select_begin_end(ctx);
}
if (!s->SaveBuffer) {
s->SaveBuffer = malloc(NAME_STACK_BUFFER_SIZE);
if (!s->SaveBuffer) {

View File

@ -3255,6 +3255,11 @@ struct gl_context
* display list). Only valid functions between those two are set.
*/
struct _glapi_table *BeginEnd;
/**
* Same as BeginEnd except vertex postion set functions. Used when
* HW GL_SELECT mode instead of BeginEnd.
*/
struct _glapi_table *HWSelectModeBeginEnd;
/**
* Dispatch table for when a graphics reset has happened.
*/

View File

@ -190,6 +190,9 @@ _vbo_DestroyContext(struct gl_context *ctx);
void
vbo_install_exec_vtxfmt(struct gl_context *ctx);
void
vbo_install_hw_select_begin_end(struct gl_context *ctx);
void
vbo_install_exec_vtxfmt_noop(struct gl_context *ctx);

View File

@ -477,7 +477,7 @@ is_vertex_position(const struct gl_context *ctx, GLuint index)
* \param C cast type (uint32_t or uint64_t)
* \param V0, V1, v2, V3 attribute value
*/
#define ATTR_UNION(A, N, T, C, V0, V1, V2, V3) \
#define ATTR_UNION_BASE(A, N, T, C, V0, V1, V2, V3) \
do { \
struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \
int sz = (sizeof(C) / sizeof(GLfloat)); \
@ -563,6 +563,9 @@ do { \
#define TAG(x) _mesa_##x
#define SUPPRESS_STATIC
#define ATTR_UNION(A, N, T, C, V0, V1, V2, V3) \
ATTR_UNION_BASE(A, N, T, C, V0, V1, V2, V3)
#include "vbo_attrib_tmp.h"
@ -842,7 +845,8 @@ _mesa_Begin(GLenum mode)
ctx->Driver.CurrentExecPrimitive = mode;
ctx->Exec = ctx->BeginEnd;
ctx->Exec = _mesa_hw_select_enabled(ctx) ?
ctx->HWSelectModeBeginEnd : ctx->BeginEnd;
/* We may have been called from a display list, in which case we should
* leave dlist.c's dispatch table in place.
@ -908,7 +912,8 @@ _mesa_End(void)
if (ctx->GLThread.enabled) {
ctx->CurrentServerDispatch = ctx->Exec;
} else if (ctx->CurrentClientDispatch == ctx->BeginEnd) {
} else if (ctx->CurrentClientDispatch == ctx->BeginEnd ||
ctx->CurrentClientDispatch == ctx->HWSelectModeBeginEnd) {
ctx->CurrentClientDispatch = ctx->CurrentServerDispatch = ctx->Exec;
_glapi_set_dispatch(ctx->CurrentClientDispatch);
}
@ -1215,3 +1220,32 @@ _es_Materialf(GLenum face, GLenum pname, GLfloat param)
p[1] = p[2] = p[3] = 0.0F;
_mesa_Materialfv(face, pname, p);
}
#undef TAG
#undef SUPPRESS_STATIC
#define TAG(x) _hw_select_##x
/* filter out none vertex api */
#define HW_SELECT_MODE
#undef ATTR_UNION
#define ATTR_UNION(A, N, T, C, V0, V1, V2, V3) \
do { \
if ((A) == 0) { \
/* TODO: insert name stack attr. */ \
} \
ATTR_UNION_BASE(A, N, T, C, V0, V1, V2, V3); \
} while (0)
#include "vbo_attrib_tmp.h"
void
vbo_install_hw_select_begin_end(struct gl_context *ctx)
{
int numEntries = MAX2(_gloffset_COUNT, _glapi_get_dispatch_table_size());
memcpy(ctx->HWSelectModeBeginEnd, ctx->BeginEnd, numEntries * sizeof(_glapi_proc));
#undef NAME
#define NAME(x) _hw_select_##x
struct _glapi_table *tab = ctx->HWSelectModeBeginEnd;
#include "api_hw_select_init.h"
}

View File

@ -134,6 +134,11 @@ vbo_install_exec_vtxfmt_noop(struct gl_context *ctx)
tab = ctx->BeginEnd;
#include "api_vtxfmt_init.h"
}
if (ctx->HWSelectModeBeginEnd) {
tab = ctx->HWSelectModeBeginEnd;
#include "api_vtxfmt_init.h"
}
}