glthread: track glPixelStore(GL_UNPACK_*)

so that glthread can compute the size of images passed to GL functions.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27490>
This commit is contained in:
Marek Olšák 2024-01-30 15:47:14 -05:00 committed by Marge Bot
parent c76efafc0d
commit ada351f2ea
3 changed files with 63 additions and 2 deletions

View file

@ -2619,13 +2619,15 @@
<glx rop="167"/>
</function>
<function name="PixelStoref" no_error="true">
<function name="PixelStoref" no_error="true"
marshal_call_after="_mesa_glthread_PixelStorei(ctx, pname, lroundf(param));">
<param name="pname" type="GLenum"/>
<param name="param" type="GLfloat"/>
<glx sop="109" handcode="client"/>
</function>
<function name="PixelStorei" es1="1.0" es2="2.0" no_error="true">
<function name="PixelStorei" es1="1.0" es2="2.0" no_error="true"
marshal_call_after="_mesa_glthread_PixelStorei(ctx, pname, param);">
<param name="pname" type="GLenum"/>
<param name="param" type="GLint"/>
<glx sop="110" handcode="client"/>

View file

@ -36,6 +36,7 @@
#include "main/glthread.h"
#include "main/glthread_marshal.h"
#include "main/hash.h"
#include "main/pixelstore.h"
#include "util/u_atomic.h"
#include "util/u_thread.h"
#include "util/u_cpu_detect.h"
@ -234,6 +235,7 @@ _mesa_glthread_init(struct gl_context *ctx)
}
_mesa_glthread_init_dispatch(ctx, ctx->MarshalExec);
_mesa_init_pixelstore_attrib(ctx, &glthread->Unpack);
for (unsigned i = 0; i < MARSHAL_MAX_BATCHES; i++) {
glthread->batches[i].ctx = ctx;
@ -469,3 +471,56 @@ _mesa_glthread_invalidate_zsbuf(struct gl_context *ctx)
_mesa_marshal_InternalInvalidateFramebufferAncillaryMESA();
return true;
}
void
_mesa_glthread_PixelStorei(struct gl_context *ctx, GLenum pname, GLint param)
{
switch (pname) {
case GL_UNPACK_SWAP_BYTES:
ctx->GLThread.Unpack.SwapBytes = !!param;
break;
case GL_UNPACK_LSB_FIRST:
ctx->GLThread.Unpack.LsbFirst = !!param;
break;
case GL_UNPACK_ROW_LENGTH:
if (param >= 0)
ctx->GLThread.Unpack.RowLength = param;
break;
case GL_UNPACK_IMAGE_HEIGHT:
if (param >= 0)
ctx->GLThread.Unpack.ImageHeight = param;
break;
case GL_UNPACK_SKIP_PIXELS:
if (param >= 0)
ctx->GLThread.Unpack.SkipPixels = param;
break;
case GL_UNPACK_SKIP_ROWS:
if (param >= 0)
ctx->GLThread.Unpack.SkipRows = param;
break;
case GL_UNPACK_SKIP_IMAGES:
if (param >= 0)
ctx->GLThread.Unpack.SkipImages = param;
break;
case GL_UNPACK_ALIGNMENT:
if (param >= 1 && param <= 8 && util_is_power_of_two_nonzero(param))
ctx->GLThread.Unpack.Alignment = param;
break;
case GL_UNPACK_COMPRESSED_BLOCK_WIDTH:
if (param >= 0)
ctx->GLThread.Unpack.CompressedBlockWidth = param;
break;
case GL_UNPACK_COMPRESSED_BLOCK_HEIGHT:
if (param >= 0)
ctx->GLThread.Unpack.CompressedBlockHeight = param;
break;
case GL_UNPACK_COMPRESSED_BLOCK_DEPTH:
if (param >= 0)
ctx->GLThread.Unpack.CompressedBlockDepth = param;
break;
case GL_UNPACK_COMPRESSED_BLOCK_SIZE:
if (param >= 0)
ctx->GLThread.Unpack.CompressedBlockSize = param;
break;
}
}

View file

@ -301,6 +301,8 @@ struct glthread_state
/** Global mutex update info. */
unsigned GlobalLockUpdateBatchCounter;
bool LockGlobalMutexes;
struct gl_pixelstore_attrib Unpack;
};
void _mesa_glthread_init(struct gl_context *ctx);
@ -400,6 +402,8 @@ void _mesa_glthread_UnrollDrawElements(struct gl_context *ctx,
GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLint basevertex);
void _mesa_glthread_unbind_uploaded_vbos(struct gl_context *ctx);
void _mesa_glthread_PixelStorei(struct gl_context *ctx, GLenum pname,
GLint param);
#ifdef __cplusplus
}