mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 10:09:36 -06:00
Merge pull request #12324 from Pokechu22/vertex-loader-dummy-tex-coords
VertexLoader: Fixes and cleanup related to skipped components
This commit is contained in:
@ -575,6 +575,102 @@ struct VAT
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
void SetTexElements(size_t idx, TexComponentCount value)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
g0.Tex0CoordElements = value;
|
||||
return;
|
||||
case 1:
|
||||
g1.Tex1CoordElements = value;
|
||||
return;
|
||||
case 2:
|
||||
g1.Tex2CoordElements = value;
|
||||
return;
|
||||
case 3:
|
||||
g1.Tex3CoordElements = value;
|
||||
return;
|
||||
case 4:
|
||||
g1.Tex4CoordElements = value;
|
||||
return;
|
||||
case 5:
|
||||
g2.Tex5CoordElements = value;
|
||||
return;
|
||||
case 6:
|
||||
g2.Tex6CoordElements = value;
|
||||
return;
|
||||
case 7:
|
||||
g2.Tex7CoordElements = value;
|
||||
return;
|
||||
default:
|
||||
PanicAlertFmt("Invalid tex coord index {}", idx);
|
||||
}
|
||||
}
|
||||
void SetTexFormat(size_t idx, ComponentFormat value)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
g0.Tex0CoordFormat = value;
|
||||
return;
|
||||
case 1:
|
||||
g1.Tex1CoordFormat = value;
|
||||
return;
|
||||
case 2:
|
||||
g1.Tex2CoordFormat = value;
|
||||
return;
|
||||
case 3:
|
||||
g1.Tex3CoordFormat = value;
|
||||
return;
|
||||
case 4:
|
||||
g1.Tex4CoordFormat = value;
|
||||
return;
|
||||
case 5:
|
||||
g2.Tex5CoordFormat = value;
|
||||
return;
|
||||
case 6:
|
||||
g2.Tex6CoordFormat = value;
|
||||
return;
|
||||
case 7:
|
||||
g2.Tex7CoordFormat = value;
|
||||
return;
|
||||
default:
|
||||
PanicAlertFmt("Invalid tex coord index {}", idx);
|
||||
}
|
||||
}
|
||||
void SetTexFrac(size_t idx, u8 value)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
g0.Tex0Frac = value;
|
||||
return;
|
||||
case 1:
|
||||
g1.Tex1Frac = value;
|
||||
return;
|
||||
case 2:
|
||||
g1.Tex2Frac = value;
|
||||
return;
|
||||
case 3:
|
||||
g1.Tex3Frac = value;
|
||||
return;
|
||||
case 4:
|
||||
g2.Tex4Frac = value;
|
||||
return;
|
||||
case 5:
|
||||
g2.Tex5Frac = value;
|
||||
return;
|
||||
case 6:
|
||||
g2.Tex6Frac = value;
|
||||
return;
|
||||
case 7:
|
||||
g2.Tex7Frac = value;
|
||||
return;
|
||||
default:
|
||||
PanicAlertFmt("Invalid tex coord index {}", idx);
|
||||
}
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct fmt::formatter<VAT>
|
||||
|
@ -77,9 +77,6 @@ VertexLoader::VertexLoader(const TVtxDesc& vtx_desc, const VAT& vtx_attr)
|
||||
|
||||
void VertexLoader::CompileVertexTranslator()
|
||||
{
|
||||
// Reset pipeline
|
||||
m_numPipelineStages = 0;
|
||||
|
||||
// Position in pc vertex format.
|
||||
int nat_offset = 0;
|
||||
|
||||
@ -149,9 +146,16 @@ void VertexLoader::CompileVertexTranslator()
|
||||
VertexLoader_Color::GetFunction(m_VtxDesc.low.Color[i], m_VtxAttr.GetColorFormat(i));
|
||||
|
||||
if (pFunc != nullptr)
|
||||
{
|
||||
WriteCall(pFunc);
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -213,12 +217,13 @@ void VertexLoader::CompileVertexTranslator()
|
||||
{
|
||||
// if there's more tex coords later, have to write a dummy call
|
||||
bool has_more = false;
|
||||
for (size_t j = 0; j < m_VtxDesc.high.TexCoord.Size(); ++j)
|
||||
for (size_t j = i + 1; j < m_VtxDesc.high.TexCoord.Size(); ++j)
|
||||
{
|
||||
if (m_VtxDesc.high.TexCoord[j] != VertexComponentFormat::NotPresent)
|
||||
{
|
||||
has_more = true;
|
||||
WriteCall(VertexLoader_TextCoord::GetDummyFunction()); // important to get indices right!
|
||||
// Keep tcIndex in sync so that the correct array is used later
|
||||
WriteCall(VertexLoader_TextCoord::GetDummyFunction());
|
||||
break;
|
||||
}
|
||||
else if (m_VtxDesc.low.TexMatIdx[j])
|
||||
@ -245,7 +250,7 @@ void VertexLoader::CompileVertexTranslator()
|
||||
|
||||
void VertexLoader::WriteCall(TPipelineFunction func)
|
||||
{
|
||||
m_PipelineStages[m_numPipelineStages++] = func;
|
||||
m_PipelineStages.push_back(func);
|
||||
}
|
||||
|
||||
int VertexLoader::RunVertices(const u8* src, u8* dst, int count)
|
||||
@ -261,8 +266,8 @@ int VertexLoader::RunVertices(const u8* src, u8* dst, int count)
|
||||
m_tcIndex = 0;
|
||||
m_colIndex = 0;
|
||||
m_texmtxwrite = m_texmtxread = 0;
|
||||
for (int i = 0; i < m_numPipelineStages; i++)
|
||||
m_PipelineStages[i](this);
|
||||
for (TPipelineFunction& func : m_PipelineStages)
|
||||
func(this);
|
||||
PRIM_LOG("\n");
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/SmallVector.h"
|
||||
#include "VideoCommon/VertexLoaderBase.h"
|
||||
|
||||
class VertexLoader;
|
||||
@ -38,8 +39,11 @@ public:
|
||||
|
||||
private:
|
||||
// Pipeline.
|
||||
TPipelineFunction m_PipelineStages[64]; // TODO - figure out real max. it's lower.
|
||||
int m_numPipelineStages;
|
||||
// 1 pos matrix + 8 texture matrices + 1 position + 1 normal or normal/binormal/tangent
|
||||
// + 2 colors + 8 texture coordinates or dummy texture coordinates + 8 texture matrices
|
||||
// merged into texture coordinates + 1 skip gives a maximum of 30
|
||||
// (Tested by VertexLoaderTest.LargeFloatVertexSpeed)
|
||||
Common::SmallVector<TPipelineFunction, 30> m_PipelineStages;
|
||||
|
||||
void CompileVertexTranslator();
|
||||
|
||||
|
@ -16,6 +16,11 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
void Color_Read_Dummy(VertexLoader* loader)
|
||||
{
|
||||
loader->m_colIndex++;
|
||||
}
|
||||
|
||||
constexpr u32 alpha_mask = 0xFF000000;
|
||||
|
||||
void SetCol(VertexLoader* loader, u32 val)
|
||||
@ -201,3 +206,8 @@ TPipelineFunction VertexLoader_Color::GetFunction(VertexComponentFormat type, Co
|
||||
}
|
||||
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);
|
||||
|
||||
// It is important to synchronize colIndex, or else the wrong color array will be used
|
||||
static TPipelineFunction GetDummyFunction();
|
||||
|
||||
private:
|
||||
template <typename T, auto last_member>
|
||||
using EnumMap = typename Common::EnumMap<T, last_member>;
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
static TPipelineFunction GetFunction(VertexComponentFormat type, ComponentFormat format,
|
||||
TexComponentCount elements);
|
||||
|
||||
// It is important to synchronize tcIndex.
|
||||
// It is important to synchronize tcIndex, or else the wrong texture coordinate array will be used
|
||||
static TPipelineFunction GetDummyFunction();
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user