blob: 93a7ea95678d16901aab21a9ada75110c85e55be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#pragma once
#include <hip/hip_runtime.h>
#include <stdexcept>
#include <string>
#include <vector>
#include <source_location>
inline void hip_check(
hipError_t err,
std::source_location loc = std::source_location::current())
{
if (err != hipSuccess) {
throw std::runtime_error(
std::string(hipGetErrorString(err)) +
" at " + loc.file_name() + ":" + std::to_string(loc.line()));
}
}
struct PyramidLevel {
int width = 0, height = 0;
float4* color_smax = nullptr; // rgb = color, a = s_max
float4* tensor = nullptr; // x=E, y=F, z=G, w=unused
};
struct Pyramid {
std::vector<PyramidLevel> levels; // 0 = finest, back() = coarsest
};
struct Params {
float radius = 5.0f;
float alpha = 1.0f; // eccentricity tuning
int num_sectors = 8;
float q = 8.0f;
float tau_w = 0.02f;
float p_s = 0.5f;
float p_d = 1.25f;
float tau_v = 0.1f;
};
PyramidLevel make_level(int width, int height);
void free_level(PyramidLevel& lvl);
Pyramid make_pyramid(int base_width, int base_height, int num_levels);
void destroy_pyramid(Pyramid& pyr);
void build_pyramid (Pyramid& pyr);
void compute_tensor(Pyramid& pyr, const Params& p);
void smooth_tensor (Pyramid& pyr, const Params& p);
void run_pipeline (Pyramid& pyr, const Params& p);
|