primitive_assembly.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <functional>
  6. #include "video_core/pica.h"
  7. #include "video_core/vertex_shader.h"
  8. namespace Pica {
  9. /*
  10. * Utility class to build triangles from a series of vertices,
  11. * according to a given triangle topology.
  12. */
  13. template<typename VertexType>
  14. struct PrimitiveAssembler {
  15. using TriangleHandler = std::function<void(VertexType& v0,
  16. VertexType& v1,
  17. VertexType& v2)>;
  18. PrimitiveAssembler(Regs::TriangleTopology topology);
  19. /*
  20. * Queues a vertex, builds primitives from the vertex queue according to the given
  21. * triangle topology, and calls triangle_handler for each generated primitive.
  22. * NOTE: We could specify the triangle handler in the constructor, but this way we can
  23. * keep event and handler code next to each other.
  24. */
  25. void SubmitVertex(VertexType& vtx, TriangleHandler triangle_handler);
  26. private:
  27. Regs::TriangleTopology topology;
  28. int buffer_index;
  29. VertexType buffer[2];
  30. bool strip_ready = false;
  31. };
  32. } // namespace