VertexLoader: never reset alpha in 8888 colors

Fixes the opening menu of Xenoblade Chronicles.
This commit is contained in:
Tillmann Karras 2015-01-20 01:58:11 +01:00
parent 80617ec6bd
commit 46ab5d63d6
5 changed files with 5 additions and 19 deletions

View File

@ -83,9 +83,6 @@ VertexLoader::VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr)
m_posScale = 1.0f / (1U << m_VtxAttr.PosFrac); m_posScale = 1.0f / (1U << m_VtxAttr.PosFrac);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
m_tcScale[i] = 1.0f / (1U << m_VtxAttr.texCoord[i].Frac); m_tcScale[i] = 1.0f / (1U << m_VtxAttr.texCoord[i].Frac);
for (int i = 0; i < 2; i++)
m_colElements[i] = m_VtxAttr.color[i].Elements;
} }
void VertexLoader::CompileVertexTranslator() void VertexLoader::CompileVertexTranslator()

View File

@ -41,7 +41,6 @@ public:
float m_tcScale[8]; float m_tcScale[8];
int m_tcIndex; int m_tcIndex;
int m_colIndex; int m_colIndex;
int m_colElements[2];
// Matrix components are first in GC format but later in PC format - we need to store it temporarily // Matrix components are first in GC format but later in PC format - we need to store it temporarily
// when decoding each vertex. // when decoding each vertex.

View File

@ -145,7 +145,7 @@ int VertexLoaderX64::ReadVertex(OpArg data, u64 attribute, int format, int count
return load_bytes; return load_bytes;
} }
void VertexLoaderX64::ReadColor(OpArg data, u64 attribute, int format, int elements) void VertexLoaderX64::ReadColor(OpArg data, u64 attribute, int format)
{ {
int load_bytes = 0; int load_bytes = 0;
switch (format) switch (format)
@ -154,8 +154,7 @@ void VertexLoaderX64::ReadColor(OpArg data, u64 attribute, int format, int eleme
case FORMAT_32B_888x: case FORMAT_32B_888x:
case FORMAT_32B_8888: case FORMAT_32B_8888:
MOV(32, R(scratch1), data); MOV(32, R(scratch1), data);
// See VertexLoader_Color.cpp for a comment on this condition. if (format != FORMAT_32B_8888)
if (format != FORMAT_32B_8888 || !elements)
OR(32, R(scratch1), Imm32(0xFF000000)); OR(32, R(scratch1), Imm32(0xFF000000));
MOV(32, MDisp(dst_reg, m_dst_ofs), R(scratch1)); MOV(32, MDisp(dst_reg, m_dst_ofs), R(scratch1));
load_bytes = 3 + (format != FORMAT_24B_888); load_bytes = 3 + (format != FORMAT_24B_888);
@ -363,7 +362,7 @@ void VertexLoaderX64::GenerateVertexLoader()
if (col[i]) if (col[i])
{ {
data = GetVertexAddr(ARRAY_COLOR + i, col[i]); data = GetVertexAddr(ARRAY_COLOR + i, col[i]);
ReadColor(data, col[i], m_VtxAttr.color[i].Comp, m_VtxAttr.color[i].Elements); ReadColor(data, col[i], m_VtxAttr.color[i].Comp);
m_native_components |= VB_HAS_COL0 << i; m_native_components |= VB_HAS_COL0 << i;
m_native_vtx_decl.colors[i].components = 4; m_native_vtx_decl.colors[i].components = 4;
m_native_vtx_decl.colors[i].enable = true; m_native_vtx_decl.colors[i].enable = true;

View File

@ -17,6 +17,6 @@ private:
Gen::FixupBranch m_skip_vertex; Gen::FixupBranch m_skip_vertex;
Gen::OpArg GetVertexAddr(int array, u64 attribute); Gen::OpArg GetVertexAddr(int array, u64 attribute);
int ReadVertex(Gen::OpArg data, u64 attribute, int format, int count_in, int count_out, u8 scaling_exponent, AttributeFormat* native_format); int ReadVertex(Gen::OpArg data, u64 attribute, int format, int count_in, int count_out, u8 scaling_exponent, AttributeFormat* native_format);
void ReadColor(Gen::OpArg data, u64 attribute, int format, int elements); void ReadColor(Gen::OpArg data, u64 attribute, int format);
void GenerateVertexLoader(); void GenerateVertexLoader();
}; };

View File

@ -92,18 +92,9 @@ void LOADERDECL Color_ReadDirect_24b_6666(VertexLoader* loader)
_SetCol6666(loader, Common::swap32(DataGetPosition() - 1)); _SetCol6666(loader, Common::swap32(DataGetPosition() - 1));
DataSkip(3); DataSkip(3);
} }
// F|RES: i am not 100 percent sure, but the colElements seems to be important for rendering only
// at least it fixes mario party 4
void LOADERDECL Color_ReadDirect_32b_8888(VertexLoader* loader) void LOADERDECL Color_ReadDirect_32b_8888(VertexLoader* loader)
{ {
// TODO (mb2): check this _SetCol(loader, DataReadU32Unswapped());
u32 col = DataReadU32Unswapped();
// "kill" the alpha
if (!loader->m_colElements[loader->m_colIndex])
col |= AMASK;
_SetCol(loader, col);
} }
template <typename I> template <typename I>