<p dir="ltr"><br>
On Feb 13, 2015 1:23 AM, "Iago Toral Quiroga" <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br>
><br>
> In the recent rewrite of the format conversion code we did not handle this.<br>
> This patch adds the missing support.<br>
><br>
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=89068">https://bugs.freedesktop.org/show_bug.cgi?id=89068</a><br>
> ---<br>
> src/mesa/main/texstore.c | 58 +++++++++++++++++++++++++++++++++++++++++++-----<br>
> 1 file changed, 53 insertions(+), 5 deletions(-)<br>
><br>
> diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c<br>
> index 4d32659..6743d13 100644<br>
> --- a/src/mesa/main/texstore.c<br>
> +++ b/src/mesa/main/texstore.c<br>
> @@ -73,6 +73,7 @@<br>
> #include "texstore.h"<br>
> #include "enums.h"<br>
> #include "glformats.h"<br>
> +#include "pixeltransfer.h"<br>
> #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"<br>
> #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"<br>
><br>
> @@ -675,12 +676,13 @@ texstore_compressed(TEXSTORE_PARAMS)<br>
> static GLboolean<br>
> texstore_rgba(TEXSTORE_PARAMS)<br>
> {<br>
> - void *tempImage = NULL;<br>
> + void *tempImage = NULL, *tempRGBA = NULL;<br>
> int srcRowStride, img;<br>
> - GLubyte *src;<br>
> + GLubyte *src, *dst;<br>
> uint32_t srcMesaFormat;<br>
> uint8_t rebaseSwizzle[4];<br>
> bool needRebase;<br>
> + bool transferOpsDone = false;<br>
><br>
> /* We have to handle MESA_FORMAT_YCBCR manually because it is a special case<br>
> * and _mesa_format_convert does not support it. In this case the we only<br>
> @@ -709,6 +711,11 @@ texstore_rgba(TEXSTORE_PARAMS)<br>
> if (!tempImage)<br>
> return GL_FALSE;<br>
><br>
> + /* _mesa_unpack_color_index_to_rgba_ubyte has handled transferops<br>
> + * if needed.<br>
> + */<br>
> + transferOpsDone = true;<br>
> +<br>
> /* Now we only have to adjust our src info for a conversion from<br>
> * the RGBA ubyte and then we continue as usual.<br>
> */<br>
> @@ -737,13 +744,53 @@ texstore_rgba(TEXSTORE_PARAMS)<br>
> srcRowStride =<br>
> _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);<br>
><br>
> + srcMesaFormat = _mesa_format_from_format_and_type(srcFormat, srcType);<br>
> + dstFormat = _mesa_get_srgb_format_linear(dstFormat);<br>
> +<br>
> + /* If we have transferOps then we need to convert to RGBA float first,<br>
> + then apply transferOps, then do the conversion to dst<br>
> + */<br>
> + if (!transferOpsDone &&<br>
> + _mesa_texstore_needs_transfer_ops(ctx, baseInternalFormat, dstFormat)) {<br>
> + /* Allocate RGBA float image */<br>
> + int elementCount = srcWidth * srcHeight * srcDepth;<br>
> + tempRGBA = malloc(4 * elementCount * sizeof(float));<br>
> + if (!tempRGBA) {<br>
> + free(tempImage);<br>
> + free(tempRGBA);<br>
> + return GL_FALSE;<br>
> + }<br>
> +<br>
> + /* Convert from src to RGBA float */<br>
> + src = (GLubyte *) srcAddr;<br>
> + dst = (GLubyte *) tempRGBA;<br>
> + for (img = 0; img < srcDepth; img++) {<br>
> + _mesa_format_convert(dst, RGBA32_FLOAT, 4 * srcWidth * sizeof(float),<br>
> + src, srcMesaFormat, srcRowStride,<br>
> + srcWidth, srcHeight, NULL);<br>
> + src += srcHeight * srcRowStride;<br>
> + dst += srcHeight * 4 * srcWidth * sizeof(float);<br>
> + }<br>
> +<br>
> + /* Apply transferOps */<br>
> + _mesa_apply_rgba_transfer_ops(ctx, ctx->_ImageTransferState, elementCount,<br>
> + (float(*)[4]) tempRGBA);<br>
> +<br>
> + /* Now we have to adjust our src info for a conversion from<br>
> + * the RGBA float image and then we continue as usual.<br>
> + */<br>
> + srcAddr = tempRGBA;<br>
> + srcFormat = GL_RGBA;<br>
> + srcType = GL_FLOAT;<br>
> + srcRowStride =<br>
> + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);</p>
<p dir="ltr">This isn't quite correct. This function will take the user's packing into account while our temporary is densely packed. The actual stride is just width * 4*sizeof(float).</p>
<p dir="ltr">> + srcMesaFormat = _mesa_format_from_format_and_type(srcFormat, srcType);</p>
<p dir="ltr">Just use the actual format here. No need to waste time looking it up.</p>
<p dir="ltr">Other than those two,<br>
Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>></p>
<p dir="ltr">> + }<br>
> +<br>
> src = (GLubyte *)<br>
> _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,<br>
> srcFormat, srcType, 0, 0, 0);<br>
><br>
> - srcMesaFormat = _mesa_format_from_format_and_type(srcFormat, srcType);<br>
> - dstFormat = _mesa_get_srgb_format_linear(dstFormat);<br>
> -<br>
> if (_mesa_get_format_base_format(dstFormat) != baseInternalFormat) {<br>
> needRebase =<br>
> _mesa_compute_rgba2base2rgba_component_mapping(baseInternalFormat,<br>
> @@ -761,6 +808,7 @@ texstore_rgba(TEXSTORE_PARAMS)<br>
> }<br>
><br>
> free(tempImage);<br>
> + free(tempRGBA);<br>
><br>
> return GL_TRUE;<br>
> }<br>
> --<br>
> 1.9.1<br>
><br>
</p>