[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37049] branches/cycles/intern/cycles: Cycles: more opencl fixes.
Brecht Van Lommel
brechtvanlommel at pandora.be
Tue May 31 13:31:00 CEST 2011
Revision: 37049
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37049
Author: blendix
Date: 2011-05-31 11:31:00 +0000 (Tue, 31 May 2011)
Log Message:
-----------
Cycles: more opencl fixes.
Modified Paths:
--------------
branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h
branches/cycles/intern/cycles/render/attribute.cpp
branches/cycles/intern/cycles/render/shader.cpp
branches/cycles/intern/cycles/util/util_math.h
branches/cycles/intern/cycles/util/util_transform.h
Modified: branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h
===================================================================
--- branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h 2011-05-31 11:28:04 UTC (rev 37048)
+++ branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h 2011-05-31 11:31:00 UTC (rev 37049)
@@ -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 @@
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 @@
#define NULL 0
+#include "util_types.h"
+
CCL_NAMESPACE_END
#endif /* __KERNEL_COMPAT_OPENCL_H__ */
Modified: branches/cycles/intern/cycles/render/attribute.cpp
===================================================================
--- branches/cycles/intern/cycles/render/attribute.cpp 2011-05-31 11:28:04 UTC (rev 37048)
+++ branches/cycles/intern/cycles/render/attribute.cpp 2011-05-31 11:31:00 UTC (rev 37049)
@@ -46,7 +46,10 @@
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)
Modified: branches/cycles/intern/cycles/render/shader.cpp
===================================================================
--- branches/cycles/intern/cycles/render/shader.cpp 2011-05-31 11:28:04 UTC (rev 37048)
+++ branches/cycles/intern/cycles/render/shader.cpp 2011-05-31 11:31:00 UTC (rev 37049)
@@ -45,6 +45,7 @@
has_displacement = false;
need_update = true;
+ need_update_attributes = true;
}
Shader::~Shader()
Modified: branches/cycles/intern/cycles/util/util_math.h
===================================================================
--- branches/cycles/intern/cycles/util/util_math.h 2011-05-31 11:28:04 UTC (rev 37048)
+++ branches/cycles/intern/cycles/util/util_math.h 2011-05-31 11:31:00 UTC (rev 37049)
@@ -345,56 +345,56 @@
__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 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 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;
}
Modified: branches/cycles/intern/cycles/util/util_transform.h
===================================================================
--- branches/cycles/intern/cycles/util/util_transform.h 2011-05-31 11:28:04 UTC (rev 37048)
+++ branches/cycles/intern/cycles/util/util_transform.h 2011-05-31 11:31:00 UTC (rev 37049)
@@ -34,16 +34,16 @@
__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;
}
More information about the Bf-blender-cvs
mailing list