glthread: align small buffer uploads to 4 bytes
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 13 Mar 2023 15:29:08 +0000 (11:29 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 15 Mar 2023 01:22:12 +0000 (01:22 +0000)
some apps (e.g., supertuxkart) use a ton of 4 byte subdata calls, and
this halves their memory consumption

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21875>

src/mesa/main/glthread_bufferobj.c

index e81f5c4..118657c 100644 (file)
@@ -88,7 +88,7 @@ _mesa_glthread_upload(struct gl_context *ctx, const void *data,
       return;
 
    /* The alignment was chosen arbitrarily. */
-   unsigned offset = align(glthread->upload_offset, 8) + start_offset;
+   unsigned offset = align(glthread->upload_offset, size <= 4 ? 4 : 8) + start_offset;
 
    /* Allocate a new buffer if needed. */
    if (unlikely(!glthread->upload_buffer || offset + size > default_size)) {