diff options
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/bvh/bvh.cpp | 43 | ||||
-rw-r--r-- | intern/cycles/bvh/bvh.h | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_triangle_intersect.h | 24 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_textures.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/mesh.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/render/scene.h | 2 |
6 files changed, 43 insertions, 44 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index f78ad3e9ce2..b1273d64098 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -130,7 +130,7 @@ void BVH::refit(Progress& progress) /* Triangles */ -void BVH::pack_triangle(int idx, float4 woop[3]) +void BVH::pack_triangle(int idx, float4 storage[3]) { int tob = pack.prim_object[idx]; assert(tob >= 0 && tob < objects.size()); @@ -143,36 +143,34 @@ void BVH::pack_triangle(int idx, float4 woop[3]) float3 v1 = vpos[vidx[1]]; float3 v2 = vpos[vidx[2]]; - woop[0] = float3_to_float4(v0); - woop[1] = float3_to_float4(v1); - woop[2] = float3_to_float4(v2); + storage[0] = float3_to_float4(v0); + storage[1] = float3_to_float4(v1); + storage[2] = float3_to_float4(v2); } -/* Curves*/ - void BVH::pack_primitives() { int nsize = TRI_NODE_SIZE; size_t tidx_size = pack.prim_index.size(); - pack.tri_woop.clear(); - pack.tri_woop.resize(tidx_size * nsize); + pack.tri_storage.clear(); + pack.tri_storage.resize(tidx_size * nsize); pack.prim_visibility.clear(); pack.prim_visibility.resize(tidx_size); for(unsigned int i = 0; i < tidx_size; i++) { if(pack.prim_index[i] != -1) { - float4 woop[3]; + float4 storage[3]; if(pack.prim_type[i] & PRIMITIVE_TRIANGLE) { - pack_triangle(i, woop); + pack_triangle(i, storage); } else { /* Avoid use of uninitialized memory. */ - memset(&woop, 0, sizeof(woop)); + memset(&storage, 0, sizeof(storage)); } - memcpy(&pack.tri_woop[i * nsize], woop, sizeof(float4)*3); + memcpy(&pack.tri_storage[i * nsize], storage, sizeof(float4)*3); int tob = pack.prim_object[i]; Object *ob = objects[tob]; @@ -182,7 +180,7 @@ void BVH::pack_primitives() pack.prim_visibility[i] |= PATH_RAY_CURVE; } else { - memset(&pack.tri_woop[i * nsize], 0, sizeof(float4)*3); + memset(&pack.tri_storage[i * nsize], 0, sizeof(float4)*3); pack.prim_visibility[i] = 0; } } @@ -219,10 +217,10 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) /* reserve */ size_t prim_index_size = pack.prim_index.size(); - size_t tri_woop_size = pack.tri_woop.size(); + size_t tri_storage_size = pack.tri_storage.size(); size_t pack_prim_index_offset = prim_index_size; - size_t pack_tri_woop_offset = tri_woop_size; + size_t pack_tri_storage_offset = tri_storage_size; size_t pack_nodes_offset = nodes_size; size_t pack_leaf_nodes_offset = leaf_nodes_size; size_t object_offset = 0; @@ -236,7 +234,7 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) if(mesh->need_build_bvh()) { if(mesh_map.find(mesh) == mesh_map.end()) { prim_index_size += bvh->pack.prim_index.size(); - tri_woop_size += bvh->pack.tri_woop.size(); + tri_storage_size += bvh->pack.tri_storage.size(); nodes_size += bvh->pack.nodes.size(); leaf_nodes_size += bvh->pack.leaf_nodes.size(); @@ -251,7 +249,7 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) pack.prim_type.resize(prim_index_size); pack.prim_object.resize(prim_index_size); pack.prim_visibility.resize(prim_index_size); - pack.tri_woop.resize(tri_woop_size); + pack.tri_storage.resize(tri_storage_size); pack.nodes.resize(nodes_size); pack.leaf_nodes.resize(leaf_nodes_size); pack.object_node.resize(objects.size()); @@ -260,7 +258,7 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) int *pack_prim_type = (pack.prim_type.size())? &pack.prim_type[0]: NULL; int *pack_prim_object = (pack.prim_object.size())? &pack.prim_object[0]: NULL; uint *pack_prim_visibility = (pack.prim_visibility.size())? &pack.prim_visibility[0]: NULL; - float4 *pack_tri_woop = (pack.tri_woop.size())? &pack.tri_woop[0]: NULL; + float4 *pack_tri_storage = (pack.tri_storage.size())? &pack.tri_storage[0]: NULL; int4 *pack_nodes = (pack.nodes.size())? &pack.nodes[0]: NULL; int4 *pack_leaf_nodes = (pack.leaf_nodes.size())? &pack.leaf_nodes[0]: NULL; @@ -322,10 +320,11 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) } /* merge triangle intersection data */ - if(bvh->pack.tri_woop.size()) { - memcpy(pack_tri_woop + pack_tri_woop_offset, &bvh->pack.tri_woop[0], - bvh->pack.tri_woop.size()*sizeof(float4)); - pack_tri_woop_offset += bvh->pack.tri_woop.size(); + if(bvh->pack.tri_storage.size()) { + memcpy(pack_tri_storage + pack_tri_storage_offset, + &bvh->pack.tri_storage[0], + bvh->pack.tri_storage.size()*sizeof(float4)); + pack_tri_storage_offset += bvh->pack.tri_storage.size(); } /* merge nodes */ diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h index 272a3fa1514..4b9f1bae801 100644 --- a/intern/cycles/bvh/bvh.h +++ b/intern/cycles/bvh/bvh.h @@ -52,8 +52,8 @@ struct PackedBVH { array<int4> leaf_nodes; /* object index to BVH node index mapping for instances */ array<int> object_node; - /* precomputed triangle intersection data, one triangle is 4x float4 */ - array<float4> tri_woop; + /* Aligned triangle storage for fatser lookup in the kernel. */ + array<float4> tri_storage; /* primitive type - triangle or strand */ array<int> prim_type; /* visibility visibilitys for primitives */ @@ -97,7 +97,7 @@ protected: /* triangles and strands*/ void pack_primitives(); - void pack_triangle(int idx, float4 woop[3]); + void pack_triangle(int idx, float4 storage[3]); /* merge instance BVH's */ void pack_instances(size_t nodes_size, size_t leaf_nodes_size); diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h index 73bfe6beeb0..d2957ad5474 100644 --- a/intern/cycles/kernel/geom/geom_triangle_intersect.h +++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h @@ -106,9 +106,9 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg, const float Sz = isect_precalc->Sz; /* Calculate vertices relative to ray origin. */ - const float4 tri_a = kernel_tex_fetch(__tri_woop, triAddr*TRI_NODE_SIZE+0), - tri_b = kernel_tex_fetch(__tri_woop, triAddr*TRI_NODE_SIZE+1), - tri_c = kernel_tex_fetch(__tri_woop, triAddr*TRI_NODE_SIZE+2); + const float4 tri_a = kernel_tex_fetch(__tri_storage, triAddr*TRI_NODE_SIZE+0), + tri_b = kernel_tex_fetch(__tri_storage, triAddr*TRI_NODE_SIZE+1), + tri_c = kernel_tex_fetch(__tri_storage, triAddr*TRI_NODE_SIZE+2); const float3 A = make_float3(tri_a.x - P.x, tri_a.y - P.y, tri_a.z - P.z); const float3 B = make_float3(tri_b.x - P.x, tri_b.y - P.y, tri_b.z - P.z); const float3 C = make_float3(tri_c.x - P.x, tri_c.y - P.y, tri_c.z - P.z); @@ -207,9 +207,9 @@ ccl_device_inline void triangle_intersect_subsurface( const float Sz = isect_precalc->Sz; /* Calculate vertices relative to ray origin. */ - const float4 tri_a = kernel_tex_fetch(__tri_woop, triAddr*TRI_NODE_SIZE+0), - tri_b = kernel_tex_fetch(__tri_woop, triAddr*TRI_NODE_SIZE+1), - tri_c = kernel_tex_fetch(__tri_woop, triAddr*TRI_NODE_SIZE+2); + const float4 tri_a = kernel_tex_fetch(__tri_storage, triAddr*TRI_NODE_SIZE+0), + tri_b = kernel_tex_fetch(__tri_storage, triAddr*TRI_NODE_SIZE+1), + tri_c = kernel_tex_fetch(__tri_storage, triAddr*TRI_NODE_SIZE+2); const float3 A = make_float3(tri_a.x - P.x, tri_a.y - P.y, tri_a.z - P.z); const float3 B = make_float3(tri_b.x - P.x, tri_b.y - P.y, tri_b.z - P.z); const float3 C = make_float3(tri_c.x - P.x, tri_c.y - P.y, tri_c.z - P.z); @@ -329,9 +329,9 @@ ccl_device_inline float3 triangle_refine(KernelGlobals *kg, P = P + D*t; - const float4 tri_a = kernel_tex_fetch(__tri_woop, isect->prim*TRI_NODE_SIZE+0), - tri_b = kernel_tex_fetch(__tri_woop, isect->prim*TRI_NODE_SIZE+1), - tri_c = kernel_tex_fetch(__tri_woop, isect->prim*TRI_NODE_SIZE+2); + const float4 tri_a = kernel_tex_fetch(__tri_storage, isect->prim*TRI_NODE_SIZE+0), + tri_b = kernel_tex_fetch(__tri_storage, isect->prim*TRI_NODE_SIZE+1), + tri_c = kernel_tex_fetch(__tri_storage, isect->prim*TRI_NODE_SIZE+2); float3 edge1 = make_float3(tri_a.x - tri_c.x, tri_a.y - tri_c.y, tri_a.z - tri_c.z); float3 edge2 = make_float3(tri_b.x - tri_c.x, tri_b.y - tri_c.y, tri_b.z - tri_c.z); float3 tvec = make_float3(P.x - tri_c.x, P.y - tri_c.y, P.z - tri_c.z); @@ -386,9 +386,9 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg, P = P + D*t; #ifdef __INTERSECTION_REFINE__ - const float4 tri_a = kernel_tex_fetch(__tri_woop, isect->prim*TRI_NODE_SIZE+0), - tri_b = kernel_tex_fetch(__tri_woop, isect->prim*TRI_NODE_SIZE+1), - tri_c = kernel_tex_fetch(__tri_woop, isect->prim*TRI_NODE_SIZE+2); + const float4 tri_a = kernel_tex_fetch(__tri_storage, isect->prim*TRI_NODE_SIZE+0), + tri_b = kernel_tex_fetch(__tri_storage, isect->prim*TRI_NODE_SIZE+1), + tri_c = kernel_tex_fetch(__tri_storage, isect->prim*TRI_NODE_SIZE+2); float3 edge1 = make_float3(tri_a.x - tri_c.x, tri_a.y - tri_c.y, tri_a.z - tri_c.z); float3 edge2 = make_float3(tri_b.x - tri_c.x, tri_b.y - tri_c.y, tri_b.z - tri_c.z); float3 tvec = make_float3(P.x - tri_c.x, P.y - tri_c.y, P.z - tri_c.z); diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h index cd181e2abd1..2a048b7e3f2 100644 --- a/intern/cycles/kernel/kernel_textures.h +++ b/intern/cycles/kernel/kernel_textures.h @@ -25,7 +25,7 @@ /* bvh */ KERNEL_TEX(float4, texture_float4, __bvh_nodes) KERNEL_TEX(float4, texture_float4, __bvh_leaf_nodes) -KERNEL_TEX(float4, texture_float4, __tri_woop) +KERNEL_TEX(float4, texture_float4, __tri_storage) KERNEL_TEX(uint, texture_uint, __prim_type) KERNEL_TEX(uint, texture_uint, __prim_visibility) KERNEL_TEX(uint, texture_uint, __prim_index) diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 6466d719859..7692c49791d 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -1122,9 +1122,9 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene * dscene->object_node.reference((uint*)&pack.object_node[0], pack.object_node.size()); device->tex_alloc("__object_node", dscene->object_node); } - if(pack.tri_woop.size()) { - dscene->tri_woop.reference(&pack.tri_woop[0], pack.tri_woop.size()); - device->tex_alloc("__tri_woop", dscene->tri_woop); + if(pack.tri_storage.size()) { + dscene->tri_storage.reference(&pack.tri_storage[0], pack.tri_storage.size()); + device->tex_alloc("__tri_storage", dscene->tri_storage); } if(pack.prim_type.size()) { dscene->prim_type.reference((uint*)&pack.prim_type[0], pack.prim_type.size()); @@ -1359,7 +1359,7 @@ void MeshManager::device_free(Device *device, DeviceScene *dscene) device->tex_free(dscene->bvh_nodes); device->tex_free(dscene->bvh_leaf_nodes); device->tex_free(dscene->object_node); - device->tex_free(dscene->tri_woop); + device->tex_free(dscene->tri_storage); device->tex_free(dscene->prim_type); device->tex_free(dscene->prim_visibility); device->tex_free(dscene->prim_index); @@ -1377,7 +1377,7 @@ void MeshManager::device_free(Device *device, DeviceScene *dscene) dscene->bvh_nodes.clear(); dscene->object_node.clear(); - dscene->tri_woop.clear(); + dscene->tri_storage.clear(); dscene->prim_type.clear(); dscene->prim_visibility.clear(); dscene->prim_index.clear(); diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h index 74976c1513c..026bef4088c 100644 --- a/intern/cycles/render/scene.h +++ b/intern/cycles/render/scene.h @@ -64,7 +64,7 @@ public: device_vector<float4> bvh_nodes; device_vector<float4> bvh_leaf_nodes; device_vector<uint> object_node; - device_vector<float4> tri_woop; + device_vector<float4> tri_storage; device_vector<uint> prim_type; device_vector<uint> prim_visibility; device_vector<uint> prim_index; |