Fix some graphical bugs on big-endian systems. (Regressions from commits f8d129b and f97283e.)

This commit is contained in:
rogerman 2017-08-05 22:45:38 -07:00
parent f377bfeb76
commit 4e1bdab8c7
4 changed files with 30 additions and 20 deletions

View File

@ -792,7 +792,7 @@ enum GPUEngineID
#define ADDRESS_STEP_512KB 0x80000
#define ADDRESS_MASK_256KB (ADDRESS_STEP_256KB-1)
#ifdef LOCAL_BE
#ifdef MSB_FIRST
struct _TILEENTRY
{
/*14*/ unsigned Palette:4;
@ -823,7 +823,7 @@ typedef union
*/
struct _COLOR { // abgr x555
#ifdef LOCAL_BE
#ifdef MSB_FIRST
unsigned alpha:1; // sometimes it is unused (pad)
unsigned blue:5;
unsigned green:5;

View File

@ -36,6 +36,12 @@
#include "./utils/colorspacehandler/colorspacehandler_SSE2.h"
#endif
#if MSB_FIRST
#define GL_TEXTURE_SRC_FORMAT GL_UNSIGNED_INT_8_8_8_8
#else
#define GL_TEXTURE_SRC_FORMAT GL_UNSIGNED_INT_8_8_8_8_REV
#endif
typedef struct
{
unsigned int major;
@ -758,11 +764,11 @@ void OpenGLTexture::Load(bool isNewTexture)
if (isNewTexture)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS, this->_sizeT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS, this->_sizeT, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
else
{
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, this->_sizeS, this->_sizeT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, this->_sizeS, this->_sizeT, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
break;
}
@ -776,13 +782,13 @@ void OpenGLTexture::Load(bool isNewTexture)
if (isNewTexture)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS*2, this->_sizeT*2, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_upscaleBuffer);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->_sizeS*1, this->_sizeT*1, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS*2, this->_sizeT*2, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->_sizeS*1, this->_sizeT*1, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
else
{
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, this->_sizeS*2, this->_sizeT*2, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_upscaleBuffer);
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, this->_sizeS*1, this->_sizeT*1, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, this->_sizeS*2, this->_sizeT*2, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, this->_sizeS*1, this->_sizeT*1, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
break;
}
@ -796,21 +802,21 @@ void OpenGLTexture::Load(bool isNewTexture)
if (isNewTexture)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS*4, this->_sizeT*4, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_upscaleBuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS*4, this->_sizeT*4, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
this->_Upscale<2>(textureSrc, this->_upscaleBuffer);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->_sizeS*2, this->_sizeT*2, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_upscaleBuffer);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->_sizeS*2, this->_sizeT*2, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->_sizeS*1, this->_sizeT*1, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->_sizeS*1, this->_sizeT*1, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
else
{
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, this->_sizeS*4, this->_sizeT*4, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_upscaleBuffer);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, this->_sizeS*4, this->_sizeT*4, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
this->_Upscale<2>(textureSrc, this->_upscaleBuffer);
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, this->_sizeS*2, this->_sizeT*2, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_upscaleBuffer);
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, this->_sizeS*2, this->_sizeT*2, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
glTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, this->_sizeS*1, this->_sizeT*1, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
glTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, this->_sizeS*1, this->_sizeT*1, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
break;
}

View File

@ -1,6 +1,6 @@
/*
Copyright (C) 2011 Roger Manuel
Copyright (C) 2012 DeSmuME team
Copyright (C) 2012-2017 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -32,5 +32,9 @@
#define HAVE_JIT
#endif
#if defined(__ppc__) || defined(__ppc64__)
#define MSB_FIRST 1
#endif
#define PORT_VERSION "Cocoa"
#define PORT_VERSION_OS_X_APP

View File

@ -472,7 +472,7 @@ TextureStore::TextureStore(const u32 texAttributes, const u32 palAttributes)
{
MemSpan currentPaletteMS = MemSpan_TexPalette(_paletteAddress, _paletteSize, false);
#ifdef WORDS_BIGENDIAN
#ifdef MSB_FIRST
currentPaletteMS.dump16(_paletteColorTable);
#else
currentPaletteMS.dump(_paletteColorTable);
@ -594,7 +594,7 @@ void TextureStore::SetTexturePalette(const MemSpan &packedPalette)
{
if (this->_paletteSize > 0)
{
#ifdef WORDS_BIGENDIAN
#ifdef MSB_FIRST
packedPalette.dump16(this->_paletteColorTable);
#else
packedPalette.dump(this->_paletteColorTable);
@ -783,7 +783,7 @@ void TextureStore::VRAMCompareAndUpdate()
currentPackedTexIndexMS.dump(this->_workingData + this->_packSize);
}
#ifdef WORDS_BIGENDIAN
#ifdef MSB_FIRST
currentPaletteMS.dump16(this->_workingData + this->_packSize + this->_packIndexSize);
#else
currentPaletteMS.dump(this->_workingData + this->_packSize + this->_packIndexSize);
@ -1210,7 +1210,7 @@ void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, co
break;
case 1:
#ifdef LOCAL_BE
#ifdef MSB_FIRST
tmp_col[2] = ( (((tmp_col[0] & 0xFF000000) >> 1)+((tmp_col[1] & 0xFF000000) >> 1)) & 0xFF000000 ) |
( (((tmp_col[0] & 0x00FF0000) + (tmp_col[1] & 0x00FF0000)) >> 1) & 0x00FF0000 ) |
( (((tmp_col[0] & 0x0000FF00) + (tmp_col[1] & 0x0000FF00)) >> 1) & 0x0000FF00 ) |
@ -1231,7 +1231,7 @@ void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, co
case 3:
{
#ifdef LOCAL_BE
#ifdef MSB_FIRST
const u32 r0 = (tmp_col[0]>>24) & 0x000000FF;
const u32 r1 = (tmp_col[1]>>24) & 0x000000FF;
const u32 g0 = (tmp_col[0]>>16) & 0x000000FF;