From 1fced9e85f17828ec0ab5cdc6bb90ec77e2940ce Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 26 Jun 2026 17:16:45 +0200 Subject: [PATCH] glx: use rpcbuf reply path in GetCompressedTexImage / GetProgramString Convert the GetCompressedTexImage (indirect_texture_compression.c) and GetProgramString (indirect_program.c) handlers, including their swapped variants, to the rpcbuf reply path. The image/string payload is a raw byte stream (x_rpcbuf_write_binary_pad()); X_SEND_REPLY_WITH_RPCBUF() derives the length and swaps the header, and the width field is swapped via X_REPLY_FIELD_CARD32() (keyed on client->swapped). This removes the __GLX_BEGIN_REPLY/__GLX_SEND_HEADER/__GLX_SEND_VOID_ARRAY macros and the explicit do_swap handling of the reply. Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/glx/indirect_program.c | 24 +++++---------- Xext/glx/indirect_texture_compression.c | 39 +++++++++---------------- 2 files changed, 21 insertions(+), 42 deletions(-) diff --git a/Xext/glx/indirect_program.c b/Xext/glx/indirect_program.c index 003411338d..96e78a8e5c 100644 --- a/Xext/glx/indirect_program.c +++ b/Xext/glx/indirect_program.c @@ -66,7 +66,7 @@ DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte * pc, GLenum pname; GLint compsize = 0; char *answer = NULL, answerBuffer[200]; - xGLXSingleReply reply = { 0, }; + xGLXGetTexImageReply reply = { 0 }; if (do_swap) { target = (GLenum) bswap_32(*(int *) (pc + 0)); @@ -89,24 +89,14 @@ DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte * pc, get_program_string(target, pname, (GLubyte *) answer); } - if (__glXErrorOccured()) { - __GLX_BEGIN_REPLY(0); - if (do_swap) - __GLX_SWAP_REPLY_HEADER(); - __GLX_SEND_HEADER(); - } - else { - __GLX_BEGIN_REPLY(compsize); - ((xGLXGetTexImageReply *) &reply)->width = compsize; - if (do_swap) { - __GLX_SWAP_REPLY_HEADER(); - swapl(&((xGLXGetTexImageReply *) &reply)->width); - } - __GLX_SEND_HEADER(); - __GLX_SEND_VOID_ARRAY(compsize); + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + if (!__glXErrorOccured()) { + reply.width = compsize; + X_REPLY_FIELD_CARD32(width); + x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize); } - error = Success; + error = X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf); } return error; diff --git a/Xext/glx/indirect_texture_compression.c b/Xext/glx/indirect_texture_compression.c index 28bb8911bc..11e7c01df7 100644 --- a/Xext/glx/indirect_texture_compression.c +++ b/Xext/glx/indirect_texture_compression.c @@ -50,7 +50,7 @@ __glXDisp_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc) const GLint level = *(GLint *) (pc + 4); GLint compsize = 0; char *answer = NULL, answerBuffer[200]; - xGLXSingleReply reply = { 0, }; + xGLXGetTexImageReply reply = { 0 }; glGetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize); @@ -63,18 +63,14 @@ __glXDisp_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc) GetCompressedTexImageARB(target, level, answer); } - if (__glXErrorOccured()) { - __GLX_BEGIN_REPLY(0); - __GLX_SEND_HEADER(); - } - else { - __GLX_BEGIN_REPLY(compsize); - ((xGLXGetTexImageReply *) &reply)->width = compsize; - __GLX_SEND_HEADER(); - __GLX_SEND_VOID_ARRAY(compsize); + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + if (!__glXErrorOccured()) { + reply.width = compsize; + X_REPLY_FIELD_CARD32(width); + x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize); } - error = Success; + error = X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf); } return error; @@ -97,7 +93,7 @@ __glXDispSwap_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc) const GLint level = (GLint) bswap_32(*(int *) (pc + 4)); GLint compsize = 0; char *answer = NULL, answerBuffer[200]; - xGLXSingleReply reply = { 0, }; + xGLXGetTexImageReply reply = { 0 }; glGetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize); @@ -110,21 +106,14 @@ __glXDispSwap_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc) GetCompressedTexImageARB(target, level, answer); } - if (__glXErrorOccured()) { - __GLX_BEGIN_REPLY(0); - __GLX_SWAP_REPLY_HEADER(); - __GLX_SEND_HEADER(); - } - else { - __GLX_BEGIN_REPLY(compsize); - ((xGLXGetTexImageReply *) &reply)->width = compsize; - __GLX_SWAP_REPLY_HEADER(); - swapl(&((xGLXGetTexImageReply *) &reply)->width); - __GLX_SEND_HEADER(); - __GLX_SEND_VOID_ARRAY(compsize); + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + if (!__glXErrorOccured()) { + reply.width = compsize; + X_REPLY_FIELD_CARD32(width); + x_rpcbuf_write_binary_pad(&rpcbuf, answer, compsize); } - error = Success; + error = X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf); } return error;