diff --git a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp index 480e486605..e6720e81a0 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp @@ -15,13 +15,10 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef VERTEXLOADER_TEXCOORD_H -#define VERTEXLOADER_TEXCOORD_H - #include "Common.h" #include "VideoCommon.h" #include "VertexLoader.h" -#include "VertexLoader_Position.h" +#include "VertexLoader_TextCoord.h" #include "NativeVertexWriter.h" #define LOG_TEX1() // PRIM_LOG("tex: %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0]); @@ -319,7 +316,7 @@ void LOADERDECL TexCoord_ReadIndex16_Float2() tcIndex++; } -ReadPosision tableReadTexCoord[4][8][2] = { +ReadTexCoord tableReadTexCoord[4][8][2] = { { {NULL, NULL,}, {NULL, NULL,}, @@ -380,5 +377,3 @@ int tableReadTexCoordVertexSize[4][8][2] = { {2, 2,}, }, }; - -#endif diff --git a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.h b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.h index 6dfd9787b2..6d94a0076b 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.h +++ b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.h @@ -18,6 +18,8 @@ #ifndef VERTEXLOADER_TEXCOORD_H #define VERTEXLOADER_TEXCOORD_H +#include "NativeVertexFormat.h" + typedef void (LOADERDECL *ReadTexCoord)(); // Hold function pointers of texture coordinates loaders. diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp index 44eac75304..4e5be78a53 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp @@ -153,7 +153,7 @@ void VertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType) _assert_msg_(VIDEO, 0 <= m_CurrentVat->g0.PosElements && m_CurrentVat->g0.PosElements <= 1, "Invalid number of vertex position elemnts!\n(m_VtxAttr.PosElements = %d)", m_CurrentVat->g0.PosElements); m_positionLoader = tableReadPosition[g_VtxDesc.Position][m_CurrentVat->g0.PosFormat][m_CurrentVat->g0.PosElements]; - m_VertexSize += tableVertexSize[g_VtxDesc.Position][m_CurrentVat->g0.PosFormat][m_CurrentVat->g0.PosElements]; + m_VertexSize += tableReadPositionVertexSize[g_VtxDesc.Position][m_CurrentVat->g0.PosFormat][m_CurrentVat->g0.PosElements]; AddAttributeLoader(LoadPosition); // Normals @@ -243,51 +243,16 @@ void VertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType) // Texture matrix indices (remove if corresponding texture coordinate isn't enabled) for (int i = 0; i < 8; i++) { - int elements = tcElements[i]; - switch (tcDesc[i]) - { - case NOT_PRESENT: - m_texCoordLoader[i] = NULL; - break; - case DIRECT: - switch (tcFormat[i]) - { - case FORMAT_UBYTE: m_VertexSize += elements?2:1; m_texCoordLoader[i] = (elements?TexCoord_ReadDirect_UByte2:TexCoord_ReadDirect_UByte1); break; - case FORMAT_BYTE: m_VertexSize += elements?2:1; m_texCoordLoader[i] = (elements?TexCoord_ReadDirect_Byte2:TexCoord_ReadDirect_Byte1); break; - case FORMAT_USHORT: m_VertexSize += elements?4:2; m_texCoordLoader[i] = (elements?TexCoord_ReadDirect_UShort2:TexCoord_ReadDirect_UShort1); break; - case FORMAT_SHORT: m_VertexSize += elements?4:2; m_texCoordLoader[i] = (elements?TexCoord_ReadDirect_Short2:TexCoord_ReadDirect_Short1); break; - case FORMAT_FLOAT: m_VertexSize += elements?8:4; m_texCoordLoader[i] = (elements?TexCoord_ReadDirect_Float2:TexCoord_ReadDirect_Float1); break; - default: _assert_(0); break; - } - AddAttributeLoader(LoadTexCoord, i); - break; - case INDEX8: - m_VertexSize += 1; - switch (tcFormat[i]) - { - case FORMAT_UBYTE: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex8_UByte2:TexCoord_ReadIndex8_UByte1); break; - case FORMAT_BYTE: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex8_Byte2:TexCoord_ReadIndex8_Byte1); break; - case FORMAT_USHORT: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex8_UShort2:TexCoord_ReadIndex8_UShort1); break; - case FORMAT_SHORT: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex8_Short2:TexCoord_ReadIndex8_Short1); break; - case FORMAT_FLOAT: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex8_Float2:TexCoord_ReadIndex8_Float1); break; - default: _assert_(0); break; - } - AddAttributeLoader(LoadTexCoord, i); - break; - case INDEX16: - m_VertexSize += 2; - switch (tcFormat[i]) - { - case FORMAT_UBYTE: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex16_UByte2:TexCoord_ReadIndex16_UByte1); break; - case FORMAT_BYTE: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex16_Byte2:TexCoord_ReadIndex16_Byte1); break; - case FORMAT_USHORT: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex16_UShort2:TexCoord_ReadIndex16_UShort1); break; - case FORMAT_SHORT: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex16_Short2:TexCoord_ReadIndex16_Short1); break; - case FORMAT_FLOAT: m_texCoordLoader[i] = (elements?TexCoord_ReadIndex16_Float2:TexCoord_ReadIndex16_Float1); break; - default: _assert_(0); - } - AddAttributeLoader(LoadTexCoord, i); - break; - } + const int desc = tcDesc[i]; + const int format = tcFormat[i]; + const int elements = tcElements[i]; + _assert_msg_(VIDEO, NOT_PRESENT <= desc && desc <= INDEX16, "Invalid texture coordinates description!\n(desc = %d)", desc); + _assert_msg_(VIDEO, FORMAT_UBYTE <= format && format <= FORMAT_FLOAT, "Invalid texture coordinates format!\n(format = %d)", format); + _assert_msg_(VIDEO, 0 <= elements && elements <= 1, "Invalid number of texture coordinates elemnts!\n(elements = %d)", elements); + + m_texCoordLoader[i] = tableReadTexCoord[desc][format][elements]; + m_VertexSize += tableReadTexCoordVertexSize[desc][format][elements]; + AddAttributeLoader(LoadTexCoord, i); } // special case if only pos and tex coord 0 and tex coord input is AB11