upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
author73N1X <115502401+73N1X@users.noreply.github.com>2026-11-22 16:20:44 -0400
committer73N1X <115502401+73N1X@users.noreply.github.com>2026-11-22 16:20:44 -0400
commitb5e9ca4ccc8a013d7f2353d290b151aeae16349e (patch)
tree53f30289e4d95bb73ee5aafdb386f1c348e3a2ab /runtime/src
parentb9cc5f9a32fa46d655fe124901706cac6a371eb4 (diff)
Runtime: expose conservative rasterization Tier 2 with capability gates
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/conservative_raster.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/runtime/src/conservative_raster.h b/runtime/src/conservative_raster.h
index cf2f5f2c0..82c1330a2 100644
--- a/runtime/src/conservative_raster.h
+++ b/runtime/src/conservative_raster.h
@@ -1,14 +1,24 @@
1#pragma once 1#pragma once
2#include <cmath> 2#include <cmath>
3#include <cstdint> 3#include <cstdint>
4#include <algorithm>
4 5
5namespace leonida::conservative_raster { 6namespace leonida::conservative_raster {
6// Tier 1 bounds the outer uncertainty to half a pixel and requires a 16.8 rasterization grid. Leave room for 7// Tier 1 bounds the outer uncertainty to half a pixel and requires a 16.8 rasterization grid. Leave room for
7// half a grid step at that minimum precision in addition to Vulkan's fixed primitive overestimation. Do not 8// half a grid step at that minimum precision in addition to Vulkan's fixed primitive overestimation. Do not
8// infer Tier 2/3 from degenerate-triangle support: their tighter bounds and InnerCoverage need separate work. 9// infer Tier 3 from degenerate-triangle support: InnerCoverage needs separate work.
9inline bool tier1(bool extension_enabled, std::uint32_t subpixel_bits, float overestimate) { 10inline bool tier1(bool extension_enabled, std::uint32_t subpixel_bits, float overestimate) {
10 constexpr float maximum = 0.5f - 1.0f / 512.0f; 11 constexpr float maximum = 0.5f - 1.0f / 512.0f;
11 return extension_enabled && subpixel_bits >= 8 && std::isfinite(overestimate) && 12 return extension_enabled && subpixel_bits >= 8 && std::isfinite(overestimate) &&
12 overestimate >= 0.0f && overestimate <= maximum; 13 overestimate >= 0.0f && overestimate <= maximum;
13} 14}
15
16inline std::uint32_t tier(bool extension_enabled, std::uint32_t subpixel_bits, float overestimate,
17 bool degenerate_triangles) {
18 if (!tier1(extension_enabled, subpixel_bits, overestimate)) return 0;
19 // Tier 2 allows 1/256 pixel total uncertainty and requires post-snap degenerates. Reserve half of the
20 // device's actual raster grid step, conservatively capped at float's useful precision, for snapping.
21 const float snap = std::ldexp(0.5f, -int(std::min(subpixel_bits, 24u)));
22 return degenerate_triangles && overestimate <= 1.0f / 256.0f - snap ? 2u : 1u;
23}
14} // namespace leonida::conservative_raster 24} // namespace leonida::conservative_raster