mesa/src/mapi/glapi
Marek Olšák e8721fefcd glthread: don't check cmd_size for small variable-sized calls
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>
2024-02-23 18:03:59 +00:00
..
gen glthread: don't check cmd_size for small variable-sized calls 2024-02-23 18:03:59 +00:00
registry Update OpenGL headers 2023-06-07 20:47:03 +00:00
tests mapi: Now _glapi_get_dispatch_table_size always equal to sizeof(struct _glapi_table) / sizeof(void *) 2023-06-27 11:38:59 +00:00
glapi.c mapi: Move shared stub into u_current.c 2022-08-22 21:32:09 +00:00
glapi.h mesa: Drop the aliases from the remap table. 2023-06-12 21:37:37 +00:00
glapi_dispatch.c mapi: Hide OpenGL functions to be exported when shared-glapi is disabled 2023-06-27 20:25:09 +00:00
glapi_entrypoint.c mapi: Delete dynamic stub generation. 2023-06-12 21:37:37 +00:00
glapi_getproc.c mapi: Remove dead struct _glapi_function in glapi/glapi_getproc.c 2023-06-29 01:36:09 +00:00
glapi_nop.c glapi: include generated headers without path 2017-10-27 11:06:07 -07:00
glapi_priv.h mapi: Delete dynamic stub generation. 2023-06-12 21:37:37 +00:00
meson.build mapi: Delete execmem support code. 2023-06-12 21:37:37 +00:00