summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------externals/boost0
-rw-r--r--src/video_core/clipper.cpp17
2 files changed, 7 insertions, 10 deletions
diff --git a/externals/boost b/externals/boost
Subproject b060148c08ae87a3a5809c4f48cb26ac667487a Subproject 97052c28acb141dbf3c5e14114af99045344b69
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp
index 0bcd0b895..e89b7a0c0 100644
--- a/src/video_core/clipper.cpp
+++ b/src/video_core/clipper.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <vector> 5#include <boost/container/static_vector.hpp>
6 6
7#include "clipper.h" 7#include "clipper.h"
8#include "pica.h" 8#include "pica.h"
@@ -98,18 +98,15 @@ static void InitScreenCoordinates(OutputVertex& vtx)
98} 98}
99 99
100void ProcessTriangle(OutputVertex &v0, OutputVertex &v1, OutputVertex &v2) { 100void ProcessTriangle(OutputVertex &v0, OutputVertex &v1, OutputVertex &v2) {
101 using boost::container::static_vector;
101 102
102 // TODO (neobrain): 103 // TODO (neobrain):
103 // The list of output vertices has some fixed maximum size, 104 // The list of output vertices has some fixed maximum size,
104 // however I haven't taken the time to figure out what it is exactly. 105 // however I haven't taken the time to figure out what it is exactly.
105 // For now, we hence just assume a maximal size of 1000 vertices. 106 // For now, we hence just assume a maximal size of 256 vertices.
106 const size_t max_vertices = 1000; 107 static const size_t MAX_VERTICES = 256;
107 std::vector<OutputVertex> buffer_vertices; 108 static_vector<OutputVertex, MAX_VERTICES> buffer_vertices;
108 std::vector<OutputVertex*> output_list{ &v0, &v1, &v2 }; 109 static_vector<OutputVertex*, MAX_VERTICES> output_list = { &v0, &v1, &v2 };
109
110 // Make sure to reserve space for all vertices.
111 // Without this, buffer reallocation would invalidate references.
112 buffer_vertices.reserve(max_vertices);
113 110
114 // Simple implementation of the Sutherland-Hodgman clipping algorithm. 111 // Simple implementation of the Sutherland-Hodgman clipping algorithm.
115 // TODO: Make this less inefficient (currently lots of useless buffering overhead happens here) 112 // TODO: Make this less inefficient (currently lots of useless buffering overhead happens here)
@@ -120,7 +117,7 @@ void ProcessTriangle(OutputVertex &v0, OutputVertex &v1, OutputVertex &v2) {
120 ClippingEdge(ClippingEdge::POS_Z, float24::FromFloat32(+1.0)), 117 ClippingEdge(ClippingEdge::POS_Z, float24::FromFloat32(+1.0)),
121 ClippingEdge(ClippingEdge::NEG_Z, float24::FromFloat32(-1.0)) }) { 118 ClippingEdge(ClippingEdge::NEG_Z, float24::FromFloat32(-1.0)) }) {
122 119
123 const std::vector<OutputVertex*> input_list = output_list; 120 const static_vector<OutputVertex*, MAX_VERTICES> input_list = output_list;
124 output_list.clear(); 121 output_list.clear();
125 122
126 const OutputVertex* reference_vertex = input_list.back(); 123 const OutputVertex* reference_vertex = input_list.back();