summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorØyvind Kolås <pippin@gimp.org>2015-09-16 22:51:05 +0200
committerØyvind Kolås <pippin@gimp.org>2015-09-16 22:51:08 +0200
commitb958869ffca7517ff5f515a05da4ffc86c8551aa (patch)
treef4964351074d4a79288d8f3b43df695f559e2263
parentb15f4f825fee76534f8e8dd05e282042b8b8c64f (diff)
opencl: replace CLAMP macros with OpenCL built-in clamp
Spotted and sorted out by Laura Ekstrand in bug #754914
-rw-r--r--opencl/motion-blur-linear.cl9
-rw-r--r--opencl/motion-blur-linear.cl.h8
-rw-r--r--opencl/texturize-canvas.cl3
-rw-r--r--opencl/texturize-canvas.cl.h3
4 files changed, 6 insertions, 17 deletions
diff --git a/opencl/motion-blur-linear.cl b/opencl/motion-blur-linear.cl
index 88befafe..265b163e 100644
--- a/opencl/motion-blur-linear.cl
+++ b/opencl/motion-blur-linear.cl
@@ -1,8 +1,3 @@
-int CLAMP(int val,int lo,int hi)
-{
- return (val < lo) ? lo : ((hi < val) ? hi : val);
-}
-
float4 get_pixel_color(const __global float4 *in_buf,
int rect_width,
int rect_height,
@@ -14,8 +9,8 @@ float4 get_pixel_color(const __global float4 *in_buf,
int ix = x - rect_x;
int iy = y - rect_y;
- ix = CLAMP(ix, 0, rect_width-1);
- iy = CLAMP(iy, 0, rect_height-1);
+ ix = clamp(ix, 0, rect_width-1);
+ iy = clamp(iy, 0, rect_height-1);
return in_buf[iy * rect_width + ix];
}
diff --git a/opencl/motion-blur-linear.cl.h b/opencl/motion-blur-linear.cl.h
index 050286fc..f1a60060 100644
--- a/opencl/motion-blur-linear.cl.h
+++ b/opencl/motion-blur-linear.cl.h
@@ -1,8 +1,4 @@
static const char* motion_blur_linear_cl_source =
-"int CLAMP(int val,int lo,int hi) \n"
-"{ \n"
-" return (val < lo) ? lo : ((hi < val) ? hi : val); \n"
-"} \n"
" \n"
"float4 get_pixel_color(const __global float4 *in_buf, \n"
" int rect_width, \n"
@@ -15,8 +11,8 @@ static const char* motion_blur_linear_cl_source =
" int ix = x - rect_x; \n"
" int iy = y - rect_y; \n"
" \n"
-" ix = CLAMP(ix, 0, rect_width-1); \n"
-" iy = CLAMP(iy, 0, rect_height-1); \n"
+" ix = clamp(ix, 0, rect_width-1); \n"
+" iy = clamp(iy, 0, rect_height-1); \n"
" \n"
" return in_buf[iy * rect_width + ix]; \n"
"} \n"
diff --git a/opencl/texturize-canvas.cl b/opencl/texturize-canvas.cl
index f2891b4b..9d68af22 100644
--- a/opencl/texturize-canvas.cl
+++ b/opencl/texturize-canvas.cl
@@ -1,4 +1,3 @@
-#define CLAMP(val,lo,hi) (val < lo) ? lo : ((hi < val) ? hi : val )
__kernel cl_texturize_canvas(__global const float * in,
__global float * out,
__global float * sdata,
@@ -23,7 +22,7 @@ __kernel cl_texturize_canvas(__global const float * in,
for(i=0; i<components; ++i)
{
color = tmp + src[index];
- out[index++] = CLAMP(color,0.0f,1.0f);
+ out[index++] = clamp(color,0.0f,1.0f);
}
if(has_alpha)
out[index] = in[index];
diff --git a/opencl/texturize-canvas.cl.h b/opencl/texturize-canvas.cl.h
index 5fa1566b..628756e1 100644
--- a/opencl/texturize-canvas.cl.h
+++ b/opencl/texturize-canvas.cl.h
@@ -1,5 +1,4 @@
static const char* texturize_canvas_cl_source =
-"#define CLAMP(val,lo,hi) (val < lo) ? lo : ((hi < val) ? hi : val ) \n"
"__kernel cl_texturize_canvas(__global const float * in, \n"
" __global float * out, \n"
" __global float * sdata, \n"
@@ -24,7 +23,7 @@ static const char* texturize_canvas_cl_source =
" for(i=0; i<components; ++i) \n"
" { \n"
" color = tmp + src[index]; \n"
-" out[index++] = CLAMP(color,0.0f,1.0f); \n"
+" out[index++] = clamp(color,0.0f,1.0f); \n"
" } \n"
" if(has_alpha) \n"
" out[index] = in[index]; \n"