HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
GU_OSDEval.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_OSDEval.h ( GU Library, C++)
7
*
8
* COMMENTS: GPU subdivision surface evaluator.
9
* Wraps CE_OSD* classes to evaluate limit surface attributes.
10
*/
11
12
#pragma once
13
14
#include "
GU_API.h
"
15
#include "
GU_OSDTopology.h
"
16
17
#include <
CE/CE_Array.h
>
18
#include <
CE/CE_Context.h
>
19
#include <
CE/CE_OSDEvaluator.h
>
20
#include <
CE/CE_OSDPatchEval.h
>
21
#include <
CE/CE_OSDRefinement.h
>
22
#include <
UT/UT_Array.h
>
23
#include <
UT/UT_Span.h
>
24
#include <
UT/UT_UniquePtr.h
>
25
26
/// GPU-side evaluator for subdivision surface limit attributes.
27
/// Owns topology, evaluator, and cached patch/refined buffers.
28
class
GU_API
GU_OSDEval
29
{
30
public
:
31
~
GU_OSDEval
();
32
33
/// Initialize evaluator kernels for a tuple size.
34
/// Must be called before evaluate().
35
bool
initEvaluator(
36
CE_Context
&context,
37
int
tuple_size);
38
39
/// Build CL topology from an OpenSubdiv TopologyRefiner.
40
/// Caller must call initEvaluator() first.
41
bool
setTopology(
42
const
GU_OSDTopology
&
topology
,
43
CE_Context
&context);
44
45
/// Upload patch coordinates. Call when capture changes.
46
bool
setPatchCoords(
47
UT_Span<const int>
patchFace,
48
UT_Span<const float>
patchU,
49
UT_Span<const float>
patchV);
50
51
/// Evaluate a coarse attribute on the limit surface.
52
/// Call order requirement: initEvaluator() -> setTopology() ->
53
/// setPatchCoords()
54
/// before evaluate().
55
/// setPatchCoords() must be called again after every successful
56
/// setTopology() and whenever the patch face/u/v inputs change.
57
/// If setPatchCoords() captured zero points, evaluate() returns false.
58
/// coarseData is already on GPU (e.g. from GA_CEAttribute::bufferR()).
59
/// outDu/outDv are optional derivative outputs and are caller-owned.
60
bool
evaluate
(
61
const
cl::Buffer
&coarseData,
62
cl::Buffer
&outResult,
63
cl::Buffer
*outDu =
nullptr
,
64
cl::Buffer
*outDv =
nullptr
);
65
66
const
CE_OSDRefinement
*
refinement
()
const
{
return
myRefinement.get(); }
67
68
/// Returns true when evaluator + topology are initialized.
69
/// Patch coordinates are tracked separately via setPatchCoords().
70
bool
isValid
()
const
71
{
72
return
myRefinement && myEvaluator;
73
}
74
75
// In-kernel evaluation support
76
77
/// Stencil-eval coarse -> refined control points.
78
/// Lazily creates/caches evaluator for the given tuple_size.
79
/// refinedOut must be pre-allocated to numRefinedVerts * tuple_size.
80
bool
refineAttribute(
81
CE_Context
&context,
82
const
cl::Buffer
&coarseData,
83
int
tuple_size,
84
CE_FloatArray
&refinedOut);
85
86
int
numFaces
()
const
{
return
myNumFaces; }
87
int
numPatches()
const
;
88
int
numPatchArrays()
const
;
89
90
/// int2[numFaces] table: (firstPatchIdx, patchCount) per coarse face.
91
/// Built on first call, cached until next setTopology().
92
const
cl::Buffer
*faceToPatchBuffer();
93
/// int[numPatchFaces] table mapping patch face -> coarse face id.
94
const
cl::Buffer
*patchToFaceBuffer();
95
96
/// Delegates to CE_OSDRefinement:
97
cl::Buffer
patchArrayBuffer()
const
;
98
cl::Buffer
patchIndexBuffer()
const
;
99
cl::Buffer
patchParamBuffer()
const
;
100
101
102
private
:
103
UT_UniquePtr<CE_OSDRefinement>
myRefinement;
104
UT_UniquePtr<CE_OSDEvaluator>
myEvaluator;
105
CE_OSDPatchCoords
myPatchCoords;
106
CE_FloatArray
myRefinedData;
107
bool
myHasPatchCoords =
false
;
108
109
// In-kernel evaluation state
110
UT_Array<CE_OSDEvaluator>
myEvaluators;
// Cached by tuple size
111
UT_Array<int>
myFaceFirstPatch;
112
CE_Array<int>
myFaceToPatch;
113
CE_Array<int>
myPatchToFace;
114
int
myNumFaces = 0;
115
int
myNumPatches = 0;
116
117
CE_OSDEvaluator
*getOrCreateEvaluator(
118
CE_Context
&context,
int
tuple_size);
119
};
TCB_SPAN_NAMESPACE_NAME::span
Definition:
UT_Span.h:175
CE_Array.h
CE_OSDPatchEval::evaluate
CE_API bool evaluate(const CE_OSDRefinement &topo, const CE_OSDEvaluator &eval, const cl::Buffer &coarse, const CE_OSDPatchCoords &patch_coords, const CE_FloatArray *refined_data, cl::Buffer &out, cl::Buffer *du, cl::Buffer *dv)
CE_Array< float >
CE_OSDRefinement
Definition:
CE_OSDRefinement.h:38
GU_OSDEval::refinement
const CE_OSDRefinement * refinement() const
Definition:
GU_OSDEval.h:66
UT_Array.h
UT_Array< CE_OSDEvaluator >
GU_OSDTopology
Definition:
GU_OSDTopology.h:31
UT_UniquePtr
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition:
UT_UniquePtr.h:39
UT_Span.h
GT_Names::topology
GT_API const UT_StringHolder topology
CE_OSDRefinement.h
GU_OSDEval
Definition:
GU_OSDEval.h:28
GU_API
#define GU_API
Definition:
GU_API.h:14
CE_OSDPatchCoords
Definition:
CE_OSDPatchEval.h:26
GU_OSDTopology.h
CE_OSDEvaluator.h
CE_Context
Definition:
CE_Context.h:88
CE_OSDPatchEval.h
GU_OSDEval::isValid
bool isValid() const
Definition:
GU_OSDEval.h:70
UT_UniquePtr.h
GU_OSDEval::numFaces
int numFaces() const
Definition:
GU_OSDEval.h:86
cl::Buffer
Memory buffer interface.
Definition:
cl.hpp:1867
GU_API.h
CE_Context.h
CE_OSDEvaluator
Definition:
CE_OSDEvaluator.h:21
GU
GU_OSDEval.h
Generated on Sun Jul 19 2026 02:14:40 for HDK by
1.8.6