[Mesa-dev] [RFC PATCH 3/4] mesa: Prefer non-swizzled formats when prefer_no_swizzle set
Francisco Jerez
currojerez at riseup.net
Tue Mar 11 13:12:33 PDT 2014
Chris Forbes <chrisf at ijw.co.nz> writes:
> If prefer_no_swizzle is set, try:
> - The exact matching format
> - Formats with the required components in the correct order, plus a junk
> component
> - finally, swizzled formats (BGRA etc)
>
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
> src/mesa/main/texformat.c | 35 +++++++++++++++++++++++++++++++----
> 1 file changed, 31 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
> index 33725dc..7cb42bc 100644
> --- a/src/mesa/main/texformat.c
> +++ b/src/mesa/main/texformat.c
> @@ -79,11 +79,13 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
> } else if (type == GL_UNSIGNED_INT_2_10_10_10_REV) {
> RETURN_IF_SUPPORTED(MESA_FORMAT_B10G10R10A2_UNORM);
> }
> - RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_UNORM);
> - RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM);
> - break;
> + /* fallthrough */
>
> case GL_RGBA8:
> + if (prefer_no_swizzle) {
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_UNORM);
> + break;
> + }
Are you sure this is correct on little endian machines? According to
the docs, MESA_FORMAT_R8G8B8A8_UNORM would end up with the R component
in the most significant byte (highest array index) and the A component
in the least significant byte (lowest array index), which seems like the
opposite of what GL_RGBA8 is specified to be by
ARB_shader_image_load_store.
> RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_UNORM);
> RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM);
> break;
> @@ -100,6 +102,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
>
> /* deep RGBA formats */
> case GL_RGB10_A2:
> + if (prefer_no_swizzle) {
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R10G10B10A2_UNORM);
> + }
This looks correct for any endianness.
> RETURN_IF_SUPPORTED(MESA_FORMAT_B10G10R10A2_UNORM);
> RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM);
> break;
> @@ -119,6 +124,11 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
> }
> /* fallthrough */
> case GL_RGB8:
> + if (prefer_no_swizzle) {
> + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UNORM8);
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8X8_UNORM);
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_UNORM);
The last two seem wrong for LE too.
> + }
> RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_UNORM8);
> RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8X8_UNORM);
> RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM);
> @@ -454,10 +464,19 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
> break;
> case GL_RGB_SNORM:
> case GL_RGB8_SNORM:
> + if (prefer_no_swizzle) {
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8X8_SNORM);
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM);
> + }
Same here.
> RETURN_IF_SUPPORTED(MESA_FORMAT_X8B8G8R8_SNORM);
> - /* FALLTHROUGH */
> + RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SNORM);
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM);
> + break;
> case GL_RGBA_SNORM:
> case GL_RGBA8_SNORM:
> + if (prefer_no_swizzle) {
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM);
> + }
And here.
> RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SNORM);
> RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM);
> break;
> @@ -525,11 +544,19 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
>
> case GL_SRGB_EXT:
> case GL_SRGB8_EXT:
> + if (prefer_no_swizzle) {
> + /* there is no MESA_FORMAT_RGB_SRGB8 */
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8X8_SRGB);
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SRGB);
And here.
> + }
> RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8);
> RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> break;
> case GL_SRGB_ALPHA_EXT:
> case GL_SRGB8_ALPHA8_EXT:
> + if (prefer_no_swizzle) {
> + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SRGB);
> + }
> RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB);
> RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> break;
> --
> 1.9.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140311/ec2ada07/attachment.pgp>
More information about the mesa-dev
mailing list