HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CE_SnippetKernelBind.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CE_SnippetImpl.h ( CE Library, C++)
7  *
8  * COMMENTS: Implementation of snippet manipulation for OpenCL
9  */
10 
11 #ifndef __CE_SnippetKernelBind__
12 #define __CE_SnippetKernelBind__
13 
14 #include "CE_API.h"
15 #include "CE_Context.h"
16 #include "CE_Snippet.h"
17 #include <UT/UT_WorkBuffer.h>
18 #include <UT/UT_ErrorManager.h>
19 
20 namespace CE_Snippet
21 {
22  template <CE_Precision PREC, typename OP>
23  bool setKernelArgument(const Binding &binding, int p,
24  cl::Kernel &kernel, int &argidx,
26  fpreal timestep,
27  UT_ErrorManager *error,
28  UT_ErrorSeverity missingseverity,
29  const OP &op);
30 
31  /// Binds each of the bindings in turn.
32  /// OP is a callback structure that knows how to bind the various
33  /// bespoke types, with
34  /// bool operator()(const CE_Snippet::Binding &binding, int p,
35  /// cl::Kernel &kernel, int &argidx,
36  /// UT_ErrorManager *error,
37  /// CE_Precision PREC)
38  template <typename OP>
39  inline bool setKernelArguments(const UT_Array<Binding> &bindings,
40  BindingPrecision nodeprecision,
41  cl::Kernel &kernel, int &argidx,
43  fpreal timestep,
44  UT_ErrorManager *error,
45  UT_ErrorSeverity missingseverity,
46  const OP &op)
47  {
48  bool ok = true;
49  int p = 0;
50  for (auto && binding : bindings)
51  {
52  auto precision = binding.precision;
54  precision = nodeprecision;
55  switch (precision)
56  {
58  UT_ASSERT(!"This should have been handled");
59  break;
61  ok &= setKernelArgument<CE_16, OP>(binding, p, kernel, argidx, buffers, timestep, error, missingseverity, op);
62  break;
64  ok &= setKernelArgument<CE_32, OP>(binding, p, kernel, argidx, buffers, timestep, error, missingseverity, op);
65  break;
67  ok &= setKernelArgument<CE_64, OP>(binding, p, kernel, argidx, buffers, timestep, error, missingseverity, op);
68  break;
69 
70  }
71  if (!ok)
72  break;
73  p++;
74  }
75  return ok;
76  }
77 
78  /// Adds an error to the error manager for mis-binding an argument.
79  CE_API void reportSetArgError(const char *name, int argidx,
80  int pidx, const char *type,
81  const char *extra, UT_ErrorManager *error);
82 
83  template <typename TYPE>
84  inline void bindKernelArgRaw(TYPE *val, int tuplesize,
85  cl::Kernel &kernel, int &argidx,
86  const char *name, const char *type, int pidx,
87  UT_ErrorManager *error,
88  const char *extra = 0)
89  {
90  try
91  {
92  kernel.setArg( argidx, tuplesize * sizeof(TYPE), val);
93  argidx++;
94  }
95  catch (cl::Error &)
96  {
97  reportSetArgError(name, argidx, pidx, type, extra, error);
98  throw;
99  }
100  }
101  /// Binds a kernel argument of the type, incrementing the argidx
102  /// Will throw an error and add the error to the provided error manager.
103  ///{
104  inline void bindKernelArgI(cl_int val, cl::Kernel &kernel, int &argidx,
105  const char *name, int pidx, UT_ErrorManager *error,
106  const char *extra = 0)
107  { bindKernelArgRaw(&val, 1, kernel, argidx, name, "int", pidx, error, extra); }
108  inline void bindKernelArgI2(cl_int *val, cl::Kernel &kernel, int &argidx,
109  const char *name, int pidx, UT_ErrorManager *error,
110  const char *extra = 0)
111  { bindKernelArgRaw(val, 2, kernel, argidx, name, "int2", pidx, error, extra); }
112  inline void bindKernelArgF(cl_float val, cl::Kernel &kernel, int &argidx,
113  const char *name, int pidx, UT_ErrorManager *error,
114  const char *extra = 0)
115  { bindKernelArgRaw(&val, 1, kernel, argidx, name, "float", pidx, error, extra); }
116  inline void bindKernelArgV2(cl_float *val, cl::Kernel &kernel, int &argidx,
117  const char *name, int pidx, UT_ErrorManager *error,
118  const char *extra = 0)
119  { bindKernelArgRaw(val, 2, kernel, argidx, name, "float2", pidx, error, extra); }
120  /// NOTE: This binds float4 due to vagaries of cl!
121  inline void bindKernelArgV3(cl_float *val, cl::Kernel &kernel, int &argidx,
122  const char *name, int pidx, UT_ErrorManager *error,
123  const char *extra = 0)
124  { bindKernelArgRaw(val, 4, kernel, argidx, name, "float3", pidx, error, extra); }
125  inline void bindKernelArgV4(cl_float *val, cl::Kernel &kernel, int &argidx,
126  const char *name, int pidx, UT_ErrorManager *error,
127  const char *extra = 0)
128  { bindKernelArgRaw(val, 4, kernel, argidx, name, "float4", pidx, error, extra); }
129  inline void bindKernelArgV16(cl_float *val, cl::Kernel &kernel, int &argidx,
130  const char *name, int pidx, UT_ErrorManager *error,
131  const char *extra = 0)
132  { bindKernelArgRaw(val, 16, kernel, argidx, name, "float16", pidx, error, extra); }
133  inline void bindKernelArgB(cl::Buffer val, cl::Kernel &kernel, int &argidx,
134  const char *name, int pidx, const char *type,
135  UT_ErrorManager *error,
136  const char *extra = 0)
137  {
138  try
139  {
140  kernel.setArg( argidx, val);
141  argidx++;
142  }
143  catch (cl::Error &)
144  {
145  reportSetArgError(name, argidx, pidx, type, extra, error);
146  throw;
147  }
148  }
149 
150  ///}
151  template <CE_Precision PREC, typename OP>
152  inline bool
154  int p,
155  cl::Kernel &kernel, int &argidx,
157  fpreal timestep,
158  UT_ErrorManager *error,
159  UT_ErrorSeverity missingseverity,
160  const OP &op)
161  {
162  bool ok = true;
163  UT_String retrieveStr;
164 
165  BindingType paramtype = BindingType::INVALID;
166  CEfloatH<PREC> param_float = 0;
167  CE_Context *clcontext = CE_Context::getContext();
168  CEintH<PREC> param_int;
169  UT_Vector4D param_float4;
170  UT_Vector3D param_float3;
171  UT_Vector2D param_float2;
172  UT_String param_string;
173 
174  CEfloatH<PREC> param_fpreal_array[16];
175 
176  paramtype = binding.type;
177 
178  // set base parameter values
179  switch (paramtype)
180  {
181  // Single integer
182  case BindingType::INT:
183  param_int = binding.intval;
184  CE_Snippet::bindKernelArgRaw(&param_int, 1,
185  kernel, argidx, binding.name, "int", p, error);
186  break;
187 
189  {
190  const cl_int array_size = binding.intarray.entries();
191  const int tuplesize = 1;
192 
193  UT_Array<CEintH<PREC>> array;
194  array.entries(array_size * tuplesize);
195 
196  int n = binding.intarray.entries();
197  for (int i = 0; i < n; i++)
198  array(i) = binding.intarray(i);
199 
200  const size_t array_data_size = array_size * tuplesize * sizeof( CEintH<PREC> );
201  // Bind null if empty.
202  cl::Buffer array_buffer;
203  if (array_data_size)
204  array_buffer = clcontext->allocBuffer(array_data_size);
205 
206  // Blocking since we will free our array shortly.
207  clcontext->writeBuffer( array_buffer, array_data_size, array.array() );
208  buffers.append(array_buffer);
209 
210  CE_Snippet::bindKernelArgI(array_size, kernel, argidx, binding.name, p, error, "size");
211  CE_Snippet::bindKernelArgB(array_buffer, kernel, argidx, binding.name, p, "int *", error, "data");
212  break;
213  }
214 
215  // Single Float
216  case BindingType::FLOAT:
217  {
218  BindingTimescale timemethod;
219  param_float = binding.fval;
220  timemethod = binding.timescale;
221 
222  switch( timemethod )
223  {
224  case BindingTimescale::NONE: // None
225  break;
226  case BindingTimescale::MULT: // * Timescale
227  param_float *= timestep;
228  break;
229  case BindingTimescale::INVERT: // 1 / Timescale
230  param_float /= timestep;
231  break;
232  case BindingTimescale::POW: // e ^ timestep
233  param_float = SYSexp( param_float * timestep );
234  break;
235  default:
236  break;
237  }
238 
239  CE_Snippet::bindKernelArgRaw(&param_float, 1,
240  kernel, argidx, binding.name, "float", p, error);
241  break;
242  }
243 
244  // Float Vector 2
245  case BindingType::FLOAT2:
246  param_float2 = binding.v2val;
247  param_fpreal_array[0] = param_float2(0);
248  param_fpreal_array[1] = param_float2(1);
249 
250  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 2,
251  kernel, argidx, binding.name, "float2", p, error);
252  break;
253 
254  // Float Vector 3
255  case BindingType::FLOAT3:
256  param_float3 = binding.v3val;
257  param_fpreal_array[0] = param_float3(0);
258  param_fpreal_array[1] = param_float3(1);
259  param_fpreal_array[2] = param_float3(2);
260  param_fpreal_array[3] = 0;
261 
262  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
263  kernel, argidx, binding.name, "float3", p, error);
264  break;
265 
266  // Float Vector 4
267  case BindingType::FLOAT4:
268  param_float4 = binding.v4val;
269  param_fpreal_array[0] = param_float4(0);
270  param_fpreal_array[1] = param_float4(1);
271  param_fpreal_array[2] = param_float4(2);
272  param_fpreal_array[3] = param_float4(3);
273  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
274  kernel, argidx, binding.name, "float4", p, error);
275  break;
276 
277  // Float vector 8
278  case BindingType::FLOAT8:
279  param_float4 = binding.v4val;
280  param_fpreal_array[0] = param_float4(0);
281  param_fpreal_array[1] = param_float4(1);
282  param_fpreal_array[2] = param_float4(2);
283  param_fpreal_array[3] = param_float4(3);
284  param_float4 = binding.v4bval;
285  param_fpreal_array[4+0] = param_float4(0);
286  param_fpreal_array[4+1] = param_float4(1);
287  param_fpreal_array[4+2] = param_float4(2);
288  param_fpreal_array[4+3] = param_float4(3);
289  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 8,
290  kernel, argidx, binding.name, "float8", p, error);
291  break;
292 
293  // Float vector 16
295  {
296  for (int r = 0; r < 4; r++)
297  for (int c = 0; c < 4; c++)
298  param_fpreal_array[r*4+c] = binding.m4val(r, c);
299  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 16,
300  kernel, argidx, binding.name, "float8", p, error);
301  break;
302  }
303 
304  case BindingType::RAMP:
305  {
306  const cl_int ramp_size = binding.rampsize;
307  const int tuplesize = binding.ramptype == BindingRampType::VECTOR ? 3 : 1;
308 
309  // load the ramp, allocate the required buffer, and populate with
310  // ramp data
311 
312  UT_Array<CEfloatH<PREC>> ramp_array;
313  ramp_array.entries(ramp_size * tuplesize);
314 
315  if (binding.ramp)
316  {
317  int writepos = 0;
318  for (int i = 0; i < ramp_size; i++)
319  {
320  float values[4];
321  fpreal pos = i / fpreal(ramp_size - 1);
322  binding.ramp->rampLookup( pos, values );
323  for (int j = 0; j < tuplesize; j++)
324  ramp_array(writepos++) = values[j];
325  }
326  }
327  else if (binding.rampdata.entries())
328  {
329  UT_ASSERT(binding.rampdata.entries() == ramp_array.entries());
330  int n = SYSmin(binding.rampdata.entries(), ramp_array.entries());
331  for (int i = 0; i < n; i++)
332  ramp_array(i) = binding.rampdata(i);
333  for (int i = n; i < ramp_array.entries(); i++)
334  ramp_array(i) = 0;
335  }
336  else
337  {
338  ramp_array.constant(0);
339  }
340 
341  const size_t ramp_data_size = ramp_size * tuplesize * sizeof( CEfloatH<PREC> );
342  cl::Buffer ramp_buffer = clcontext->allocBuffer(ramp_data_size);
343  // Blocking since we will free our array shortly.
344  clcontext->writeBuffer( ramp_buffer, ramp_data_size, ramp_array.array() );
345  buffers.append(ramp_buffer);
346 
347  CE_Snippet::bindKernelArgI(ramp_size, kernel, argidx, binding.name, p, error, "size");
348  CE_Snippet::bindKernelArgB(ramp_buffer, kernel, argidx, binding.name, p, "float *", error, "data");
349  break;
350  }
351 
355  {
356  // Ignore unbound optional volumes
357  if (!op(binding, p, kernel, argidx, error, PREC))
358  {
359  UT_WorkBuffer msg;
360  msg.sprintf("Invalid field '%s'", (const char *) binding.fieldname);
361  if (missingseverity != UT_ERROR_NONE)
362  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
363  return false;
364  }
365 
366  break;
367  }
369  {
370  // Fetch our geometry
371  BindingAttribType atype = binding.attribtype;
372  int tuplesize = binding.attribsize;
373  bool isarray = atype == BindingAttribType::FLOATARRAY || atype == BindingAttribType::INTARRAY;
374  bool optional = binding.optional;
375 
376  if (!op(binding, p, kernel, argidx, error, PREC))
377  {
378  if (!optional)
379  {
380  UT_WorkBuffer msg;
381  msg.sprintf("Invalid attribute '%s'", (const char *) binding.attribute);
382  if (missingseverity != UT_ERROR_NONE)
383  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
384  return false;
385  }
386  else
387  {
388  // Check if we are to bind a default value...
389  if (!isarray && binding.defval)
390  {
391  if (atype == BindingAttribType::INT)
392  {
393  // Single integer
394  param_int = binding.intval;
395  CE_Snippet::bindKernelArgRaw(&param_int, 1,
396  kernel, argidx, binding.name, "int", p, error);
397  }
398  else if (tuplesize == 2)
399  {
400  param_float2 = binding.v2val;
401  param_fpreal_array[0] = param_float2(0);
402  param_fpreal_array[1] = param_float2(1);
403 
404  CE_Snippet::bindKernelArgRaw( param_fpreal_array, 2,
405  kernel, argidx, binding.name, "float2", p, error);
406  }
407  else if (tuplesize == 3)
408  {
409  // Float Vector 3
410  param_float3 = binding.v3val;
411  param_fpreal_array[0] = param_float3(0);
412  param_fpreal_array[1] = param_float3(1);
413  param_fpreal_array[2] = param_float3(2);
414  param_fpreal_array[3] = 0;
415 
416  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
417  kernel, argidx, binding.name, "float3", p, error);
418  }
419  else if (tuplesize == 4)
420  {
421  // Float Vector 4
422  param_float4 = binding.v4val;
423  param_fpreal_array[0] = param_float4(0);
424  param_fpreal_array[1] = param_float4(1);
425  param_fpreal_array[2] = param_float4(2);
426  param_fpreal_array[3] = param_float4(3);
427  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
428  kernel, argidx, binding.name, "float4", p, error);
429  }
430  else
431  {
432  // All other bind a single float default
433  param_float = binding.fval;
434  CE_Snippet::bindKernelArgRaw(&param_float, 1,
435  kernel, argidx, binding.name, "float", p, error);
436  }
437  }
438 
439  return true;
440  }
441  }
442 
443  break;
444  }
445 
446  case BindingType::VOLUME:
447  {
448  bool optional = binding.optional;
449 
450  // Ignore unbound optional volumes
451  if (!op(binding, p, kernel, argidx, error, PREC))
452  {
453  if (optional)
454  {
455  // Check if we are to bind a default value...
456  if (binding.defval)
457  {
458  param_float = binding.fval;
459  CE_Snippet::bindKernelArgRaw(&param_float, 1,
460  kernel, argidx, binding.name, "float", p, error);
461  }
462  return true;
463  }
464  else
465  {
466  UT_WorkBuffer msg;
467  msg.sprintf("Invalid volume '%s'", (const char *) binding.volume);
468  if (missingseverity != UT_ERROR_NONE)
469  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
470  return false;
471  }
472  }
473 
474  break;
475  }
476 
477  case BindingType::VDB:
478  {
479  bool optional = binding.optional;
480 
481  // Ignore unbound optional volumes
482  if (!op(binding, p, kernel, argidx, error, PREC))
483  {
484  if (!optional)
485  {
486  UT_WorkBuffer msg;
487  msg.sprintf("Invalid vdb '%s'", (const char *) binding.volume);
488  if (missingseverity != UT_ERROR_NONE)
489  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
490  return false;
491  }
492  else
493  {
494  // Check if we are to bind a default value...
495  if (binding.defval)
496  {
497  param_float = binding.fval;
498  CE_Snippet::bindKernelArgRaw(&param_float, 1,
499  kernel, argidx, binding.name, "float", p, error);
500  }
501  return true;
502  }
503  }
504  break;
505  }
506 
507  case BindingType::OPTION:
508  {
509  bool optional = binding.optional;
510  bool defval = binding.defval;
511  bool flttype = (binding.optiontype == BindingOptionType::FLOAT);
512  int tuplesize = binding.optionsize;
513 
514  // Ignore unbound optional volumes
515  if (!op(binding, p, kernel, argidx, error, PREC))
516  {
517  if (!optional)
518  {
519  UT_WorkBuffer msg;
520  msg.sprintf("Invalid option '%s'", (const char *) binding.optionname);
521  if (missingseverity != UT_ERROR_NONE)
522  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
523  return false;
524  }
525  else
526  {
527  // Check if we are to bind a default value...
528  if (defval)
529  {
530  if (!flttype)
531  {
532  // Integers are single value.
533  param_int = binding.intval;
534  CE_Snippet::bindKernelArgRaw(&param_int, 1,
535  kernel, argidx, binding.name, "int", p, error);
536  }
537  else if (tuplesize == 2)
538  {
539  param_float2 = binding.v2val;
540  param_fpreal_array[0] = param_float2(0);
541  param_fpreal_array[1] = param_float2(1);
542 
543  CE_Snippet::bindKernelArgRaw( param_fpreal_array, 2,
544  kernel, argidx, binding.name, "float2", p, error);
545  }
546  else if (tuplesize == 3)
547  {
548  // Float Vector 3
549  param_float3 = binding.v3val;
550  param_fpreal_array[0] = param_float3(0);
551  param_fpreal_array[1] = param_float3(1);
552  param_fpreal_array[2] = param_float3(2);
553  param_fpreal_array[3] = 0;
554 
555  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
556  kernel, argidx, binding.name, "float3", p, error);
557  }
558  else if (tuplesize == 4)
559  {
560  // Float Vector 4
561  param_float4 = binding.v4val;
562  param_fpreal_array[0] = param_float4(0);
563  param_fpreal_array[1] = param_float4(1);
564  param_fpreal_array[2] = param_float4(2);
565  param_fpreal_array[3] = param_float4(3);
566  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
567  kernel, argidx, binding.name, "float4", p, error);
568  }
569  else
570  {
571  // All other bind a single float default
572  param_float = binding.fval;
573  CE_Snippet::bindKernelArgRaw(&param_float, 1,
574  kernel, argidx, binding.name, "float", p, error);
575  }
576  }
577  return true;
578  }
579  }
580  break;
581  }
582 
583  case BindingType::LAYER:
584  {
585  bool optional = binding.optional;
586  bool defval = binding.defval;
587 
588  // Ignore unbound optional volumes
589  if (!op(binding, p, kernel, argidx, error, PREC))
590  {
591  if (!optional)
592  {
593  UT_WorkBuffer msg;
594  msg.sprintf("Invalid image '%s'", (const char *) binding.name);
595  if (missingseverity != UT_ERROR_NONE)
596  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
597  return false;
598  }
599  else
600  {
601  if (defval)
602  {
603  switch (binding.layertype)
604  {
606  param_int = binding.intval;
607  CE_Snippet::bindKernelArgRaw(&param_int, 1,
608  kernel, argidx, binding.name, "int", p, error);
609  break;
611  param_float = binding.fval;
612  CE_Snippet::bindKernelArgRaw(&param_float, 1,
613  kernel, argidx, binding.name, "float", p, error);
614  break;
616  param_fpreal_array[0] = binding.v2val(0);
617  param_fpreal_array[1] = binding.v2val(1);
618  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 2,
619  kernel, argidx, binding.name, "float2", p, error);
620  break;
622  param_fpreal_array[0] = binding.v3val(0);
623  param_fpreal_array[1] = binding.v3val(1);
624  param_fpreal_array[2] = binding.v3val(2);
625  param_fpreal_array[3] = 0;
626  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
627  kernel, argidx, binding.name, "float3", p, error);
628  break;
629  default:
630  param_fpreal_array[0] = binding.v4val(0);
631  param_fpreal_array[1] = binding.v4val(1);
632  param_fpreal_array[2] = binding.v4val(2);
633  param_fpreal_array[3] = binding.v4val(3);
634  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
635  kernel, argidx, binding.name, "float4", p, error);
636  }
637  }
638  return true;
639  }
640  }
641  break;
642  }
643  default:
644  break;
645  }
646 
647  return ok;
648  }
649 
650 } /// namespace
651 
652 #endif
#define CE_API
Definition: CE_API.h:11
BindingType type
Definition: CE_Snippet.h:148
UT_StringHolder attribute
Definition: CE_Snippet.h:168
UT_StringHolder fieldname
Definition: CE_Snippet.h:156
void bindKernelArgB(cl::Buffer val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, const char *type, UT_ErrorManager *error, const char *extra=0)
typename CE_PrecisionResolver< P >::host_int_type CEintH
Definition: CE_Precision.h:62
UT_Matrix4D m4val
Definition: CE_Snippet.h:183
SYS_FORCE_INLINE const char * buffer() const
CE_API void reportSetArgError(const char *name, int argidx, int pidx, const char *type, const char *extra, UT_ErrorManager *error)
Adds an error to the error manager for mis-binding an argument.
void bindKernelArgF(cl_float val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
UT_ErrorSeverity
Definition: UT_Error.h:25
T * array()
Definition: UT_Array.h:839
int32_t cl_int
Definition: cl_platform.h:260
UT_StringHolder name
Definition: CE_Snippet.h:147
typename CE_PrecisionResolver< P >::host_float_type CEfloatH
Definition: CE_Precision.h:61
UT_Vector4D v4val
Definition: CE_Snippet.h:181
void writeBuffer(const cl::Buffer &buf, size_t size, const void *p, bool blocking=true, size_t offset=0)
Write the specified number of bytes to the buffer.
UT_Vector4D v4bval
Definition: CE_Snippet.h:182
UT_StringHolder optionname
Definition: CE_Snippet.h:189
void bindKernelArgV2(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
bool setKernelArguments(const UT_Array< Binding > &bindings, BindingPrecision nodeprecision, cl::Kernel &kernel, int &argidx, UT_Array< cl::Buffer > &buffers, fpreal timestep, UT_ErrorManager *error, UT_ErrorSeverity missingseverity, const OP &op)
UT_Vector2D UT_Vector3D v3val
Definition: CE_Snippet.h:180
bool setKernelArgument(const Binding &binding, int p, cl::Kernel &kernel, int &argidx, UT_Array< cl::Buffer > &buffers, fpreal timestep, UT_ErrorManager *error, UT_ErrorSeverity missingseverity, const OP &op)
}
GLdouble n
Definition: glcorearb.h:2008
void bindKernelArgV3(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
NOTE: This binds float4 due to vagaries of cl!
static CE_Context * getContext(bool gl_shared=true, bool shared_fallback=true)
BindingOptionType optiontype
Definition: CE_Snippet.h:190
BindingLayerType layertype
Definition: CE_Snippet.h:154
const GLuint * buffers
Definition: glcorearb.h:661
GLuint const GLchar * name
Definition: glcorearb.h:786
UT_SharedPtr< UT_Ramp > ramp
Definition: CE_Snippet.h:149
exint append()
Definition: UT_Array.h:142
int sprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
BindingRampType ramptype
Definition: CE_Snippet.h:151
GLenum GLint GLint * precision
Definition: glcorearb.h:1925
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
float cl_float
Definition: cl_platform.h:266
GLint j
Definition: glad.h:2733
void bindKernelArgI(cl_int val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
void bindKernelArgI2(cl_int *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
BindingAttribType attribtype
Definition: CE_Snippet.h:170
UT_Array< int > intarray
Definition: CE_Snippet.h:153
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint GLfloat * val
Definition: glcorearb.h:1608
void bindKernelArgV4(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
A global error manager scope.
Memory buffer interface.
Definition: cl.hpp:1867
UT_Vector2D v2val
Definition: CE_Snippet.h:179
void constant(const T &v)
Quickly set the array to a single value.
void bindKernelArgV16(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
cl_int setArg(cl_uint index, T value)
Definition: cl.hpp:2614
UT_Array< float > rampdata
Definition: CE_Snippet.h:150
Kernel interface that implements cl_kernel.
Definition: cl.hpp:2544
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
GLboolean r
Definition: glcorearb.h:1222
#define SYSmin(a, b)
Definition: SYS_Math.h:1571
type
Definition: core.h:1059
void bindKernelArgRaw(TYPE *val, int tuplesize, cl::Kernel &kernel, int &argidx, const char *name, const char *type, int pidx, UT_ErrorManager *error, const char *extra=0)
cl::Buffer allocBuffer(int64 size, bool usePool=true, bool read=true, bool write=true, uint32 ogl_bind=SYS_UINT32_MAX)
UT_StringHolder volume
Definition: CE_Snippet.h:160
UT_ErrorSeverity addGeneric(const char *type, int code, const char *msg, UT_ErrorSeverity sev, const UT_SourceLocation *loc=0)
BindingTimescale timescale
Definition: CE_Snippet.h:187