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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-05-31 15:31:00 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-05-31 15:31:00 +0400
commit64c2d5e90e7ec80eb693c814787d8eee393c3bab (patch)
tree0d3f2be5289ad5f6a09b316d538159854fbb8f92
parenteedcba7ed57e85b01b4aa5bc106502178835e6ae (diff)
Cycles: more opencl fixes.
-rw-r--r--intern/cycles/kernel/kernel_compat_opencl.h22
-rw-r--r--intern/cycles/render/attribute.cpp5
-rw-r--r--intern/cycles/render/shader.cpp1
-rw-r--r--intern/cycles/util/util_math.h24
-rw-r--r--intern/cycles/util/util_transform.h8
5 files changed, 40 insertions, 20 deletions
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index e6e54850605..c8be03d7dd0 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -22,10 +22,10 @@
#define __KERNEL_GPU__
#define __KERNEL_OPENCL__
-#include "util_types.h"
-
CCL_NAMESPACE_BEGIN
+#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
+
#define __device
#define __device_inline
@@ -42,12 +42,26 @@ __device float kernel_tex_interp_(__global float *data, int width, float x)
return (1.0f - t)*data[index] + t*data[nindex];
}
-#define make_float3(x, y, z) ((float3)(x, y, z)) /* todo 1.1 */
+#define make_float2(x, y) ((float2)(x, y))
+#define make_float3(x, y, z) ((float3)(x, y, z, 0.0f))
+#define make_float4(x, y, z, w) ((float4)(x, y, z, w))
+#define make_int2(x, y) ((int2)(x, y))
+#define make_int3(x, y, z) ((int3)(x, y, z, 0))
+#define make_int4(x, y, z, w) ((int4)(x, y, z, w))
+
+typedef float4 float3;
+typedef int4 int3;
#define __uint_as_float(x) as_float(x)
#define __float_as_uint(x) as_uint(x)
#define __int_as_float(x) as_float(x)
#define __float_as_int(x) as_int(x)
+#define sqrtf(x) sqrt(((float)x))
+#define cosf(x) cos(((float)x))
+#define sinf(x) sin(((float)x))
+#define powf(x, y) pow(((float)x), ((float)y))
+#define fabsf(x) fabs(((float)x))
+#define copysignf(x, y) copysign(((float)x), ((float)y))
#define kernel_data (*kg->data)
#define kernel_tex_interp(t, x) \
@@ -57,6 +71,8 @@ __device float kernel_tex_interp_(__global float *data, int width, float x)
#define NULL 0
+#include "util_types.h"
+
CCL_NAMESPACE_END
#endif /* __KERNEL_COMPAT_OPENCL_H__ */
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index 815478cb733..aa18ca7d7cb 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -46,7 +46,10 @@ void Attribute::reserve(int numverts, int numtris)
size_t Attribute::data_sizeof()
{
- return type.size();
+ if(type == TypeDesc::TypeFloat)
+ return sizeof(float);
+ else
+ return sizeof(float3);
}
size_t Attribute::element_size(int numverts, int numtris)
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 9ea162d3ad0..548beaaecdd 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -45,6 +45,7 @@ Shader::Shader()
has_displacement = false;
need_update = true;
+ need_update_attributes = true;
}
Shader::~Shader()
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index e6dd00fd86b..1bb3f5b6097 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -345,56 +345,56 @@ __device_inline float average(const float3 a)
__device_inline float3 operator-(const float3 a)
{
- float3 r = {-a.x, -a.y, -a.z};
+ float3 r = make_float3(-a.x, -a.y, -a.z);
return r;
}
__device_inline float3 operator*(const float3 a, const float3 b)
{
- float3 r = {a.x*b.x, a.y*b.y, a.z*b.z};
+ float3 r = make_float3(a.x*b.x, a.y*b.y, a.z*b.z);
return r;
}
__device_inline float3 operator*(const float3 a, float f)
{
- float3 r = {a.x*f, a.y*f, a.z*f};
+ float3 r = make_float3(a.x*f, a.y*f, a.z*f);
return r;
}
__device_inline float3 operator*(float f, const float3 a)
{
- float3 r = {a.x*f, a.y*f, a.z*f};
+ float3 r = make_float3(a.x*f, a.y*f, a.z*f);
return r;
}
__device_inline float3 operator/(float f, const float3 a)
{
- float3 r = {f/a.x, f/a.y, f/a.z};
+ float3 r = make_float3(f/a.x, f/a.y, f/a.z);
return r;
}
__device_inline float3 operator/(const float3 a, float f)
{
float invf = 1.0f/f;
- float3 r = {a.x*invf, a.y*invf, a.z*invf};
+ float3 r = make_float3(a.x*invf, a.y*invf, a.z*invf);
return r;
}
__device_inline float3 operator/(const float3 a, const float3 b)
{
- float3 r = {a.x/b.x, a.y/b.y, a.z/b.z};
+ float3 r = make_float3(a.x/b.x, a.y/b.y, a.z/b.z);
return r;
}
__device_inline float3 operator+(const float3 a, const float3 b)
{
- float3 r = {a.x+b.x, a.y+b.y, a.z+b.z};
+ float3 r = make_float3(a.x+b.x, a.y+b.y, a.z+b.z);
return r;
}
__device_inline float3 operator-(const float3 a, const float3 b)
{
- float3 r = {a.x-b.x, a.y-b.y, a.z-b.z};
+ float3 r = make_float3(a.x-b.x, a.y-b.y, a.z-b.z);
return r;
}
@@ -446,7 +446,7 @@ __device_inline float dot(const float3 a, const float3 b)
__device_inline float3 cross(const float3 a, const float3 b)
{
- float3 r = {a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x};
+ float3 r = make_float3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x);
return r;
}
@@ -486,13 +486,13 @@ __device_inline bool operator!=(const float3 a, const float3 b)
__device_inline float3 min(float3 a, float3 b)
{
- float3 r = {min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)};
+ float3 r = make_float3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
return r;
}
__device_inline float3 max(float3 a, float3 b)
{
- float3 r = {max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)};
+ float3 r = make_float3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
return r;
}
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index e2b022dc478..e904674a981 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -34,16 +34,16 @@ typedef struct Transform {
__device_inline float3 transform(const Transform *t, const float3 a)
{
- float4 b = {a.x, a.y, a.z, 1.0f};
- float3 c = {dot(t->x, b), dot(t->y, b), dot(t->z, b)};
+ float4 b = make_float4(a.x, a.y, a.z, 1.0f);
+ float3 c = make_float3(dot(t->x, b), dot(t->y, b), dot(t->z, b));
return c/dot(t->w, b);
}
__device_inline float3 transform_direction(const Transform *t, const float3 a)
{
- float4 b = {a.x, a.y, a.z, 0.0f};
- float3 c = {dot(t->x, b), dot(t->y, b), dot(t->z, b)};
+ float4 b = make_float4(a.x, a.y, a.z, 0.0f);
+ float3 c = make_float3(dot(t->x, b), dot(t->y, b), dot(t->z, b));
return c;
}