skip to content
==> include/pathtrace/digest.h <==
1/* @ajax/pathtrace-digest: the digests of programs/pathtrace (pathtrace-core lib.rs): FNV-1a 64 over
2 * u32 words, a tile's digest folded from its 32 column digests, and a pass-sum payload's digest (a
3 * fleet job item's J_PART, as meshd's assembler checks it). Freestanding. */
4#ifndef PATHTRACE_DIGEST_H
5#define PATHTRACE_DIGEST_H
6
7#include <stddef.h>
8#include <stdint.h>
9
10#define PT_FNV_OFFSET 0xcbf29ce484222325ull
11#define PT_FNV_PRIME 0x00000100000001b3ull
12
13static inline uint64_t pt_fnv(uint64_t h, uint32_t w) { return (h ^ w) * PT_FNV_PRIME; }
14
15/* FNV-1a 64 over the 32 column digests (lo word, hi word) in column order. */
16uint64_t pt_fold(const uint64_t cols[32]);
17/* FNV-1a 64 over n words from PT_FNV_OFFSET. */
18uint64_t pt_fnv_words(const uint32_t *w, size_t n);
19/* A payload's digest: words are f32 bits, row-major, r g b per pixel (TILE_PIX x 3); per column FNV
20 * over its rows' r g b, the columns folded in order. */
21uint64_t pt_payload_digest(const uint32_t *words);
22
23#endif