glx: use rpcbuf reply path in singlepix.c pixel queries

Convert all pixel-read reply handlers (ReadPixels, GetTexImage,
GetPolygonStipple, GetSeparableFilter, GetConvolutionFilter,
GetHistogram, GetMinmax, GetColorTable) from the
__GLX_BEGIN_REPLY/__GLX_SEND_HEADER/__GLX_SEND_*_ARRAY macros to the
rpcbuf reply path. The image payload is a raw byte stream (no element
swap; GL handles pixel swapping via GL_PACK_SWAP_BYTES), so it goes
through x_rpcbuf_write_binary_pad(); the reply length is derived from
the payload by X_SEND_REPLY_WITH_RPCBUF(). Where a reply carries extra
fields (width/height/depth), the reply struct is declared with its
concrete type and those fields are swapped via X_REPLY_FIELD_CARD32()
(no-op for the non-swapped dispatch, where client->swapped is false).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2026-06-26 16:01:25 +02:00 • committed by Enrico Weigelt
commit 03eecd059f

View file

@ -78,16 +78,11 @@ __glXDisp_ReadPixels(__GLXclientState * cl, GLbyte * pc)
*(GLsizei *) (pc + 8), *(GLsizei *) (pc + 12),
*(GLenum *) (pc + 16), *(GLenum *) (pc + 20), answer);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
}
else {
__GLX_BEGIN_REPLY(compsize);
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
return Success;
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured())
x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize);
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
int
@ -101,7 +96,7 @@ __glXDisp_GetTexImage(__GLXclientState * cl, GLbyte * pc)
int error;
char *answer, answerBuffer[200];
GLint width = 0, height = 0, depth = 1;
xGLXSingleReply reply = { 0, };
xGLXGetTexImageReply reply = { 0 };
REQUEST_FIXED_SIZE(xGLXSingleReq, 20);
@ -137,19 +132,18 @@ __glXDisp_GetTexImage(__GLXclientState * cl, GLbyte * pc)
glGetTexImage(*(GLenum *) (pc + 0), *(GLint *) (pc + 4),
*(GLenum *) (pc + 8), *(GLenum *) (pc + 12), answer);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured()) {
reply.width = width;
reply.height = height;
reply.depth = depth;
X_REPLY_FIELD_CARD32(width);
X_REPLY_FIELD_CARD32(height);
X_REPLY_FIELD_CARD32(depth);
x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize);
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetTexImageReply *) &reply)->width = width;
((xGLXGetTexImageReply *) &reply)->height = height;
((xGLXGetTexImageReply *) &reply)->depth = depth;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
return Success;
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
int
@ -179,16 +173,11 @@ __glXDisp_GetPolygonStipple(__GLXclientState * cl, GLbyte * pc)
__glXClearErrorOccured();
glGetPolygonStipple((GLubyte *) answer);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
}
else {
__GLX_BEGIN_REPLY(128);
__GLX_SEND_HEADER();
__GLX_SEND_BYTE_ARRAY(128);
}
return Success;
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured())
x_rpcbuf_write_binary_pad(&rpcbuf, answer, 128);
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
static int
@ -202,7 +191,7 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0, height = 0;
xGLXSingleReply reply = { 0, };
xGLXGetSeparableFilterReply reply = { 0 };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -237,19 +226,16 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
glGetSeparableFilter(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
*(GLenum *) (pc + 8), answer, answer + compsize, NULL);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
}
else {
__GLX_BEGIN_REPLY(compsize + compsize2);
((xGLXGetSeparableFilterReply *) &reply)->width = width;
((xGLXGetSeparableFilterReply *) &reply)->height = height;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize + compsize2);
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured()) {
reply.width = width;
reply.height = height;
X_REPLY_FIELD_CARD32(width);
X_REPLY_FIELD_CARD32(height);
x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize + compsize2);
}
return Success;
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
int
@ -281,7 +267,7 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0, height = 0;
xGLXSingleReply reply = { 0, };
xGLXGetConvolutionFilterReply reply = { 0 };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -314,19 +300,16 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
glGetConvolutionFilter(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
*(GLenum *) (pc + 8), answer);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetConvolutionFilterReply *) &reply)->width = width;
((xGLXGetConvolutionFilterReply *) &reply)->height = height;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured()) {
reply.width = width;
reply.height = height;
X_REPLY_FIELD_CARD32(width);
X_REPLY_FIELD_CARD32(height);
x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize);
}
return Success;
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
int
@ -358,7 +341,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0;
xGLXSingleReply reply = { 0, };
xGLXGetHistogramReply reply = { 0 };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -385,18 +368,14 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__glXClearErrorOccured();
glGetHistogram(target, reset, format, type, answer);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetHistogramReply *) &reply)->width = width;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured()) {
reply.width = width;
X_REPLY_FIELD_CARD32(width);
x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize);
}
return Success;
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
int
@ -449,17 +428,11 @@ GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__glXClearErrorOccured();
glGetMinmax(target, reset, format, type, answer);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
}
else {
__GLX_BEGIN_REPLY(compsize);
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured())
x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize);
return Success;
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
int
@ -491,7 +464,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0;
xGLXSingleReply reply = { 0, };
xGLXGetColorTableReply reply = { 0 };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -518,18 +491,14 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
glGetColorTable(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
*(GLenum *) (pc + 8), answer);
if (__glXErrorOccured()) {
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetColorTableReply *) &reply)->width = width;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!__glXErrorOccured()) {
reply.width = width;
X_REPLY_FIELD_CARD32(width);
x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize);
}
return Success;
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
}
int