glthread: pack "size" in Pointer calls as 16 bits

The only legal values are {1, 2, 3, 4, GL_BGRA}.
We need GLpacked16i to be unsigned, not signed, because GL_BGRA is
greater than 0x8000.

This decreases the size of 1 frame by 10% in Viewperf2020/Catia1.
It decreases the size of many Pointer calls by 8 bytes.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27350>
This commit is contained in:
Marek Olšák 2024-01-08 02:04:55 -05:00 committed by Marge Bot
parent 13a8efcb2c
commit 1388be4d39
3 changed files with 12 additions and 0 deletions

View file

@ -229,6 +229,8 @@ class PrintCode(gl_XML.gl_print_base):
out('cmd->{0} = MIN2({0}, 0xffff); /* clamped to 0xffff (invalid enum) */'.format(p.name))
elif type == 'GLclamped16i':
out('cmd->{0} = CLAMP({0}, INT16_MIN, INT16_MAX);'.format(p.name))
elif type == 'GLpacked16i':
out('cmd->{0} = {0} < 0 ? UINT16_MAX : MIN2({0}, UINT16_MAX);'.format(p.name))
else:
out('cmd->{0} = {0};'.format(p.name))
if variable_params:

View file

@ -43,6 +43,9 @@ def get_marshal_type(func_name, param):
if (type, param.name) == ('GLsizei', 'stride'):
return 'GLclamped16i'
if (type, param.name) == ('GLint', 'size'):
return 'GLpacked16i'
return type
def get_type_size(func_name, param):
@ -60,6 +63,7 @@ def get_type_size(func_name, param):
'GLushort': 2,
'GLhalfNV': 2,
'GLclamped16i': 2, # clamped by glthread
'GLpacked16i': 2, # clamped by glthread
'GLint': 4,
'GLuint': 4,
'GLbitfield': 4,

View file

@ -35,6 +35,12 @@
#include "main/macros.h"
#include "main/matrix.h"
/* 32-bit signed integer clamped to 0..UINT16_MAX to compress parameters
* for glthread. All values < 0 and >= UINT16_MAX are expected to throw
* GL_INVALID_VALUE. Negative values are mapped to UINT16_MAX.
*/
typedef uint16_t GLpacked16i;
/* 32-bit signed integer clamped to 16 bits. */
typedef int16_t GLclamped16i;