diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-12-05 09:36:39 -0500 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-12-05 09:36:41 -0500 |
| commit | 69f2ca2230d0c51710456977a6ea9d0449ba2fc7 (patch) | |
| tree | 8f987d75473d0d6133188db7e6bd0b70f22c3ddb /Source/Core/VideoCommon/IndexGenerator.cpp | |
| parent | 15fc71cfcf5f94221443aaff99ae559fa3cb4633 (diff) | |
VideoCommon/IndexGenerator: Make use of anonymous namespace
More things will be moved into this in subsequent changes. While we're
at it, we can also make use of std::array.
Diffstat (limited to 'Source/Core/VideoCommon/IndexGenerator.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/IndexGenerator.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/Source/Core/VideoCommon/IndexGenerator.cpp b/Source/Core/VideoCommon/IndexGenerator.cpp index 5e45cc6a5f..761d1da7e5 100644 --- a/Source/Core/VideoCommon/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/IndexGenerator.cpp @@ -2,46 +2,52 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "VideoCommon/IndexGenerator.h" + +#include <array> #include <cstddef> #include <cstring> #include "Common/CommonTypes.h" #include "Common/Compiler.h" #include "Common/Logging/Log.h" -#include "VideoCommon/IndexGenerator.h" #include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/VideoConfig.h" +namespace +{ +constexpr u16 s_primitive_restart = UINT16_MAX; + +using PrimitiveFunction = u16*(*)(u16*, u32, u32); +std::array<PrimitiveFunction, 8> s_primitive_table; +} // Anonymous namespace + // Init u16* IndexGenerator::index_buffer_current; u16* IndexGenerator::BASEIptr; u32 IndexGenerator::base_index; -static const u16 s_primitive_restart = UINT16_MAX; - -static u16* (*primitive_table[8])(u16*, u32, u32); - void IndexGenerator::Init() { if (g_Config.backend_info.bSupportsPrimitiveRestart) { - primitive_table[OpcodeDecoder::GX_DRAW_QUADS] = AddQuads<true>; - primitive_table[OpcodeDecoder::GX_DRAW_QUADS_2] = AddQuads_nonstandard<true>; - primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLES] = AddList<true>; - primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_STRIP] = AddStrip<true>; - primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_FAN] = AddFan<true>; + s_primitive_table[OpcodeDecoder::GX_DRAW_QUADS] = AddQuads<true>; + s_primitive_table[OpcodeDecoder::GX_DRAW_QUADS_2] = AddQuads_nonstandard<true>; + s_primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLES] = AddList<true>; + s_primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_STRIP] = AddStrip<true>; + s_primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_FAN] = AddFan<true>; } else { - primitive_table[OpcodeDecoder::GX_DRAW_QUADS] = AddQuads<false>; - primitive_table[OpcodeDecoder::GX_DRAW_QUADS_2] = AddQuads_nonstandard<false>; - primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLES] = AddList<false>; - primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_STRIP] = AddStrip<false>; - primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_FAN] = AddFan<false>; + s_primitive_table[OpcodeDecoder::GX_DRAW_QUADS] = AddQuads<false>; + s_primitive_table[OpcodeDecoder::GX_DRAW_QUADS_2] = AddQuads_nonstandard<false>; + s_primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLES] = AddList<false>; + s_primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_STRIP] = AddStrip<false>; + s_primitive_table[OpcodeDecoder::GX_DRAW_TRIANGLE_FAN] = AddFan<false>; } - primitive_table[OpcodeDecoder::GX_DRAW_LINES] = &AddLineList; - primitive_table[OpcodeDecoder::GX_DRAW_LINE_STRIP] = &AddLineStrip; - primitive_table[OpcodeDecoder::GX_DRAW_POINTS] = &AddPoints; + s_primitive_table[OpcodeDecoder::GX_DRAW_LINES] = &AddLineList; + s_primitive_table[OpcodeDecoder::GX_DRAW_LINE_STRIP] = &AddLineStrip; + s_primitive_table[OpcodeDecoder::GX_DRAW_POINTS] = &AddPoints; } void IndexGenerator::Start(u16* Indexptr) @@ -53,7 +59,7 @@ void IndexGenerator::Start(u16* Indexptr) void IndexGenerator::AddIndices(int primitive, u32 numVerts) { - index_buffer_current = primitive_table[primitive](index_buffer_current, numVerts, base_index); + index_buffer_current = s_primitive_table[primitive](index_buffer_current, numVerts, base_index); base_index += numVerts; } |
