diff options
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_math_fast.h | 2 | ||||
-rw-r--r-- | intern/cycles/util/util_ssei.h | 3 | ||||
-rw-r--r-- | intern/cycles/util/util_system.cpp | 52 | ||||
-rw-r--r-- | intern/cycles/util/util_texture.h | 12 | ||||
-rw-r--r-- | intern/cycles/util/util_vector.h | 4 |
5 files changed, 36 insertions, 37 deletions
diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h index 107b36ce6cd..5ae56290f05 100644 --- a/intern/cycles/util/util_math_fast.h +++ b/intern/cycles/util/util_math_fast.h @@ -362,7 +362,7 @@ ccl_device float fast_atan2f(float y, float x) ccl_device float fast_log2f(float x) { /* NOTE: clamp to avoid special cases and make result "safe" from large - * negative values/nans. */ + * negative values/NAN's. */ x = clamp(x, FLT_MIN, FLT_MAX); unsigned bits = __float_as_uint(x); int exponent = (int)(bits >> 23) - 127; diff --git a/intern/cycles/util/util_ssei.h b/intern/cycles/util/util_ssei.h index ce8f7de3fa2..cd51dbff2f1 100644 --- a/intern/cycles/util/util_ssei.h +++ b/intern/cycles/util/util_ssei.h @@ -457,7 +457,8 @@ template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const ssei shuffle(const ssei &a, const ssei &b) { # ifdef __KERNEL_NEON__ - int32x4_t result = shuffle_neon<int32x4_t, i0, i1, i2, i3>(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b)); + int32x4_t result = shuffle_neon<int32x4_t, i0, i1, i2, i3>(vreinterpretq_s32_m128i(a), + vreinterpretq_s32_m128i(b)); return vreinterpretq_m128i_s32(result); # else return _mm_castps_si128( diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index 6500a59e42c..03bc5aea1dd 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -145,7 +145,8 @@ int system_cpu_num_active_group_processors() return numaAPI_GetNumCurrentNodesProcessors(); } -#if !defined(_WIN32) || defined(FREE_WINDOWS) +/* Equivalent of Windows __cpuid for x86 processors on other platforms. */ +#if (!defined(_WIN32) || defined(FREE_WINDOWS)) && (defined(__x86_64__) || defined(__i386__)) static void __cpuid(int data[4], int selector) { # if defined(__x86_64__) @@ -166,7 +167,34 @@ static void __cpuid(int data[4], int selector) string system_cpu_brand_string() { -#if !defined(WIN32) && !defined(__x86_64__) && !defined(__i386__) +#if defined(__APPLE__) + /* Get from system on macOS. */ + char modelname[512] = ""; + size_t bufferlen = 512; + if (sysctlbyname("machdep.cpu.brand_string", &modelname, &bufferlen, NULL, 0) == 0) { + return modelname; + } +#elif defined(WIN32) || defined(__x86_64__) || defined(__i386__) + /* Get from intrinsics on Windows and x86. */ + char buf[49] = {0}; + int result[4] = {0}; + + __cpuid(result, 0x80000000); + + if (result[0] != 0 && result[0] >= (int)0x80000004) { + __cpuid((int *)(buf + 0), 0x80000002); + __cpuid((int *)(buf + 16), 0x80000003); + __cpuid((int *)(buf + 32), 0x80000004); + + string brand = buf; + + /* Make it a bit more presentable. */ + brand = string_remove_trademark(brand); + + return brand; + } +#else + /* Get from /proc/cpuinfo on Unix systems. */ FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); if (cpuinfo != nullptr) { char cpuinfo_buf[513] = ""; @@ -186,24 +214,6 @@ string system_cpu_brand_string() } } } -#else - char buf[49] = {0}; - int result[4] = {0}; - - __cpuid(result, 0x80000000); - - if (result[0] != 0 && result[0] >= (int)0x80000004) { - __cpuid((int *)(buf + 0), 0x80000002); - __cpuid((int *)(buf + 16), 0x80000003); - __cpuid((int *)(buf + 32), 0x80000004); - - string brand = buf; - - /* make it a bit more presentable */ - brand = string_remove_trademark(brand); - - return brand; - } #endif return "Unknown CPU"; } @@ -213,7 +223,7 @@ int system_cpu_bits() return (sizeof(void *) * 8); } -#if defined(__x86_64__) || defined(_M_X64) || defined(i386) || defined(_M_IX86) +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) struct CPUCapabilities { bool x64; diff --git a/intern/cycles/util/util_texture.h b/intern/cycles/util/util_texture.h index b445ab1488f..71bf9c65911 100644 --- a/intern/cycles/util/util_texture.h +++ b/intern/cycles/util/util_texture.h @@ -21,18 +21,12 @@ CCL_NAMESPACE_BEGIN -/* Texture limits on devices. */ -#define TEX_NUM_MAX (INT_MAX >> 4) - /* Color to use when textures are not found. */ #define TEX_IMAGE_MISSING_R 1 #define TEX_IMAGE_MISSING_G 0 #define TEX_IMAGE_MISSING_B 1 #define TEX_IMAGE_MISSING_A 1 -/* Texture type. */ -#define kernel_tex_type(tex) (tex & IMAGE_DATA_TYPE_MASK) - /* Interpolation types for textures * cuda also use texture space to store other objects */ typedef enum InterpolationType { @@ -45,9 +39,6 @@ typedef enum InterpolationType { INTERPOLATION_NUM_TYPES, } InterpolationType; -/* Texture types - * Since we store the type in the lower bits of a flat index, - * the shift and bit mask constant below need to be kept in sync. */ typedef enum ImageDataType { IMAGE_DATA_TYPE_FLOAT4 = 0, IMAGE_DATA_TYPE_BYTE4 = 1, @@ -75,9 +66,6 @@ typedef enum ImageAlphaType { IMAGE_ALPHA_NUM_TYPES, } ImageAlphaType; -#define IMAGE_DATA_TYPE_SHIFT 4 -#define IMAGE_DATA_TYPE_MASK 0xF - /* Extension types for textures. * * Defines how the image is extrapolated past its original bounds. */ diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h index 04fb33368d9..87cd4de8438 100644 --- a/intern/cycles/util/util_vector.h +++ b/intern/cycles/util/util_vector.h @@ -43,8 +43,8 @@ class vector : public std::vector<value_type, allocator_type> { /* Try as hard as possible to use zero memory. */ void free_memory() { - BaseClass::resize(0); - BaseClass::shrink_to_fit(); + vector<value_type, allocator_type> empty; + BaseClass::swap(empty); } /* Some external API might demand working with std::vector. */ |