Fix for Cycles (CUDA) compilation (again ...). Moved the AttributeStandard enum typedef and the attribute_standard_name mapping function to util_attribute/util_types headers, so they can properly be used by kernel and render files alike. This should avoid any std C includes which are not available in CUDA. Thanks to Sergey for help!

This commit is contained in:
Lukas Toenne
2012-09-07 11:06:45 +00:00
parent 8b6046cdad
commit a9105a7dea
11 changed files with 172 additions and 81 deletions

View File

@@ -16,6 +16,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kernel_attribute.h"
#include "kernel_projection.h"
CCL_NAMESPACE_BEGIN
@@ -183,48 +184,13 @@ __device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *s
/* motion */
/* note: declared in kernel.h, have to add it here because kernel.h is not available */
bool kernel_osl_use(KernelGlobals *kg);
__device int triangle_find_attribute(KernelGlobals *kg, ShaderData *sd, uint id)
{
#ifdef __OSL__
if (kernel_osl_use(kg)) {
/* for OSL, a hash map is used to lookup the attribute by name. */
OSLGlobals::AttributeMap &attr_map = kg->osl.attribute_map[sd->object];
ustring stdname = ustring(std::string("std::") + attribute_standard_name((AttributeStandard)id).c_str());
OSLGlobals::AttributeMap::const_iterator it = attr_map.find(stdname);
if (it != attr_map.end()) {
const OSLGlobals::Attribute &osl_attr = it->second;
/* return result */
return (osl_attr.elem == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : osl_attr.offset;
}
else
return (int)ATTR_STD_NOT_FOUND;
}
else
#endif
{
/* for SVM, find attribute by unique id */
uint attr_offset = sd->object*kernel_data.bvh.attributes_map_stride;
uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
while(attr_map.x != id)
attr_map = kernel_tex_fetch(__attributes_map, ++attr_offset);
/* return result */
return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : attr_map.z;
}
}
__device float4 triangle_motion_vector(KernelGlobals *kg, ShaderData *sd)
{
float3 motion_pre = sd->P, motion_post = sd->P;
/* deformation motion */
int offset_pre = triangle_find_attribute(kg, sd, ATTR_STD_MOTION_PRE);
int offset_post = triangle_find_attribute(kg, sd, ATTR_STD_MOTION_POST);
int offset_pre = find_attribute(kg, sd, ATTR_STD_MOTION_PRE);
int offset_post = find_attribute(kg, sd, ATTR_STD_MOTION_POST);
if(offset_pre != ATTR_STD_NOT_FOUND)
motion_pre = triangle_attribute_float3(kg, sd, ATTR_ELEMENT_VERTEX, offset_pre, NULL, NULL);
@@ -283,7 +249,7 @@ __device float4 triangle_motion_vector(KernelGlobals *kg, ShaderData *sd)
__device float3 triangle_uv(KernelGlobals *kg, ShaderData *sd)
{
int offset_uv = triangle_find_attribute(kg, sd, ATTR_STD_UV);
int offset_uv = find_attribute(kg, sd, ATTR_STD_UV);
if(offset_uv == ATTR_STD_NOT_FOUND)
return make_float3(0.0f, 0.0f, 0.0f);