2ff87ed6
Add text coverage variant helpers
a73x 2026-04-09 07:58
Commit message
src/renderer.zig
| Old | New | ||
|---|---|---|---|
| @@ -313,6 +313,22 @@ fn nextInstanceCapacity(current: u32, needed: u32) u32 { | |||
| 313 | return capacity; | 313 | return capacity; |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | pub const CoverageVariant = enum(u32) { | ||
| 317 | baseline, | ||
| 318 | mild, | ||
| 319 | medium, | ||
| 320 | crisp, | ||
| 321 | }; | ||
| 322 | |||
| 323 | fn coverageVariantParams(variant: CoverageVariant) [2]f32 { | ||
| 324 | return switch (variant) { | ||
| 325 | .baseline => .{ 1.0, 0.0 }, | ||
| 326 | .mild => .{ 1.15, 0.0 }, | ||
| 327 | .medium => .{ 1.3, 0.0 }, | ||
| 328 | .crisp => .{ 1.55, -0.08 }, | ||
| 329 | }; | ||
| 330 | } | ||
| 331 | |||
| 316 | const InstanceUploadRequest = struct { | 332 | const InstanceUploadRequest = struct { |
| 317 | current_capacity: u32, | 333 | current_capacity: u32, |
| 318 | offset_instances: u32, | 334 | offset_instances: u32, |
| @@ -1468,6 +1484,22 @@ test "swapchainNeedsRebuild flags suboptimal result" { | |||
| 1468 | try std.testing.expect(!swapchainNeedsRebuild(.success)); | 1484 | try std.testing.expect(!swapchainNeedsRebuild(.success)); |
| 1469 | } | 1485 | } |
| 1470 | 1486 | ||
| 1487 | test "coverageVariantParams returns baseline values" { | ||
| 1488 | try std.testing.expectEqualDeep([2]f32{ 1.0, 0.0 }, coverageVariantParams(.baseline)); | ||
| 1489 | } | ||
| 1490 | |||
| 1491 | test "coverageVariantParams steepens progressively" { | ||
| 1492 | const mild = coverageVariantParams(.mild); | ||
| 1493 | const medium = coverageVariantParams(.medium); | ||
| 1494 | const crisp = coverageVariantParams(.crisp); | ||
| 1495 | |||
| 1496 | try std.testing.expect(mild[0] < medium[0]); | ||
| 1497 | try std.testing.expect(medium[0] < crisp[0]); | ||
| 1498 | try std.testing.expectEqual(@as(f32, 0.0), mild[1]); | ||
| 1499 | try std.testing.expectEqual(@as(f32, 0.0), medium[1]); | ||
| 1500 | try std.testing.expectEqual(@as(f32, -0.08), crisp[1]); | ||
| 1501 | } | ||
| 1502 | |||
| 1471 | test "range upload falls back to full upload when capacity must grow" { | 1503 | test "range upload falls back to full upload when capacity must grow" { |
| 1472 | const decision = planInstanceUpload(.{ | 1504 | const decision = planInstanceUpload(.{ |
| 1473 | .current_capacity = 8, | 1505 | .current_capacity = 8, |