[Mesa-dev] Wrong colors in 3D apps on big-endian systems
Christian Zigotzky
chzigotzky at xenosoft.de
Fri Mar 7 16:34:06 PST 2014
Hi All,
I have figured out that the following definitions are not necessary for
big-endian systems in the file "src/gallium/include/pipe/p_format.h":
#if defined(PIPE_ARCH_LITTLE_ENDIAN)
#define PIPE_FORMAT_RGBA8888_UNORM PIPE_FORMAT_R8G8B8A8_UNORM
#define PIPE_FORMAT_RGBX8888_UNORM PIPE_FORMAT_R8G8B8X8_UNORM
#define PIPE_FORMAT_BGRA8888_UNORM PIPE_FORMAT_B8G8R8A8_UNORM
#define PIPE_FORMAT_BGRX8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
#define PIPE_FORMAT_ARGB8888_UNORM PIPE_FORMAT_A8R8G8B8_UNORM
#define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_X8R8G8B8_UNORM
#define PIPE_FORMAT_ABGR8888_UNORM PIPE_FORMAT_A8B8G8R8_UNORM
#define PIPE_FORMAT_XBGR8888_UNORM PIPE_FORMAT_X8B8G8R8_UNORM
#elif defined(PIPE_ARCH_BIG_ENDIAN)
#define PIPE_FORMAT_ABGR8888_UNORM PIPE_FORMAT_R8G8B8A8_UNORM
#define PIPE_FORMAT_XBGR8888_UNORM PIPE_FORMAT_R8G8B8X8_UNORM
#define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
#define PIPE_FORMAT_ARGB8888_UNORM PIPE_FORMAT_B8G8R8A8_UNORM
#define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
#define PIPE_FORMAT_BGRA8888_UNORM PIPE_FORMAT_A8R8G8B8_UNORM
#define PIPE_FORMAT_BGRX8888_UNORM PIPE_FORMAT_X8R8G8B8_UNORM
#define PIPE_FORMAT_RGBA8888_UNORM PIPE_FORMAT_A8B8G8R8_UNORM
#define PIPE_FORMAT_RGBX8888_UNORM PIPE_FORMAT_X8B8G8R8_UNORM
#endif
This definitions for big-endian systems are responsible for the wrong
colors problem. I have commented out the big-endian definitions.
//#if defined(PIPE_ARCH_LITTLE_ENDIAN)
#define PIPE_FORMAT_RGBA8888_UNORM PIPE_FORMAT_R8G8B8A8_UNORM
#define PIPE_FORMAT_RGBX8888_UNORM PIPE_FORMAT_R8G8B8X8_UNORM
#define PIPE_FORMAT_BGRA8888_UNORM PIPE_FORMAT_B8G8R8A8_UNORM
#define PIPE_FORMAT_BGRX8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
#define PIPE_FORMAT_ARGB8888_UNORM PIPE_FORMAT_A8R8G8B8_UNORM
#define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_X8R8G8B8_UNORM
#define PIPE_FORMAT_ABGR8888_UNORM PIPE_FORMAT_A8B8G8R8_UNORM
#define PIPE_FORMAT_XBGR8888_UNORM PIPE_FORMAT_X8B8G8R8_UNORM
//#elif defined(PIPE_ARCH_BIG_ENDIAN)
//#define PIPE_FORMAT_ABGR8888_UNORM PIPE_FORMAT_R8G8B8A8_UNORM
//#define PIPE_FORMAT_XBGR8888_UNORM PIPE_FORMAT_R8G8B8X8_UNORM
//#define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
//#define PIPE_FORMAT_ARGB8888_UNORM PIPE_FORMAT_B8G8R8A8_UNORM
//#define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
//#define PIPE_FORMAT_BGRA8888_UNORM PIPE_FORMAT_A8R8G8B8_UNORM
//#define PIPE_FORMAT_BGRX8888_UNORM PIPE_FORMAT_X8R8G8B8_UNORM
//#define PIPE_FORMAT_RGBA8888_UNORM PIPE_FORMAT_A8B8G8R8_UNORM
//#define PIPE_FORMAT_RGBX8888_UNORM PIPE_FORMAT_X8B8G8R8_UNORM
//#endif
And Mesa 10.1.0 works with the right colors on my PPC Linux system.
Rgds,
Christian
On 07.03.2014 11:28, Christian Zigotzky wrote:
>
>
> On Don, 2014-03-06 at 20:06 +0100, Christian Zigotzky wrote:
>> Hi Thomas,
>> Hi Michel,
>>
>> There are any problems with false colors since Mesa 9.2 on big-endian
>> (PowerPC) systems. I've figured out that the following line in
>> "src/gallium/drivers/r600/evergreen_state.c" the problem is.
>>
>> case V_028C70_COLOR_8_8_8_8:
>>
>> When I comment out this case then the colors are to 99% right. But if I
>> comment out the following lines then all colors are correct.
>>
>> /* 32-bit buffers. */
>> //case PIPE_FORMAT_A8B8G8R8_SRGB:
>> //case PIPE_FORMAT_A8B8G8R8_UNORM:
>> case PIPE_FORMAT_A8R8G8B8_UNORM:
>> //case PIPE_FORMAT_B8G8R8A8_SRGB:
>> //case PIPE_FORMAT_B8G8R8A8_UNORM:
>> //case PIPE_FORMAT_B8G8R8X8_UNORM:
>> //case PIPE_FORMAT_R8G8B8A8_SNORM:
>> //case PIPE_FORMAT_R8G8B8A8_UNORM:
>> //case PIPE_FORMAT_R8G8B8X8_UNORM:
>> //case PIPE_FORMAT_R8G8B8X8_SNORM:
>> //case PIPE_FORMAT_R8G8B8X8_SRGB:
>> //case PIPE_FORMAT_R8G8B8X8_UINT:
>> //case PIPE_FORMAT_R8G8B8X8_SINT:
>> //case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
>> //case PIPE_FORMAT_X8B8G8R8_UNORM:
>> //case PIPE_FORMAT_X8R8G8B8_UNORM:
>> //case PIPE_FORMAT_R8G8B8_UNORM:
>> //case PIPE_FORMAT_R8G8B8A8_SINT:
>> //case PIPE_FORMAT_R8G8B8A8_UINT:
>> return V_028C70_COLOR_8_8_8_8;
>>
>> Neverball, Glxgears, and SuperTuxKart works fine with the right colors.
>>
>> Screenshots:
>> http://forum.hyperion-entertainment.biz/viewtopic.php?f=35&t=2137&p=26037#p26037
>>
>>
>> The patched Mesa 10.0.3 and 10.1.0 works well on Debian Sid and on
>> Lubuntu 14.04.
>>
>> Could you patch the official Mesa, please?
>
> That's not a proper solution.
>
> You probably need to change some of the cases in
> r600_colorformat_endian_swap(), and maybe some other code setting
> endianness related register fields. Basically, the r600g driver assumes
> the x8x8x8x8 formats are packed in host byte order, which used to work
> because st/mesa also happened to use them like that. But now the
> definition of those formats has been clarified to be byte arrays,
> independent from host byte order.
>
> You may also need the st/dri patch to use packed formats which I posted
> in a revent discussion about this on the mesa-dev mailing list.
>
> Speaking of which, you should also bring this up on the mesa-dev mailing
> list again, instead of contacting individuals.
>
>
More information about the mesa-dev
mailing list