Circles & Triangle Fan Topology

Reporter: RobertBColton  |  Status: open  |  Last Modified: January 08, 2019, 09:35:28 PM
Long story short, some APIs, like Metal and Direct3D10 and above, do not support triangle fans. Further, triangle fans do not lend themselves to being batched together efficiently. I suppose it is for these reasons that YoYoGames dropped support for triangle fans in GMS2. For ENIGMA's D3D11 system, I have mapped the fan topology to 0 in the vertex backend until we work this out.

ENIGMA uses triangle fans internally in a few places for several reasons. The first place is for drawing filled circles and the second is for modeling the sides of 3D blocks and the ends of 3D cylinders. Prior to generalizing the model implementation in #1289 we were converting triangle fans to triangle lists so they could be easily batched with other primitives, but that was undone during the cleanup temporarily. It doesn't matter anyway because solving the issue at the model level of abstraction would not solve the problem for the lower-level vertex_* functions which can also use triangle fans.

So because the triangle fan conversion was not kept in the model class, and D3D11 does not support that topology, currently these systems will not draw circles or blocks properly. We need to decide together how we want to address this as there are several routes we can take or combine into a final solution to the problem.

  • We can simply remove the use of triangle fans from our internal code and warn the user they are not supported on some backends and devices. This is currently the approach taken by GMS2.
  • We can go back to converting triangle fans to triangle lists so that they can be combined with adjacent primitives in the model class. This would leave them broke when using the lower-level vertex_* functions directly.
  • We could convert the triangle fans to triangle lists in the vertex_* family of functions. But that may be challenging considering that the primitive topology is not specified until vertex_submit is called. This option would also be less efficient than converting them in the model class which would be able to automatically combine the triangle fans with other adjacent primitives.
  • If doing any of the above, we could do these conversions for only the systems that do not support the given topologies. However, it may be desirable to just convert the fans always so they are batched more efficiently.

Primitive Abstraction Layers

Please sign in to post comments, or you can view this issue on GitHub.