-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <tgrant@nvidia.com>
- Loading branch information
Showing
91 changed files
with
2,293 additions
and
1,446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.