GCC Code Coverage Report


ernie/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
1 / 1
100.0%
Branches:
1 / 2
50.0%
Functions:
-
-%

shaders/scene/geometry.slang
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 /// @file geometry.slang
3 /// @brief Geometry as kernels read it: its kinds and records, shared with C++ (geometry.h).
4 #ifdef __cplusplus
5 #pragma once
6 #include "ernie/shaders/shared.h"
7 namespace ernie::shaders {
8 #else
9 import buffer_ref;
10 #endif
11
12 /// The kinds of geometry: triangles, then the unit shapes procedural primitives stand for.
13 static const uint kTriangles = 0;
14 static const uint kSphere = 1;
15 static const uint kCube = 2;
16 static const uint kCylinder = 3;
17 static const uint kCone = 4;
18 static const uint kCapsule = 5;
19 static const uint kPlane = 6;
20
21 /// A geometry as kernels read it, by geometry id: an instance's custom index.
22
1/2
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
39 struct GeometryRecord {
23 uint kind;
24 /// A capsule's segment half-length over its radius.
25 float halfLength;
26 uint vertexCount;
27 uint triangleCount;
28 /// Triangles' x, y, z positions and their corners' indices, three a triangle.
29 BufferRef<float> vertices;
30 BufferRef<uint> indices;
31 };
32
33 #ifdef __cplusplus
34 } // namespace ernie::shaders
35 #else
36
37 /// Writes a triangle's corners, in the geometry's frame, to `corners`.
38 void Corners(GeometryRecord record, uint triangle, out float3 corners[3]) {
39 for (uint i = 0; i < 3; ++i) {
40 uint at = 3 * record.indices[3 * triangle + i];
41 corners[i] = float3(record.vertices[at], record.vertices[at + 1], record.vertices[at + 2]);
42 }
43 }
44
45 #endif
46