Convert VertexLoader_Color to a table
This commit is contained in:
parent
4cc442d7cd
commit
bc7da726a5
|
@ -205,98 +205,16 @@ void VertexLoader::CompileVertexTranslator()
|
||||||
m_native_vtx_decl.colors[i].components = 4;
|
m_native_vtx_decl.colors[i].components = 4;
|
||||||
m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE;
|
m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE;
|
||||||
m_native_vtx_decl.colors[i].integer = false;
|
m_native_vtx_decl.colors[i].integer = false;
|
||||||
switch (m_VtxDesc.low.Color[i])
|
|
||||||
{
|
m_VertexSize += VertexLoader_Color::GetSize(m_VtxDesc.low.Color[i], m_VtxAttr.color[i].Comp);
|
||||||
case VertexComponentFormat::NotPresent:
|
TPipelineFunction pFunc =
|
||||||
break;
|
VertexLoader_Color::GetFunction(m_VtxDesc.low.Color[i], m_VtxAttr.color[i].Comp);
|
||||||
case VertexComponentFormat::Direct:
|
|
||||||
switch (m_VtxAttr.color[i].Comp)
|
if (pFunc != nullptr)
|
||||||
{
|
WriteCall(pFunc);
|
||||||
case ColorFormat::RGB565:
|
else
|
||||||
m_VertexSize += 2;
|
ASSERT(m_VtxDesc.low.Color[i] == VertexComponentFormat::NotPresent);
|
||||||
WriteCall(Color_ReadDirect_16b_565);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGB888:
|
|
||||||
m_VertexSize += 3;
|
|
||||||
WriteCall(Color_ReadDirect_24b_888);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGB888x:
|
|
||||||
m_VertexSize += 4;
|
|
||||||
WriteCall(Color_ReadDirect_32b_888x);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA4444:
|
|
||||||
m_VertexSize += 2;
|
|
||||||
WriteCall(Color_ReadDirect_16b_4444);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA6666:
|
|
||||||
m_VertexSize += 3;
|
|
||||||
WriteCall(Color_ReadDirect_24b_6666);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA8888:
|
|
||||||
m_VertexSize += 4;
|
|
||||||
WriteCall(Color_ReadDirect_32b_8888);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASSERT(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case VertexComponentFormat::Index8:
|
|
||||||
m_VertexSize += 1;
|
|
||||||
switch (m_VtxAttr.color[i].Comp)
|
|
||||||
{
|
|
||||||
case ColorFormat::RGB565:
|
|
||||||
WriteCall(Color_ReadIndex8_16b_565);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGB888:
|
|
||||||
WriteCall(Color_ReadIndex8_24b_888);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGB888x:
|
|
||||||
WriteCall(Color_ReadIndex8_32b_888x);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA4444:
|
|
||||||
WriteCall(Color_ReadIndex8_16b_4444);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA6666:
|
|
||||||
WriteCall(Color_ReadIndex8_24b_6666);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA8888:
|
|
||||||
WriteCall(Color_ReadIndex8_32b_8888);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASSERT(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case VertexComponentFormat::Index16:
|
|
||||||
m_VertexSize += 2;
|
|
||||||
switch (m_VtxAttr.color[i].Comp)
|
|
||||||
{
|
|
||||||
case ColorFormat::RGB565:
|
|
||||||
WriteCall(Color_ReadIndex16_16b_565);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGB888:
|
|
||||||
WriteCall(Color_ReadIndex16_24b_888);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGB888x:
|
|
||||||
WriteCall(Color_ReadIndex16_32b_888x);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA4444:
|
|
||||||
WriteCall(Color_ReadIndex16_16b_4444);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA6666:
|
|
||||||
WriteCall(Color_ReadIndex16_24b_6666);
|
|
||||||
break;
|
|
||||||
case ColorFormat::RGBA8888:
|
|
||||||
WriteCall(Color_ReadIndex16_32b_8888);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASSERT(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Common for the three bottom cases
|
|
||||||
if (m_VtxDesc.low.Color[i] != VertexComponentFormat::NotPresent)
|
if (m_VtxDesc.low.Color[i] != VertexComponentFormat::NotPresent)
|
||||||
{
|
{
|
||||||
components |= VB_HAS_COL0 << i;
|
components |= VB_HAS_COL0 << i;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/MsgHandler.h"
|
||||||
#include "Common/Swap.h"
|
#include "Common/Swap.h"
|
||||||
|
|
||||||
#include "VideoCommon/VertexLoader.h"
|
#include "VideoCommon/VertexLoader.h"
|
||||||
|
@ -136,7 +137,6 @@ void Color_ReadIndex_32b_8888(VertexLoader* loader)
|
||||||
(index * g_main_cp_state.array_strides[ARRAY_COLOR0 + loader->m_colIndex]);
|
(index * g_main_cp_state.array_strides[ARRAY_COLOR0 + loader->m_colIndex]);
|
||||||
SetCol(loader, Read32(address));
|
SetCol(loader, Read32(address));
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
|
||||||
|
|
||||||
void Color_ReadDirect_24b_888(VertexLoader* loader)
|
void Color_ReadDirect_24b_888(VertexLoader* loader)
|
||||||
{
|
{
|
||||||
|
@ -149,10 +149,12 @@ void Color_ReadDirect_32b_888x(VertexLoader* loader)
|
||||||
SetCol(loader, Read24(DataGetPosition()));
|
SetCol(loader, Read24(DataGetPosition()));
|
||||||
DataSkip(4);
|
DataSkip(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color_ReadDirect_16b_565(VertexLoader* loader)
|
void Color_ReadDirect_16b_565(VertexLoader* loader)
|
||||||
{
|
{
|
||||||
SetCol565(loader, DataRead<u16>());
|
SetCol565(loader, DataRead<u16>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color_ReadDirect_16b_4444(VertexLoader* loader)
|
void Color_ReadDirect_16b_4444(VertexLoader* loader)
|
||||||
{
|
{
|
||||||
u16 value;
|
u16 value;
|
||||||
|
@ -161,62 +163,52 @@ void Color_ReadDirect_16b_4444(VertexLoader* loader)
|
||||||
SetCol4444(loader, value);
|
SetCol4444(loader, value);
|
||||||
DataSkip(2);
|
DataSkip(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color_ReadDirect_24b_6666(VertexLoader* loader)
|
void Color_ReadDirect_24b_6666(VertexLoader* loader)
|
||||||
{
|
{
|
||||||
SetCol6666(loader, Common::swap32(DataGetPosition() - 1));
|
SetCol6666(loader, Common::swap32(DataGetPosition() - 1));
|
||||||
DataSkip(3);
|
DataSkip(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color_ReadDirect_32b_8888(VertexLoader* loader)
|
void Color_ReadDirect_32b_8888(VertexLoader* loader)
|
||||||
{
|
{
|
||||||
SetCol(loader, DataReadU32Unswapped());
|
SetCol(loader, DataReadU32Unswapped());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color_ReadIndex8_16b_565(VertexLoader* loader)
|
constexpr TPipelineFunction s_table_read_color[4][6] = {
|
||||||
|
{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
|
||||||
|
{Color_ReadDirect_16b_565, Color_ReadDirect_24b_888, Color_ReadDirect_32b_888x,
|
||||||
|
Color_ReadDirect_16b_4444, Color_ReadDirect_24b_6666, Color_ReadDirect_32b_8888},
|
||||||
|
{Color_ReadIndex_16b_565<u8>, Color_ReadIndex_24b_888<u8>, Color_ReadIndex_32b_888x<u8>,
|
||||||
|
Color_ReadIndex_16b_4444<u8>, Color_ReadIndex_24b_6666<u8>, Color_ReadIndex_32b_8888<u8>},
|
||||||
|
{Color_ReadIndex_16b_565<u16>, Color_ReadIndex_24b_888<u16>, Color_ReadIndex_32b_888x<u16>,
|
||||||
|
Color_ReadIndex_16b_4444<u16>, Color_ReadIndex_24b_6666<u16>, Color_ReadIndex_32b_8888<u16>},
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr u32 s_table_read_color_vertex_size[4][6] = {
|
||||||
|
{0, 0, 0, 0, 0, 0},
|
||||||
|
{2, 3, 4, 2, 3, 4},
|
||||||
|
{1, 1, 1, 1, 1, 1},
|
||||||
|
{2, 2, 2, 2, 2, 2},
|
||||||
|
};
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
u32 VertexLoader_Color::GetSize(VertexComponentFormat type, ColorFormat format)
|
||||||
{
|
{
|
||||||
Color_ReadIndex_16b_565<u8>(loader);
|
if (format > ColorFormat::RGBA8888)
|
||||||
|
{
|
||||||
|
PanicAlertFmt("Invalid color format {}", format);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
void Color_ReadIndex8_24b_888(VertexLoader* loader)
|
return s_table_read_color_vertex_size[u32(type)][u32(format)];
|
||||||
{
|
|
||||||
Color_ReadIndex_24b_888<u8>(loader);
|
|
||||||
}
|
|
||||||
void Color_ReadIndex8_32b_888x(VertexLoader* loader)
|
|
||||||
{
|
|
||||||
Color_ReadIndex_32b_888x<u8>(loader);
|
|
||||||
}
|
|
||||||
void Color_ReadIndex8_16b_4444(VertexLoader* loader)
|
|
||||||
{
|
|
||||||
Color_ReadIndex_16b_4444<u8>(loader);
|
|
||||||
}
|
|
||||||
void Color_ReadIndex8_24b_6666(VertexLoader* loader)
|
|
||||||
{
|
|
||||||
Color_ReadIndex_24b_6666<u8>(loader);
|
|
||||||
}
|
|
||||||
void Color_ReadIndex8_32b_8888(VertexLoader* loader)
|
|
||||||
{
|
|
||||||
Color_ReadIndex_32b_8888<u8>(loader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color_ReadIndex16_16b_565(VertexLoader* loader)
|
TPipelineFunction VertexLoader_Color::GetFunction(VertexComponentFormat type, ColorFormat format)
|
||||||
{
|
{
|
||||||
Color_ReadIndex_16b_565<u16>(loader);
|
if (format > ColorFormat::RGBA8888)
|
||||||
}
|
|
||||||
void Color_ReadIndex16_24b_888(VertexLoader* loader)
|
|
||||||
{
|
{
|
||||||
Color_ReadIndex_24b_888<u16>(loader);
|
PanicAlertFmt("Invalid color format {}", format);
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
void Color_ReadIndex16_32b_888x(VertexLoader* loader)
|
return s_table_read_color[u32(type)][u32(format)];
|
||||||
{
|
|
||||||
Color_ReadIndex_32b_888x<u16>(loader);
|
|
||||||
}
|
|
||||||
void Color_ReadIndex16_16b_4444(VertexLoader* loader)
|
|
||||||
{
|
|
||||||
Color_ReadIndex_16b_4444<u16>(loader);
|
|
||||||
}
|
|
||||||
void Color_ReadIndex16_24b_6666(VertexLoader* loader)
|
|
||||||
{
|
|
||||||
Color_ReadIndex_24b_6666<u16>(loader);
|
|
||||||
}
|
|
||||||
void Color_ReadIndex16_32b_8888(VertexLoader* loader)
|
|
||||||
{
|
|
||||||
Color_ReadIndex_32b_8888<u16>(loader);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,25 +4,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class VertexLoader;
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "VideoCommon/VertexLoader.h"
|
||||||
|
|
||||||
void Color_ReadDirect_24b_888(VertexLoader* loader);
|
enum class VertexComponentFormat;
|
||||||
void Color_ReadDirect_32b_888x(VertexLoader* loader);
|
enum class ColorFormat;
|
||||||
void Color_ReadDirect_16b_565(VertexLoader* loader);
|
|
||||||
void Color_ReadDirect_16b_4444(VertexLoader* loader);
|
|
||||||
void Color_ReadDirect_24b_6666(VertexLoader* loader);
|
|
||||||
void Color_ReadDirect_32b_8888(VertexLoader* loader);
|
|
||||||
|
|
||||||
void Color_ReadIndex8_16b_565(VertexLoader* loader);
|
class VertexLoader_Color
|
||||||
void Color_ReadIndex8_24b_888(VertexLoader* loader);
|
{
|
||||||
void Color_ReadIndex8_32b_888x(VertexLoader* loader);
|
public:
|
||||||
void Color_ReadIndex8_16b_4444(VertexLoader* loader);
|
static u32 GetSize(VertexComponentFormat type, ColorFormat format);
|
||||||
void Color_ReadIndex8_24b_6666(VertexLoader* loader);
|
static TPipelineFunction GetFunction(VertexComponentFormat type, ColorFormat format);
|
||||||
void Color_ReadIndex8_32b_8888(VertexLoader* loader);
|
};
|
||||||
|
|
||||||
void Color_ReadIndex16_16b_565(VertexLoader* loader);
|
|
||||||
void Color_ReadIndex16_24b_888(VertexLoader* loader);
|
|
||||||
void Color_ReadIndex16_32b_888x(VertexLoader* loader);
|
|
||||||
void Color_ReadIndex16_16b_4444(VertexLoader* loader);
|
|
||||||
void Color_ReadIndex16_24b_6666(VertexLoader* loader);
|
|
||||||
void Color_ReadIndex16_32b_8888(VertexLoader* loader);
|
|
||||||
|
|
Loading…
Reference in New Issue