yuzu-emu
/
yuzu
Archived
1
0
Fork 0
This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
yuzu/src/video_core/primitive_assembly.cpp

63 lines
1.8 KiB
C++
Raw Normal View History

2014-07-27 12:58:30 +00:00
// Copyright 2014 Citra Emulator Project
2014-12-17 05:38:14 +00:00
// Licensed under GPLv2 or any later version
2014-07-27 12:58:30 +00:00
// Refer to the license.txt file included.
#include "pica.h"
#include "primitive_assembly.h"
#include "vertex_shader.h"
#include "common/logging/log.h"
#include "video_core/debug_utils/debug_utils.h"
2014-07-27 12:58:30 +00:00
namespace Pica {
2014-07-27 12:58:30 +00:00
template<typename VertexType>
PrimitiveAssembler<VertexType>::PrimitiveAssembler(Regs::TriangleTopology topology)
: topology(topology), buffer_index(0) {
}
2014-07-27 12:58:30 +00:00
template<typename VertexType>
void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandler triangle_handler)
2014-07-27 12:58:30 +00:00
{
switch (topology) {
2014-07-27 12:58:30 +00:00
case Regs::TriangleTopology::List:
case Regs::TriangleTopology::ListIndexed:
if (buffer_index < 2) {
buffer[buffer_index++] = vtx;
} else {
buffer_index = 0;
triangle_handler(buffer[0], buffer[1], vtx);
2014-07-27 12:58:30 +00:00
}
break;
case Regs::TriangleTopology::Strip:
2014-07-27 12:58:30 +00:00
case Regs::TriangleTopology::Fan:
if (strip_ready)
triangle_handler(buffer[0], buffer[1], vtx);
buffer[buffer_index] = vtx;
2014-07-27 12:58:30 +00:00
if (topology == Regs::TriangleTopology::Strip) {
strip_ready |= (buffer_index == 1);
buffer_index = !buffer_index;
} else if (topology == Regs::TriangleTopology::Fan) {
buffer_index = 1;
strip_ready = true;
2014-07-27 12:58:30 +00:00
}
break;
default:
LOG_ERROR(HW_GPU, "Unknown triangle topology %x:", (int)topology);
2014-07-27 12:58:30 +00:00
break;
}
}
// explicitly instantiate use cases
template
struct PrimitiveAssembler<VertexShader::OutputVertex>;
template
struct PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex>;
2014-07-27 12:58:30 +00:00
} // namespace