Page MenuHome

T61513: Refactored Cycles Attribute Retrieval
ClosedPublic

Authored by Jeroen Bakker (jbakker) on Feb 19 2019, 2:01 PM.

Details

Summary

There is a generic function to retrieve float and float3 attributes
primitive_attribute_float and primitive_attribute_float3`. Inside
these functions an prioritised if-else construction checked where
the attribute is stored and then retrieved from that location.

Actually the calling function knows already where the data is stored.
So we could simplify this by splitting these functions and remove
the check logic.

This patch splits the primitive_attribute_float? functions into
primitive_surface_attribute_float? and primitive_volume_attribute_float?.
What leads to less branching and more optimum kernels.

This will reduce the compilation time and render time for kernels.
Especially in production scenes there is a lot of benefit.

Impact in compilation times

  job  |   scene_name    | previous |  new  | percentage 
-------+-----------------+----------+-------+------------
t61513 | empty           |    10.63 | 10.66 |          0%
t61513 | bmw             |    17.91 | 17.65 |          1%
t61513 | fishycat        |    19.57 | 17.68 |         10%
t61513 | barbershop      |    54.10 | 24.41 |         55%
t61513 | classroom       |    17.55 | 16.29 |          7%
t61513 | koro            |    18.92 | 18.05 |          5%
t61513 | pavillion       |    17.43 | 16.52 |          5%
t61513 | splash279       |    16.48 | 14.91 |         10%
t61513 | volume_emission |    36.22 | 21.60 |         40%

Impact in render times

  job  |   scene_name    | previous |  new   | percentage 
-------+-----------------+----------+--------+------------
61513 | empty           |    21.06 |  20.35 |          3%
61513 | bmw             |   198.44 | 190.05 |          4%
61513 | fishycat        |   394.20 | 401.25 |         -2%
61513 | barbershop      |  1188.16 | 912.39 |         23%
61513 | classroom       |   341.08 | 340.38 |          0%
61513 | koro            |   472.43 | 471.80 |          0%
61513 | pavillion       |   905.77 | 899.80 |          1%
61513 | splash279       |    55.26 |  54.86 |          1%
61513 | volume_emission |    62.59 |  61.70 |          1%

There is also a possitive impact when using CPU and CUDA, but they are small.

I didn't split the hair logic from the surface logic due to:

  • Hair and surface use same attribute types. It was not clear if it could be splitted when looking at the code only.
  • Hair and surface are quick to compile and to read. So the benefit is quite small.

Diff Detail

Repository
rB Blender
Branch
local-opencl-T61513 (branched from master)
Build Status
Buildable 2952
Build 2952: arc lint + arc unit

Event Timeline

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Feb 19 2019, 2:02 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Feb 19 2019, 2:04 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Brecht Van Lommel (brecht) requested changes to this revision.Feb 19 2019, 2:21 PM

When committing this, please see the notes from:
https://developer.blender.org/rB9800837b987930e6152c2dc27cae5bd55873d306#218533

It's best not to use arc land directly, but arc land --hold or manually cherry-pick so you can edit the commit message.

intern/cycles/kernel/geom/geom_primitive.h
27–29

Adjust indentation to keep alignment of arguments, here and in other places.

intern/cycles/kernel/osl/osl_services.cpp
571

Despite the name get_mesh_element_attribute this function needs to support volume attributes as well.

This function could be renamed to get_primitive_attribute for clarity.

intern/cycles/kernel/svm/svm_attribute.h
48

The Attribute node still needs to support both surface and volume attributes, it seems to be just for surfaces now?

This revision now requires changes to proceed.Feb 19 2019, 2:21 PM
Jeroen Bakker (jbakker) marked 3 inline comments as done.Feb 19 2019, 3:46 PM
  • D4375: Addressed Code Review Comments
This revision is now accepted and ready to land.Feb 19 2019, 3:50 PM
This revision was automatically updated to reflect the committed changes.