summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoBackends/Software/SWVertexLoader.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/SWVertexLoader.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
index 5c0362b2c5..af99e5ba85 100644
--- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
+++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
@@ -36,20 +36,21 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
{
DebugUtil::OnObjectBegin();
- u8 primitiveType = 0;
+ using OpcodeDecoder::Primitive;
+ Primitive primitive_type = Primitive::GX_DRAW_QUADS;
switch (m_current_primitive_type)
{
case PrimitiveType::Points:
- primitiveType = OpcodeDecoder::GX_DRAW_POINTS;
+ primitive_type = Primitive::GX_DRAW_POINTS;
break;
case PrimitiveType::Lines:
- primitiveType = OpcodeDecoder::GX_DRAW_LINES;
+ primitive_type = Primitive::GX_DRAW_LINES;
break;
case PrimitiveType::Triangles:
- primitiveType = OpcodeDecoder::GX_DRAW_TRIANGLES;
+ primitive_type = Primitive::GX_DRAW_TRIANGLES;
break;
case PrimitiveType::TriangleStrip:
- primitiveType = OpcodeDecoder::GX_DRAW_TRIANGLE_STRIP;
+ primitive_type = Primitive::GX_DRAW_TRIANGLE_STRIP;
break;
}
@@ -57,7 +58,7 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
if (g_renderer->IsBBoxEnabled())
g_renderer->BBoxFlush();
- m_setup_unit.Init(primitiveType);
+ m_setup_unit.Init(primitive_type);
// set all states with are stored within video sw
for (int i = 0; i < 4; i++)
@@ -74,7 +75,7 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
memset(static_cast<void*>(&m_vertex), 0, sizeof(m_vertex));
// parse the videocommon format to our own struct format (m_vertex)
- SetFormat(g_main_cp_state.last_id, primitiveType);
+ SetFormat();
ParseVertex(VertexLoaderManager::GetCurrentVertexFormat()->GetVertexDeclaration(), index);
// transform this vertex so that it can be used for rasterization (outVertex)
@@ -98,7 +99,7 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
DebugUtil::OnObjectEnd();
}
-void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
+void SWVertexLoader::SetFormat()
{
// matrix index from xf regs or cp memory?
if (xfmem.MatrixIndexA.PosNormalMtxIdx != g_main_cp_state.matrix_index_a.PosNormalMtxIdx ||
@@ -144,7 +145,7 @@ static void ReadVertexAttribute(T* dst, DataReader src, const AttributeFormat& f
if (format.enable)
{
src.Skip(format.offset);
- src.Skip(base_component * (1 << (format.type >> 1)));
+ src.Skip(base_component * GetElementSize(format.type));
int i;
for (i = 0; i < std::min(format.components - base_component, components); i++)
@@ -152,24 +153,24 @@ static void ReadVertexAttribute(T* dst, DataReader src, const AttributeFormat& f
int i_dst = reverse ? components - i - 1 : i;
switch (format.type)
{
- case VAR_UNSIGNED_BYTE:
+ case ComponentFormat::UByte:
dst[i_dst] = ReadNormalized<T, u8>(src.Read<u8, swap>());
break;
- case VAR_BYTE:
+ case ComponentFormat::Byte:
dst[i_dst] = ReadNormalized<T, s8>(src.Read<s8, swap>());
break;
- case VAR_UNSIGNED_SHORT:
+ case ComponentFormat::UShort:
dst[i_dst] = ReadNormalized<T, u16>(src.Read<u16, swap>());
break;
- case VAR_SHORT:
+ case ComponentFormat::Short:
dst[i_dst] = ReadNormalized<T, s16>(src.Read<s16, swap>());
break;
- case VAR_FLOAT:
+ case ComponentFormat::Float:
dst[i_dst] = ReadNormalized<T, float>(src.Read<float, swap>());
break;
}
- ASSERT_MSG(VIDEO, !format.integer || format.type != VAR_FLOAT,
+ ASSERT_MSG(VIDEO, !format.integer || format.type != ComponentFormat::Float,
"only non-float values are allowed to be streamed as integer");
}
for (; i < components; i++)