-
Notifications
You must be signed in to change notification settings - Fork 2
/
cuda_render.cuh
42 lines (38 loc) · 1.38 KB
/
cuda_render.cuh
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
#ifndef CUDA_RENDER_CUH
#define CUDA_RENDER_CUH
#include <GL/glew.h>
#include <cuda_gl_interop.h>
#include "Geometry.hh"
#include "UniformGrid.hh"
#include "cuda_render.hh"
#define BLOCK_SIZE 64
cudaGraphicsResource_t cuda_buffer;
cudaGraphicsResource_t cuda_display_buffer;
cudaGraphicsResource_t cuda_texture;
cudaStream_t cuda_stream;
struct CUDAKernelArgs {
size_t w;
size_t h;
Mat4f camera;
AABB bounds;
UniformGrid grid;
bool accel;
unsigned iteration;
float *pixels;
float *display_pixels;
};
__global__ void cuda_render_kernel(CUDAKernelArgs args);
__global__ void cuda_tonemap_kernel(CUDAKernelArgs args);
__device__ Float3 cuda_trace(const Float3 &ray_orig, const Float3 &ray_dir,
AABB world_bounds, const UniformGrid &grid,
int depth);
__device__ bool cuda_ray_intersect(const Float3 &ray_orig,
const Float3 &ray_dir, AABB world_bounds,
const UniformGrid &grid,
Float3 &intersection, Geometry *&hit_geom);
template <typename II>
__device__ bool cuda_ray_intersect_items(const Float3 &ray_orig,
const Float3 &ray_dir, II b, II e,
Float3 &intersection,
Geometry *&hit_geom);
#endif