diff options
Diffstat (limited to 'intern/cycles/render/mesh.cpp')
-rw-r--r-- | intern/cycles/render/mesh.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 955fa390e06..f0b06a1e14a 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -1209,6 +1209,8 @@ void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<Att osl_attr.type = TypeDesc::TypeFloat; else if(req.triangle_type == TypeDesc::TypeMatrix) osl_attr.type = TypeDesc::TypeMatrix; + else if(req.triangle_type == TypeFloat2) + osl_attr.type = TypeFloat2; else osl_attr.type = TypeDesc::TypeColor; @@ -1318,6 +1320,8 @@ void MeshManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *sc attr_map[index].w = NODE_ATTR_FLOAT; else if(req.triangle_type == TypeDesc::TypeMatrix) attr_map[index].w = NODE_ATTR_MATRIX; + else if(req.triangle_type == TypeFloat2) + attr_map[index].w = NODE_ATTR_FLOAT2; else attr_map[index].w = NODE_ATTR_FLOAT3; @@ -1335,6 +1339,8 @@ void MeshManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *sc attr_map[index].w = NODE_ATTR_FLOAT; else if(req.curve_type == TypeDesc::TypeMatrix) attr_map[index].w = NODE_ATTR_MATRIX; + else if(req.curve_type == TypeFloat2) + attr_map[index].w = NODE_ATTR_FLOAT2; else attr_map[index].w = NODE_ATTR_FLOAT3; @@ -1352,6 +1358,8 @@ void MeshManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *sc attr_map[index].w = NODE_ATTR_FLOAT; else if(req.subd_type == TypeDesc::TypeMatrix) attr_map[index].w = NODE_ATTR_MATRIX; + else if(req.subd_type == TypeFloat2) + attr_map[index].w = NODE_ATTR_FLOAT2; else attr_map[index].w = NODE_ATTR_FLOAT3; @@ -1380,6 +1388,7 @@ static void update_attribute_element_size(Mesh *mesh, Attribute *mattr, AttributePrimitive prim, size_t *attr_float_size, + size_t *attr_float2_size, size_t *attr_float3_size, size_t *attr_uchar4_size) { @@ -1395,6 +1404,9 @@ static void update_attribute_element_size(Mesh *mesh, else if(mattr->type == TypeDesc::TypeFloat) { *attr_float_size += size; } + else if(mattr->type == TypeFloat2) { + *attr_float2_size += size; + } else if(mattr->type == TypeDesc::TypeMatrix) { *attr_float3_size += size * 4; } @@ -1407,6 +1419,8 @@ static void update_attribute_element_size(Mesh *mesh, static void update_attribute_element_offset(Mesh *mesh, device_vector<float>& attr_float, size_t& attr_float_offset, + device_vector<float2>& attr_float2, + size_t& attr_float2_offset, device_vector<float4>& attr_float3, size_t& attr_float3_offset, device_vector<uchar4>& attr_uchar4, @@ -1453,6 +1467,16 @@ static void update_attribute_element_offset(Mesh *mesh, } attr_float_offset += size; } + else if(mattr->type == TypeFloat2) { + float2 *data = mattr->data_float2(); + offset = attr_float2_offset; + + assert(attr_float2.size() >= offset + size); + for(size_t k = 0; k < size; k++) { + attr_float2[offset+k] = data[k]; + } + attr_float2_offset += size; + } else if(mattr->type == TypeDesc::TypeMatrix) { Transform *tfm = mattr->data_transform(); offset = attr_float3_offset; @@ -1537,6 +1561,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, * take 2x of overall attribute memory usage. */ size_t attr_float_size = 0; + size_t attr_float2_size = 0; size_t attr_float3_size = 0; size_t attr_uchar4_size = 0; for(size_t i = 0; i < scene->meshes.size(); i++) { @@ -1551,28 +1576,33 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, triangle_mattr, ATTR_PRIM_TRIANGLE, &attr_float_size, + &attr_float2_size, &attr_float3_size, &attr_uchar4_size); update_attribute_element_size(mesh, curve_mattr, ATTR_PRIM_CURVE, &attr_float_size, + &attr_float2_size, &attr_float3_size, &attr_uchar4_size); update_attribute_element_size(mesh, subd_mattr, ATTR_PRIM_SUBD, &attr_float_size, + &attr_float2_size, &attr_float3_size, &attr_uchar4_size); } } dscene->attributes_float.alloc(attr_float_size); + dscene->attributes_float2.alloc(attr_float2_size); dscene->attributes_float3.alloc(attr_float3_size); dscene->attributes_uchar4.alloc(attr_uchar4_size); size_t attr_float_offset = 0; + size_t attr_float2_offset = 0; size_t attr_float3_offset = 0; size_t attr_uchar4_offset = 0; @@ -1590,6 +1620,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, update_attribute_element_offset(mesh, dscene->attributes_float, attr_float_offset, + dscene->attributes_float2, attr_float2_offset, dscene->attributes_float3, attr_float3_offset, dscene->attributes_uchar4, attr_uchar4_offset, triangle_mattr, @@ -1599,6 +1630,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, update_attribute_element_offset(mesh, dscene->attributes_float, attr_float_offset, + dscene->attributes_float2, attr_float2_offset, dscene->attributes_float3, attr_float3_offset, dscene->attributes_uchar4, attr_uchar4_offset, curve_mattr, @@ -1608,6 +1640,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, update_attribute_element_offset(mesh, dscene->attributes_float, attr_float_offset, + dscene->attributes_float2, attr_float2_offset, dscene->attributes_float3, attr_float3_offset, dscene->attributes_uchar4, attr_uchar4_offset, subd_mattr, @@ -1633,6 +1666,9 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, if(dscene->attributes_float.size()) { dscene->attributes_float.copy_to_device(); } + if(dscene->attributes_float2.size()) { + dscene->attributes_float2.copy_to_device(); + } if(dscene->attributes_float3.size()) { dscene->attributes_float3.copy_to_device(); } @@ -2265,6 +2301,7 @@ void MeshManager::device_free(Device *device, DeviceScene *dscene) dscene->patches.free(); dscene->attributes_map.free(); dscene->attributes_float.free(); + dscene->attributes_float2.free(); dscene->attributes_float3.free(); dscene->attributes_uchar4.free(); |