HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_Refine.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: GT_Refine.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_Refine__
12 #define __GT_Refine__
13 
14 #include "GT_API.h"
15 #include "GT_Handles.h"
16 #include <SYS/SYS_Types.h>
17 #include <UT/UT_ParallelUtil.h>
18 
19 ///@brief Processes primitives generated by refinement process
21 public:
22  /// Default constructor
23  GT_Refine() {}
24 
25  /// Destructor
26  virtual ~GT_Refine();
27 
28  /// Return true if the refinement allows threaded refinement of primitives
29  virtual bool allowThreading() const { return true; }
30 
31  /// This method is called for all primitives generated during the
32  /// refinement process.
33  virtual void addPrimitive(const GT_PrimitiveHandle &prim) = 0;
34 
35  /// Convenience method called by primitives which support parallel for
36  /// loops for refinement.
37  template <typename Range, typename Body>
38  void refineRange(const Range &range, const Body &body)
39  {
40  if (allowThreading())
41  {
42  // Use a task scope here because USD packed
43  // primitives, as part of their refinement, may
44  // actually cause a LOP node to cook. If the
45  // LOP cook requires the HOM_Lock, or other
46  // task scope lock, we need to allow this
47  // (see Bug 111243).
48  UTparallelForTaskScope(range, body);
49  }
50  else
51  UTserialFor(range, body);
52  }
53 
54 public:
55  /// @{
56  /// For memory tracking, we override the new/delete operators
57  static void *operator new(size_t size);
58  static void *operator new(size_t size, void *p);
59  static void operator delete(void *p, size_t size);
60  /// @}
61 
62 protected:
63 };
64 
65 #endif
GT_Refine()
Default constructor.
Definition: GT_Refine.h:23
GLenum GLint * range
Definition: glcorearb.h:1925
void UTparallelForTaskScope(const Range &range, const Body &body, const int subscribe_ratio=2, const int min_grain_size=1)
#define GT_API
Definition: GT_API.h:13
virtual bool allowThreading() const
Return true if the refinement allows threaded refinement of primitives.
Definition: GT_Refine.h:29
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
void refineRange(const Range &range, const Body &body)
Definition: GT_Refine.h:38
GLsizeiptr size
Definition: glcorearb.h:664
void UTserialFor(const Range &range, const Body &body)