VertexLoader: Fix wrong array being used if color 1 is present but color 0 isn't
This worked correctly on the JIT vertex loaders, and for the equivalent case with texture coordinates. I'm not aware of any games this affects (but libogc does mention a semi-related scenario at 6bc0317c7d/gc/ogc/gx.h (L1855-L1857)
.)
This commit is contained in:
parent
1ee6824324
commit
36796abc08
|
@ -149,9 +149,16 @@ void VertexLoader::CompileVertexTranslator()
|
||||||
VertexLoader_Color::GetFunction(m_VtxDesc.low.Color[i], m_VtxAttr.GetColorFormat(i));
|
VertexLoader_Color::GetFunction(m_VtxDesc.low.Color[i], m_VtxAttr.GetColorFormat(i));
|
||||||
|
|
||||||
if (pFunc != nullptr)
|
if (pFunc != nullptr)
|
||||||
|
{
|
||||||
WriteCall(pFunc);
|
WriteCall(pFunc);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ASSERT(m_VtxDesc.low.Color[i] == VertexComponentFormat::NotPresent);
|
ASSERT(m_VtxDesc.low.Color[i] == VertexComponentFormat::NotPresent);
|
||||||
|
// Keep colIndex in sync if color 0 is absent but color 1 is present
|
||||||
|
if (i == 0 && m_VtxDesc.low.Color[1] != VertexComponentFormat::NotPresent)
|
||||||
|
WriteCall(VertexLoader_Color::GetDummyFunction());
|
||||||
|
}
|
||||||
|
|
||||||
if (m_VtxDesc.low.Color[i] != VertexComponentFormat::NotPresent)
|
if (m_VtxDesc.low.Color[i] != VertexComponentFormat::NotPresent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,11 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
void Color_Read_Dummy(VertexLoader* loader)
|
||||||
|
{
|
||||||
|
loader->m_colIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr u32 alpha_mask = 0xFF000000;
|
constexpr u32 alpha_mask = 0xFF000000;
|
||||||
|
|
||||||
void SetCol(VertexLoader* loader, u32 val)
|
void SetCol(VertexLoader* loader, u32 val)
|
||||||
|
@ -201,3 +206,8 @@ TPipelineFunction VertexLoader_Color::GetFunction(VertexComponentFormat type, Co
|
||||||
}
|
}
|
||||||
return s_table_read_color[type][format];
|
return s_table_read_color[type][format];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TPipelineFunction VertexLoader_Color::GetDummyFunction()
|
||||||
|
{
|
||||||
|
return Color_Read_Dummy;
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ public:
|
||||||
|
|
||||||
static TPipelineFunction GetFunction(VertexComponentFormat type, ColorFormat format);
|
static TPipelineFunction GetFunction(VertexComponentFormat type, ColorFormat format);
|
||||||
|
|
||||||
|
// It is important to synchronize colIndex, or else the wrong color array will be used
|
||||||
|
static TPipelineFunction GetDummyFunction();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T, auto last_member>
|
template <typename T, auto last_member>
|
||||||
using EnumMap = typename Common::EnumMap<T, last_member>;
|
using EnumMap = typename Common::EnumMap<T, last_member>;
|
||||||
|
|
Loading…
Reference in New Issue