Skip to content

Commit 827deea

Browse files
committed
Auto merge of #1154 - tocubed:adjacency-info, r=kvark
Add primitives with adjacency information Fixes #1152 by adding additional variants to `Primitive`.
2 parents 634155e + d87d688 commit 827deea

File tree

6 files changed

+43
-0
lines changed

6 files changed

+43
-0
lines changed

src/backend/dx11/src/factory.rs

+4
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ impl core::Factory<R> for Factory {
569569
LineStrip => D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP,
570570
TriangleList => D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST,
571571
TriangleStrip => D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP,
572+
LineListAdjacency => D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ,
573+
LineStripAdjacency => D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ,
574+
TriangleListAdjacency => D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ,
575+
TriangleStripAdjacency => D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ,
572576
PatchList(num) => {
573577
if num == 0 || (num as usize) > caps.max_patch_size {
574578
return Err(core::pso::CreationError)

src/backend/gl/src/command.rs

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ fn primitive_to_gl(primitive: c::Primitive) -> gl::types::GLenum {
2929
LineStrip => gl::LINE_STRIP,
3030
TriangleList => gl::TRIANGLES,
3131
TriangleStrip => gl::TRIANGLE_STRIP,
32+
LineListAdjacency => gl::LINES_ADJACENCY,
33+
LineStripAdjacency => gl::LINE_STRIP_ADJACENCY,
34+
TriangleListAdjacency => gl::TRIANGLES_ADJACENCY,
35+
TriangleStripAdjacency => gl::TRIANGLE_STRIP_ADJACENCY,
3236
//TriangleFan => gl::TRIANGLE_FAN,
3337
PatchList(_) => gl::PATCHES
3438
}

src/backend/metal/src/map.rs

+7
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ pub fn map_topology(primitive: Primitive) -> MTLPrimitiveTopologyClass {
104104
Primitive::LineStrip |
105105
Primitive::TriangleStrip |
106106
Primitive::PatchList(_) => MTLPrimitiveTopologyClass::Unspecified,
107+
108+
// Metal does not support geometry shaders and hence does not support
109+
// adjacency primitives
110+
Primitive::LineListAdjacency |
111+
Primitive::LineStripAdjacency |
112+
Primitive::TriangleListAdjacency |
113+
Primitive::TriangleStripAdjacency => MTLPrimitiveTopologyClass::Unspecified,
107114
}
108115
}
109116

src/backend/vulkan/src/data.rs

+4
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ pub fn map_topology(prim: Primitive) -> vk::PrimitiveTopology {
306306
Primitive::LineStrip => vk::PRIMITIVE_TOPOLOGY_LINE_STRIP,
307307
Primitive::TriangleList => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
308308
Primitive::TriangleStrip => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
309+
Primitive::LineListAdjacency => vk::PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY,
310+
Primitive::LineStripAdjacency => vk::PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY,
311+
Primitive::TriangleListAdjacency => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY,
312+
Primitive::TriangleStripAdjacency => vk::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY,
309313
Primitive::PatchList(_) => vk::PRIMITIVE_TOPOLOGY_PATCH_LIST,
310314
}
311315
}

src/core/src/lib.rs

+20
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,26 @@ pub enum Primitive {
154154
/// Every three consecutive vertices represent a single triangle. For example, with `[a, b, c,
155155
/// d]`, `a`, `b`, and `c` form a triangle, and `b`, `c`, and `d` form a triangle.
156156
TriangleStrip,
157+
/// Each quadtruplet of vertices represent a single line segment with adjacency information.
158+
/// For example, with `[a, b, c, d]`, `b` and `c` form a line, and `a` and `d` are the adjacent
159+
/// vertices.
160+
LineListAdjacency,
161+
/// Every four consecutive vertices represent a single line segment with adjacency information.
162+
/// For example, with `[a, b, c, d, e]`, `[a, b, c, d]` form a line segment with adjacency, and
163+
/// `[b, c, d, e]` form a line segment with adjacency.
164+
LineStripAdjacency,
165+
/// Each sextuplet of vertices represent a single traingle with adjacency information. For
166+
/// example, with `[a, b, c, d, e, f]`, `a`, `c`, and `e` form a traingle, and `b`, `d`, and
167+
/// `f` are the adjacent vertices, where `b` is adjacent to the edge formed by `a` and `c`, `d`
168+
/// is adjacent to the edge `c` and `e`, and `f` is adjacent to the edge `e` and `a`.
169+
TriangleListAdjacency,
170+
/// Every even-numbered vertex (every other starting from the first) represents an additional
171+
/// vertex for the triangle strip, while odd-numbered vertices (every other starting from the
172+
/// second) represent adjacent vertices. For example, with `[a, b, c, d, e, f, g, h]`, `[a, c,
173+
/// e, g]` form a triangle strip, and `[b, d, f, h]` are the adjacent vertices, where `b`, `d`,
174+
/// and `f` are adjacent to the first triangle in the strip, and `d`, `f`, and `h` are adjacent
175+
/// to the second.
176+
TriangleStripAdjacency,
157177
/// Patch list,
158178
/// used with shaders capable of producing primitives on their own (tessellation)
159179
PatchList(PatchSize),

src/render/src/slice.rs

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ impl<R: Resources> Slice<R> {
9696
p::LineStrip => (nv-1),
9797
p::TriangleList => nv / 3,
9898
p::TriangleStrip => (nv-2) / 3,
99+
p::LineListAdjacency => nv / 4,
100+
p::LineStripAdjacency => (nv-3),
101+
p::TriangleListAdjacency => nv / 6,
102+
p::TriangleStripAdjacency => (nv-4) / 2,
99103
p::PatchList(num) => nv / (num as u32),
100104
}
101105
}

0 commit comments

Comments
 (0)