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 {
22 public:
23  /// Default constructor
24  GT_Refine() {}
25 
26  /// Destructor
27  virtual ~GT_Refine();
28 
29  /// Return true if the refinement allows threaded refinement of primitives
30  virtual bool allowThreading() const { return true; }
31 
32  /// This method is called for all primitives generated during the
33  /// refinement process.
34  virtual void addPrimitive(const GT_PrimitiveHandle &prim) = 0;
35 
36  /// Convenience method called by primitives which support parallel for
37  /// loops for refinement.
38  template <typename Range, typename Body>
39  void refineRange(const Range &range, const Body &body)
40  {
41  if (allowThreading())
42  {
43  // Use a task scope here because USD packed
44  // primitives, as part of their refinement, may
45  // actually cause a LOP node to cook. If the
46  // LOP cook requires the HOM_Lock, or other
47  // task scope lock, we need to allow this
48  // (see Bug 111243).
49  UTparallelForTaskScope(range, body);
50  }
51  else
52  UTserialFor(range, body);
53  }
54 
55 public:
56  /// @{
57  /// For memory tracking, we override the new/delete operators
58  static void *operator new(size_t size);
59  static void *operator new(size_t size, void *p);
60  static void operator delete(void *p, size_t size);
61  /// @}
62 
63 protected:
64 };
65 
66 #endif
GT_Refine()
Default constructor.
Definition: GT_Refine.h:24
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:30
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
void refineRange(const Range &range, const Body &body)
Definition: GT_Refine.h:39
GLsizeiptr size
Definition: glcorearb.h:664
void UTserialFor(const Range &range, const Body &body)