Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_math.h11
-rw-r--r--intern/cycles/util/util_optimization.h2
-rw-r--r--intern/cycles/util/util_transform.h7
-rw-r--r--intern/cycles/util/util_vector.h48
4 files changed, 49 insertions, 19 deletions
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 97c93516496..7d6dfd34e0e 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -1447,14 +1447,9 @@ ccl_device bool ray_triangle_intersect_uv(
return true;
}
-#if defined(__KERNEL_CUDA__) && (defined(i386) || defined(_M_IX86)) && (defined(__KERNEL_EXPERIMENTAL__) || __CUDA_ARCH__ == 500)
-ccl_device_noinline
-#else
-ccl_device
-#endif
-bool ray_quad_intersect(float3 ray_P, float3 ray_D, float ray_t,
- float3 quad_P, float3 quad_u, float3 quad_v,
- float3 *isect_P, float *isect_t)
+ccl_device bool ray_quad_intersect(float3 ray_P, float3 ray_D, float ray_t,
+ float3 quad_P, float3 quad_u, float3 quad_v,
+ float3 *isect_P, float *isect_t)
{
float3 v0 = quad_P - quad_u*0.5f - quad_v*0.5f;
float3 v1 = quad_P + quad_u*0.5f - quad_v*0.5f;
diff --git a/intern/cycles/util/util_optimization.h b/intern/cycles/util/util_optimization.h
index c951c35fc76..42d3ca69b3a 100644
--- a/intern/cycles/util/util_optimization.h
+++ b/intern/cycles/util/util_optimization.h
@@ -101,7 +101,7 @@
#ifdef _MSC_VER
#include <intrin.h>
-#else
+#elif (defined(__x86_64__) || defined(__i386__))
#include <x86intrin.h>
#endif
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index ba8d04b5c16..f01db64a79b 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -347,7 +347,12 @@ ccl_device_inline Transform transform_quick_inverse(Transform M)
* scale can be inverted but what about shearing? */
Transform R;
float det = M.x.x*(M.z.z*M.y.y - M.z.y*M.y.z) - M.y.x*(M.z.z*M.x.y - M.z.y*M.x.z) + M.z.x*(M.y.z*M.x.y - M.y.y*M.x.z);
-
+ if(det == 0.0f) {
+ M.x.x += 1e-8f;
+ M.y.y += 1e-8f;
+ M.z.z += 1e-8f;
+ det = M.x.x*(M.z.z*M.y.y - M.z.y*M.y.z) - M.y.x*(M.z.z*M.x.y - M.z.y*M.x.z) + M.z.x*(M.y.z*M.x.y - M.y.y*M.x.z);
+ }
det = (det != 0.0f)? 1.0f/det: 0.0f;
float3 Rx = det*make_float3(M.z.z*M.y.y - M.z.y*M.y.z, M.z.y*M.x.z - M.z.z*M.x.y, M.y.z*M.x.y - M.y.y*M.x.z);
diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h
index 15a65be0ef0..623436483a0 100644
--- a/intern/cycles/util/util_vector.h
+++ b/intern/cycles/util/util_vector.h
@@ -105,6 +105,7 @@ public:
{
data = NULL;
datasize = 0;
+ capacity = 0;
}
array(size_t newsize)
@@ -112,10 +113,12 @@ public:
if(newsize == 0) {
data = NULL;
datasize = 0;
+ capacity = 0;
}
else {
data = (T*)util_aligned_malloc(sizeof(T)*newsize, alignment);
datasize = newsize;
+ capacity = datasize;
}
}
@@ -129,11 +132,13 @@ public:
if(from.datasize == 0) {
data = NULL;
datasize = 0;
+ capacity = 0;
}
else {
data = (T*)util_aligned_malloc(sizeof(T)*from.datasize, alignment);
memcpy(data, from.data, from.datasize*sizeof(T));
datasize = from.datasize;
+ capacity = datasize;
}
return *this;
@@ -142,6 +147,7 @@ public:
array& operator=(const vector<T>& from)
{
datasize = from.size();
+ capacity = datasize;
data = NULL;
if(datasize > 0) {
@@ -157,28 +163,39 @@ public:
util_aligned_free(data);
}
- void resize(size_t newsize)
+ T* resize(size_t newsize)
{
if(newsize == 0) {
clear();
}
else if(newsize != datasize) {
- T *newdata = (T*)util_aligned_malloc(sizeof(T)*newsize, alignment);
- if(data) {
- memcpy(newdata, data, ((datasize < newsize)? datasize: newsize)*sizeof(T));
- util_aligned_free(data);
+ if(newsize > capacity) {
+ T *newdata = (T*)util_aligned_malloc(sizeof(T)*newsize, alignment);
+ if(newdata == NULL) {
+ /* Allocation failed, likely out of memory. */
+ clear();
+ return NULL;
+ }
+ else if(data) {
+ memcpy(newdata, data, ((datasize < newsize)? datasize: newsize)*sizeof(T));
+ util_aligned_free(data);
+ }
+ data = newdata;
+ capacity = newsize;
}
-
- data = newdata;
datasize = newsize;
}
+ return data;
}
void clear()
{
- util_aligned_free(data);
- data = NULL;
+ if(data != NULL) {
+ util_aligned_free(data);
+ data = NULL;
+ }
datasize = 0;
+ capacity = 0;
}
size_t size() const
@@ -192,9 +209,22 @@ public:
return data[i];
}
+ void reserve(size_t newcapacity) {
+ if(newcapacity > capacity) {
+ T *newdata = (T*)util_aligned_malloc(sizeof(T)*newcapacity, alignment);
+ if(data) {
+ memcpy(newdata, data, ((datasize < newcapacity)? datasize: newcapacity)*sizeof(T));
+ util_aligned_free(data);
+ }
+ data = newdata;
+ capacity = newcapacity;
+ }
+ }
+
protected:
T *data;
size_t datasize;
+ size_t capacity;
};
CCL_NAMESPACE_END