OWL
Loading...
Searching...
No Matches
pyOWL.h
1#define PYOWL_EXPORT_TYPE(Type) \
2 __constant__ int __owl_typeDecl__##Type = sizeof(Type);
3
4/* 'export' a device variable in device code, such that host-side
5 python bindings can 'find' it and write to it. First parameter is
6 the (device-)type of that variable (e.g., OWL_FLOAT3, OWL_INT,
7 etc); second one is the device type/struct that this varaible is a
8 member of (eg, 'RayGen' if it's a variable of a ray-gen program
9 whose data is stored in a struct of that name; third parameter is
10 how we want to refer to this variable on the python side (eg,
11 'camera_origin'), and last is he name of the member of the
12 device-side struct that stores the actual variable (eg,
13 'camera.origin')
14*/
15#define PYOWL_EXPORT_VARIABLE(type,typeName,varName,var) \
16 __constant__ int __owl_varDeclOffset__##typeName##____##varName = (size_t)&((typeName*)0)->var; \
17 __constant__ int __owl_varDeclType__##typeName##____##varName = type;
18
19
20/*
21Example: Suppose we have a device-side ray-gen program that uses the
22following struct to store its data:
23
24# pyOWL CUDA device code:
25struct RayGen {
26 struct {
27 uint32_t *memory;
28 uint2 size;
29 } fb;
30 ...
31}
32
33Then the device-side struct 'RayGen' would be declared as
34
35# pyOWL CUDA device code:
36 PYOWL_EXPORT_TYPE(RayGen)
37
38and its variable RayGen::fb.memory and RayGen::fb.size could be exported as
39
40# pyOWL CUDA device code:
41 PYOWL_EXPORT_VARIABLE(OWL_BUFPTR,RayGen,fb_memory,fb.size)
42 PYOWL_EXPORT_VARIABLE(OWL_BUFPTR,RayGen,fb_size,fb.size)
43
44On the host side --- assuming the user has already created some python
45variables `frame_buffer` and `fb_size` --- these can then be set as
46
47# main user python code:
48 ray_gen.set_2i("fb_size",fb_size)
49 ray_gen.set_buffer("fb_memory",frame_buffer)
50*/
51
52
53
54