[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57794] trunk/blender/intern/cycles: Code cleanup: cycles

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jun 27 01:29:33 CEST 2013


Revision: 57794
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57794
Author:   blendix
Date:     2013-06-26 23:29:33 +0000 (Wed, 26 Jun 2013)
Log Message:
-----------
Code cleanup: cycles
* Reshuffle SSE #ifdefs to try to avoid compilation errors enabling SSE on 32 bit.
* Remove CUDA kernel launch size exception on Mac, is not needed.
* Make OSL file compilation quiet like c/cpp files.

Modified Paths:
--------------
    trunk/blender/intern/cycles/device/device_cuda.cpp
    trunk/blender/intern/cycles/kernel/kernel_compat_opencl.h
    trunk/blender/intern/cycles/kernel/kernel_sse2.cpp
    trunk/blender/intern/cycles/kernel/shaders/CMakeLists.txt
    trunk/blender/intern/cycles/kernel/shaders/SConscript
    trunk/blender/intern/cycles/util/util_types.h
    trunk/blender/intern/cycles/util/util_vector.h

Modified: trunk/blender/intern/cycles/device/device_cuda.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_cuda.cpp	2013-06-26 23:15:52 UTC (rev 57793)
+++ trunk/blender/intern/cycles/device/device_cuda.cpp	2013-06-26 23:29:33 UTC (rev 57794)
@@ -607,13 +607,8 @@
 		cuda_assert(cuParamSetSize(cuPathTrace, offset))
 
 		/* launch kernel: todo find optimal size, cache config for fermi */
-#ifndef __APPLE__
 		int xthreads = 16;
 		int ythreads = 16;
-#else
-		int xthreads = 8;
-		int ythreads = 8;
-#endif
 		int xblocks = (rtile.w + xthreads - 1)/xthreads;
 		int yblocks = (rtile.h + ythreads - 1)/ythreads;
 
@@ -676,13 +671,8 @@
 		cuda_assert(cuParamSetSize(cuFilmConvert, offset))
 
 		/* launch kernel: todo find optimal size, cache config for fermi */
-#ifndef __APPLE__
 		int xthreads = 16;
 		int ythreads = 16;
-#else
-		int xthreads = 8;
-		int ythreads = 8;
-#endif
 		int xblocks = (task.w + xthreads - 1)/xthreads;
 		int yblocks = (task.h + ythreads - 1)/ythreads;
 
@@ -730,11 +720,7 @@
 		cuda_assert(cuParamSetSize(cuDisplace, offset))
 
 		/* launch kernel: todo find optimal size, cache config for fermi */
-#ifndef __APPLE__
 		int xthreads = 16;
-#else
-		int xthreads = 8;
-#endif
 		int xblocks = (task.shader_w + xthreads - 1)/xthreads;
 
 		cuda_assert(cuFuncSetCacheConfig(cuDisplace, CU_FUNC_CACHE_PREFER_L1))

Modified: trunk/blender/intern/cycles/kernel/kernel_compat_opencl.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_compat_opencl.h	2013-06-26 23:15:52 UTC (rev 57793)
+++ trunk/blender/intern/cycles/kernel/kernel_compat_opencl.h	2013-06-26 23:29:33 UTC (rev 57794)
@@ -108,7 +108,6 @@
 
 /* data lookup defines */
 #define kernel_data (*kg->data)
-#define kernel_tex_lookup(t, x, offset, size) kernel_tex_lookup_(kg->t, offset, size, x)
 #define kernel_tex_fetch(t, index) kg->t[index]
 
 /* define NULL */

Modified: trunk/blender/intern/cycles/kernel/kernel_sse2.cpp
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_sse2.cpp	2013-06-26 23:15:52 UTC (rev 57793)
+++ trunk/blender/intern/cycles/kernel/kernel_sse2.cpp	2013-06-26 23:29:33 UTC (rev 57794)
@@ -22,7 +22,7 @@
 
 #ifdef WITH_OPTIMIZED_KERNEL
 
-//#define __KERNEL_SSE2__
+#define __KERNEL_SSE2__
 
 #include "kernel.h"
 #include "kernel_compat_cpu.h"

Modified: trunk/blender/intern/cycles/kernel/shaders/CMakeLists.txt
===================================================================
--- trunk/blender/intern/cycles/kernel/shaders/CMakeLists.txt	2013-06-26 23:15:52 UTC (rev 57793)
+++ trunk/blender/intern/cycles/kernel/shaders/CMakeLists.txt	2013-06-26 23:29:33 UTC (rev 57794)
@@ -91,7 +91,7 @@
 	string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _OSO_FILE ${_OSO_FILE})
 	add_custom_command(
 		OUTPUT ${_OSO_FILE} 
-		COMMAND ${OSL_COMPILER} -O2  -I"${CMAKE_CURRENT_SOURCE_DIR}" ${_OSL_FILE}
+		COMMAND ${OSL_COMPILER} -q -O2  -I"${CMAKE_CURRENT_SOURCE_DIR}" ${_OSL_FILE}
 		DEPENDS ${_OSL_FILE} ${SRC_OSL_HEADERS})
 	list(APPEND SRC_OSO
 		${_OSO_FILE}

Modified: trunk/blender/intern/cycles/kernel/shaders/SConscript
===================================================================
--- trunk/blender/intern/cycles/kernel/shaders/SConscript	2013-06-26 23:15:52 UTC (rev 57793)
+++ trunk/blender/intern/cycles/kernel/shaders/SConscript	2013-06-26 23:29:33 UTC (rev 57794)
@@ -57,7 +57,7 @@
             osl_file = os.path.join(source_dir, f)
             oso_file = os.path.join(build_dir, f.replace('.osl', '.oso'))
 
-            command = "%s -O2 -I%s -o %s %s" % (osl_compiler, source_dir, oso_file, osl_file)
+            command = "%s -q -O2 -I%s -o %s %s" % (osl_compiler, source_dir, oso_file, osl_file)
 
             shaders.Command(oso_file, f, command)
             shaders.Depends(oso_file, [f] + dependencies)

Modified: trunk/blender/intern/cycles/util/util_types.h
===================================================================
--- trunk/blender/intern/cycles/util/util_types.h	2013-06-26 23:15:52 UTC (rev 57793)
+++ trunk/blender/intern/cycles/util/util_types.h	2013-06-26 23:29:33 UTC (rev 57794)
@@ -61,59 +61,49 @@
 
 #ifndef __KERNEL_GPU__
 
-/* not enabled, globally applying it just gives slowdown,
- * but useful for testing. */
-//#define __KERNEL_SSE__
-#ifdef __KERNEL_SSE__
-
-#include <xmmintrin.h> /* SSE 1 */
-#include <emmintrin.h> /* SSE 2 */
-#include <pmmintrin.h> /* SSE 3 */
-#include <tmmintrin.h> /* SSSE 3 */
-#include <smmintrin.h> /* SSE 4 */
-
+/* not enabled, globally applying it gives slowdown, only for testing. */
+#if 0
+#define __KERNEL_SSE__
 #ifndef __KERNEL_SSE2__
 #define __KERNEL_SSE2__
 #endif
-
 #ifndef __KERNEL_SSE3__
 #define __KERNEL_SSE3__
 #endif
-
 #ifndef __KERNEL_SSSE3__
 #define __KERNEL_SSSE3__
 #endif
-
 #ifndef __KERNEL_SSE4__
 #define __KERNEL_SSE4__
 #endif
+#endif
 
-#else
+/* SSE2 is always available on x86_64 CPUs, so auto enable */
+#if defined(__x86_64__) && !defined(__KERNEL_SSE2__)
+#define __KERNEL_SSE2__
+#endif
 
-#if defined(__x86_64__) || defined(__KERNEL_SSSE3__)
+/* SSE intrinsics headers */
+#ifndef FREE_WINDOWS64
 
-/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
- * Since we can't avoid including <windows.h>, better only include that */
-#ifdef FREE_WINDOWS64
-#include <windows.h>
-#else
+#ifdef __KERNEL_SSE2__
 #include <xmmintrin.h> /* SSE 1 */
 #include <emmintrin.h> /* SSE 2 */
+#endif
 
 #ifdef __KERNEL_SSE3__
 #include <pmmintrin.h> /* SSE 3 */
 #endif
+
 #ifdef __KERNEL_SSSE3__
 #include <tmmintrin.h> /* SSSE 3 */
 #endif
-#endif
 
-/* SSE2 is available on x64 and SSE3 CPUs, so enable here as well */
-#ifndef __KERNEL_SSE2__
-#define __KERNEL_SSE2__
-#endif
+#else
 
-#endif
+/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
+ * Since we can't avoid including <windows.h>, better only include that */
+#include <windows.h>
 
 #endif
 
@@ -553,30 +543,6 @@
 }
 #endif
 
-#ifndef __KERNEL_GPU__
-
-static inline void *malloc_aligned(size_t size, size_t alignment)
-{
-	void *data = (void*)malloc(size + sizeof(void*) + alignment - 1);
-
-	union { void *ptr; size_t offset; } u;
-	u.ptr = (char*)data + sizeof(void*);
-	u.offset = (u.offset + alignment - 1) & ~(alignment - 1);
-	*(((void**)u.ptr) - 1) = data;
-
-	return u.ptr;
-}
-
-static inline void free_aligned(void *ptr)
-{
-	if(ptr) {
-		void *data = *(((void**)ptr) - 1);
-		free(data);
-	}
-}
-
-#endif
-
 CCL_NAMESPACE_END
 
 #endif /* __UTIL_TYPES_H__ */

Modified: trunk/blender/intern/cycles/util/util_vector.h
===================================================================
--- trunk/blender/intern/cycles/util/util_vector.h	2013-06-26 23:15:52 UTC (rev 57793)
+++ trunk/blender/intern/cycles/util/util_vector.h	2013-06-26 23:29:33 UTC (rev 57794)
@@ -30,6 +30,26 @@
 
 using std::vector;
 
+static inline void *malloc_aligned(size_t size, size_t alignment)
+{
+	void *data = (void*)malloc(size + sizeof(void*) + alignment - 1);
+
+	union { void *ptr; size_t offset; } u;
+	u.ptr = (char*)data + sizeof(void*);
+	u.offset = (u.offset + alignment - 1) & ~(alignment - 1);
+	*(((void**)u.ptr) - 1) = data;
+
+	return u.ptr;
+}
+
+static inline void free_aligned(void *ptr)
+{
+	if(ptr) {
+		void *data = *(((void**)ptr) - 1);
+		free(data);
+	}
+}
+
 /* Array
  *
  * Simplified version of vector, serving multiple purposes:




More information about the Bf-blender-cvs mailing list