HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP2_FullImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * FullImageFilter.
27  */
28 #ifndef _COP2_FULLIMAGEFILTER_H_
29 #define _COP2_FULLIMAGEFILTER_H_
30 
31 #include <UT/UT_Lock.h>
32 
33 #include <COP2/COP2_MaskOp.h>
34 
35 namespace HDK_Sample {
36 
38 {
39 public:
40  // Normal op stuff...
41  static OP_Node *myConstructor(OP_Network*, const char *,
42  OP_Operator *);
47  static const char *myInputLabels[];
48 
49 
50  // static cookFullImage callback.
51  static OP_ERROR filter(COP2_Context &context,
52  const TIL_Region *input,
53  TIL_Region *output,
54  COP2_Node *me);
55  // non static version, called by filter.
57  const TIL_Region *input,
58  TIL_Region *output);
59 
60  // since this is single threaded per-plane, hint this to the scheduler.
61  // You can restrict threading so that:
62  // maxp - a maximum of 'maxp' threads cooking the same plane in this
63  // node at once.
64  // maxn - a maximum of 'maxn' threads can be cooking in a single
65  // instance of this node at once.
66  // op - a maximum of 'op' threads can be cooking in instances of
67  // this operator at once.
68 
69  // This basically says that only 1 thread may cook a given plane at a time,
70  // but several threads may be in this node cooking different planes.
72  COP2_Context &,
73  int &maxp,
74  int &maxn,
75  int &op) const override
76  {
77  maxp = 1;
78  maxn = op = TIL_MAX_THREADS;
79  }
80 
81  // For the output area (an area of a plane belonging to this node)
82  // and a set of input areas, determine which input areas and which
83  // parts of these areas are needed to cook the output area.
85  COP2_CookAreaInfo &output_area,
86  const COP2_CookAreaList &input_areas,
87  COP2_CookAreaList &needed_areas) override;
88 
89 protected:
90  ~COP2_FullImageFilter() override;
91 
93  int array_index,
94  float t,
95  int xres, int yres,
96  int thread,
97  int max_threads) override;
98 
100  TIL_TileList *tiles) override;
101 
102  // if we expand or change the image bounds, we need to override this method
103  // and set the new bounds.
104  void computeImageBounds(COP2_Context &context) override;
105 
106 private:
107  COP2_FullImageFilter(OP_Network *parent, const char *name,
108  OP_Operator *entry);
109 
110  fpreal SIZE(fpreal t) { return evalFloat("size", 0, t); }
111 };
112 
114 {
115 public:
118 
119  float mySize;
121 };
122 
123 } // End HDK_Sample namespace
124 
125 #endif
126 
static OP_TemplatePair myTemplatePair
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
OP_ERROR doCookMyTile(COP2_Context &context, TIL_TileList *tiles) override
void getMaxNumThreadsInCook(COP2_Context &, int &maxp, int &maxn, int &op) const override
void computeImageBounds(COP2_Context &context) override
OP_ERROR filterImage(COP2_Context &context, const TIL_Region *input, TIL_Region *output)
static OP_ERROR filter(COP2_Context &context, const TIL_Region *input, TIL_Region *output, COP2_Node *me)
GLuint const GLchar * name
Definition: glcorearb.h:786
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
GLdouble t
Definition: glad.h:2397
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
fpreal64 fpreal
Definition: SYS_Types.h:277
static OP_VariablePair myVariablePair
#define TIL_MAX_THREADS
Definition: TIL_Defines.h:38
void getInputDependenciesForOutputArea(COP2_CookAreaInfo &output_area, const COP2_CookAreaList &input_areas, COP2_CookAreaList &needed_areas) override
static CH_LocalVariable myVariableList[]
COP2_ContextData * newContextData(const TIL_Plane *p, int array_index, float t, int xres, int yres, int thread, int max_threads) override