Просмотр исходного кода

Merge pull request #261 from neobrain/boost

Add Boost as a submodule and add some minor cleanups using Boost.Range
Tony Wasserka 11 лет назад
Родитель
Сommit
33e61ef514
5 измененных файлов с 25 добавлено и 9 удалено
  1. 3 0
      .gitmodules
  2. 8 0
      CMakeLists.txt
  3. 1 0
      externals/boost
  4. 3 3
      src/common/string_util.cpp
  5. 10 6
      src/video_core/vertex_shader.cpp

+ 3 - 0
.gitmodules

@@ -1,3 +1,6 @@
 [submodule "externals/inih/inih"]
 [submodule "externals/inih/inih"]
 	path = externals/inih/inih
 	path = externals/inih/inih
 	url = https://github.com/svn2github/inih
 	url = https://github.com/svn2github/inih
+[submodule "externals/boost"]
+	path = externals/boost
+	url = https://github.com/citra-emu/ext-boost.git

+ 8 - 0
CMakeLists.txt

@@ -19,6 +19,14 @@ if (PNG_FOUND)
     add_definitions(-DHAVE_PNG)
     add_definitions(-DHAVE_PNG)
 endif ()
 endif ()
 
 
+find_package(Boost)
+if (Boost_FOUND)
+    include_directories(${Boost_INCLUDE_DIRS})
+else()
+    message(STATUS "Boost not found, falling back to externals")
+    include_directories(externals/boost)
+endif()
+
 # Include bundled CMake modules
 # Include bundled CMake modules
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules")
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules")
 
 

+ 1 - 0
externals/boost

@@ -0,0 +1 @@
+Subproject commit b060148c08ae87a3a5809c4f48cb26ac667487ab

+ 3 - 3
src/common/string_util.cpp

@@ -2,7 +2,7 @@
 // Licensed under GPLv2
 // Licensed under GPLv2
 // Refer to the license.txt file included.
 // Refer to the license.txt file included.
 
 
-#include <algorithm>
+#include <boost/range/algorithm.hpp>
 
 
 #include "common/common.h"
 #include "common/common.h"
 #include "common/string_util.h"
 #include "common/string_util.h"
@@ -18,13 +18,13 @@ namespace Common {
 
 
 /// Make a string lowercase
 /// Make a string lowercase
 std::string ToLower(std::string str) {
 std::string ToLower(std::string str) {
-    std::transform(str.begin(), str.end(), str.begin(), ::tolower);
+    boost::transform(str, str.begin(), ::tolower);
     return str;
     return str;
 }
 }
 
 
 /// Make a string uppercase
 /// Make a string uppercase
 std::string ToUpper(std::string str) {
 std::string ToUpper(std::string str) {
-    std::transform(str.begin(), str.end(), str.begin(), ::toupper);
+    boost::transform(str, str.begin(), ::toupper);
     return str;
     return str;
 }
 }
 
 

+ 10 - 6
src/video_core/vertex_shader.cpp

@@ -2,11 +2,16 @@
 // Licensed under GPLv2
 // Licensed under GPLv2
 // Refer to the license.txt file included.
 // Refer to the license.txt file included.
 
 
+#include <boost/range/algorithm.hpp>
+
+#include <common/file_util.h>
+
+#include <core/mem_map.h>
+
+#include "debug_utils/debug_utils.h"
+
 #include "pica.h"
 #include "pica.h"
 #include "vertex_shader.h"
 #include "vertex_shader.h"
-#include "debug_utils/debug_utils.h"
-#include <core/mem_map.h>
-#include <common/file_util.h>
 
 
 namespace Pica {
 namespace Pica {
 
 
@@ -238,7 +243,7 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes)
     // Setup input register table
     // Setup input register table
     const auto& attribute_register_map = registers.vs_input_register_map;
     const auto& attribute_register_map = registers.vs_input_register_map;
     float24 dummy_register;
     float24 dummy_register;
-    std::fill(&state.input_register_table[0], &state.input_register_table[16], &dummy_register);
+    boost::fill(state.input_register_table, &dummy_register);
     if(num_attributes > 0) state.input_register_table[attribute_register_map.attribute0_register] = &input.attr[0].x;
     if(num_attributes > 0) state.input_register_table[attribute_register_map.attribute0_register] = &input.attr[0].x;
     if(num_attributes > 1) state.input_register_table[attribute_register_map.attribute1_register] = &input.attr[1].x;
     if(num_attributes > 1) state.input_register_table[attribute_register_map.attribute1_register] = &input.attr[1].x;
     if(num_attributes > 2) state.input_register_table[attribute_register_map.attribute2_register] = &input.attr[2].x;
     if(num_attributes > 2) state.input_register_table[attribute_register_map.attribute2_register] = &input.attr[2].x;
@@ -272,8 +277,7 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes)
 
 
     state.status_registers[0] = false;
     state.status_registers[0] = false;
     state.status_registers[1] = false;
     state.status_registers[1] = false;
-    std::fill(state.call_stack, state.call_stack + sizeof(state.call_stack) / sizeof(state.call_stack[0]),
-              VertexShaderState::INVALID_ADDRESS);
+    boost::fill(state.call_stack, VertexShaderState::INVALID_ADDRESS);
     state.call_stack_pointer = &state.call_stack[0];
     state.call_stack_pointer = &state.call_stack[0];
 
 
     ProcessShaderCode(state);
     ProcessShaderCode(state);