From 16a03bade2bd6df232e60b19b07b00bdeb8ca75b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 May 2019 09:38:09 -0400 Subject: VertexLoader_TextCoord: Place helper functions in anonymous namespace Gives them all internal linkage. --- Source/Core/VideoCommon/VertexLoader_TextCoord.cpp | 121 ++++++--------------- 1 file changed, 32 insertions(+), 89 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoader_TextCoord.cpp') diff --git a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp index a64e1f1cde..02bfc8922b 100644 --- a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp +++ b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp @@ -14,6 +14,8 @@ #include "VideoCommon/VertexLoaderManager.h" #include "VideoCommon/VertexLoaderUtils.h" +namespace +{ template void LOG_TEX(); @@ -32,19 +34,19 @@ void LOG_TEX<2>() // ((float*)g_vertex_manager_write_ptr)[-1]); } -static void TexCoord_Read_Dummy(VertexLoader* loader) +void TexCoord_Read_Dummy(VertexLoader* loader) { loader->m_tcIndex++; } template -float TCScale(T val, float scale) +constexpr float TCScale(T val, float scale) { return val * scale; } template <> -float TCScale(float val, float scale) +constexpr float TCScale(float val, [[maybe_unused]] float scale) { return val; } @@ -52,7 +54,7 @@ float TCScale(float val, float scale) template void TexCoord_ReadDirect(VertexLoader* loader) { - auto const scale = loader->m_tcScale[loader->m_tcIndex]; + const auto scale = loader->m_tcScale[loader->m_tcIndex]; DataReader dst(g_vertex_manager_write_ptr, nullptr); DataReader src(g_video_buffer_read_ptr, nullptr); @@ -71,11 +73,11 @@ void TexCoord_ReadIndex(VertexLoader* loader) { static_assert(std::is_unsigned::value, "Only unsigned I is sane!"); - auto const index = DataRead(); - auto const data = reinterpret_cast( + const auto index = DataRead(); + const auto data = reinterpret_cast( VertexLoaderManager::cached_arraybases[ARRAY_TEXCOORD0 + loader->m_tcIndex] + (index * g_main_cp_state.array_strides[ARRAY_TEXCOORD0 + loader->m_tcIndex])); - auto const scale = loader->m_tcScale[loader->m_tcIndex]; + const auto scale = loader->m_tcScale[loader->m_tcIndex]; DataReader dst(g_vertex_manager_write_ptr, nullptr); for (int i = 0; i != N; ++i) @@ -86,7 +88,7 @@ void TexCoord_ReadIndex(VertexLoader* loader) ++loader->m_tcIndex; } -static TPipelineFunction tableReadTexCoord[4][8][2] = { +TPipelineFunction tableReadTexCoord[4][8][2] = { { { nullptr, @@ -177,96 +179,37 @@ static TPipelineFunction tableReadTexCoord[4][8][2] = { }, }; -static int tableReadTexCoordVertexSize[4][8][2] = { +int tableReadTexCoordVertexSize[4][8][2] = { { - { - 0, - 0, - }, - { - 0, - 0, - }, - { - 0, - 0, - }, - { - 0, - 0, - }, - { - 0, - 0, - }, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, + {0, 0}, }, { - { - 1, - 2, - }, - { - 1, - 2, - }, - { - 2, - 4, - }, - { - 2, - 4, - }, - { - 4, - 8, - }, + {1, 2}, + {1, 2}, + {2, 4}, + {2, 4}, + {4, 8}, }, { - { - 1, - 1, - }, - { - 1, - 1, - }, - { - 1, - 1, - }, - { - 1, - 1, - }, - { - 1, - 1, - }, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}, }, { - { - 2, - 2, - }, - { - 2, - 2, - }, - { - 2, - 2, - }, - { - 2, - 2, - }, - { - 2, - 2, - }, + {2, 2}, + {2, 2}, + {2, 2}, + {2, 2}, + {2, 2}, }, }; +} // Anonymous namespace unsigned int VertexLoader_TextCoord::GetSize(u64 _type, unsigned int _format, unsigned int _elements) -- cgit v1.2.3 From 9569c79ca20413b866206add51e249cbb18e462b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 May 2019 09:39:27 -0400 Subject: VertexLoader_TextCoord: Make lookup tables immutable Allows the compiler to place the data within the read-only segment. --- Source/Core/VideoCommon/VertexLoader_TextCoord.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoader_TextCoord.cpp') diff --git a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp index 02bfc8922b..52723225f9 100644 --- a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp +++ b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp @@ -88,7 +88,7 @@ void TexCoord_ReadIndex(VertexLoader* loader) ++loader->m_tcIndex; } -TPipelineFunction tableReadTexCoord[4][8][2] = { +constexpr TPipelineFunction s_table_read_tex_coord[4][8][2] = { { { nullptr, @@ -179,7 +179,7 @@ TPipelineFunction tableReadTexCoord[4][8][2] = { }, }; -int tableReadTexCoordVertexSize[4][8][2] = { +constexpr int s_table_read_tex_coord_vertex_size[4][8][2] = { { {0, 0}, {0, 0}, @@ -214,13 +214,13 @@ int tableReadTexCoordVertexSize[4][8][2] = { unsigned int VertexLoader_TextCoord::GetSize(u64 _type, unsigned int _format, unsigned int _elements) { - return tableReadTexCoordVertexSize[_type][_format][_elements]; + return s_table_read_tex_coord_vertex_size[_type][_format][_elements]; } TPipelineFunction VertexLoader_TextCoord::GetFunction(u64 _type, unsigned int _format, unsigned int _elements) { - return tableReadTexCoord[_type][_format][_elements]; + return s_table_read_tex_coord[_type][_format][_elements]; } TPipelineFunction VertexLoader_TextCoord::GetDummyFunction() -- cgit v1.2.3 From 24527474293a180a015ea549055852ddd0167dbe Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 May 2019 09:42:05 -0400 Subject: VertexLoader_TextCoord: Tidy up public function definitions We can use u32 instead of unsigned int to shorten up these definitions and make them much nicer to read. While we're at it, change the size array to house u32 elements to match the return value of the function. --- Source/Core/VideoCommon/VertexLoader_TextCoord.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoader_TextCoord.cpp') diff --git a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp index 52723225f9..3a31527b2c 100644 --- a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp +++ b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp @@ -179,7 +179,7 @@ constexpr TPipelineFunction s_table_read_tex_coord[4][8][2] = { }, }; -constexpr int s_table_read_tex_coord_vertex_size[4][8][2] = { +constexpr u32 s_table_read_tex_coord_vertex_size[4][8][2] = { { {0, 0}, {0, 0}, @@ -211,16 +211,14 @@ constexpr int s_table_read_tex_coord_vertex_size[4][8][2] = { }; } // Anonymous namespace -unsigned int VertexLoader_TextCoord::GetSize(u64 _type, unsigned int _format, - unsigned int _elements) +u32 VertexLoader_TextCoord::GetSize(u64 type, u32 format, u32 elements) { - return s_table_read_tex_coord_vertex_size[_type][_format][_elements]; + return s_table_read_tex_coord_vertex_size[type][format][elements]; } -TPipelineFunction VertexLoader_TextCoord::GetFunction(u64 _type, unsigned int _format, - unsigned int _elements) +TPipelineFunction VertexLoader_TextCoord::GetFunction(u64 type, u32 format, u32 elements) { - return s_table_read_tex_coord[_type][_format][_elements]; + return s_table_read_tex_coord[type][format][elements]; } TPipelineFunction VertexLoader_TextCoord::GetDummyFunction() -- cgit v1.2.3