mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-17 20:28:05 +02:00
This removes the size checking, syncing, and direct execution if
the variable-sized call is always small. Don't use safe_mul in that case
either. Only calls already using marshal_count are affected. Example:
Before:
static void GLAPIENTRY
_mesa_marshal_PointParameterfv(GLenum pname, const GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
int params_size = safe_mul(_mesa_point_param_enum_to_count(pname), 1 * sizeof(GLfloat));
int cmd_size = sizeof(struct marshal_cmd_PointParameterfv) + params_size;
if (unlikely(params_size < 0 || (params_size > 0 && !params) || (unsigned)cmd_size > MARSHAL_MAX_CMD_SIZE)) {
_mesa_glthread_finish_before(ctx, "PointParameterfv");
CALL_PointParameterfv(ctx->Dispatch.Current, (pname, params));
return;
}
struct marshal_cmd_PointParameterfv *cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_PointParameterfv, cmd_size);
cmd->num_slots = align(cmd_size, 8) / 8;
cmd->pname = MIN2(pname, 0xffff); /* clamped to 0xffff (invalid enum) */
char *variable_data = (char *) (cmd + 1);
memcpy(variable_data, params, params_size);
}
After:
static void GLAPIENTRY
_mesa_marshal_PointParameterfv(GLenum pname, const GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
int params_size = _mesa_point_param_enum_to_count(pname) * 1 * sizeof(GLfloat);
int cmd_size = sizeof(struct marshal_cmd_PointParameterfv) + params_size;
assert(cmd_size >= 0 && cmd_size <= MARSHAL_MAX_CMD_SIZE);
struct marshal_cmd_PointParameterfv *cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_PointParameterfv, cmd_size);
cmd->num_slots = align(cmd_size, 8) / 8;
cmd->pname = MIN2(pname, 0xffff); /* clamped to 0xffff (invalid enum) */
char *variable_data = (char *) (cmd + 1);
memcpy(variable_data, params, params_size);
}
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27350>
|
||
|---|---|---|
| .. | ||
| gen | ||
| registry | ||
| tests | ||
| glapi.c | ||
| glapi.h | ||
| glapi_dispatch.c | ||
| glapi_entrypoint.c | ||
| glapi_getproc.c | ||
| glapi_nop.c | ||
| glapi_priv.h | ||
| meson.build | ||