-
Notifications
You must be signed in to change notification settings - Fork 8
/
Renderer.h
71 lines (52 loc) · 1.53 KB
/
Renderer.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
#pragma once
#include <thrust/device_vector.h>
#include <vector_types.h>
#include "Camera.h"
#include "Light.h"
#include "Object3D.h"
#include "VoxelData.h"
class Renderer
{
public:
Renderer( int frameWidthInPixels, int frameHeightInPixels, bool shadowMapping );
~Renderer();
void render
(
Object3D const & obj,
Camera const & cam,
Light const & light,
int animationFrameIndex,
uchar4 * outColorBuffer
);
private:
/* Prevent Renderer from being copied */
Renderer( Renderer const & copy );
Renderer & operator=( Renderer const & rhs );
static int const nTHREADS_TRAV_KERNEL = 128;
static int const nTHREADS_DRAW_KERNEL = 128;
static int const nTHREADS_DRAW_SHADOW_KERNEL = 192;
int m_frameWidth;
int m_frameHeight;
bool m_shadowMapping;
thrust::device_vector< BFSJob > m_dJobQueue;
thrust::device_vector< unsigned int > m_dDepthBuffer;
thrust::device_vector< VoxelData > m_dVoxelBuffer;
thrust::device_vector< float > m_dShadowMap;
cudaTextureObject_t m_tDepthBuffer;
void rasterize
(
Object3D const & obj,
Camera const & cam,
Light const & light,
int animationFrameIndex,
bool shadowPass,
uchar4 * outColorBuffer
);
void clearColorBuffer( uchar4 * dpOutColorBuffer );
void clearDepthBuffer();
void clearShadowMap();
void fillJobQueue( BFSJob const * dpJobs, int jobCount );
int resolution() const;
/* Computes ceil( (double) nElements / nThreadsPerBlock ) */
static int nBlocks( int nElements, int nThreadsPerBlock );
};