MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
DispatchLayouts.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
7constexpr uint32_t CC_BACKGROUND_HOST = 0xFFFFFFFFU;
8constexpr uint32_t CC_UNCLAIMED_HOST = 0U;
9
10/** Standard 2D workgroup used by all pixel-to-pixel vision shaders */
11constexpr std::array<uint32_t, 3> k_wg2d { 8, 8, 1 };
12/** Maximum number of connected components that can be labeled in a single pass */
13constexpr uint32_t k_max_components = 4096;
14/** Maximum number of points that can be stored in a single contour */
15constexpr uint32_t k_max_points_per_contour = 4096;
16/** Maximum number of contours that can be stored in a single pass */
17constexpr uint32_t k_max_holes_per_label = 4;
18/** Maximum number of trace slots that can be stored in a single pass (for contour tracing) */
20/** Upper bound on tracked keypoints, matching extract_peaks' buffer capacity */
21constexpr uint32_t k_flow_max_points = 4096;
22/** Smallest pyramid level edge worth building */
23constexpr uint32_t k_flow_min_level_extent = 16;
24/** Largest window radius the tracker's shared template cache holds */
25constexpr uint32_t k_flow_max_radius = 15;
26/** Frame change, in 1/1024 intensity summed over pixels, at or below which a frame counts as a repeat */
27constexpr uint32_t k_flow_duplicate_energy = 16;
28/** Largest summation window radius of the dense solver */
29constexpr uint32_t k_flow_dense_max_radius = 15;
30/** Occupancy grid capacity in cells; the cell size grows to fit large frames */
31constexpr uint32_t k_flow_grid_capacity = 1U << 18;
32
33constexpr uint32_t k_flow_select_local = 256;
34
35constexpr size_t k_flow_args_count = 4;
36constexpr uint64_t k_flow_args_stride = 3 * sizeof(uint32_t);
37/** Export buffer size in vec4: one header plus two per track */
38constexpr size_t k_flow_export_vec4 = size_t { 1 } + size_t { k_flow_max_points } * 2;
39
40// ============================================================================
41// Internal push constant layouts
42// ============================================================================
43
45 float value;
46};
48 float lo0, lo1, lo2;
49 float hi0, hi1, hi2;
50 uint32_t channels;
51};
53 uint32_t block_size;
54 float offset;
55 uint32_t channels;
56};
57struct OtsuHistPC {
58 uint32_t width;
59 uint32_t height;
60 uint32_t channels;
61};
63 uint32_t channels;
64};
66 float scale;
67 float offset;
68};
69struct MorphPC {
70 uint32_t radius;
71};
72struct IngestPC {
73 uint32_t width;
74 uint32_t height;
75};
76/** Half-open pixel rectangle [x0, x1) x [y0, y1) */
77struct PixelRect {
78 uint32_t x0;
79 uint32_t y0;
80 uint32_t x1;
81 uint32_t y1;
82};
83
84/**
85 * @brief Pixel rectangle of a normalised region over a w x h image, clamped
86 * to the image. No region is the whole image. A region that clamps to
87 * nothing gives an empty rectangle, which masks everything.
88 */
90 const std::optional<Kinesis::Vision::BoundingBox>& region, uint32_t w, uint32_t h)
91{
92 if (!region)
93 return { .x0 = 0U, .y0 = 0U, .x1 = w, .y1 = h };
94
95 const auto fw = static_cast<float>(w);
96 const auto fh = static_cast<float>(h);
97 const auto clamp_to = [](float v, uint32_t hi) {
98 return static_cast<uint32_t>(std::clamp(v, 0.0F, static_cast<float>(hi)));
99 };
100 return {
101 .x0 = clamp_to(std::floor(region->x * fw), w),
102 .y0 = clamp_to(std::floor(region->y * fh), h),
103 .x1 = clamp_to(std::ceil((region->x + region->w) * fw), w),
104 .y1 = clamp_to(std::ceil((region->y + region->h) * fh), h),
105 };
106}
107
108struct HarrisPC {
109 float k;
110 uint32_t pass;
111 uint32_t width;
112 uint32_t height;
114};
115struct CannyPC {
116 float sigma;
117 float lo;
118 float hi;
119};
121 float wr;
122 float wg;
123 float wb;
124 float wa;
125};
127 uint32_t radius;
128 uint32_t width;
129 uint32_t height;
130};
132 std::shared_ptr<Core::VKImage> output;
133 std::shared_ptr<Core::VKImage> input;
134};
137 float value;
138};
140 uint32_t width;
141 uint32_t height;
142};
145};
148 uint32_t nms_radius;
149 uint32_t width;
150 uint32_t height;
153};
155 uint32_t width;
156 uint32_t height;
157 uint32_t block_width;
158 uint32_t block_height;
159};
160struct CCMergePC {
161 uint32_t width;
162 uint32_t height;
163 uint32_t block_width;
164 uint32_t block_height;
165};
167 uint32_t block_width;
168 uint32_t block_height;
169};
171 uint32_t width;
172 uint32_t height;
173 uint32_t block_width;
174 uint32_t block_height;
177};
178struct CCResetPC {
179 uint32_t lut_size;
181};
183 uint32_t target_label;
184 uint32_t width;
185 uint32_t height;
186};
188 uint32_t width;
189 uint32_t height;
190 uint32_t max_segments;
191};
193 uint32_t width;
194 uint32_t height;
195 uint32_t phase;
196};
198 uint32_t width;
199 uint32_t height;
200};
202 uint32_t width;
203 uint32_t height;
206 uint32_t max_contours;
207};
209 uint32_t width;
210 uint32_t height;
214 uint32_t phase;
215 float min_area;
217};
223 uint32_t round;
224 uint32_t count;
225};
226
228 uint32_t target_atlas;
229 uint32_t level;
230 uint32_t src_w;
231 uint32_t src_h;
232 uint32_t src_ox;
233 uint32_t src_oy;
234 uint32_t dst_w;
235 uint32_t dst_h;
236 uint32_t dst_ox;
237 uint32_t dst_oy;
238 uint32_t src_channel;
239};
240struct FlowLkPC {
241 uint32_t curr_atlas;
242 uint32_t level;
243 uint32_t coarsest;
244 uint32_t pad0;
245 uint32_t lvl_ox;
246 uint32_t lvl_oy;
247 uint32_t lvl_w;
248 uint32_t lvl_h;
249 uint32_t base_w;
250 uint32_t base_h;
255 uint32_t max_points;
256 uint32_t pad1;
257 uint32_t backward;
259};
260
261enum class FlowSelectPhase : uint8_t {
262 CLEAR = 0,
263 SURVIVORS = 1,
264 HISTOGRAM = 2,
265 THRESHOLD = 3,
266 ADD_STRONG = 4,
267 ADD_MARGINAL = 5,
268 COMMIT = 6,
269 PUBLISH = 7,
270 ARGS = 8,
271};
272
274 uint32_t phase;
275 uint32_t max_points;
276 uint32_t have_prev;
277 uint32_t grid_w;
278 uint32_t grid_h;
279 uint32_t grid_cells;
280 float cell;
281 float base_w;
282 float base_h;
283 uint32_t publish_slot;
285};
286
292
293enum class FlowDensePhase : uint8_t {
294 TENSOR_H = 0,
295 TENSOR_V = 1,
296 WARP_INIT = 2,
297 WARP = 3,
298 BOX_H = 4,
299 SOLVE = 5,
300 VISUALIZE = 6,
301};
302
304 uint32_t phase;
305 uint32_t curr_atlas;
306 uint32_t out_parity;
307 uint32_t level;
308 uint32_t lvl_ox;
309 uint32_t lvl_oy;
310 uint32_t lvl_w;
311 uint32_t lvl_h;
312 uint32_t crs_ox;
313 uint32_t crs_oy;
314 uint32_t crs_w;
315 uint32_t crs_h;
316 uint32_t has_coarse;
317 uint32_t radius;
319 float max_step;
323};
324
325struct ConfinePC {
326 uint32_t src_x, src_y, src_w, src_h;
327 uint32_t out_w, out_h;
328};
329
330/**
331 * @brief Clamped record count from an exported buffer's vec4 header, or
332 * nullopt when the buffer isn't readable.
333 *
334 * Shared by every read_exported_* decode: header[0].x holds the count as
335 * uint bits, clamped to the buffer's actual capacity at stride_vec4 per
336 * record (one header vec4 assumed).
337 */
338inline std::optional<uint32_t> exported_record_count(
339 const std::shared_ptr<Portal::Graphics::GpuBufferHandle>& handle,
340 size_t stride_vec4)
341{
342 if (!handle || !handle->mapped_ptr || handle->size_bytes < sizeof(glm::vec4))
343 return std::nullopt;
344
345 const auto* header = static_cast<const glm::vec4*>(handle->mapped_ptr);
346 const size_t capacity = (handle->size_bytes / sizeof(glm::vec4) - 1U) / stride_vec4;
347 return static_cast<uint32_t>(std::min<size_t>(std::bit_cast<uint32_t>(header[0].x), capacity));
348}
349
350} // namespace MayaFlux::Yantra::VisionInternal
uint32_t h
Definition InkPress.cpp:29
GPU execution layer for Kinesis::Vision::VisionSequence.
constexpr size_t k_flow_export_vec4
Export buffer size in vec4: one header plus two per track.
constexpr uint32_t k_max_holes_per_label
Maximum number of contours that can be stored in a single pass.
constexpr uint32_t k_flow_min_level_extent
Smallest pyramid level edge worth building.
constexpr uint32_t k_flow_duplicate_energy
Frame change, in 1/1024 intensity summed over pixels, at or below which a frame counts as a repeat.
constexpr uint32_t k_flow_max_radius
Largest window radius the tracker's shared template cache holds.
std::optional< uint32_t > exported_record_count(const std::shared_ptr< Portal::Graphics::GpuBufferHandle > &handle, size_t stride_vec4)
Clamped record count from an exported buffer's vec4 header, or nullopt when the buffer isn't readable...
constexpr uint32_t k_max_components
Maximum number of connected components that can be labeled in a single pass.
constexpr uint32_t k_flow_grid_capacity
Occupancy grid capacity in cells; the cell size grows to fit large frames.
constexpr uint32_t k_max_points_per_contour
Maximum number of points that can be stored in a single contour.
PixelRect region_rect(const std::optional< Kinesis::Vision::BoundingBox > &region, uint32_t w, uint32_t h)
Pixel rectangle of a normalised region over a w x h image, clamped to the image.
constexpr uint32_t k_flow_max_points
Upper bound on tracked keypoints, matching extract_peaks' buffer capacity.
constexpr std::array< uint32_t, 3 > k_wg2d
Standard 2D workgroup used by all pixel-to-pixel vision shaders.
constexpr uint32_t k_max_trace_slots
Maximum number of trace slots that can be stored in a single pass (for contour tracing)
constexpr uint32_t k_flow_dense_max_radius
Largest summation window radius of the dense solver.
ElementType
Element type the shader expects in this binding.
Half-open pixel rectangle [x0, x1) x [y0, y1)