ISAAC
Overview :: Library Doc :: Server Doc :: JSON Commands

In Situ Animation of Accelerated Computations

isaac_kernel.hpp
Go to the documentation of this file.
1 /* This file is part of ISAAC.
2  *
3  * ISAAC is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * ISAAC is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with ISAAC. If not, see <www.gnu.org/licenses/>. */
15 
16 #pragma once
17 
18 #include "isaac_macros.hpp"
20 #include "isaac_functors.hpp"
21 
22 #include <boost/mpl/at.hpp>
23 #include <boost/mpl/vector.hpp>
24 #include <boost/mpl/back.hpp>
25 #include <boost/mpl/bool.hpp>
26 #include <boost/mpl/push_back.hpp>
27 #include <boost/fusion/include/push_back.hpp>
28 #include <boost/mpl/size.hpp>
29 
30 #include <float.h>
31 
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
34 #pragma GCC diagnostic ignored "-Wsign-compare"
35 
36 namespace isaac
37 {
38 
39 namespace fus = boost::fusion;
40 namespace mpl = boost::mpl;
41 
42 typedef isaac_float (*isaac_functor_chain_pointer_4)(isaac_float_dim <4>, isaac_int );
43 typedef isaac_float (*isaac_functor_chain_pointer_3)(isaac_float_dim <3>, isaac_int );
44 typedef isaac_float (*isaac_functor_chain_pointer_2)(isaac_float_dim <2>, isaac_int );
45 typedef isaac_float (*isaac_functor_chain_pointer_1)(isaac_float_dim <1>, isaac_int );
47 
49 ISAAC_CONSTANT isaac_size_struct<3> isaac_size_d[1]; //[1] to access it for cuda and alpaka the same way
52 
53 
54 template
55 <
56  typename TFunctorVector,
57  int TFeatureDim,
58  int NR
59 >
61 {
62  ISAAC_DEVICE static isaac_functor_chain_pointer_N call( isaac_int const * const bytecode )
63  {
64  #define ISAAC_SUB_CALL(Z, I, U) \
65  if (bytecode[ISAAC_MAX_FUNCTORS-NR] == I) \
66  return FillFunctorChainPointerKernelStruct \
67  < \
68  typename mpl::push_back< TFunctorVector, typename boost::mpl::at_c<IsaacFunctorPool,I>::type >::type, \
69  TFeatureDim, \
70  NR - 1 \
71  > ::call( bytecode );
72  BOOST_PP_REPEAT( ISAAC_FUNCTOR_COUNT, ISAAC_SUB_CALL, ~)
73  #undef ISAAC_SUB_CALL
74  return NULL; //Should never be reached anyway
75  }
76 };
77 
78 template
79 <
80  typename TFunctorVector,
81  int TFeatureDim
82 >
84  isaac_float_dim < TFeatureDim > const value,
85  isaac_int const src_id
86 )
87 {
88  #define ISAAC_LEFT_DEF(Z,I,U) mpl::at_c< TFunctorVector, ISAAC_MAX_FUNCTORS - I - 1 >::type::call(
89  #define ISAAC_RIGHT_DEF(Z,I,U) , isaac_parameter_d[ src_id * ISAAC_MAX_FUNCTORS + I ] )
90  #define ISAAC_LEFT BOOST_PP_REPEAT( ISAAC_MAX_FUNCTORS, ISAAC_LEFT_DEF, ~)
91  #define ISAAC_RIGHT BOOST_PP_REPEAT( ISAAC_MAX_FUNCTORS, ISAAC_RIGHT_DEF, ~)
92  // expands to: funcN( ... func1( func0( data, p[0] ), p[1] ) ... p[N] );
93  return ISAAC_LEFT value ISAAC_RIGHT .value.x;
94  #undef ISAAC_LEFT_DEF
95  #undef ISAAC_LEFT
96  #undef ISAAC_RIGHT_DEF
97  #undef ISAAC_RIGHT
98 }
99 
100 
101 template
102 <
103  typename TFunctorVector,
104  int TFeatureDim
105 >
107 <
108  TFunctorVector,
109  TFeatureDim,
110  0 //<- Specialization
111 >
112 {
114  {
115  return reinterpret_cast<isaac_functor_chain_pointer_N>(applyFunctorChain<TFunctorVector,TFeatureDim>);
116  }
117 };
118 
119 
120 #if ISAAC_ALPAKA == 1
122  {
123  template <typename TAcc__>
124  ALPAKA_FN_ACC void operator()(
125  TAcc__ const &acc,
126 #else
128 #endif
129  isaac_functor_chain_pointer_N * const functor_chain_d)
130 #if ISAAC_ALPAKA == 1
131  const
132 #endif
133  {
134  isaac_int bytecode[ISAAC_MAX_FUNCTORS];
135  for (int i = 0; i < ISAAC_MAX_FUNCTORS; i++)
136  bytecode[i] = 0;
137  for (int i = 0; i < ISAAC_FUNCTOR_COMPLEX; i++)
138  {
139  functor_chain_d[i*4+0] = FillFunctorChainPointerKernelStruct<mpl::vector<>,1,ISAAC_MAX_FUNCTORS>::call( bytecode );
140  functor_chain_d[i*4+1] = FillFunctorChainPointerKernelStruct<mpl::vector<>,2,ISAAC_MAX_FUNCTORS>::call( bytecode );
141  functor_chain_d[i*4+2] = FillFunctorChainPointerKernelStruct<mpl::vector<>,3,ISAAC_MAX_FUNCTORS>::call( bytecode );
142  functor_chain_d[i*4+3] = FillFunctorChainPointerKernelStruct<mpl::vector<>,4,ISAAC_MAX_FUNCTORS>::call( bytecode );
143  for (int j = ISAAC_MAX_FUNCTORS - 1; j >= 0; j--)
144  if ( bytecode[j] < ISAAC_FUNCTOR_COUNT-1 )
145  {
146  bytecode[j]++;
147  break;
148  }
149  else
150  bytecode[j] = 0;
151  }
152  }
153 #if ISAAC_ALPAKA == 1
154  };
155 #endif
156 
157 template <
158  isaac_int TInterpolation,
159  typename NR,
160  typename TSource,
161  typename TPos,
162  typename TPointerArray,
163  typename TLocalSize,
164  typename TScale
165 >
167  const TSource& source,
168  const TPos& pos,
169  const TPointerArray& pointerArray,
170  const TLocalSize& local_size,
171  const TScale& scale
172 )
173 {
174  isaac_float_dim < TSource::feature_dim > data;
175  isaac_float_dim < TSource::feature_dim >* ptr = (isaac_float_dim < TSource::feature_dim >*)(pointerArray.pointer[ NR::value ] );
176  if (TInterpolation == 0)
177  {
178  isaac_int3 coord =
179  {
180  isaac_int(pos.x),
181  isaac_int(pos.y),
182  isaac_int(pos.z)
183  };
184  if (TSource::persistent)
185  data = source[coord];
186  else
187  data = ptr[coord.x + ISAAC_GUARD_SIZE + (coord.y + ISAAC_GUARD_SIZE) * (local_size.value.x + 2 * ISAAC_GUARD_SIZE) + (coord.z + ISAAC_GUARD_SIZE) * ( (local_size.value.x + 2 * ISAAC_GUARD_SIZE) * (local_size.value.y + 2 * ISAAC_GUARD_SIZE) )];
188  }
189  else
190  {
191  isaac_int3 coord;
192  isaac_float_dim < TSource::feature_dim > data8[2][2][2];
193  for (int x = 0; x < 2; x++)
194  for (int y = 0; y < 2; y++)
195  for (int z = 0; z < 2; z++)
196  {
197  coord.x = isaac_int(x?ceil(pos.x):floor(pos.x));
198  coord.y = isaac_int(y?ceil(pos.y):floor(pos.y));
199  coord.z = isaac_int(z?ceil(pos.z):floor(pos.z));
200  if (!TSource::has_guard && TSource::persistent)
201  {
202  if ( isaac_uint(coord.x) >= local_size.value.x )
203  coord.x = isaac_int(x?floor(pos.x):ceil(pos.x));
204  if ( isaac_uint(coord.y) >= local_size.value.y )
205  coord.y = isaac_int(y?floor(pos.y):ceil(pos.y));
206  if ( isaac_uint(coord.z) >= local_size.value.z )
207  coord.z = isaac_int(z?floor(pos.z):ceil(pos.z));
208  }
209  if (TSource::persistent)
210  data8[x][y][z] = source[coord];
211  else
212  data8[x][y][z] = ptr[coord.x + ISAAC_GUARD_SIZE + (coord.y + ISAAC_GUARD_SIZE) * (local_size.value.x + 2 * ISAAC_GUARD_SIZE) + (coord.z + ISAAC_GUARD_SIZE) * ( (local_size.value.x + 2 * ISAAC_GUARD_SIZE) * (local_size.value.y + 2 * ISAAC_GUARD_SIZE) )];
213  }
214  //Against annoying double->float casting warning with gcc5
215  #pragma GCC diagnostic push
216  #pragma GCC diagnostic ignored "-Wnarrowing"
217  isaac_float_dim < 3 > pos_in_cube =
218  {
219  pos.x - floor(pos.x),
220  pos.y - floor(pos.y),
221  pos.z - floor(pos.z)
222  };
223  #pragma GCC diagnostic pop
224  isaac_float_dim < TSource::feature_dim > data4[2][2];
225  for (int x = 0; x < 2; x++)
226  for (int y = 0; y < 2; y++)
227  data4[x][y].value =
228  data8[x][y][0].value * (isaac_float(1) - pos_in_cube.value.z) +
229  data8[x][y][1].value * ( pos_in_cube.value.z);
230  isaac_float_dim < TSource::feature_dim > data2[2];
231  for (int x = 0; x < 2; x++)
232  data2[x].value =
233  data4[x][0].value * (isaac_float(1) - pos_in_cube.value.y) +
234  data4[x][1].value * ( pos_in_cube.value.y);
235  data.value =
236  data2[0].value * (isaac_float(1) - pos_in_cube.value.x) +
237  data2[1].value * ( pos_in_cube.value.x);
238  }
239  isaac_float result = isaac_float(0);
240 
241  #if ISAAC_ALPAKA == 1 || defined(__CUDA_ARCH__)
242  if (TSource::feature_dim == 1)
243  result = reinterpret_cast<isaac_functor_chain_pointer_1>(isaac_function_chain_d[ NR::value ])( *(reinterpret_cast< isaac_float_dim<1>* >(&data)), NR::value );
244  if (TSource::feature_dim == 2)
245  result = reinterpret_cast<isaac_functor_chain_pointer_2>(isaac_function_chain_d[ NR::value ])( *(reinterpret_cast< isaac_float_dim<2>* >(&data)), NR::value );
246  if (TSource::feature_dim == 3)
247  result = reinterpret_cast<isaac_functor_chain_pointer_3>(isaac_function_chain_d[ NR::value ])( *(reinterpret_cast< isaac_float_dim<3>* >(&data)), NR::value );
248  if (TSource::feature_dim == 4)
249  result = reinterpret_cast<isaac_functor_chain_pointer_4>(isaac_function_chain_d[ NR::value ])( *(reinterpret_cast< isaac_float_dim<4>* >(&data)), NR::value );
250  #endif
251  return result;
252 }
253 
254 template < typename TLocalSize >
255 ISAAC_HOST_DEVICE_INLINE void check_coord( isaac_float3& coord, const TLocalSize local_size)
256 {
257  if (coord.x < isaac_float(0))
258  coord.x = isaac_float(0);
259  if (coord.y < isaac_float(0))
260  coord.y = isaac_float(0);
261  if (coord.z < isaac_float(0))
262  coord.z = isaac_float(0);
263  if ( coord.x >= isaac_float(local_size.value.x) )
264  coord.x = isaac_float(local_size.value.x)-isaac_float(1);
265  if ( coord.y >= isaac_float(local_size.value.y) )
266  coord.y = isaac_float(local_size.value.y)-isaac_float(1);
267  if ( coord.z >= isaac_float(local_size.value.z) )
268  coord.z = isaac_float(local_size.value.z)-isaac_float(1);
269 }
270 
271 template <
272  size_t Ttransfer_size,
273  typename TFilter,
274  isaac_int TInterpolation,
275  isaac_int TIsoSurface
276 >
278 {
279  template
280  <
281  typename NR,
282  typename TSource,
283  typename TColor,
284  typename TPos,
285  typename TLocalSize,
286  typename TTransferArray,
287  typename TSourceWeight,
288  typename TPointerArray,
289  typename TFeedback,
290  typename TStep,
291  typename TStepLength,
292  typename TScale
293  >
295  const NR& nr,
296  const TSource& source,
297  TColor& color,
298  const TPos& pos,
299  const TLocalSize& local_size,
300  const TTransferArray& transferArray,
301  const TSourceWeight& sourceWeight,
302  const TPointerArray& pointerArray,
303  TFeedback& feedback,
304  const TStep& step,
305  const TStepLength& stepLength,
306  const TScale& scale
307  ) const
308  {
309  if ( mpl::at_c< TFilter, NR::value >::type::value )
310  {
311  isaac_float result = get_value< TInterpolation, NR >( source, pos, pointerArray, local_size, scale );
312  isaac_int lookup_value = isaac_int( round(result * isaac_float( Ttransfer_size ) ) );
313  if (lookup_value < 0 )
314  lookup_value = 0;
315  if (lookup_value >= Ttransfer_size )
316  lookup_value = Ttransfer_size - 1;
317  isaac_float4 value = transferArray.pointer[ NR::value ][ lookup_value ];
318  if (TIsoSurface)
319  {
320  if (value.w >= isaac_float(0.5))
321  {
322  isaac_float3 left = {-1, 0, 0};
323  left = left + pos;
324  if (!TSource::has_guard && TSource::persistent)
325  check_coord( left, local_size);
326  isaac_float3 right = { 1, 0, 0};
327  right = right + pos;
328  if (!TSource::has_guard && TSource::persistent)
329  check_coord( right, local_size );
330  isaac_float d1;
331  if (TInterpolation)
332  d1 = right.x - left.x;
333  else
334  d1 = isaac_int(right.x) - isaac_int(left.x);
335 
336  isaac_float3 up = { 0,-1, 0};
337  up = up + pos;
338  if (!TSource::has_guard && TSource::persistent)
339  check_coord( up, local_size );
340  isaac_float3 down = { 0, 1, 0};
341  down = down + pos;
342  if (!TSource::has_guard && TSource::persistent)
343  check_coord( down, local_size );
344  isaac_float d2;
345  if (TInterpolation)
346  d2 = down.y - up.y;
347  else
348  d2 = isaac_int(down.y) - isaac_int(up.y);
349 
350  isaac_float3 front = { 0, 0,-1};
351  front = front + pos;
352  if (!TSource::has_guard && TSource::persistent)
353  check_coord( front, local_size );
354  isaac_float3 back = { 0, 0, 1};
355  back = back + pos;
356  if (!TSource::has_guard && TSource::persistent)
357  check_coord( back, local_size );
358  isaac_float d3;
359  if (TInterpolation)
360  d3 = back.z - front.z;
361  else
362  d3 = isaac_int(back.z) - isaac_int(front.z);
363 
364  isaac_float3 gradient=
365  {
366  (get_value< TInterpolation, NR >( source, right, pointerArray, local_size, scale ) -
367  get_value< TInterpolation, NR >( source, left, pointerArray, local_size, scale )) / d1,
368  (get_value< TInterpolation, NR >( source, down, pointerArray, local_size, scale ) -
369  get_value< TInterpolation, NR >( source, up, pointerArray, local_size, scale )) / d2,
370  (get_value< TInterpolation, NR >( source, back, pointerArray, local_size, scale ) -
371  get_value< TInterpolation, NR >( source, front, pointerArray, local_size, scale )) / d3
372  };
373  isaac_float l = sqrt(
374  gradient.x * gradient.x +
375  gradient.y * gradient.y +
376  gradient.z * gradient.z
377  );
378  if (l == isaac_float(0))
379  color = value;
380  else
381  {
382  gradient = gradient / l;
383  isaac_float3 light = step / stepLength;
384  isaac_float ac = fabs(
385  gradient.x * light.x +
386  gradient.y * light.y +
387  gradient.z * light.z );
388  #if ISAAC_SPECULAR == 1
389  color.x = value.x * ac + ac * ac * ac * ac;
390  color.y = value.y * ac + ac * ac * ac * ac;
391  color.z = value.z * ac + ac * ac * ac * ac;
392  #else
393  color.x = value.x * ac;
394  color.y = value.y * ac;
395  color.z = value.z * ac;
396  #endif
397  }
398  color.w = isaac_float(1);
399  feedback = 1;
400  }
401  }
402  else
403  {
404  value.w *= sourceWeight.value[ NR::value ];
405  color.x = color.x + value.x * value.w;
406  color.y = color.y + value.y * value.w;
407  color.z = color.z + value.z * value.w;
408  color.w = color.w + value.w;
409  }
410  }
411  }
412 };
413 
414 template <
415  typename TFilter
416 >
418 {
419  template
420  <
421  typename NR,
422  typename TSource,
423  typename TResult
424  >
426  const NR& nr,
427  const TSource& source,
428  TResult& result
429  ) const
430  {
431  result |= mpl::at_c< TFilter, NR::value >::type::value;
432  }
433 };
434 
435 
436 template <
437  typename TSimDim,
438  typename TSourceList,
439  typename TTransferArray,
440  typename TSourceWeight,
441  typename TPointerArray,
442  typename TFilter,
443  size_t Ttransfer_size,
444  isaac_int TInterpolation,
445  isaac_int TIsoSurface,
446  typename TScale
447 >
448 #if ISAAC_ALPAKA == 1
449  struct isaacRenderKernel
450  {
451  template <typename TAcc__>
452  ALPAKA_FN_ACC void operator()(
453  TAcc__ const &acc,
454 #else
455  __global__ void isaacRenderKernel(
456 #endif
457  uint32_t * const pixels,
458  const isaac_size2 framebuffer_size,
459  const isaac_uint2 framebuffer_start,
460  const TSourceList sources,
461  isaac_float step,
462  const isaac_float4 background_color,
463  const TTransferArray transferArray,
464  const TSourceWeight sourceWeight,
465  const TPointerArray pointerArray,
466  const TScale scale,
467  const clipping_struct input_clipping)
468 #if ISAAC_ALPAKA == 1
469  const
470 #endif
471  {
472  isaac_uint2 pixel[ISAAC_VECTOR_ELEM];
473  bool finish[ISAAC_VECTOR_ELEM];
474 #if ISAAC_ALPAKA == 1
475  auto threadIdx = alpaka::idx::getIdx<alpaka::Grid, alpaka::Threads>(acc);
477  {
478  pixel[e].x = isaac_uint(threadIdx[2]) * isaac_uint(ISAAC_VECTOR_ELEM) + e;
479  pixel[e].y = isaac_uint(threadIdx[1]);
480 #else
482  {
483  pixel[e].x = isaac_uint(threadIdx.x + blockIdx.x * blockDim.x) * isaac_uint(ISAAC_VECTOR_ELEM) + e;
484  pixel[e].y = isaac_uint(threadIdx.y + blockIdx.y * blockDim.y);
485 #endif
486  finish[e] = false;
487  pixel[e] = pixel[e] + framebuffer_start;
488  if ( ISAAC_FOR_EACH_DIM_TWICE(2, pixel[e], >= framebuffer_size, || ) 0 )
489  finish[e] = true;
490  }
492 
493  bool at_least_one[ISAAC_VECTOR_ELEM];
494  isaac_float4 color[ISAAC_VECTOR_ELEM];
495 
497  {
498  color[e] = background_color;
499  at_least_one[e] = true;
501  if (!at_least_one[e])
502  {
503  if (!finish[e])
504  ISAAC_SET_COLOR( pixels[pixel[e].x + pixel[e].y * framebuffer_size.x], color[e] )
505  finish[e] = true;
506  }
507  }
509 
510  isaac_float2 pixel_f[ISAAC_VECTOR_ELEM];
511  isaac_float4 start_p[ISAAC_VECTOR_ELEM];
512  isaac_float4 end_p[ISAAC_VECTOR_ELEM];
513  isaac_float3 start[ISAAC_VECTOR_ELEM];
514  isaac_float3 end[ISAAC_VECTOR_ELEM];
515  isaac_int3 move[ISAAC_VECTOR_ELEM];
516  isaac_float3 move_f[ISAAC_VECTOR_ELEM];
518  isaac_float3 vec[ISAAC_VECTOR_ELEM];
519  isaac_float l_scaled[ISAAC_VECTOR_ELEM];
521  isaac_float3 step_vec[ISAAC_VECTOR_ELEM];
522  isaac_float3 count_start[ISAAC_VECTOR_ELEM];
523  isaac_float3 local_size_f[ISAAC_VECTOR_ELEM];
524  isaac_float3 count_end[ISAAC_VECTOR_ELEM];
525 
527  {
528  pixel_f[e].x = isaac_float( pixel[e].x )/(isaac_float)framebuffer_size.x*isaac_float(2)-isaac_float(1);
529  pixel_f[e].y = isaac_float( pixel[e].y )/(isaac_float)framebuffer_size.y*isaac_float(2)-isaac_float(1);
530 
531  start_p[e].x = pixel_f[e].x*ISAAC_Z_NEAR;
532  start_p[e].y = pixel_f[e].y*ISAAC_Z_NEAR;
533  start_p[e].z = -1.0f*ISAAC_Z_NEAR;
534  start_p[e].w = 1.0f*ISAAC_Z_NEAR;
535 
536  end_p[e].x = pixel_f[e].x*ISAAC_Z_FAR;
537  end_p[e].y = pixel_f[e].y*ISAAC_Z_FAR;
538  end_p[e].z = 1.0f*ISAAC_Z_FAR;
539  end_p[e].w = 1.0f*ISAAC_Z_FAR;
540 
541  start[e].x = isaac_inverse_d[ 0] * start_p[e].x + isaac_inverse_d[ 4] * start_p[e].y + isaac_inverse_d[ 8] * start_p[e].z + isaac_inverse_d[12] * start_p[e].w;
542  start[e].y = isaac_inverse_d[ 1] * start_p[e].x + isaac_inverse_d[ 5] * start_p[e].y + isaac_inverse_d[ 9] * start_p[e].z + isaac_inverse_d[13] * start_p[e].w;
543  start[e].z = isaac_inverse_d[ 2] * start_p[e].x + isaac_inverse_d[ 6] * start_p[e].y + isaac_inverse_d[10] * start_p[e].z + isaac_inverse_d[14] * start_p[e].w;
544 
545  end[e].x = isaac_inverse_d[ 0] * end_p[e].x + isaac_inverse_d[ 4] * end_p[e].y + isaac_inverse_d[ 8] * end_p[e].z + isaac_inverse_d[12] * end_p[e].w;
546  end[e].y = isaac_inverse_d[ 1] * end_p[e].x + isaac_inverse_d[ 5] * end_p[e].y + isaac_inverse_d[ 9] * end_p[e].z + isaac_inverse_d[13] * end_p[e].w;
547  end[e].z = isaac_inverse_d[ 2] * end_p[e].x + isaac_inverse_d[ 6] * end_p[e].y + isaac_inverse_d[10] * end_p[e].z + isaac_inverse_d[14] * end_p[e].w;
548  isaac_float max_size = isaac_size_d[0].max_global_size_scaled / 2.0f;
549 
550  //scale to globale grid size
551  start[e] = start[e] * max_size;
552  end[e] = end[e] * max_size;
553 
554  for (isaac_int i = 0; i < input_clipping.count; i++)
555  {
556  clipping[e].elem[i].position = input_clipping.elem[i].position * max_size;
557  clipping[e].elem[i].normal = input_clipping.elem[i].normal;
558  }
559 
560  //move to local (scaled) grid
561  move[e].x = isaac_int(isaac_size_d[0].global_size_scaled.value.x) / isaac_int(2) - isaac_int(isaac_size_d[0].position_scaled.value.x);
562  move[e].y = isaac_int(isaac_size_d[0].global_size_scaled.value.y) / isaac_int(2) - isaac_int(isaac_size_d[0].position_scaled.value.y);
563  move[e].z = isaac_int(isaac_size_d[0].global_size_scaled.value.z) / isaac_int(2) - isaac_int(isaac_size_d[0].position_scaled.value.z);
564 
565  move_f[e].x = isaac_float(move[e].x);
566  move_f[e].y = isaac_float(move[e].y);
567  move_f[e].z = isaac_float(move[e].z);
568 
569  start[e] = start[e] + move_f[e];
570  end[e] = end[e] + move_f[e];
571  for (isaac_int i = 0; i < input_clipping.count; i++)
572  clipping[e].elem[i].position = clipping[e].elem[i].position + move_f[e];
573 
574  vec[e] = end[e] - start[e];
575  l_scaled[e] = sqrt( vec[e].x * vec[e].x + vec[e].y * vec[e].y + vec[e].z * vec[e].z );
576 
577  start[e].x = start[e].x / scale.x;
578  start[e].y = start[e].y / scale.y;
579  start[e].z = start[e].z / scale.z;
580  end[e].x = end[e].x / scale.x;
581  end[e].y = end[e].y / scale.y;
582  end[e].z = end[e].z / scale.z;
583  for (isaac_int i = 0; i < input_clipping.count; i++)
584  {
585  clipping[e].elem[i].position.x = clipping[e].elem[i].position.x / scale.x;
586  clipping[e].elem[i].position.y = clipping[e].elem[i].position.y / scale.y;
587  clipping[e].elem[i].position.z = clipping[e].elem[i].position.z / scale.z;
588  }
589 
590  vec[e] = end[e] - start[e];
591  l[e] = sqrt( vec[e].x * vec[e].x + vec[e].y * vec[e].y + vec[e].z * vec[e].z );
592 
593  step_vec[e] = vec[e] / l[e] * step;
594  count_start[e] = - start[e] / step_vec[e];
595  local_size_f[e].x = isaac_float(isaac_size_d[0].local_size.value.x);
596  local_size_f[e].y = isaac_float(isaac_size_d[0].local_size.value.y);
597  local_size_f[e].z = isaac_float(isaac_size_d[0].local_size.value.z);
598 
599  count_end[e] = ( local_size_f[e] - start[e] ) / step_vec[e];
600 
601  //count_start shall have the smaller values
602  ISAAC_SWITCH_IF_SMALLER( count_end[e].x, count_start[e].x )
603  ISAAC_SWITCH_IF_SMALLER( count_end[e].y, count_start[e].y )
604  ISAAC_SWITCH_IF_SMALLER( count_end[e].z, count_start[e].z )
605 
606  //calc intersection of all three super planes and save in [count_start.x ; count_end.x]
607  count_start[e].x = ISAAC_MAX( ISAAC_MAX( count_start[e].x, count_start[e].y ), count_start[e].z );
608  count_end[e].x = ISAAC_MIN( ISAAC_MIN( count_end[e].x, count_end[e].y ), count_end[e].z );
609  if ( count_start[e].x > count_end[e].x)
610  {
611  if (!finish[e])
612  ISAAC_SET_COLOR( pixels[pixel[e].x + pixel[e].y * framebuffer_size.x], color[e] )
613  finish[e] = true;
614  }
615  }
617 
620  isaac_float3 pos[ISAAC_VECTOR_ELEM];
621  isaac_int3 coord[ISAAC_VECTOR_ELEM];
623  isaac_float intersection_step[ISAAC_VECTOR_ELEM];
624 
626  {
627  first[e] = isaac_int( floor(count_start[e].x) );
628  last[e] = isaac_int( ceil(count_end[e].x) );
629 
630  //Moving last and first until their points are valid
631  pos[e] = start[e] + step_vec[e] * isaac_float(last[e]);
632  coord[e].x = isaac_int(floor(pos[e].x));
633  coord[e].y = isaac_int(floor(pos[e].y));
634  coord[e].z = isaac_int(floor(pos[e].z));
635  while ( (ISAAC_FOR_EACH_DIM_TWICE(3, coord[e], >= isaac_size_d[0].local_size.value, || )
636  ISAAC_FOR_EACH_DIM (3, coord[e], < 0 || ) 0 ) && first[e] <= last[e])
637  {
638  last[e]--;
639  pos[e] = start[e] + step_vec[e] * isaac_float(last[e]);
640  coord[e].x = isaac_int(floor(pos[e].x));
641  coord[e].y = isaac_int(floor(pos[e].y));
642  coord[e].z = isaac_int(floor(pos[e].z));
643  }
644  pos[e] = start[e] + step_vec[e] * isaac_float(first[e]);
645  coord[e].x = isaac_int(floor(pos[e].x));
646  coord[e].y = isaac_int(floor(pos[e].y));
647  coord[e].z = isaac_int(floor(pos[e].z));
648  while ( (ISAAC_FOR_EACH_DIM_TWICE(3, coord[e], >= isaac_size_d[0].local_size.value, || )
649  ISAAC_FOR_EACH_DIM (3, coord[e], < 0 || ) 0 ) && first[e] <= last[e])
650  {
651  first[e]++;
652  pos[e] = start[e] + step_vec[e] * isaac_float(first[e]);
653  coord[e].x = isaac_int(floor(pos[e].x));
654  coord[e].y = isaac_int(floor(pos[e].y));
655  coord[e].z = isaac_int(floor(pos[e].z));
656  }
657 
658  //Extra clipping
659  for (isaac_int i = 0; i < input_clipping.count; i++)
660  {
661  d[e] = step_vec[e].x * clipping[e].elem[i].normal.x
662  + step_vec[e].y * clipping[e].elem[i].normal.y
663  + step_vec[e].z * clipping[e].elem[i].normal.z;
664  intersection_step[e] = ( clipping[e].elem[i].position.x * clipping[e].elem[i].normal.x
665  + clipping[e].elem[i].position.y * clipping[e].elem[i].normal.y
666  + clipping[e].elem[i].position.z * clipping[e].elem[i].normal.z
667  - start[e].x * clipping[e].elem[i].normal.x
668  - start[e].y * clipping[e].elem[i].normal.y
669  - start[e].z * clipping[e].elem[i].normal.z ) / d[e];
670  if (d[e] > 0)
671  {
672  if ( last[e] < intersection_step[e] )
673  {
674  if (!finish[e])
675  ISAAC_SET_COLOR( pixels[pixel[e].x + pixel[e].y * framebuffer_size.x], color[e] )
676  finish[e] = true;
677  }
678  if ( first[e] < intersection_step[e] )
679  first[e] = ceil( intersection_step[e] );
680  }
681  else
682  {
683  if ( first[e] > intersection_step[e] )
684  {
685  if (!finish[e])
686  ISAAC_SET_COLOR( pixels[pixel[e].x + pixel[e].y * framebuffer_size.x], color[e] )
687  finish[e] = true;
688  }
689  if ( last[e] > intersection_step[e] )
690  last[e] = floor( intersection_step[e] );
691  }
692  }
693  }
695 
696  isaac_float min_size[ISAAC_VECTOR_ELEM];
698  isaac_float4 value[ISAAC_VECTOR_ELEM];
701  isaac_float4 color_add[ISAAC_VECTOR_ELEM];
702 
704  {
705  //Starting the main loop
706  min_size[e] = ISAAC_MIN(
707  int(isaac_size_d[0].global_size.value.x), ISAAC_MIN (
708  int(isaac_size_d[0].global_size.value.y),
709  int(isaac_size_d[0].global_size.value.z) ) );
710  factor[e] = step / /*isaac_size_d[0].max_global_size*/ min_size[e] * isaac_float(2) * l[e]/l_scaled[e];
711  for (isaac_int i = first[e]; i <= last[e]; i++)
712  {
713  pos[e] = start[e] + step_vec[e] * isaac_float(i);
714  value[e].x = 0;
715  value[e].y = 0;
716  value[e].z = 0;
717  value[e].w = 0;
718  result[e] = 0;
720  (
721  sources,
723  <
724  Ttransfer_size,
725  TFilter,
726  TInterpolation,
727  TIsoSurface
728  >(),
729  value[e],
730  pos[e],
731  isaac_size_d[0].local_size,
732  transferArray,
733  sourceWeight,
734  pointerArray,
735  result[e],
736  step_vec[e],
737  step,
738  scale
739  );
740  /*if ( mpl::size< TSourceList >::type::value > 1)
741  value = value / isaac_float( mpl::size< TSourceList >::type::value );*/
742  if (TIsoSurface)
743  {
744  if (result[e])
745  {
746  color[e] = value[e];
747  break;
748  }
749  }
750  else
751  {
752  oma[e] = isaac_float(1) - color[e].w;
753  value[e] = value[e] * factor[e];
754  color_add[e].x = oma[e] * value[e].x; // * value.w does merge_source_iterator
755  color_add[e].y = oma[e] * value[e].y; // * value.w does merge_source_iterator
756  color_add[e].z = oma[e] * value[e].z; // * value.w does merge_source_iterator
757  color_add[e].w = oma[e] * value[e].w;
758  color[e] = color[e] + color_add[e];
759  if (color[e].w > isaac_float(0.99))
760  break;
761  }
762  }
763  #if ISAAC_SHOWBORDER == 1
764  if (color[e].w <= isaac_float(0.99))
765  {
766  oma[e] = isaac_float(1) - color[e].w;
767  color_add[e].x = 0;
768  color_add[e].y = 0;
769  color_add[e].z = 0;
770  color_add[e].w = oma[e] * factor[e] * isaac_float(10);
771  };
772  color[e] = color[e] + color_add[e];
773  }
774  #endif
775  if (!finish[e])
776  ISAAC_SET_COLOR( pixels[pixel[e].x + pixel[e].y * framebuffer_size.x], color[e] )
777  }
778  }
779 #if ISAAC_ALPAKA == 1
780  };
781 #endif
782 
783 template <
784  typename TSimDim,
785  typename TSourceList,
786  typename TTransferArray,
787  typename TSourceWeight,
788  typename TPointerArray,
789  typename TFilter,
790  typename TFramebuffer,
791  size_t TTransfer_size,
792  typename TScale,
793 #if ISAAC_ALPAKA == 1
794  typename TAccDim,
795  typename TAcc,
796  typename TStream,
797  typename TFunctionChain,
798 #endif
799  int N
800 >
802 {
803  inline static void call(
804 #if ISAAC_ALPAKA == 1
805  TStream stream,
806 #endif
807  TFramebuffer framebuffer,
808  const isaac_size2& framebuffer_size,
809  const isaac_uint2& framebuffer_start,
810  const TSourceList& sources,
811  const isaac_float& step,
812  const isaac_float4& background_color,
813  const TTransferArray& transferArray,
814  const TSourceWeight& sourceWeight,
815  const TPointerArray& pointerArray,
816  IceTInt const * const readback_viewport,
817  const isaac_int interpolation,
818  const isaac_int iso_surface,
819  const TScale& scale,
820  const clipping_struct& clipping
821  )
822  {
823  if (sourceWeight.value[ mpl::size< TSourceList >::type::value - N] == isaac_float(0) )
825  <
826  TSimDim,
827  TSourceList,
828  TTransferArray,
829  TSourceWeight,
830  TPointerArray,
831  typename mpl::push_back< TFilter, mpl::false_ >::type,
832  TFramebuffer,
833  TTransfer_size,
834  TScale,
835 #if ISAAC_ALPAKA == 1
836  TAccDim,
837  TAcc,
838  TStream,
839  TFunctionChain,
840 #endif
841  N - 1
842  >
843  ::call(
844 #if ISAAC_ALPAKA == 1
845  stream,
846 #endif
847  framebuffer,
848  framebuffer_size,
849  framebuffer_start,
850  sources,
851  step,
852  background_color,
853  transferArray,
854  sourceWeight,
855  pointerArray,
856  readback_viewport,
857  interpolation,
858  iso_surface,
859  scale,
860  clipping
861  );
862  else
864  <
865  TSimDim,
866  TSourceList,
867  TTransferArray,
868  TSourceWeight,
869  TPointerArray,
870  typename mpl::push_back< TFilter, mpl::true_ >::type,
871  TFramebuffer,
872  TTransfer_size,
873  TScale,
874 #if ISAAC_ALPAKA == 1
875  TAccDim,
876  TAcc,
877  TStream,
878  TFunctionChain,
879 #endif
880  N - 1
881  >
882  ::call(
883 #if ISAAC_ALPAKA == 1
884  stream,
885 #endif
886  framebuffer,
887  framebuffer_size,
888  framebuffer_start,
889  sources,
890  step,
891  background_color,
892  transferArray,
893  sourceWeight,
894  pointerArray,
895  readback_viewport,
896  interpolation,
897  iso_surface,
898  scale,
899  clipping
900  );
901  }
902 };
903 
904 template <
905  typename TSimDim,
906  typename TSourceList,
907  typename TTransferArray,
908  typename TSourceWeight,
909  typename TPointerArray,
910  typename TFilter,
911  typename TFramebuffer,
912  size_t TTransfer_size,
913  typename TScale
914 #if ISAAC_ALPAKA == 1
915  ,typename TAccDim
916  ,typename TAcc
917  ,typename TStream
918  ,typename TFunctionChain
919 #endif
920 >
922 <
923  TSimDim,
924  TSourceList,
925  TTransferArray,
926  TSourceWeight,
927  TPointerArray,
928  TFilter,
929  TFramebuffer,
930  TTransfer_size,
931  TScale,
932 #if ISAAC_ALPAKA == 1
933  TAccDim,
934  TAcc,
935  TStream,
936  TFunctionChain,
937 #endif
938  0 //<-- spezialisation
939 >
940 {
941  inline static void call(
942 #if ISAAC_ALPAKA == 1
943  TStream stream,
944 #endif
945  TFramebuffer framebuffer,
946  const isaac_size2& framebuffer_size,
947  const isaac_uint2& framebuffer_start,
948  const TSourceList& sources,
949  const isaac_float& step,
950  const isaac_float4& background_color,
951  const TTransferArray& transferArray,
952  const TSourceWeight& sourceWeight,
953  const TPointerArray& pointerArray,
954  IceTInt const * const readback_viewport,
955  const isaac_int interpolation,
956  const isaac_int iso_surface,
957  const TScale& scale,
958  const clipping_struct& clipping
959  )
960  {
961  isaac_size2 block_size=
962  {
963  size_t(8),
964  size_t(16)
965  };
966  isaac_size2 grid_size=
967  {
968  size_t((readback_viewport[2]+block_size.x-1)/block_size.x + ISAAC_VECTOR_ELEM - 1)/size_t(ISAAC_VECTOR_ELEM),
969  size_t((readback_viewport[3]+block_size.y-1)/block_size.y)
970  };
971  #if ISAAC_ALPAKA == 1
972 #if ALPAKA_ACC_GPU_CUDA_ENABLED == 1
973  if ( mpl::not_<boost::is_same<TAcc, alpaka::acc::AccGpuCudaRt<TAccDim, size_t> > >::value )
974 #endif
975  {
976  grid_size.x = size_t(readback_viewport[2] + ISAAC_VECTOR_ELEM - 1)/size_t(ISAAC_VECTOR_ELEM);
977  grid_size.y = size_t(readback_viewport[3]);
978  block_size.x = size_t(1);
979  block_size.y = size_t(1);
980  }
981  const alpaka::vec::Vec<TAccDim, size_t> threads (size_t(1), size_t(1), size_t(ISAAC_VECTOR_ELEM));
982  const alpaka::vec::Vec<TAccDim, size_t> blocks (size_t(1), block_size.y, block_size.x);
983  const alpaka::vec::Vec<TAccDim, size_t> grid (size_t(1), grid_size.y, grid_size.x);
984  auto const workdiv(alpaka::workdiv::WorkDivMembers<TAccDim, size_t>(grid,blocks,threads));
985  #define ISAAC_KERNEL_START \
986  { \
987  isaacRenderKernel \
988  < \
989  TSimDim, \
990  TSourceList, \
991  TTransferArray, \
992  TSourceWeight, \
993  TPointerArray, \
994  TFilter, \
995  TTransfer_size,
996  #define ISAAC_KERNEL_END \
997  ,TScale \
998  > \
999  kernel; \
1000  auto const instance \
1001  ( \
1002  alpaka::exec::create<TAcc> \
1003  ( \
1004  workdiv, \
1005  kernel, \
1006  alpaka::mem::view::getPtrNative(framebuffer), \
1007  framebuffer_size, \
1008  framebuffer_start, \
1009  sources, \
1010  step, \
1011  background_color, \
1012  transferArray, \
1013  sourceWeight, \
1014  pointerArray, \
1015  scale, \
1016  clipping \
1017  ) \
1018  ); \
1019  alpaka::stream::enqueue(stream, instance); \
1020  }
1021  #else
1022  dim3 block (block_size.x, block_size.y);
1023  dim3 grid (grid_size.x, grid_size.y);
1024  #define ISAAC_KERNEL_START \
1025  isaacRenderKernel \
1026  < \
1027  TSimDim, \
1028  TSourceList, \
1029  TTransferArray, \
1030  TSourceWeight, \
1031  TPointerArray, \
1032  TFilter, \
1033  TTransfer_size,
1034  #define ISAAC_KERNEL_END \
1035  > \
1036  <<<grid, block>>> \
1037  ( \
1038  framebuffer, \
1039  framebuffer_size, \
1040  framebuffer_start, \
1041  sources, \
1042  step, \
1043  background_color, \
1044  transferArray, \
1045  sourceWeight, \
1046  pointerArray, \
1047  scale, \
1048  clipping \
1049  );
1050 
1051  #endif
1052  if (interpolation)
1053  {
1054  if (iso_surface)
1056  1,
1057  1
1059  else
1061  1,
1062  0
1064  }
1065  else
1066  {
1067  if (iso_surface)
1069  0,
1070  1
1072  else
1074  0,
1075  0
1077  }
1078  #undef ISAAC_KERNEL_START
1079  #undef ISAAC_KERNEL_END
1080  }
1081 };
1082 
1083 template <int N>
1085 {
1086  isaac_int nr[N];
1087 };
1088 
1089 template
1090 <
1091  int count,
1092  typename TDest
1093 >
1094 #if ISAAC_ALPAKA == 1
1096  {
1097  template <typename TAcc__>
1098  ALPAKA_FN_ACC void operator()(
1099  TAcc__ const &acc,
1100 #else
1102 #endif
1103  isaac_functor_chain_pointer_N * const functor_chain_choose_d,
1104  isaac_functor_chain_pointer_N const * const functor_chain_d,
1105  TDest dest)
1106 #if ISAAC_ALPAKA == 1
1107  const
1108 #endif
1109  {
1110  for (int i = 0; i < count; i++)
1111  functor_chain_choose_d[i] = functor_chain_d[dest.nr[i]];
1112  }
1113 #if ISAAC_ALPAKA == 1
1114  };
1115 #endif
1116 
1117 template
1118 <
1119  typename TSource
1120 >
1121 #if ISAAC_ALPAKA == 1
1122  struct updateBufferKernel
1123  {
1124  template <typename TAcc__>
1125  ALPAKA_FN_ACC void operator()(
1126  TAcc__ const &acc,
1127 #else
1128  __global__ void updateBufferKernel(
1129 #endif
1130  const TSource source,
1131  void * const pointer,
1132  const isaac_int3 local_size)
1133 #if ISAAC_ALPAKA == 1
1134  const
1135 #endif
1136  {
1137  #if ISAAC_ALPAKA == 1
1138  auto threadIdx = alpaka::idx::getIdx<alpaka::Grid, alpaka::Threads>(acc);
1139  isaac_int3 dest =
1140  {
1141  isaac_int(threadIdx[1]),
1142  isaac_int(threadIdx[2]),
1143  0
1144  };
1145  #else
1146  isaac_int3 dest =
1147  {
1148  isaac_int(threadIdx.x + blockIdx.x * blockDim.x),
1149  isaac_int(threadIdx.y + blockIdx.y * blockDim.y),
1150  0
1151  };
1152  #endif
1153  isaac_int3 coord = dest;
1154  coord.x -= ISAAC_GUARD_SIZE;
1155  coord.y -= ISAAC_GUARD_SIZE;
1156  if ( ISAAC_FOR_EACH_DIM_TWICE(2, dest, >= local_size, + 2 * ISAAC_GUARD_SIZE || ) 0 )
1157  return;
1158  isaac_float_dim < TSource::feature_dim >* ptr = (isaac_float_dim < TSource::feature_dim >*)(pointer);
1159  if (TSource::has_guard)
1160  {
1161  coord.z = -ISAAC_GUARD_SIZE;
1162  for (;dest.z < local_size.z + 2 * ISAAC_GUARD_SIZE; dest.z++)
1163  {
1164  ptr[dest.x + dest.y * (local_size.x + 2 * ISAAC_GUARD_SIZE) + dest.z * ( (local_size.x + 2 * ISAAC_GUARD_SIZE) * (local_size.y + 2 * ISAAC_GUARD_SIZE) )] = source[coord];
1165  coord.z++;
1166  }
1167  }
1168  else
1169  {
1170  if (coord.x < 0)
1171  coord.x = 0;
1172  if (coord.x >= local_size.x)
1173  coord.x = local_size.x-1;
1174  if (coord.y < 0)
1175  coord.y = 0;
1176  if (coord.y >= local_size.y)
1177  coord.y = local_size.y-1;
1178  coord.z = 0;
1179  for (; dest.z < ISAAC_GUARD_SIZE; dest.z++)
1180  ptr[dest.x + dest.y * (local_size.x + 2 * ISAAC_GUARD_SIZE) + dest.z * ( (local_size.x + 2 * ISAAC_GUARD_SIZE) * (local_size.y + 2 * ISAAC_GUARD_SIZE) )] = source[coord];
1181  for (;dest.z < local_size.z + ISAAC_GUARD_SIZE - 1; dest.z++)
1182  {
1183  ptr[dest.x + dest.y * (local_size.x + 2 * ISAAC_GUARD_SIZE) + dest.z * ( (local_size.x + 2 * ISAAC_GUARD_SIZE) * (local_size.y + 2 * ISAAC_GUARD_SIZE) )] = source[coord];
1184  coord.z++;
1185  }
1186  for (;dest.z < local_size.z + 2 * ISAAC_GUARD_SIZE; dest.z++)
1187  ptr[dest.x + dest.y * (local_size.x + 2 * ISAAC_GUARD_SIZE) + dest.z * ( (local_size.x + 2 * ISAAC_GUARD_SIZE) * (local_size.y + 2 * ISAAC_GUARD_SIZE) )] = source[coord];
1188  }
1189  }
1190 #if ISAAC_ALPAKA == 1
1191  };
1192 #endif
1193 
1194 template
1195 <
1196  typename TSource
1197 >
1198 #if ISAAC_ALPAKA == 1
1199  struct minMaxKernel
1200  {
1201  template <typename TAcc__>
1202  ALPAKA_FN_ACC void operator()(
1203  TAcc__ const &acc,
1204 #else
1205  __global__ void minMaxKernel(
1206 #endif
1207  const TSource source,
1208  const int nr,
1209  minmax_struct * const result,
1210  const isaac_int3 local_size,
1211  void const * const pointer)
1212 #if ISAAC_ALPAKA == 1
1213  const
1214 #endif
1215  {
1216  #if ISAAC_ALPAKA == 1
1217  auto threadIdx = alpaka::idx::getIdx<alpaka::Grid, alpaka::Threads>(acc);
1218  isaac_int3 coord =
1219  {
1220  isaac_int(threadIdx[1]),
1221  isaac_int(threadIdx[2]),
1222  0
1223  };
1224  #else
1225  isaac_int3 coord =
1226  {
1227  isaac_int(threadIdx.x + blockIdx.x * blockDim.x),
1228  isaac_int(threadIdx.y + blockIdx.y * blockDim.y),
1229  0
1230  };
1231  #endif
1232  if ( ISAAC_FOR_EACH_DIM_TWICE(2, coord, >= local_size, || ) 0 )
1233  return;
1234  isaac_float min = FLT_MAX;
1235  isaac_float max = -FLT_MAX;
1236  for (;coord.z < local_size.z; coord.z++)
1237  {
1238  isaac_float_dim < TSource::feature_dim > data;
1239  if (TSource::persistent)
1240  data = source[coord];
1241  else
1242  {
1243  isaac_float_dim < TSource::feature_dim >* ptr = (isaac_float_dim < TSource::feature_dim >*)(pointer);
1244  data = ptr[coord.x + ISAAC_GUARD_SIZE + (coord.y + ISAAC_GUARD_SIZE) * (local_size.x + 2 * ISAAC_GUARD_SIZE) + (coord.z + ISAAC_GUARD_SIZE) * ( (local_size.x + 2 * ISAAC_GUARD_SIZE) * (local_size.y + 2 * ISAAC_GUARD_SIZE) )];
1245  };
1246  isaac_float value = isaac_float(0);
1247  #if ISAAC_ALPAKA == 1 || defined(__CUDA_ARCH__)
1248  if (TSource::feature_dim == 1)
1249  value = reinterpret_cast<isaac_functor_chain_pointer_1>(isaac_function_chain_d[ nr ])( *(reinterpret_cast< isaac_float_dim<1>* >(&data)), nr );
1250  if (TSource::feature_dim == 2)
1251  value = reinterpret_cast<isaac_functor_chain_pointer_2>(isaac_function_chain_d[ nr ])( *(reinterpret_cast< isaac_float_dim<2>* >(&data)), nr );
1252  if (TSource::feature_dim == 3)
1253  value = reinterpret_cast<isaac_functor_chain_pointer_3>(isaac_function_chain_d[ nr ])( *(reinterpret_cast< isaac_float_dim<3>* >(&data)), nr );
1254  if (TSource::feature_dim == 4)
1255  value = reinterpret_cast<isaac_functor_chain_pointer_4>(isaac_function_chain_d[ nr ])( *(reinterpret_cast< isaac_float_dim<4>* >(&data)), nr );
1256  #endif
1257  if (value > max)
1258  max = value;
1259  if (value < min)
1260  min = value;
1261  }
1262  result[coord.x + coord.y * local_size.x].min = min;
1263  result[coord.x + coord.y * local_size.x].max = max;
1264  }
1265 #if ISAAC_ALPAKA == 1
1266  };
1267 #endif
1268 
1269 } //namespace isaac;
1270 
1271 #pragma GCC diagnostic pop
float isaac_float
Definition: isaac_types.hpp:25
#define ISAAC_LEFT
ISAAC_DEVICE isaac_float applyFunctorChain(isaac_float_dim< TFeatureDim > const value, isaac_int const src_id)
#define ISAAC_KERNEL_END
ISAAC_CONSTANT isaac_functor_chain_pointer_N isaac_function_chain_d[ISAAC_MAX_SOURCES]
ISAAC_HOST_DEVICE_INLINE isaac_float get_value(const TSource &source, const TPos &pos, const TPointerArray &pointerArray, const TLocalSize &local_size, const TScale &scale)
isaac_float(* isaac_functor_chain_pointer_2)(isaac_float_dim< 2 >, isaac_int)
#define ISAAC_SWITCH_IF_SMALLER(left, right)
Definition: isaac.hpp:60
ISAAC_NO_HOST_DEVICE_WARNING ISAAC_HOST_DEVICE_INLINE void isaac_for_each_with_mpl_params(Sequence &seq, F const &f, P &... p)
ISAAC_HOST_DEVICE_INLINE void check_coord(isaac_float3 &coord, const TLocalSize local_size)
#define ISAAC_MAX_SOURCES
static void call(TFramebuffer framebuffer, const isaac_size2 &framebuffer_size, const isaac_uint2 &framebuffer_start, const TSourceList &sources, const isaac_float &step, const isaac_float4 &background_color, const TTransferArray &transferArray, const TSourceWeight &sourceWeight, const TPointerArray &pointerArray, IceTInt const *const readback_viewport, const isaac_int interpolation, const isaac_int iso_surface, const TScale &scale, const clipping_struct &clipping)
#define ISAAC_ELEM_ALL_TRUE_RETURN(NAME)
ISAAC_HOST_DEVICE_INLINE void operator()(const NR &nr, const TSource &source, TColor &color, const TPos &pos, const TLocalSize &local_size, const TTransferArray &transferArray, const TSourceWeight &sourceWeight, const TPointerArray &pointerArray, TFeedback &feedback, const TStep &step, const TStepLength &stepLength, const TScale &scale) const
#define ISAAC_KERNEL_START
#define ISAAC_ELEM_ITERATE(NAME)
int32_t isaac_int
Definition: isaac_types.hpp:26
#define ISAAC_FUNCTOR_COUNT
#define ISAAC_FUNCTOR_COMPLEX
isaac_float(* isaac_functor_chain_pointer_3)(isaac_float_dim< 3 >, isaac_int)
ISAAC_CONSTANT isaac_float4 isaac_parameter_d[ISAAC_MAX_SOURCES *ISAAC_MAX_FUNCTORS]
struct isaac::clipping_struct::@0 elem[ISAAC_MAX_CLIPPING]
uint32_t isaac_uint
Definition: isaac_types.hpp:27
#define ISAAC_MAX_FUNCTORS
#define ISAAC_FOR_EACH_DIM_TWICE(dim, start, middle, end)
isaac_float(* isaac_functor_chain_pointer_4)(isaac_float_dim< 4 >, isaac_int)
#define ISAAC_FOR_EACH_DIM(dim, start, end)
__global__ void fillFunctorChainPointerKernel(isaac_functor_chain_pointer_N *const functor_chain_d)
isaac_float(* isaac_functor_chain_pointer_1)(isaac_float_dim< 1 >, isaac_int)
#define ISAAC_HOST_DEVICE_INLINE
static void call(TFramebuffer framebuffer, const isaac_size2 &framebuffer_size, const isaac_uint2 &framebuffer_start, const TSourceList &sources, const isaac_float &step, const isaac_float4 &background_color, const TTransferArray &transferArray, const TSourceWeight &sourceWeight, const TPointerArray &pointerArray, IceTInt const *const readback_viewport, const isaac_int interpolation, const isaac_int iso_surface, const TScale &scale, const clipping_struct &clipping)
__global__ void updateBufferKernel(const TSource source, void *const pointer, const isaac_int3 local_size)
__global__ void isaacRenderKernel(uint32_t *const pixels, const isaac_size2 framebuffer_size, const isaac_uint2 framebuffer_start, const TSourceList sources, isaac_float step, const isaac_float4 background_color, const TTransferArray transferArray, const TSourceWeight sourceWeight, const TPointerArray pointerArray, const TScale scale, const clipping_struct input_clipping)
static ISAAC_DEVICE isaac_functor_chain_pointer_N call(isaac_int const *const bytecode)
#define ISAAC_MAX
__global__ void minMaxKernel(const TSource source, const int nr, minmax_struct *const result, const isaac_int3 local_size, void const *const pointer)
#define ISAAC_SET_COLOR(dest, color)
isaac_float(* isaac_functor_chain_pointer_N)(void *, isaac_int)
ISAAC_CONSTANT isaac_size_struct< 3 > isaac_size_d[1]
ISAAC_CONSTANT isaac_float isaac_inverse_d[16]
#define ISAAC_Z_NEAR
#define ISAAC_MIN
ISAAC_HOST_DEVICE_INLINE void operator()(const NR &nr, const TSource &source, TResult &result) const
#define ISAAC_SUB_CALL(Z, I, U)
#define ISAAC_CONSTANT
__global__ void updateFunctorChainPointerKernel(isaac_functor_chain_pointer_N *const functor_chain_choose_d, isaac_functor_chain_pointer_N const *const functor_chain_d, TDest dest)
#define ISAAC_Z_FAR
static ISAAC_DEVICE isaac_functor_chain_pointer_N call(isaac_int const *const bytecode)
#define ISAAC_RIGHT
#define ISAAC_VECTOR_ELEM
#define ISAAC_DEVICE
#define ISAAC_GUARD_SIZE