Fermat
vertex_storage.h
1 /*
2  * Fermat
3  *
4  * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the NVIDIA CORPORATION nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #pragma once
30 
31 #include <cugar/linalg/vector.h>
32 
35 
38 
39 enum class VertexSampling
40 {
41  kAll = 0,
42  kEnd = 1
43 };
44 
45 enum class VertexOrdering
46 {
47  kRandomOrdering = 0,
48  kPathOrdering = 1
49 };
50 
52 {
54  vertex(NULL),
55  vertex_path_id(NULL),
56  vertex_gbuffer(NULL),
57  vertex_pos(NULL),
58  vertex_input(NULL),
59  vertex_weights(NULL),
60  vertex_counts(NULL),
61  vertex_counter(NULL) {}
62 
63  VPL* vertex;
64  uint32* vertex_path_id;
65  uint4* vertex_gbuffer;
66  float4* vertex_pos;
67  uint2* vertex_input;
68  float2* vertex_weights;
69  uint32* vertex_counts;
70  uint32* vertex_counter;
71 };
72 
74 {
75  void alloc(const uint32 n_paths, const uint32 n_vertices)
76  {
77  vertex.alloc(n_vertices);
78  vertex_path_id.alloc(n_vertices);
79  vertex_pos.alloc(n_vertices);
80  vertex_gbuffer.alloc(n_vertices);
81  vertex_input.alloc(n_vertices);
82  vertex_weights.alloc(n_vertices);
83  vertex_counts.alloc(n_paths);
84  vertex_counter.alloc(1);
85  }
86 
87  VertexStorageView view()
88  {
90  r.vertex = vertex.ptr();
91  r.vertex_path_id = vertex_path_id.ptr();
92  r.vertex_pos = vertex_pos.ptr();
93  r.vertex_gbuffer = vertex_gbuffer.ptr();
94  r.vertex_input = vertex_input.ptr();
95  r.vertex_weights = vertex_weights.ptr();
96  r.vertex_counts = vertex_counts.ptr();
97  r.vertex_counter = vertex_counter.ptr();
98  return r;
99  }
100 
101  DomainBuffer<CUDA_BUFFER, VPL> vertex; // VPL descriptor: needed for local surface and BSDF reconstruction
102  DomainBuffer<CUDA_BUFFER, uint32> vertex_path_id; // vertex path id: (path # | vertex #)
103  DomainBuffer<CUDA_BUFFER, float4> vertex_pos; // vertex position + normal (useful for tree building)
104  DomainBuffer<CUDA_BUFFER, uint4> vertex_gbuffer; // bsdf parameters
105  DomainBuffer<CUDA_BUFFER, uint2> vertex_input; // incident direction / radiance
106  DomainBuffer<CUDA_BUFFER, float2> vertex_weights; // see 'PathWeights' struct
107  DomainBuffer<CUDA_BUFFER, uint32> vertex_counts; // vertex counts, by depth
108  DomainBuffer<CUDA_BUFFER, uint32> vertex_counter; // vertex counts, by depth
109 };
110 
Definition: lights.h:59
Definition: vertex_storage.h:51
Definition: vertex_storage.h:73