2014-03-29 12:03:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011-2013 Blender Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2014-03-29 12:03:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Attributes
|
|
|
|
*
|
|
|
|
* We support an arbitrary number of attributes on various mesh elements.
|
|
|
|
* On vertices, triangles, curve keys, curves, meshes and volume grids.
|
|
|
|
* Most of the code for attribute reading is in the primitive files.
|
|
|
|
*
|
|
|
|
* Lookup of attributes is different between OSL and SVM, as OSL is ustring
|
|
|
|
* based while for SVM we use integer ids. */
|
|
|
|
|
2016-07-16 23:42:28 +00:00
|
|
|
ccl_device_inline uint subd_triangle_patch(KernelGlobals *kg, const ShaderData *sd);
|
|
|
|
|
|
|
|
ccl_device_inline uint attribute_primitive_type(KernelGlobals *kg, const ShaderData *sd)
|
|
|
|
{
|
|
|
|
#ifdef __HAIR__
|
|
|
|
if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
|
|
|
|
return ATTR_PRIM_CURVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if(subd_triangle_patch(kg, sd) != ~0) {
|
|
|
|
return ATTR_PRIM_SUBD;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return ATTR_PRIM_TRIANGLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-01 21:36:27 +00:00
|
|
|
ccl_device_inline AttributeDescriptor attribute_not_found()
|
|
|
|
{
|
2016-07-17 02:57:06 +00:00
|
|
|
const AttributeDescriptor desc = {ATTR_ELEMENT_NONE, (NodeAttributeType)0, 0, ATTR_STD_NOT_FOUND};
|
2016-07-01 21:36:27 +00:00
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
2014-03-29 12:03:48 +00:00
|
|
|
/* Find attribute based on ID */
|
|
|
|
|
2016-07-01 21:36:27 +00:00
|
|
|
ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id)
|
2014-03-29 12:03:48 +00:00
|
|
|
{
|
2016-07-01 21:36:27 +00:00
|
|
|
if(ccl_fetch(sd, object) == PRIM_NONE) {
|
|
|
|
return attribute_not_found();
|
|
|
|
}
|
2014-03-29 12:03:48 +00:00
|
|
|
|
2014-03-29 12:03:48 +00:00
|
|
|
/* for SVM, find attribute by unique id */
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
uint attr_offset = ccl_fetch(sd, object)*kernel_data.bvh.attributes_map_stride;
|
2016-07-16 23:42:28 +00:00
|
|
|
attr_offset += attribute_primitive_type(kg, sd);
|
2014-03-29 12:03:48 +00:00
|
|
|
uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
|
|
|
|
|
|
|
|
while(attr_map.x != id) {
|
2015-01-31 09:39:19 +00:00
|
|
|
if(UNLIKELY(attr_map.x == ATTR_STD_NONE)) {
|
2016-07-01 21:36:27 +00:00
|
|
|
return attribute_not_found();
|
2015-01-31 09:39:19 +00:00
|
|
|
}
|
2014-03-29 12:03:48 +00:00
|
|
|
attr_offset += ATTR_PRIM_TYPES;
|
|
|
|
attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
|
|
|
|
}
|
2014-03-29 12:03:48 +00:00
|
|
|
|
2016-07-01 21:36:27 +00:00
|
|
|
AttributeDescriptor desc;
|
|
|
|
desc.element = (AttributeElement)attr_map.y;
|
2014-03-29 12:03:48 +00:00
|
|
|
|
2016-08-17 14:33:28 +00:00
|
|
|
if(ccl_fetch(sd, prim) == PRIM_NONE &&
|
|
|
|
desc.element != ATTR_ELEMENT_MESH &&
|
|
|
|
desc.element != ATTR_ELEMENT_VOXEL &&
|
|
|
|
desc.element != ATTR_ELEMENT_OBJECT)
|
|
|
|
{
|
2016-07-01 21:36:27 +00:00
|
|
|
return attribute_not_found();
|
|
|
|
}
|
2014-03-29 12:03:48 +00:00
|
|
|
|
2014-03-29 12:03:48 +00:00
|
|
|
/* return result */
|
2016-07-01 21:36:27 +00:00
|
|
|
desc.offset = (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : (int)attr_map.z;
|
2016-07-17 02:57:06 +00:00
|
|
|
desc.type = (NodeAttributeType)(attr_map.w & 0xff);
|
|
|
|
desc.flags = (AttributeFlag)(attr_map.w >> 8);
|
2016-07-01 21:36:27 +00:00
|
|
|
|
|
|
|
return desc;
|
2014-03-29 12:03:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-29 12:03:48 +00:00
|
|
|
/* Transform matrix attribute on meshes */
|
|
|
|
|
2016-07-01 21:36:27 +00:00
|
|
|
ccl_device Transform primitive_attribute_matrix(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc)
|
2014-03-29 12:03:48 +00:00
|
|
|
{
|
|
|
|
Transform tfm;
|
|
|
|
|
2016-07-01 21:36:27 +00:00
|
|
|
tfm.x = kernel_tex_fetch(__attributes_float3, desc.offset + 0);
|
|
|
|
tfm.y = kernel_tex_fetch(__attributes_float3, desc.offset + 1);
|
|
|
|
tfm.z = kernel_tex_fetch(__attributes_float3, desc.offset + 2);
|
|
|
|
tfm.w = kernel_tex_fetch(__attributes_float3, desc.offset + 3);
|
2014-03-29 12:03:48 +00:00
|
|
|
|
|
|
|
return tfm;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|