-
Notifications
You must be signed in to change notification settings - Fork 2
/
Context_ex.h
91 lines (70 loc) · 2.01 KB
/
Context_ex.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
namespace VkInline
{
namespace Internal
{
class BaseLevelAS;
class TopLevelAS;
}
class BaseLevelAS
{
public:
BaseLevelAS(SVBuffer* indBuf, SVBuffer* posBuf);
BaseLevelAS(SVBuffer* aabbBuf);
~BaseLevelAS();
Internal::BaseLevelAS* internal() { return m_blas; }
const Internal::BaseLevelAS* internal() const { return m_blas; }
private:
Internal::BaseLevelAS* m_blas;
};
class Mat4
{
public:
Mat4(const float* data);
const float* data() const { return m_data; }
private:
float m_data[16];
};
struct BLAS_EX
{
const BaseLevelAS* blas;
const Mat4* trans;
};
class TopLevelAS
{
public:
TopLevelAS(const std::vector<std::vector<BLAS_EX>>& blases);
~TopLevelAS();
Internal::TopLevelAS* internal() { return m_tlas; }
const Internal::TopLevelAS* internal() const { return m_tlas; }
private:
Internal::TopLevelAS* m_tlas;
};
class BodyHitShaders
{
public:
BodyHitShaders(const char* body_closest_hit, const char* body_intersection);
const char* body_closest_hit() const;
const char* body_intersection() const;
private:
std::string m_body_closest_hit;
std::string m_body_intersection;
};
class RayTracer
{
public:
size_t num_params() const { return m_param_names.size(); }
RayTracer(const std::vector<const char*>& param_names, const char* body_raygen, const std::vector<const char*>& body_miss, const std::vector<const BodyHitShaders*>& body_hit, unsigned maxRecursionDepth, bool type_locked = false);
bool launch(dim_type glbDim, const ShaderViewable** args, const std::vector<TopLevelAS*>& arr_tlas,
const std::vector<Texture2D*>& tex2ds, const std::vector<Texture3D*>& tex3ds, const std::vector<Cubemap*>& cubemaps, size_t times_submission = 1);
private:
std::vector<std::string> m_param_names;
std::string m_body_raygen;
std::vector<std::string> m_body_miss;
std::vector<const BodyHitShaders*> m_body_hit;
unsigned m_maxRecursionDepth;
bool m_type_locked;
unsigned m_kid;
std::vector<size_t> m_offsets;
std::mutex m_mu_type_lock;
};
}