Commit bda7495
authored
OptiX testrender overhaul (take two) (#1897)
This PR is a continuation of #1829, updated to include the recently added triangle mesh support. It enables full path tracing support for the OptiX backend in testrender. We have tried to share code between the CPU and OptiX backends where practical. There is more sharing in this PR than there was in #1829, which should reduce the maintenance burden a bit.
ID-based dispatch
Virtual function calls aren't well supported in OptiX, so rather than using regular C++ polymorphism to invoke the sample(), eval(), and get_albedo() functions for each of the BSDF sub-types, we manually invoke the correct function based on the closure ID (which we have added as a member of the BSDF class).
```
#define BSDF_CAST(BSDF_TYPE, bsdf) reinterpret_cast<const BSDF_TYPE*>(bsdf)
OSL_HOSTDEVICE Color3
CompositeBSDF::get_albedo(const BSDF* bsdf, const Vec3& wo) const
{
Color3 albedo(0);
switch (bsdf->id) {
case DIFFUSE_ID:
albedo = BSDF_CAST(Diffuse<0>, bsdf)->get_albedo(wo);
break;
case TRANSPARENT_ID:
case MX_TRANSPARENT_ID:
albedo = BSDF_CAST(Transparent, bsdf)->get_albedo(wo);
break;
```
Iterative closure evaluation
Another key change is the non-recursive closure evaluation. We apply the same style of iterative tree traversal used in the previous OptiX version of process_closure() to the shared implementations of process_closure(), evaluate_layer_opacity(), process_medium_closure(), and process_background_closure().
Background sampling
We've included support for background closures. This includes an OptiX implementation of the Background::prepare() function. We've broken that function into three phases, where phases 1 and 3 are parallelized across a warp and phase 2 is executed on a single thread. This offers a decent speedup over a single-threaded implementation without the complexity of a more sophisticated implementation.
```
// from background.h
template<typename F>
OSL_HOSTDEVICE void prepare_cuda(int stride, int idx, F cb)
{
prepare_cuda_01(stride, idx, cb);
if (idx == 0)
prepare_cuda_02();
prepare_cuda_03(stride, idx);
}
```
Tests
I have enabled the render-* tests for OptiX mode. I've added alternative reference images, since the GPU output exceeds the difference threshold on many of the tests. But in most cases the difference between the CPU and GPU output is very small.
---------
Signed-off-by: Tim Grant <[email protected]>1 parent 0d3e9d2 commit bda7495
File tree
91 files changed
+2293
-1446
lines changed- src
- cmake
- include/OSL
- testrender
- cuda
- testshade
- cuda
- testsuite
- render-background
- ref
- render-bumptest
- ref
- render-bunny
- ref
- render-cornell
- ref
- render-furnace-diffuse
- ref
- render-material-layer
- render-microfacet
- ref
- render-mx-burley-diffuse
- ref
- render-mx-conductor
- ref
- render-mx-dielectric-glass
- ref
- render-mx-dielectric
- ref
- render-mx-furnace-burley-diffuse
- ref
- render-mx-furnace-oren-nayar
- ref
- render-mx-furnace-sheen
- ref
- render-mx-generalized-schlick-glass
- ref
- render-mx-generalized-schlick
- ref
- render-mx-layer
- ref
- render-mx-sheen
- ref
- render-oren-nayar
- OPTIX_CACHE
- ref
- render-raytypes
- ref
- render-uv
- ref
- render-veachmis
- ref
- render-ward
- ref
- testoptix-noise
- ref
- testoptix-reparam
- ref
- testoptix
- ref
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
91 files changed
+2293
-1446
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
485 | 489 | | |
486 | 490 | | |
487 | 491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | | - | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
58 | | - | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 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 | + | |
13 | 38 | | |
| 39 | + | |
14 | 40 | | |
| 41 | + | |
| 42 | + | |
15 | 43 | | |
16 | 44 | | |
| 45 | + | |
17 | 46 | | |
18 | 47 | | |
19 | 48 | | |
| 49 | + | |
20 | 50 | | |
21 | 51 | | |
22 | 52 | | |
23 | 53 | | |
| 54 | + | |
24 | 55 | | |
25 | 56 | | |
26 | 57 | | |
| |||
29 | 60 | | |
30 | 61 | | |
31 | 62 | | |
| 63 | + | |
32 | 64 | | |
33 | 65 | | |
34 | 66 | | |
| |||
43 | 75 | | |
44 | 76 | | |
45 | 77 | | |
46 | | - | |
| 78 | + | |
47 | 79 | | |
| 80 | + | |
48 | 81 | | |
49 | 82 | | |
50 | 83 | | |
| |||
65 | 98 | | |
66 | 99 | | |
67 | 100 | | |
| 101 | + | |
68 | 102 | | |
69 | 103 | | |
70 | 104 | | |
| |||
90 | 124 | | |
91 | 125 | | |
92 | 126 | | |
| 127 | + | |
93 | 128 | | |
94 | 129 | | |
95 | 130 | | |
| |||
101 | 136 | | |
102 | 137 | | |
103 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
104 | 229 | | |
105 | | - | |
| 230 | + | |
106 | 231 | | |
107 | 232 | | |
108 | 233 | | |
| |||
115 | 240 | | |
116 | 241 | | |
117 | 242 | | |
118 | | - | |
119 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
120 | 246 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
124 | 250 | | |
125 | 251 | | |
| 252 | + | |
126 | 253 | | |
127 | 254 | | |
128 | 255 | | |
| |||
137 | 264 | | |
138 | 265 | | |
139 | 266 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
146 | 274 | | |
147 | 275 | | |
148 | 276 | | |
0 commit comments