Free Electron
SurfaceAccessorOpenCL.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __opencl_SurfaceAccessorOpenCL_h__
8 #define __opencl_SurfaceAccessorOpenCL_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 //* TODO coordinate counts between accessors
16 
17 /**************************************************************************//**
18  @brief Accessor backed with a OpenCL
19 
20  @ingroup opencl
21 *//***************************************************************************/
22 class FE_DL_EXPORT SurfaceAccessorOpenCL:
23  virtual public SurfaceAccessorBase,
24  public CastableAs<SurfaceAccessorOpenCL>
25 {
26  public:
28 virtual ~SurfaceAccessorOpenCL(void);
29 
30  using SurfaceAccessorBase::set;
31  using SurfaceAccessorBase::append;
32  using SurfaceAccessorBase::spatialVector;
33 
34  //* as SurfaceAccessorI
35 virtual U32 count(void) const;
36 virtual U32 subCount(U32 a_index) const;
37 
38 virtual void set(U32 a_index,U32 a_subIndex,String a_string);
39 virtual String string(U32 a_index,U32 a_subIndex=0);
40 
41 virtual void set(U32 a_index,U32 a_subIndex,I32 a_integer);
42 virtual I32 integer(U32 a_index,U32 a_subIndex=0);
43 
44 virtual I32 append(I32 a_integer);
45 virtual I32 append(void);
46 virtual I32 append(SurfaceAccessibleI::Form a_form);
47 virtual void append(U32 a_index,I32 a_integer);
48 virtual void append(Array< Array<I32> >& a_rPrimVerts);
49 
50 virtual void set(U32 a_index,U32 a_subIndex,Real a_real);
51 virtual Real real(U32 a_index,U32 a_subIndex=0);
52 
53 virtual void set(U32 a_index,U32 a_subIndex,
54  const SpatialVector& a_spatialVector);
55 virtual SpatialVector spatialVector(U32 a_index,U32 a_subIndex=0);
56 
57  BWORD bind(SurfaceAccessibleI::Element a_element,
58  SurfaceAccessibleI::Attribute a_attribute)
59  {
60  m_attribute=a_attribute;
61 
62  String name;
63  switch(a_attribute)
64  {
65  case SurfaceAccessibleI::e_generic:
66  //* TODO
67  name="_generic_";
68  break;
69  case SurfaceAccessibleI::e_position:
70  name="P";
71  break;
72  case SurfaceAccessibleI::e_normal:
73  name="N";
74  break;
75  case SurfaceAccessibleI::e_uv:
76  name="uv";
77  break;
78  case SurfaceAccessibleI::e_color:
79  name="Cd";
80  break;
81  case SurfaceAccessibleI::e_vertices:
82  name="vertStart";
83  break;
84 // m_attrName="vertices";
85 // FEASSERT(a_element==
86 // SurfaceAccessibleI::e_primitive);
87 // m_element=a_element;
88 // return TRUE;
89  case SurfaceAccessibleI::e_properties:
90  name="properties";
91  break;
92 // m_attrName="properties";
93 // FEASSERT(a_element==
94 // SurfaceAccessibleI::e_primitive);
95 // m_element=a_element;
96 // return TRUE;
97  }
98  return bindInternal(a_element,name);
99  }
100  BWORD bind(SurfaceAccessibleI::Element a_element,
101  const String& a_name)
102  {
103  String name=a_name;
104  m_attribute=SurfaceAccessibleI::e_generic;
105 
106  if(name=="P")
107  {
108  m_attribute=SurfaceAccessibleI::e_position;
109  }
110  else if(name=="N")
111  {
112  m_attribute=SurfaceAccessibleI::e_normal;
113  }
114  else if(name=="uv")
115  {
116  m_attribute=SurfaceAccessibleI::e_uv;
117  }
118  else if(name=="Cd")
119  {
120  m_attribute=SurfaceAccessibleI::e_color;
121  }
122 
123  return bindInternal(a_element,name);
124  }
125 
126  private:
127 
128 virtual BWORD bindInternal(SurfaceAccessibleI::Element a_element,
129  const String& a_name);
130 
131  void setAttrType(String a_attrType);
132 
133  void ensureBufferSize(
134  SurfaceAccessibleOpenCL::Bridge* a_pBridge,
135  I32 a_minSize,I32 a_sizeof);
136 
137  I32 pointIndexForVertex(U32 a_index,U32 a_subIndex);
138 
139  String m_bridgeName;
140 
141 const SurfaceAccessibleOpenCL::Bridge* m_pBridgeConst;
142 const SurfaceAccessibleOpenCL::Bridge* m_pPositionBridgeConst;
143 const SurfaceAccessibleOpenCL::Bridge* m_pVertStartBridgeConst;
144 const SurfaceAccessibleOpenCL::Bridge* m_pVertCountBridgeConst;
145 const SurfaceAccessibleOpenCL::Bridge* m_pVertPointBridgeConst;
146 
147  SurfaceAccessibleOpenCL::Bridge* m_pBridge;
148  SurfaceAccessibleOpenCL::Bridge* m_pPositionBridge;
149  SurfaceAccessibleOpenCL::Bridge* m_pVertStartBridge;
150  SurfaceAccessibleOpenCL::Bridge* m_pVertCountBridge;
151  SurfaceAccessibleOpenCL::Bridge* m_pVertPointBridge;
152 
154 };
155 
156 } /* namespace ext */
157 } /* namespace fe */
158 
159 #endif /* __opencl_SurfaceAccessorOpenCL_h__ */
kernel
Definition: namespace.dox:3
Common Functionality for Accessor Surface.
Definition: SurfaceAccessorBase.h:20
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21
Accessor backed with a OpenCL.
Definition: SurfaceAccessorOpenCL.h:22
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192