HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_CESnippet.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: GU_CESnippet.h ( CE Library, C++)
7  *
8  * COMMENTS: Snippet binding for GU objects into CE_Snippet.
9  */
10 
11 #ifndef __GU_CESnippet__
12 #define __GU_CESnippet__
13 
14 #include "GU_API.h"
15 #include "GU_OSDEval.h"
16 
17 #include <CE/CE_Array.h>
18 #include <CE/CE_BVH.h>
19 #include <CE/CE_Snippet.h>
20 
21 class GU_Detail;
22 class GEO_PrimVolume;
25 
27 {
28 public:
29  GU_CESnippetBindOp(GU_Detail *gdp = nullptr)
30  : myGdp(gdp)
31  , myRefVol(nullptr)
32  { }
33 
35 
36  static GA_AttributeOwner attribClassToOwner(CE_Snippet::BindingAttribClass cls);
37  static CE_Snippet::BindingAttribClass ownerToAttribClass(GA_AttributeOwner owner);
38 
39  /// Reset the working objects, but leave pinned buffers intact.
40  void resetReferences()
41  { myGdp = nullptr; myRefVol = nullptr; }
42  /// Add an accessor as a reference to hold.
44  { myAttribs.append(access); }
45 
46  void setGdp(GU_Detail *gdp) { myGdp = gdp; }
47  void setRefVol(const GEO_PrimVolume *vol) { myRefVol = vol; }
48 
49  /// Is this binding optional, and if so, does it exist in the geometry?
50  bool requiresHas(const CE_Snippet::Binding &binding, CE_Precision precision) const;
51 
52  bool operator()(const CE_Snippet::Binding &binding, int p,
53  cl::Kernel &kernel, int &argidx,
55  CE_Precision precision) const;
56 
57  /// Clear all buffers that were pinned during the binding process
58  /// Should only be done _after_ the kernel has been dispatched.
59  /// Usually just let the destructor handle this.
61  { myAttribs.clear(); myBVHs.clear(); myOSDEvals.clear(); myOSDRefined.clear(); }
62 
63 protected:
64  bool setAttribute(const CE_Snippet::Binding &binding, int p,
65  cl::Kernel &kernel, int &argidx,
67  CE_Precision precision) const;
68 
69  bool setVolume(const CE_Snippet::Binding &binding, int p,
70  cl::Kernel &kernel, int &argidx,
72  CE_Precision precision) const;
73 
74  bool setVDB(const CE_Snippet::Binding &binding, int p,
75  cl::Kernel &kernel, int &argidx,
77  CE_Precision precision) const;
78 
81 
82  /// Attribute accessors that are pinned.
84  /// Temporary attribute BVH objects created on demand (TODO: remove).
86  /// OSD evaluators per input, and refined CP buffers per OSD binding.
89 };
90 
91 #endif
void setGdp(GU_Detail *gdp)
Definition: GU_CESnippet.h:46
void addReference(GA_CEAttributeAccessorPtr access)
Add an accessor as a reference to hold.
Definition: GU_CESnippet.h:43
const GEO_PrimVolume * myRefVol
Definition: GU_CESnippet.h:80
UT_Array< CE_BVH > myBVHs
Temporary attribute BVH objects created on demand (TODO: remove).
Definition: GU_CESnippet.h:85
UT_Array< UT_UniquePtr< GU_OSDEval > > myOSDEvals
OSD evaluators per input, and refined CP buffers per OSD binding.
Definition: GU_CESnippet.h:87
< returns > If no error
Definition: snippets.dox:2
GU_CESnippetBindOp(GU_Detail *gdp=nullptr)
Definition: GU_CESnippet.h:29
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
GLuint GLint GLboolean GLint GLenum access
Definition: glcorearb.h:2222
CE_Precision
Definition: CE_Precision.h:18
int setVolume(int speaker, float vol) override
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
#define GU_API
Definition: GU_API.h:14
UT_SharedPtr< GA_CEAttributeAccessor > GA_CEAttributeAccessorPtr
Definition: GA_Attribute.h:59
GLenum GLint GLint * precision
Definition: glcorearb.h:1925
void resetPinnedBuffers()
Definition: GU_CESnippet.h:60
GA_AttributeOwner
Definition: GA_Types.h:35
UT_Array< GA_CEAttributeAccessorPtr > myAttribs
Attribute accessors that are pinned.
Definition: GU_CESnippet.h:83
A global error manager scope.
BindingAttribClass
Definition: CE_Snippet.h:72
UT_Array< UT_UniquePtr< CE_FloatArray > > myOSDRefined
Definition: GU_CESnippet.h:88
Kernel interface that implements cl_kernel.
Definition: cl.hpp:2544
void setRefVol(const GEO_PrimVolume *vol)
Definition: GU_CESnippet.h:47
GU_Detail * myGdp
Definition: GU_CESnippet.h:79