2014-07-27 18:28:30 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "pica.h"
|
|
|
|
#include "primitive_assembly.h"
|
|
|
|
#include "vertex_shader.h"
|
|
|
|
|
2014-08-17 21:14:55 +05:30
|
|
|
#include "video_core/debug_utils/debug_utils.h"
|
2014-07-27 18:28:30 +05:30
|
|
|
|
2014-08-17 21:14:55 +05:30
|
|
|
namespace Pica {
|
2014-07-27 18:28:30 +05:30
|
|
|
|
2014-08-17 21:14:55 +05:30
|
|
|
template<typename VertexType>
|
|
|
|
PrimitiveAssembler<VertexType>::PrimitiveAssembler(Regs::TriangleTopology topology)
|
|
|
|
: topology(topology), buffer_index(0) {
|
|
|
|
}
|
2014-07-27 18:28:30 +05:30
|
|
|
|
2014-08-17 21:14:55 +05:30
|
|
|
template<typename VertexType>
|
|
|
|
void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandler triangle_handler)
|
2014-07-27 18:28:30 +05:30
|
|
|
{
|
2014-08-17 21:14:55 +05:30
|
|
|
switch (topology) {
|
2014-07-27 18:28:30 +05:30
|
|
|
case Regs::TriangleTopology::List:
|
|
|
|
case Regs::TriangleTopology::ListIndexed:
|
|
|
|
if (buffer_index < 2) {
|
|
|
|
buffer[buffer_index++] = vtx;
|
|
|
|
} else {
|
|
|
|
buffer_index = 0;
|
|
|
|
|
2014-08-17 21:14:55 +05:30
|
|
|
triangle_handler(buffer[0], buffer[1], vtx);
|
2014-07-27 18:28:30 +05:30
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Regs::TriangleTopology::Fan:
|
|
|
|
if (buffer_index == 2) {
|
|
|
|
buffer_index = 0;
|
|
|
|
|
2014-08-17 21:14:55 +05:30
|
|
|
triangle_handler(buffer[0], buffer[1], vtx);
|
2014-07-27 18:28:30 +05:30
|
|
|
|
|
|
|
buffer[1] = vtx;
|
|
|
|
} else {
|
|
|
|
buffer[buffer_index++] = vtx;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Render_Software, "Unknown triangle topology %x:", (int)topology);
|
2014-07-27 18:28:30 +05:30
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-17 21:14:55 +05:30
|
|
|
// explicitly instantiate use cases
|
|
|
|
template
|
|
|
|
struct PrimitiveAssembler<VertexShader::OutputVertex>;
|
|
|
|
template
|
|
|
|
struct PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex>;
|
2014-07-27 18:28:30 +05:30
|
|
|
|
|
|
|
} // namespace
|