box-min.cl.h 4.01 KB
Newer Older
1
static const char* box_min_cl_source =
2 3 4 5 6 7 8 9 10 11 12 13
"__kernel void kernel_min_hor (__global const float4     *in,                  \n"
"                              __global       float4     *aux,                 \n"
"                              int width, int radius)                          \n"
"{                                                                             \n"
"  const int in_index = get_global_id(0) * (width + 2 * radius)                \n"
"                       + (radius + get_global_id (1));                        \n"
"                                                                              \n"
"  const int aux_index = get_global_id(0) * width + get_global_id (1);         \n"
"  int i;                                                                      \n"
"  float4 min;                                                                 \n"
"  float4 in_v;                                                                \n"
"                                                                              \n"
14
"  min = (float4)(FLT_MAX);                                                    \n"
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
"                                                                              \n"
"  if (get_global_id(1) < width)                                               \n"
"    {                                                                         \n"
"      for (i=-radius; i <= radius; i++)                                       \n"
"        {                                                                     \n"
"          in_v = in[in_index + i];                                            \n"
"          min = min > in_v ? in_v : min;                                      \n"
"        }                                                                     \n"
"        aux[aux_index] = min;                                                 \n"
"    }                                                                         \n"
"}                                                                             \n"
"                                                                              \n"
"__kernel void kernel_min_ver (__global const float4     *aux,                 \n"
"                              __global       float4     *out,                 \n"
"                              int width, int radius)                          \n"
"{                                                                             \n"
"                                                                              \n"
"  const int out_index = get_global_id(0) * width + get_global_id (1);         \n"
"  int aux_index = out_index;                                                  \n"
"  int i;                                                                      \n"
"  float4 min;                                                                 \n"
"  float4 aux_v;                                                               \n"
"                                                                              \n"
38
"  min = (float4)(FLT_MAX);                                                    \n"
39 40 41 42 43 44 45 46 47 48 49 50 51
"                                                                              \n"
"  if(get_global_id(1) < width)                                                \n"
"    {                                                                         \n"
"      for (i=-radius; i <= radius; i++)                                       \n"
"        {                                                                     \n"
"          aux_v = aux[aux_index];                                             \n"
"          min = min > aux_v ? aux_v : min;                                    \n"
"          aux_index += width;                                                 \n"
"        }                                                                     \n"
"        out[out_index] = min;                                                 \n"
"    }                                                                         \n"
"}                                                                             \n"
;