Cycles:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 2 Dec 2011 14:26:28 +0000 (14:26 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 2 Dec 2011 14:26:28 +0000 (14:26 +0000)
* Fix broken compile of test app.
* Fix some warnings compiling with gcc for 32 bit.
* More tweaks to avoid extended precision issue from #29301.

intern/cycles/CMakeLists.txt
intern/cycles/SConscript
intern/cycles/app/cycles_xml.cpp
intern/cycles/kernel/kernel_bvh.h
intern/cycles/render/mesh.cpp
intern/cycles/subd/subd_mesh.cpp
intern/cycles/util/util_cache.h
intern/cycles/util/util_system.cpp

index 9b05d2c332d368f0a5f2173a2be76b982072df7a..3dc9ca5d284da360dc6ee4a4c45c8ed67b9d9292 100644 (file)
@@ -16,7 +16,7 @@ if(WIN32 AND MSVC)
        set(CYCLES_OPTIMIZED_KERNEL_FLAGS "/arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /EHsc")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /EHsc")
 elseif(CMAKE_COMPILER_IS_GNUCC)
-       set(CYCLES_OPTIMIZED_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3")
+       set(CYCLES_OPTIMIZED_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mfpmath=sse")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
 endif()
 
index 3299faa864a16eb9948aeac9fc4461ae487a1aa7..bc9eb563e50f332738673ae6555554621bb7fdc4 100644 (file)
@@ -46,13 +46,14 @@ if env['WITH_BF_RAYOPTIMIZATION']:
     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
         optim_cxxflags.append('/arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /EHsc'.split())
     else:
-        optim_cxxflags.append('-ffast-math -msse -msse2 -msse3'.split())
+        optim_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mfpmath=sse'.split())
     
-    optim_defs = defs + ['WITH_OPTIMIZED_KERNEL']
+    defs.append('WITH_OPTIMIZED_KERNEL')
+    optim_defs = defs[:]
     optim_sources = [path.join('kernel', 'kernel_optimized.cpp')]
 
     cycles_optim = cycles.Clone()
-    cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[0], compileflags=[None], cxx_compileflags=optim_cxxflags)
+    cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[10], compileflags=[None], cxx_compileflags=optim_cxxflags)
 
 cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], compileflags=[None], cxx_compileflags=cxxflags)
 
index d89c30619b6a7631b63bb65fca480e6d529a65fc..0bd0c48933d10c3b762849c0209f044f990e002b 100644 (file)
@@ -339,64 +339,33 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
                else if(string_iequals(node.name(), "noise_texture")) {
                        snode = new NoiseTextureNode();
                }
-               else if(string_iequals(node.name(), "blend_texture")) {
-                       BlendTextureNode *blend = new BlendTextureNode();
-                       xml_read_enum(&blend->progression, BlendTextureNode::progression_enum, node, "progression");
-                       xml_read_enum(&blend->axis, BlendTextureNode::axis_enum, node, "axis");
+               else if(string_iequals(node.name(), "gradient_texture")) {
+                       GradientTextureNode *blend = new GradientTextureNode();
+                       xml_read_enum(&blend->type, GradientTextureNode::type_enum, node, "type");
                        snode = blend;
                }
-               else if(string_iequals(node.name(), "clouds_texture")) {
-                       CloudsTextureNode *clouds = new CloudsTextureNode();
-                       xml_read_bool(&clouds->hard, node, "hard");
-                       xml_read_int(&clouds->depth, node, "depth");
-                       xml_read_enum(&clouds->basis, CloudsTextureNode::basis_enum, node, "basis");
-                       snode = clouds;
-               }
                else if(string_iequals(node.name(), "voronoi_texture")) {
                        VoronoiTextureNode *voronoi = new VoronoiTextureNode();
-                       xml_read_enum(&voronoi->distance_metric, VoronoiTextureNode::distance_metric_enum, node, "distance_metric");
                        xml_read_enum(&voronoi->coloring, VoronoiTextureNode::coloring_enum, node, "coloring");
                        snode = voronoi;
                }
                else if(string_iequals(node.name(), "musgrave_texture")) {
                        MusgraveTextureNode *musgrave = new MusgraveTextureNode();
                        xml_read_enum(&musgrave->type, MusgraveTextureNode::type_enum, node, "type");
-                       xml_read_enum(&musgrave->basis, MusgraveTextureNode::basis_enum, node, "basis");
                        snode = musgrave;
                }
-               else if(string_iequals(node.name(), "marble_texture")) {
-                       MarbleTextureNode *marble = new MarbleTextureNode();
-                       xml_read_enum(&marble->type, MarbleTextureNode::type_enum, node, "type");
-                       xml_read_enum(&marble->wave, MarbleTextureNode::wave_enum, node, "wave");
-                       xml_read_enum(&marble->basis, MarbleTextureNode::basis_enum, node, "basis");
-                       xml_read_bool(&marble->hard, node, "hard");
-                       xml_read_int(&marble->depth, node, "depth");
-                       snode = marble;
-               }
                else if(string_iequals(node.name(), "magic_texture")) {
                        MagicTextureNode *magic = new MagicTextureNode();
                        xml_read_int(&magic->depth, node, "depth");
                        snode = magic;
                }
-               else if(string_iequals(node.name(), "stucci_texture")) {
-                       StucciTextureNode *stucci = new StucciTextureNode();
-                       xml_read_enum(&stucci->type, StucciTextureNode::type_enum, node, "type");
-                       xml_read_enum(&stucci->basis, StucciTextureNode::basis_enum, node, "basis");
-                       xml_read_bool(&stucci->hard, node, "hard");
-                       snode = stucci;
-               }
-               else if(string_iequals(node.name(), "distorted_noise_texture")) {
-                       DistortedNoiseTextureNode *dist = new DistortedNoiseTextureNode();
-                       xml_read_enum(&dist->basis, DistortedNoiseTextureNode::basis_enum, node, "basis");
-                       xml_read_enum(&dist->distortion_basis, DistortedNoiseTextureNode::basis_enum, node, "distortion_basis");
+               else if(string_iequals(node.name(), "noise_texture")) {
+                       NoiseTextureNode *dist = new NoiseTextureNode();
                        snode = dist;
                }
-               else if(string_iequals(node.name(), "wood_texture")) {
-                       WoodTextureNode *wood = new WoodTextureNode();
-                       xml_read_enum(&wood->type, WoodTextureNode::type_enum, node, "type");
-                       xml_read_enum(&wood->wave, WoodTextureNode::wave_enum, node, "wave");
-                       xml_read_enum(&wood->basis, WoodTextureNode::basis_enum, node, "basis");
-                       xml_read_bool(&wood->hard, node, "hard");
+               else if(string_iequals(node.name(), "wave_texture")) {
+                       WaveTextureNode *wood = new WaveTextureNode();
+                       xml_read_enum(&wood->type, WaveTextureNode::type_enum, node, "type");
                        snode = wood;
                }
                else if(string_iequals(node.name(), "mapping")) {
index 04150b7ea90c66605a86c6badc0016d127c64e57..35215fd0f9fd1de4b58cb491cd5209ddf42486bb 100644 (file)
@@ -33,6 +33,15 @@ CCL_NAMESPACE_BEGIN
 #define BVH_NODE_SIZE 4
 #define TRI_NODE_SIZE 3
 
+/* silly workaround for float extended precision that happens when compiling
+   without sse support on x86, it results in different results for float ops
+   that you would otherwise expect to compare correctly */
+#if !defined(__i386__) || defined(__SSE__)
+#define NO_EXTENDED_PRECISION
+#else
+#define NO_EXTENDED_PRECISION volatile
+#endif
+
 __device_inline float3 bvh_inverse_direction(float3 dir)
 {
        /* avoid divide by zero (ooeps = exp2f(-80.0f)) */
@@ -94,8 +103,8 @@ __device_inline void bvh_node_intersect(KernelGlobals *kg,
        float c0hiy = n0xy.w * idir.y - ood.y;
        float c0loz = nz.x * idir.z - ood.z;
        float c0hiz = nz.y * idir.z - ood.z;
-       float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f);
-       float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t);
+       NO_EXTENDED_PRECISION float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f);
+       NO_EXTENDED_PRECISION float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t);
 
        float c1loz = nz.z * idir.z - ood.z;
        float c1hiz = nz.w * idir.z - ood.z;
@@ -103,8 +112,8 @@ __device_inline void bvh_node_intersect(KernelGlobals *kg,
        float c1hix = n1xy.y * idir.x - ood.x;
        float c1loy = n1xy.z * idir.y - ood.y;
        float c1hiy = n1xy.w * idir.y - ood.y;
-       float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f);
-       float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t);
+       NO_EXTENDED_PRECISION float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f);
+       NO_EXTENDED_PRECISION float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t);
 
        /* decide which nodes to traverse next */
 #ifdef __VISIBILITY_FLAG__
index 19992771c1d508b879314aeedee0a4e4d5771e6c..fc2dd49205a712e3c19f9440d3af479f8234ddc8 100644 (file)
@@ -685,9 +685,9 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
                        if(!mesh->transform_applied) {
                                string msg = "Updating Mesh BVH ";
                                if(mesh->name == "")
-                                       msg += string_printf("%ld/%ld", i+1, num_instance_bvh);
+                                       msg += string_printf("%lu/%lu", (unsigned long)(i+1), (unsigned long)num_instance_bvh);
                                else
-                                       msg += string_printf("%s %ld/%ld", mesh->name.c_str(), i+1, num_instance_bvh);
+                                       msg += string_printf("%s %lu/%lu", mesh->name.c_str(), (unsigned long)(i+1), (unsigned long)num_instance_bvh);
                                progress.set_status(msg, "Building BVH");
 
                                mesh->compute_bvh(&scene->params, progress);
index 8ed4854b786829ae2b705ea1bcdf40ee4d629b0a..3e6e0de48eaa65c4fbf3c0b9c2c5746e0e97e8c2 100644 (file)
@@ -88,7 +88,7 @@ SubdFace *SubdMesh::add_face(int *index, int num)
        /* test non-manifold cases */
        if(!can_add_face(index, num)) {
                /* we could try to add face in opposite winding instead .. */
-               fprintf(stderr, "Warning: non manifold mesh, invalid face '%lu'.\n", faces.size());
+               fprintf(stderr, "Warning: non manifold mesh, invalid face '%lu'.\n", (unsigned long)faces.size());
                return NULL;
        }
        
index 91e8a94a58423ebd0fbc11a9be68dfbf2a42b8c9..6e3c7c47e39bba02c68024751f699ae36b633bf7 100644 (file)
@@ -106,7 +106,7 @@ public:
                data.resize(size/sizeof(T));
 
                if(!fread(&data[0], size, 1, f)) {
-                       fprintf(stderr, "Failed to read vector data from cache (%ld).\n", size);
+                       fprintf(stderr, "Failed to read vector data from cache (%lu).\n", (unsigned long)size);
                        return;
                }
        }
index abf5e08de9700e44ba12a95db6212441a44eed74..e8c81e576542cf7e73fcc2c466d20384fe4212f3 100644 (file)
@@ -142,15 +142,15 @@ bool system_cpu_support_optimized()
        static bool caps_init = false;
 
        if(!caps_init) {
-               int result[4], num, num_ex;
+               int result[4], num; //, num_ex;
 
                memset(&caps, 0, sizeof(caps));
 
                __cpuid(result, 0);
                num = result[0];
 
-               __cpuid(result, 0x80000000);
-               num_ex = result[0];
+               /*__cpuid(result, 0x80000000);
+               num_ex = result[0];*/
 
                if(num >= 1){
                        __cpuid(result, 0x00000001);