Commit Graph

759 Commits

Author SHA1 Message Date
Sergey Sharybin
6fff73e3f0 Merge branch 'blender-v2.82-release' 2020-01-23 16:59:50 +01:00
Sergey Sharybin
517870a4a1 CMake: Refactor external dependencies handling
This is a more correct fix to the issue Brecht was fixing in D6600.

While the fix in that patch worked fine for linking it broke ASAN
runtime under some circumstances.
For example, `make full debug developer` would compile, but trying
to start blender will cause assert failure in ASAN (related on check
that ASAN is not running already).

Top-level idea: leave it to CMake to keep track of dependency graph.

The root of the issue comes to the fact that target like "blender" is
configured to use a lot of static libraries coming from Blender sources
and to use external static libraries. There is nothing which ensures
order between blender's and external libraries. Only order of blender
libraries is guaranteed.

It was possible that due to a cycle or other circumstances some of
blender libraries would have been passed to linker after libraries
it uses, causing linker errors.

For example, this order will likely fail:

  libbf_blenfont.a libfreetype6.a libbf_blenfont.a

This change makes it so blender libraries are explicitly provided
their dependencies to an external libraries, which allows CMake to
ensure they are always linked against them.

General rule here: if bf_foo depends on an external library it is
to be provided to LIBS for bf_foo.
For example, if bf_blenkernel depends on opensubdiv then LIBS in
blenkernel's CMakeLists.txt is to include OPENSUBDIB_LIBRARIES.

The change is made based on searching for used include folders
such as OPENSUBDIV_INCLUDE_DIRS and adding corresponding libraries
to LIBS ion that CMakeLists.txt. Transitive dependencies are not
simplified by this approach, but I am not aware of any downside of
this: CMake should be smart enough to simplify them on its side.
And even if not, this shouldn't affect linking time.

Benefit of not relying on transitive dependencies is that build
system is more robust towards future changes. For example, if
bf_intern_opensubiv is no longer depends on OPENSUBDIV_LIBRARIES
and all such code is moved to bf_blenkernel this will not break
linking.

The not-so-trivial part is change to blender_add_lib (and its
version in Cycles). The complexity is caused by libraries being
provided as a single list argument which doesn't allow to use
different release and debug libraries on Windows. The idea is:

- Have every library prefixed as "optimized" or "debug" if
  separation is needed (non-prefixed libraries will be considered
  "generic").

- Loop through libraries passed to function and do simple parsing
  which will look for "optimized" and "debug" words and specify
  following library to corresponding category.

This isn't something particularly great. Alternative would be to
use target_link_libraries() directly, which sounds like more code
but which is more explicit and allows to have more flexibility
and control comparing to wrapper approach.

Tested the following configurations on Linux, macOS and Windows:

- make full debug developer
- make full release developer
- make lite debug developer
- make lite release developer

NOTE: Linux libraries needs to be compiled with D6641 applied,
otherwise, depending on configuration, it's possible to run into
duplicated zlib symbols error.

Differential Revision: https://developer.blender.org/D6642
2020-01-23 16:59:18 +01:00
Antonio Vazquez
fb671035be Merge branch 'blender-v2.82-release' 2020-01-23 16:56:26 +01:00
Patrick Mours
26687dda5a Fix T71344: Optix render errors with motion blur and unknown bone constraint relationship
The OptiX SRT motion expects a motion defined by translation,
rotation, shear and scale, but the matrix decomposition code in
Cycles was not able to extract shear information and instead
produced a stretch matrix with the information baked in. This
caused conflicting transforms between traversal and shading
and lead to render artifacts.
This patch changes the matrix decomposition to produce factors
inline with what OptiX expects to fix that.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6605
2020-01-22 15:49:14 +01:00
Patrick Mours
2a638e8c90 Merge branch 'blender-v2.82-release' 2020-01-14 17:49:04 +01:00
Patrick Mours
ff430dea66 Fix rendering motion blur scenes with OptiX failing with CUDA_ERROR_INVALID_CONTEXT
Commit baeb11826b9fe5525db6dd05ba5271949079fc1e switched memory
allocation for the motion transform to use CUDA directly, instead of going
through abstractions. But no CUDA context was set active before those
were called, so the calls failed. This fixes that by binding a context beforehand.
2020-01-14 17:48:16 +01:00
Patrick Mours
89578a8f6e Fix OptiX acceleration structure failing to build in viewport
The `optixAccelBuild` API throws an error when the property to get compacted size is passed in
without the `OPTIX_BUILD_FLAG_ALLOW_COMPACTION` flag set. This is not currently hit
because `background` is always true (set in `mem_alloc`), but would become an issue once that
is sorted out, so fixing it now to be safe.
2020-01-10 16:03:11 +01:00
Patrick Mours
d5ca72191c Cycles: Add OptiX AI denoiser support
This patch adds support for the OptiX denoiser as an alternative to the existing NLM denoiser in Cycles. It's re-using the same denoising architecture based on tiles and therefore implicitly also works with multiple GPUs.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D6395
2020-01-08 16:53:11 +01:00
Jeroen Bakker
f5e37af5a8 Cycles/OpenCL: Remove NULL PTR Workaround
In the current OpenCL implementation we have a work-around for platforms
that didn't support NULL pointers. We used to replace all NULLs and
empty arrays with a pointer to a single byte on the OpenCL Device.

During investigation of {T65924} it was asked to remove this work-around
for testing. This change improves the render times.

    SCENE              | BEFORE | AFTER
   --------------------+--------+-------
   bmw27               | 108    | 89
   barbershop_interior | 867    | 673
   classroom           | 270    | 173
   fishy_cat           | 244    | 196
   koro                | 249    | 207
   pavillon_barcelona  | 582    | 414

Note that this change does not fix T65924 it just improves the
rendering performance for OpenCL. We haven't tested this patch on all
platforms so we should keep an eye out on the tracker.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D6391
2019-12-11 11:59:21 +01:00
Patrick Mours
baeb11826b Cycles: Add OptiX acceleration structure compaction
This adds compaction support for OptiX acceleration structures, which reduces the device memory footprint in a post step after building. Depending on the scene this can reduce the amount of used device memory quite a bit and even improve performance (smaller acceleration structure improves cache usage). It's only enabled for background renders to make acceleration structure builds fast in viewport.

Also fixes a bug in the memory management for OptiX acceleration structures: These were held in a dynamic vector of 'device_memory' instances and used the mem_alloc/mem_free functions. However, those keep track of memory instances in the 'cuda_mem_map' via pointers to 'device_memory' (which works fine everywhere else since those are never copied/moved). But in the case of the vector, it may decide to reallocate at some point, which invalidates those pointers and would result in some nasty accesses to invalid memory. So it is not actually safe to move a 'device_memory' object and therefore this removes the move operator overloads again.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6369
2019-12-09 14:32:12 +01:00
Patrick Mours
8caeae9f40 Fix crash if OptiX context creation fails in Cycles
When encountering an error during context creation, the "OptiXDevice" constructor aborts early.
This means the "cuda_stream" vector is never resized and the destructor iterated over non-existent data.
2019-11-28 17:07:14 +01:00
Patrick Mours
70a32adfeb Fix assert in Cycles memory statistics when using OptiX on multiple GPUs
The acceleration structure built by OptiX may be different between GPUs, so cannot assume the memory size is the same for all.
This fixes that by moving the memory management for all OptiX acceleration structures into the responsibility of each device (was already the case for BLAS previously, now for TLAS too).
2019-11-28 13:57:02 +01:00
Patrick Mours
03cdfc2ff6 Fix potential access to deleted memory in OptiX kernel loading code
Calling "OptiXDevice::load_kernels" multiple times would call "optixPipelineDestroy" on a pipeline
pointer that may have already been deleted previously (since the PIP_SHADER_EVAL pipeline is only
created conditionally).
This change also avoids a CUDA kernel reload every time this is called. The CUDA kernels are
precompiled and don't change, so there is no need to reload them every time.
2019-11-25 18:36:55 +01:00
Sergey Sharybin
4ab0b2b5aa Merge branch 'blender-v2.81-release' 2019-11-07 11:12:44 +01:00
Sergey Sharybin
aa2904ea13 Cycles: Fix strict compiler warning
Pointer used for math arithmetics in assert().
CUDA device pointer is actually an integer type, not a pointer.
2019-11-07 11:06:41 +01:00
af9a50bfe6 Merge branch 'blender-v2.81-release' 2019-11-05 17:35:27 +01:00
Ha Hyung-jin
9a9e93e804 Fix T71071: errors when using multiple CUDA/Optix GPUs and host mapped memory
The multi device code did not correctly handle cases where some GPUs store a
resource in device memory and others store it in host mapped memory.

Differential Revision: https://developer.blender.org/D6126
2019-11-05 16:40:55 +01:00
Patrick Mours
200267eb96 Merge branch 'blender-v2.81-release' 2019-10-21 15:53:29 +02:00
Patrick Mours
d0cba5caf4 Fix T70937: Cycles fails in viewport when rendering with OptiX
Was caused by D6068, which did not handle "MEM_PIXELS" memory
when not in background mode. Before that it always fell back to using
generic device memory, so restoring that behavior. In future this
should be changes to use OpenGL interop for optimal performance.
2019-10-21 14:23:45 +02:00
Philipp Oeser
8148bf8cf0 Merge branch 'blender-v2.81-release' 2019-10-18 13:33:20 +02:00
Patrick Mours
8378db40c7 Cycles: Fix out of memory when rendering some scenes with OptiX that work with CUDA
The OptiX implementation wasn't trying to allocate memory on the host if device allocation failed, while the CUDA implementation did. This copies the implementation over to OptiX to remedy that.

Differential Revision: https://developer.blender.org/D6068
2019-10-18 12:23:27 +02:00
Stefan Werner
35a545b752 Cycles: Allow PTX targets for CUDA kernel build.
This is intended for developers on Windows primarily:
Now, CUDA architectures of type compute_xx are supported. This allows for quicker builds,
at the expense of the CUDA driver running ptxas the first time a kernel is loaded.

Differential Revision: https://developer.blender.org/D5953
2019-10-16 10:29:04 +02:00
Patrick Mours
0091b84df0 Fix T70268: Render failures with Vector pass active with OptiX in Cycles
Rendering would produce invalid results or crash if the Vector pass was active but motion blur was inactive. This caused the OptiX BVH to be built with motion (because objects reported motion available), but the pipeline to be built without motion support (since with disabled motion blur this is not in the list of requested features). The two are not compatible and therefore caused issues. This patch fixes that by not building the BVH with motion if motion blur is not active (which makes sense).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5968
2019-10-02 13:23:29 +02:00
Patrick Mours
8dd9172aa2 Fix "motion_blur" tests with OptiX in Cycles
Curves with motion blur produced wrong results with OptiX (T69801). This is because the AABBs for the motion steps were calculated from incorrect attribute data because the offset into the attribute data array was incorrect.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5961
2019-10-01 20:01:51 +02:00
Patrick Mours
91f6aa6a57 Fix memory leak after using OptiX in Cycles
The "optix_devices" array was not freed on exit, which caused a memory leak (see T69801).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5944
2019-09-30 14:05:40 +02:00
1d1ef2e797 Revert part of "GPencil: Invert Paste operator and make Paste to Active default"
This commit accidentally undid a bunch of previous commits. Only the intended
changes are left now.
2019-09-23 11:09:00 +02:00
Patrick Mours
a2b52dc571 Cycles: add Optix device backend
This uses hardware-accelerated raytracing on NVIDIA RTX graphics cards.

It is still currently experimental. Most features are supported, but a few
are still missing like baking, branched path tracing and using CPU memory.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.81/Cycles#NVIDIA_RTX

For building with Optix support, the Optix SDK must be installed. See here for
build instructions:
https://wiki.blender.org/wiki/Building_Blender/CUDA

Differential Revision: https://developer.blender.org/D5363
2019-09-13 11:50:11 +02:00
Jeroen Bakker
b9ed30c25c Cycles: OpenCL Separate Compilation Debug Flag
OpenCL Parallel compilation only works inside Blender. When using cycles in a different setup (standaline or other software) it failed compiling kernels as they don't have the appropriate Python API and command line arguments.

This change introduces a `running_inside_blender` debug flag, that triggers out of process compilation of the kernels. Compilation still happens in subthread that enabled the preview kernels and compilation of the kernels during BVH building

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5439
2019-08-30 13:53:23 +02:00
Patrick Mours
c32377da98 Cycles: support move semantics for device_memory
Ref D5363
2019-08-26 17:42:52 +02:00
Antonio Vazquez
51d9f56f87 GPencil: Invert Paste operator and make Paste to Active default
Before there were two options: Paste to original layer called "Paste" and Paste to active   layer called "Paste & Merge"

Now, by default the paste is in active layer and the "Paste & Merge" has been renamed "Paste".

For old "Paste", now is called "Paste by Layer" and it's not the default value anymore.

Note: Minor edits to add icons not present in Differential revision.

Differential Revision: https://developer.blender.org/D5591
2019-08-26 15:49:16 +02:00
Lazydodo
b9f61eb874 Cycles: Fix Architecture logging on x64.
x64 builds with WITH_CYCLES_OPTIMIZED_KERNEL_SSE2 not defined
since SSE2 is the lower bar for x64 cpus. Turning the architecture
logging related if into the last if in the architecture detection
chain, which will never execute unless you turn off all kernels
in de debug flags.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5579
2019-08-26 07:22:44 -06:00
Campbell Barton
2425401a59 Cleanup: spelling 2019-08-04 12:51:44 +10:00
Sergey Sharybin
7ad21c3876 Fix T66604: Cycles bake crash on specific scene with volume
The issue was caused by un-initialized local storage for volume
intersection hits which are supposed to be stored in per-thread
KernelGlobals.

Fix is to make thread_shader() be the same as thread_render() in
respect of KernelGlobals.

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5230
2019-07-11 15:44:09 +02:00
Campbell Barton
cd6b49f995 Cleanup: spelling 2019-07-07 15:38:41 +10:00
Aaron Carlisle
fdcfc263e9 Use latest/version number for manual links
We want users to go to the current version for their current version 
when possible if not point to latest.

/dev should really only be for development related work. End users 
should not be browsing /dev unless they are reading about upcoming 
features ahead of time.
2019-07-04 18:24:36 -04:00
b10921f0cc Fix Cycles CUDA suboptimal performance on Windows 10 with recent graphics cards
When compute preemption is available we schedule more work which is more
efficient. However the CUDA driver appears to be incorrectly reporting this as
unavailable, even though it should be supported starting with Windows 10 1803
and Pascal and Turing (10x0 and 20x0) graphics cards.

This reduces render time by about a 25% difference on our benchmark scenes. On
Linux compute preemption appears to be reported correctly.
2019-06-18 20:05:36 +02:00
Lukas Stockner
cc600de669 Cycles Denoising: Get rid of halos around bright edges
Previously, bright edges (e.g. caused by rim lighting) would sometimes get
halos around them after denoising.

This change introduces a log(1+x) highlight compression step that is performed
before denoising and reversed afterwards. That way, the denoising algorithm
itself operates in the compressed space and therefore bright edges cause less
numerical issues.
2019-06-01 00:45:03 +02:00
Sergey Sharybin
fced0f0437 Cycles: Don't advertise BVH8 being supported on 32bit platforms
The kernel does not use AVX2 vectorization, and trying to use BVH8 was
leading to an empty scenes.

Fixes T64624: Ctest : Win32 + AVX2 fails virtually all cycles tests
2019-05-16 11:51:25 +02:00
b63ffa8919 Fix Cycles build error after recent changes
We need to do aligned alloc of the services instead of globals now since the
concurrent map moved there.
2019-05-14 15:06:23 +02:00
a5c89574a3 Fix Cycles assert on exit after recent changes 2019-05-03 18:04:47 +02:00
fadb6f3466 Cleanup: refactor Cycles OSL texture handling
This adds our own OSL texture handle, that has info for OIIO textures or our
own custom texture types. A filename to handle hash map is used for lookups.
This is efficient because it happens at OSL compile time, because the optimizer
can figure out constant strings and replace them with texture handles.
2019-05-03 15:36:20 +02:00
Campbell Barton
c47d669f24 Cleanup: comments (long lines) in cycles 2019-05-01 21:41:07 +10:00
Campbell Barton
9ade9d247d CMake: fix Cycles linking with OpenCL 2019-04-19 14:00:16 +02:00
Campbell Barton
108045faa0 ClangFormat: format '#if 0' code in intern/ 2019-04-17 08:17:13 +02:00
Campbell Barton
e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton
5498e7f193 CMake: add library deps to CMakeLists.txt
Tested to work on Linux and macOS.

This will be enabled once all platforms are verified.

See D4684
2019-04-16 06:20:52 +02:00
Campbell Barton
813e470eac CMake: cleanup, arg rename, add definitions last 2019-04-16 06:15:18 +02:00
c515ea2e93 Fix vertex array leak in Cycles viewport drawing. 2019-03-26 19:56:43 +01:00
Campbell Barton
5ef4b0438c Cleanup: trailing space 2019-03-19 15:08:16 +11:00
e691929686 Merge branch 'blender2.7' 2019-03-17 12:54:19 +01:00