Commit Graph

589 Commits

Author SHA1 Message Date
db8bc1d982 Fix a few harmless maybe uninitialized warnings with GCC 5.4.
GCC seems to detect uninitialized into function calls now, but then isn't
always smart enough to see that it is actually initialized. Disabling this
warning entirely seems a bit too much, so initialize a bit more now.
2017-07-21 00:54:58 +02:00
Mai Lavelle
9c3f1ad003 Cycles: Add artificial memory limit debug option for OpenCL 2017-07-06 05:25:46 -04:00
Mai Lavelle
95b345b2fe Revert "Cycles: use std::min and max for extra overloads"
We already have this in util_algorithm.h

This reverts commit cff172c7621d89773baa99a9460f19056efb5f1e.
2017-07-06 04:21:29 -04:00
Mai Lavelle
cff172c762 Cycles: use std::min and max for extra overloads 2017-07-05 19:43:34 -04:00
Sergey Sharybin
31f8ca5034 Cycles: Fix compilation error after recent logging changes
This file uses std::ostream for helper << operators, so need to make sure
corresponding header is included.
2017-07-05 20:40:55 +02:00
Sergey Sharybin
58c456b12d Cycles: Fix compilation error when building without Glog and no C++11 2017-07-05 12:01:12 +02:00
Mai Lavelle
c8fa716c06 Cycles: Use float constants instead of double 2017-06-29 23:07:18 -04:00
Sergey Sharybin
794311c92b Cycles: Fix race condition happening in progress utility
This is not enough to mutex-guard modification code of integer values,
since this operation is NOT atomic. This is not even safe for a single
byte data types.

For now guarded the getter functions, similar to other functions in
this module.

Ideally we want to switch modification to an atomic operations, so we
wouldn't need any locks in the getters.
2017-06-16 10:22:35 +02:00
Mai Lavelle
4360e8ce13 Cycles: Add atomic decrement functions to util_atomic.h 2017-06-10 03:51:18 -04:00
Sergey Sharybin
6a546fc73e Cycles: Don't leave multiple spaces in the device name 2017-06-08 12:15:24 +02:00
Sergey Sharybin
55c15ad9de Cycles: Use falltrhough attribute to help catching missing break statements 2017-05-24 17:23:54 +02:00
Sergey Sharybin
38a2bf665b Cycles: Cleanup, style and unused arguments
- Some arguments were inapproriatry tagged as unused
  using (void)foo semantic.

  Only use such semantic in tricky casses, when something
  needs to be ignored in release builds or something is
  dependent on tricky ifndef policy.

  For rest of the cases just use void foo(int /bar*/)
  semantic, which ensures variable is not used. Solves
  confusion and code running out of sync with later
  development.

- Used proper unused semantic to some arguments.

- Added braces to make code easier to follow, tricky
  indentation with ifdef, uh.
2017-05-20 05:21:27 -07:00
Lukas Stockner
3dee1f079f Fix T51560: Black pixels on a denoising render
Once again, numerical instabilities causing the Cholesky decomposition to fail.

However, further increasing the diagonal correction just because of a few
pixels in very specific scenes and settings seems unjustified.
Therefore, this commit simply falls back to the basic NLM-filtered pixel
if the more advanced model fails.
2017-05-19 23:31:49 +02:00
Sergey Sharybin
ef549b9e55 Cycles: Cleanup, always use parenthesis
Easier to read/follow, and more robust for the further changes.
2017-05-19 12:57:51 +02:00
Sergey Sharybin
908bb8bd82 Cycles: Cleanup, indentation in preprocessor 2017-05-19 12:54:46 +02:00
Sergey Sharybin
803337f3f6 \0;115;0cCycles: Cleanup, use ccl_restrict instead of ccl_restrict_ptr
There were following issues with ccl_restrict_ptr:

- We already had ccl_restrict for all platforms.

- It was secretly adding `const` qualifier to the declaration,
  which is quite weird since non-const pointer can also be
  declared as restricted.

- We never in Blender are using foo_ptr or FooPtr type definitions,
  so not sure why we should introduce such a thing here.

- It is absolutely wrong from semantic point of view to put pointer
  into the restrict macro -- const is a part of type, not part of
  hint for compiler that some pointer is never aliased.
2017-05-19 12:41:03 +02:00
Lukas Stockner
a21277b996 Fix T51555: Cycles tile count is incorrect when denoising is enabled
Now rendered and denoised tiles are counted and displayed separately.
2017-05-19 03:29:18 +02:00
Sergey Sharybin
c4d122e305 Cycles: Optimize expansion of headers in the source
Use smarter check of where the file is coming from instead of
attempting to replace same source twice with different settings.

Brings down processing time from 3.6sec to 1.8sec.
2017-05-17 17:26:35 +02:00
Lukas Stockner
58a0c27546 Cycles: Fix occasional black pixels from denoising with excessive radii
Numerical inaccuracies would cause the XtWX matrix to be no longer
positive-semidefinite, which in turn caused the LSQ solver to fail.
2017-05-11 03:21:54 +02:00
Sergey Sharybin
49523c4d0e Cycles: Fix compilation error with gcc-6.3.0 and debug mode 2017-05-08 15:41:28 +02:00
lazydodo
c9451f1cff [Cycles] Fix math problems in safe_logf
log(0) is undefined and should not have been included
log(1) == 0, dividing by zero is not recommended
2017-05-07 09:16:14 -06:00
Lukas Stockner
43b374e8c5 Cycles: Implement denoising option for reducing noise in the rendered image
This commit contains the first part of the new Cycles denoising option,
which filters the resulting image using information gathered during rendering
to get rid of noise while preserving visual features as well as possible.

To use the option, enable it in the render layer options. The default settings
fit a wide range of scenes, but the user can tweak individual settings to
control the tradeoff between a noise-free image, image details, and calculation
time.

Note that the denoiser may still change in the future and that some features
are not implemented yet. The most important missing feature is animation
denoising, which uses information from multiple frames at once to produce a
flicker-free and smoother result. These features will be added in the future.

Finally, thanks to all the people who supported this project:

- Google (through the GSoC) and Theory Studios for sponsoring the development
- The authors of the papers I used for implementing the denoiser (more details
  on them will be included in the technical docs)
- The other Cycles devs for feedback on the code, especially Sergey for
  mentoring the GSoC project and Brecht for the code review!
- And of course the users who helped with testing, reported bugs and things
  that could and/or should work better!
2017-05-07 14:40:58 +02:00
Pablo Vazquez
d29e3ebcc6 Typo: 'Signle program' -> 'Single program' 2017-05-04 22:15:53 +02:00
Dalai Felinto
c171f0b3c9 Fix Cycles build on Windows 2017-05-03 21:16:45 +02:00
Sergey Sharybin
6f9c839f44 Cycles: Fix OpenCL compilation failure after recent color changes
It is really confusing to have some functions available in some devices
and not on another devices.
2017-05-03 14:11:19 +02:00
Sergey Sharybin
e616cd5706 Cycles: Add utility function to convert float4 color from srgb to linear
It will use SSE2 optimized version when is possible.
2017-05-03 11:19:40 +02:00
Sergey Sharybin
9ebd737df3 Cycles: Use relative path for #line directives
This way moving Blender bundle around doesn't re-trigger kernels compilation.
2017-04-28 17:46:11 +02:00
Sergey Sharybin
c648ddb9a1 Cycles: Correct comment after previous commit 2017-04-28 16:47:24 +02:00
Sergey Sharybin
9ff88a596c Cycles: Lower default severity level to ERROR 2017-04-28 16:46:30 +02:00
Sergey Sharybin
4245ed360e Cycles: Cleanup, indentaiton and trailing whitespace and wrapping 2017-04-28 13:21:17 +02:00
Thomas Dinges
a00f54332d Cleanup: Some style and code tweaks to Image Code after changes.
Whitespace and order of switch/case etc. Let's try to stick to float4/byte4/half4/float/byte/half order as defined in "ImageDataType".
2017-04-27 11:11:08 +02:00
Stefan Werner
ec25060a05 Unlimited number of textures for Cycles
This patch allows for an unlimited number of textures in Cycles where the hardware allows. It replaces a number static arrays with dynamic arrays and changes the way the flat_slot indices are calculated. Eventually, I'd like to get to a point where there are only flat slots left and textures off all kinds are stored in a single array.

Note that the arrays in DeviceScene are changed from containing device_vector<T> objects to device_vector<T>* pointers. Ideally, I'd like to store objects, but dynamic resizing of a std:vector in pre-C++11 calls the copy constructor, which for a good reason is not implemented for device_vector. Once we require C++11 for Cycles builds, we can implement a move constructor for device_vector and store objects again.

The limits for CUDA Fermi hardware still apply.

Reviewers: tod_baudais, InsigMathK, dingto, #cycles

Reviewed By: dingto, #cycles

Subscribers: dingto, smellslikedonkey

Differential Revision: https://developer.blender.org/D2650
2017-04-27 09:35:22 +02:00
Mai Lavelle
90b2539248 Cycles: Change OpenCL split kernel to use single program by default
Single program builds twice as fast as multi programs, so its better for
users to have it as the default.
2017-04-26 10:48:15 -04:00
Sergey Sharybin
ab4f6f01a6 Cycles: Fix strict compiler flags 2017-04-25 14:12:14 +02:00
Sergey Sharybin
0a07cdbe80 Cycles: Split vectorized math utilities to a dedicated files
This file was even a bigger mess than vectorized types header,
cleaning it up to make it easier to maintain this files and
extend further.
2017-04-25 10:33:26 +02:00
Sergey Sharybin
51ec9441b7 Cycles: Split vectorized types into separate files
The final goal to reach is to make vectorized types much easier to maintain
and the previous design had following issues:

- Having all types and methods implementation made the source file rather
  bloated and unfun to navigate in.

- It was not possible to quickly glance available API for the type you are
  interested in.

- Adding more vectorization types will bloat the file even more, making
  things even more tricky to follow.
2017-04-25 10:33:26 +02:00
Sergey Sharybin
b06cd746ce Cycles: Cleanup, preprocessor indentation 2017-04-25 10:33:26 +02:00
Sergey Sharybin
360cf8393a Cycles: Make vectorized types constructor from register explicit
This is not a cheap operation which we dont' want to happen silently.
2017-04-13 15:08:00 +02:00
Sergey Sharybin
e6392458d3 Cycles: Remove unused function
It was quite wrong actually by doing some __m128 to flaot4 round trips.
2017-04-13 15:08:00 +02:00
lazydodo
b332fc8f23 [Cycles/msvc] Get cycles_kernel compile time under control.
Ever since we merged the extra texture types (half etc) and spit kernel the compile time for cycles_kernel has been going out of control.

It's currently sitting at a cool 1295.762 seconds with our standard compiler (2013/x64/release)

I'm not entirely sure why msvc gets upset with it, but the inlining of matrix near the bottom of the tri-cubic 3d interpolator is the source of the issue, this patch excludes it from being inlined.

This patch bring it back down to a manageable 186 seconds. (7x faster!!)

with the attached bzzt.blend that @sergey  kindly provided i got the following results with builds with identical hashes

58:51.73 buildbot
58:04.23 Patched

it's really close, the slight speedup could be explained by the switch instead of having multiple if's (switches do generate more optimal code than a chain of if/else/if/else statements) but in all honesty it might just have been pure luck (dev box,very polluted, bad for benchmarks) regardless, this patch doesn't seem to slow down anything with my limited testing.

{F532336}

{F532337}

Reviewers: brecht, lukasstockner97, juicyfruit, dingto, sergey

Reviewed By: brecht, dingto, sergey

Subscribers: InsigMathK, sergey

Tags: #cycles

Differential Revision: https://developer.blender.org/D2595
2017-04-07 10:26:55 -06:00
Sergey Sharybin
3ce30823ff Cycles: Add utility class to simplify scoped spin locks 2017-04-05 14:57:34 +02:00
Mai Lavelle
4b7d95290f Cycles: More fixes after include changes 2017-03-31 10:12:13 +02:00
Sergey Sharybin
0579eaae1f Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.

For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.

Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.

This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.

Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.

Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner

Reviewed By: lukasstockner97, maiself, nirved, dingto

Subscribers: brecht

Differential Revision: https://developer.blender.org/D2586
2017-03-29 13:41:11 +02:00
Sergey Sharybin
61db9ee27a Cycles: Attempt to workaround compilation error on new CUDA toolkit and sm_2x 2017-03-29 11:50:17 +02:00
Sergey Sharybin
6ea54fe9ff Cycles: Switch to reformulated Pluecker ray/triangle intersection
The intention of this commit it to address issues mentioned in the
reports T43865,T50164 and T50452.

The code is based on Embree code with some extra vectorization
to speed up single ray to single triangle intersection.

Unfortunately, such a fix is not coming for free. There is some
slowdown for AVX2 processors, mainly due to different vectorization
code, which caused different number of instructions to be executed
and different instructions-per-cycle counters. But on another hand
this commit makes pre-AVX2 platforms such as AVX and SSE4.1 a bit
faster. The prerformance goes as following:

              2.78c AVX2   2.78c AVX   Patch AVX2         Patch AVX
BMW            05:21.09     06:05.34    05:32.97 (+3.5%)   05:34.97 (-8.5%)
Classroom      16:55.36     18:24.51    17:10.41 (+1.4%)   17:15.87 (-6.3%)
Fishy Cat      08:08.49     08:36.26    08:09.19 (+0.2%)   08:12.25 (-4.7%
Koro           11:22.54     11:45.24    11:13.25 (-1.5%)   11:43.81 (-0.3%)
Barcelone      14:18.32     16:09.46    14:15.20 (-0.4%)   14:25.15 (-10.8%)

On GPU the performance is about 1.5-2% slower in my tests on GTX1080
but afraid we can't do much as a part of this chaneg here and
consider it a price to pay for more proper intersection check.

Made in collaboration with Maxym Dmytrychenko, big thanks to him!

Reviewers: brecht, juicyfruit, lukasstockner97, dingto

Differential Revision: https://developer.blender.org/D1574
2017-03-28 17:26:47 +02:00
Sergey Sharybin
3f61280327 Cycles: Pass m128 vectors by const reference 2017-03-28 11:01:11 +02:00
Sergey Sharybin
bd053ac7ba Cycles: Correct ifdef around float3 intrinsics 2017-03-27 16:13:07 +02:00
Sergey Sharybin
5b45715f8a Cycles: Correct isfinite check used in integrator
Use fast-math friendly version of this function.

We should probably avoid unsafe fast math, but this is to be done with
real care with all the benchmarks properly done.

For now comitting much safer fix.
2017-03-24 15:39:33 +01:00
Sergey Sharybin
a96110e710 Cycles: Remove old non-optimized triangle intersection function
It is unused now and if we want similar function we should use
Pluecker intersection which is same performance with SSE optimization
but which is more watertight.
2017-03-23 17:59:34 +01:00
Sergey Sharybin
a1348dde2e Cycles: Fix speed regression on GPU
Avoid construction of temporary array and make utility function force-inlined.
Additionally avoid calling float4_to_float3 twice.

This brings render times to the same values as before current patch series.
2017-03-23 17:45:19 +01:00