HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GA_CEAttribute.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: GA_CEAttribute.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  * A GA_Attribute backed on the Compute Engine
10  */
11 
12 #ifndef __GA_CEAttribute__
13 #define __GA_CEAttribute__
14 
15 #include "GA_API.h"
16 
17 #include <CE/CE_Context.h>
18 #include "GA_Detail.h"
19 #include "GA_Attribute.h"
20 
21 #ifdef CE_ENABLED
22 
24 {
25 public:
27 
28  virtual ~GA_CEAttribute();
29 
30  void clearBuffers();
31 
32  bool isValid() const
33  {
34  return myBuffer();
35  }
36 
37  cl::Buffer buffer() const { return myBuffer; }
38  cl::Buffer indexBuffer() const { return myIndexBuffer; }
39  GA_Size entries() const { return myEntries; }
40  int tupleSize() const { return myTupleSize; }
41  GA_StorageClass storage() const { return myStorage; }
42  bool isArray() const { return myIsArray; }
43 
44  bool attributeToOCL(const GA_Detail *gdp,
45  GA_AttributeOwner owner,
46  const char *aname,
48  int &tuplesize,
49  bool isarray,
50  bool docopy = true)
51  {
52  if (!gdp) return false;
53  if (!UTisstring(aname))
54  return false;
55  const GA_Attribute *attrib = gdp->getAttributes().findAttribute(owner, aname);
56  if (!attrib)
57  return false;
58  return attributeToOCL(attrib, storage, tuplesize, isarray, docopy);
59  }
60  bool attributeToOCL(const GA_Attribute *attrib,
61  GA_StorageClass storage,
62  int &tuplesize,
63  bool isarray,
64  bool docopy = true);
65 
66  bool oclToAttribute(GA_Detail *gdp, GA_AttributeOwner owner, const char *aname)
67  {
68  if (!gdp) return false;
69  if (!UTisstring(aname))
70  return false;
71  GA_Attribute *attrib = gdp->getAttributes().findAttribute(owner, aname);
72  if (!attrib)
73  return false;
74  return oclToAttribute(attrib);
75  }
76  bool oclToAttribute(GA_Attribute *attrib);
77 
78  bool isWriteBackRequired() const { return myWriteBackRequired; }
79  void setWriteBackRequired(bool isrequired) { myWriteBackRequired = isrequired; }
80 
81 protected:
82 
83  // GPU Buffers:
84  cl::Buffer myBuffer;
85  cl::Buffer myIndexBuffer;
86 
87  // CPU Buffers:
88  UT_Array<cl_int> myIndexArray;
89  UT_Array<cl_float> myFloatArray;
90  UT_Array<cl_int> myIntArray;
91 
92  // Number of entries.
93  GA_Size myEntries;
94  GA_Size myTupleSize;
95  GA_StorageClass myStorage;
96  bool myIsArray;
97 
98  // Whether the buffer has been written to by CE
99  bool myWriteBackRequired;
100 };
101 
102 #else
103 
105 {
106 public:
107 };
108 
109 #endif
110 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
const GA_Attribute * findAttribute(GA_AttributeScope scope, const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_order_size) const
GA_StorageClass
Definition: GA_Types.h:68
#define GA_API
Definition: GA_API.h:12
GLuint buffer
Definition: glcorearb.h:659
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GA_AttributeSet & getAttributes()
Definition: GA_Detail.h:719
GA_AttributeOwner
Definition: GA_Types.h:33
png_infop png_sPLT_tpp entries
Definition: png.h:2481
SYS_FORCE_INLINE bool UTisstring(const char *s)
Definition: UT_String.h:58
Memory buffer interface.
Definition: cl.hpp:1863
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
Container class for all geometry.
Definition: GA_Detail.h:96