aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core/primitive_assembly.cpp
diff options
context:
space:
mode:
authorGravatar Tony Wasserka <NeoBrainX@gmail.com>2014-08-17 17:44:55 +0200
committerGravatar Tony Wasserka <NeoBrainX@gmail.com>2014-08-25 22:03:19 +0200
commit2f1c129f6407fe2d5c8c3e57c6717d5668570de5 (patch)
tree5d12dadd9ffe3b46b9b94a84b7688d6d3b8260fd /src/video_core/primitive_assembly.cpp
parent9679d231df0bc8fac9e0e596ab78750bb38ef248 (diff)
Pica: Consolidate the primitive assembly code in PrimitiveAssembly and GeometryDumper.
Diffstat (limited to 'src/video_core/primitive_assembly.cpp')
-rw-r--r--src/video_core/primitive_assembly.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp
index 2354ffb9..dabf2d1a 100644
--- a/src/video_core/primitive_assembly.cpp
+++ b/src/video_core/primitive_assembly.cpp
@@ -2,21 +2,23 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include "clipper.h"
#include "pica.h"
#include "primitive_assembly.h"
#include "vertex_shader.h"
-namespace Pica {
+#include "video_core/debug_utils/debug_utils.h"
-namespace PrimitiveAssembly {
+namespace Pica {
-static OutputVertex buffer[2];
-static int buffer_index = 0; // TODO: reset this on emulation restart
+template<typename VertexType>
+PrimitiveAssembler<VertexType>::PrimitiveAssembler(Regs::TriangleTopology topology)
+ : topology(topology), buffer_index(0) {
+}
-void SubmitVertex(OutputVertex& vtx)
+template<typename VertexType>
+void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandler triangle_handler)
{
- switch (registers.triangle_topology) {
+ switch (topology) {
case Regs::TriangleTopology::List:
case Regs::TriangleTopology::ListIndexed:
if (buffer_index < 2) {
@@ -24,7 +26,7 @@ void SubmitVertex(OutputVertex& vtx)
} else {
buffer_index = 0;
- Clipper::ProcessTriangle(buffer[0], buffer[1], vtx);
+ triangle_handler(buffer[0], buffer[1], vtx);
}
break;
@@ -32,7 +34,7 @@ void SubmitVertex(OutputVertex& vtx)
if (buffer_index == 2) {
buffer_index = 0;
- Clipper::ProcessTriangle(buffer[0], buffer[1], vtx);
+ triangle_handler(buffer[0], buffer[1], vtx);
buffer[1] = vtx;
} else {
@@ -41,11 +43,15 @@ void SubmitVertex(OutputVertex& vtx)
break;
default:
- ERROR_LOG(GPU, "Unknown triangle mode %x:", (int)registers.triangle_topology.Value());
+ ERROR_LOG(GPU, "Unknown triangle topology %x:", (int)topology);
break;
}
}
-} // namespace
+// explicitly instantiate use cases
+template
+struct PrimitiveAssembler<VertexShader::OutputVertex>;
+template
+struct PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex>;
} // namespace