Browse Source

Add MeshPrimitive::Instances, Faces and Edges.

To support meshes that are not so GPU-friendly. And also meshlets at a
later point.
pull/371/head
Vladimír Vondruš 6 years ago
parent
commit
d096aa68cc
  1. 5
      doc/changelog.dox
  2. 5
      src/Magnum/GL/Mesh.cpp
  3. 5
      src/Magnum/GL/Test/MeshTest.cpp
  4. 3
      src/Magnum/Implementation/meshPrimitiveMapping.hpp
  5. 43
      src/Magnum/Mesh.h
  6. 5
      src/Magnum/Vk/Enums.cpp

5
doc/changelog.dox

@ -50,6 +50,11 @@ See also:
@ref Color3us, @ref Color4us convenience typedefs for half-float, 8- and
16-bit integer vector and color types
- New @ref VertexFormat enum for vertex formats and related utilities
- New @ref MeshPrimitive::Instances, @ref MeshPrimitive::Faces and
@ref MeshPrimitive::Edges primitive types for describing per-instance,
per-face and per-edge data. Those don't map to any common GPU API, but can
be used by various importers to provide access to mesh data that is not
necessarily GPU-friendly.
@subsubsection changelog-latest-new-audio Audio library

5
src/Magnum/GL/Mesh.cpp

@ -54,7 +54,10 @@ constexpr MeshPrimitive PrimitiveMapping[]{
MeshPrimitive::LineStrip,
MeshPrimitive::Triangles,
MeshPrimitive::TriangleStrip,
MeshPrimitive::TriangleFan
MeshPrimitive::TriangleFan,
MeshPrimitive(~UnsignedInt{}), /* Instances */
MeshPrimitive(~UnsignedInt{}), /* Faces */
MeshPrimitive(~UnsignedInt{}) /* Edges */
};
constexpr MeshIndexType IndexTypeMapping[]{

5
src/Magnum/GL/Test/MeshTest.cpp

@ -191,7 +191,10 @@ void MeshTest::mapPrimitiveImplementationSpecific() {
}
void MeshTest::mapPrimitiveUnsupported() {
CORRADE_SKIP("All primitive types are supported.");
std::ostringstream out;
Error redirectError{&out};
meshPrimitive(Magnum::MeshPrimitive::Instances);
CORRADE_COMPARE(out.str(), "GL::meshPrimitive(): unsupported primitive MeshPrimitive::Instances\n");
}
void MeshTest::mapPrimitiveInvalid() {

3
src/Magnum/Implementation/meshPrimitiveMapping.hpp

@ -32,4 +32,7 @@ _c(LineStrip)
_c(Triangles)
_c(TriangleStrip)
_c(TriangleFan)
_c(Instances)
_c(Faces)
_c(Edges)
#endif

43
src/Magnum/Mesh.h

@ -135,7 +135,48 @@ enum class MeshPrimitive: UnsignedInt {
* @def_vk_keyword{PRIMITIVE_TOPOLOGY_TRIANGLE_FAN,PrimitiveTopology}. Not
* supported on D3D or Metal.
*/
TriangleFan
TriangleFan,
/**
* Per-instance data.
* @m_since_latest
*
* Has no direct mapping to GPU APIs, but can be used to annotate
* @ref Trade::MeshData containing per-instance data (such as colors,
* transformations or texture layers) and then used to populate an instance
* buffer. Index buffer has no defined meaning for instance data.
*/
Instances,
/**
* Per-face data.
* @m_since_latest
*
* Can be used to annotate @ref Trade::MeshData containing data that are
* per-face, as opposed to per-vertex. Has no direct mapping to common GPU
* APIs, there it either has to be converted to per-vertex (which usually
* involves slightly duplicating the original per-vertex data) or accessed
* via a direct buffer/texture fetch from a shader using e.g.
* @glsl gl_VertexID @ce. Index buffer can be used to deduplicate per-face
* data.
*/
Faces,
/**
* Per-edge data.
* @m_since_latest
*
* Can be used to annotate @ref Trade::MeshData containing data that are
* per-edge, as opposed to per-vertex. This is different from
* @ref MeshPrimitive::Lines as it has just one entry per line segment,
* instead of two. Has no direct mapping to common GPU APIs, there it has
* to be converted to per-vertex (which usually involves slightly
* duplicating the original per-vertex data). Index buffer can be used to
* deduplicate per-face data. Can also be used for example to describe a
* half-edge mesh representation.
* @see @ref Trade::meshAttributeCustom()
*/
Edges
};
/** @debugoperatorenum{MeshPrimitive} */

5
src/Magnum/Vk/Enums.cpp

@ -43,7 +43,10 @@ constexpr VkPrimitiveTopology PrimitiveTopologyMapping[]{
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP,
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN,
VkPrimitiveTopology(~UnsignedInt{}), /* Instances */
VkPrimitiveTopology(~UnsignedInt{}), /* Faces */
VkPrimitiveTopology(~UnsignedInt{}) /* Edges */
};
constexpr VkIndexType IndexTypeMapping[]{

Loading…
Cancel
Save