OpenSubdiv
Loading...
Searching...
No Matches
clPatchTable.h
Go to the documentation of this file.
1//
2// Copyright 2015 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_CL_PATCH_TABLE_H
9#define OPENSUBDIV3_OSD_CL_PATCH_TABLE_H
10
11#include "../version.h"
12
13#include "../osd/opencl.h"
14#include "../osd/nonCopyable.h"
15#include "../osd/types.h"
16
17#include <vector>
18
19namespace OpenSubdiv {
20namespace OPENSUBDIV_VERSION {
21
22namespace Far{
23 class PatchTable;
24};
25
26namespace Osd {
27
35class CLPatchTable : private NonCopyable<CLPatchTable> {
36public:
38 static CLPatchTable *Create(Far::PatchTable const *patchTable,
39 cl_context clContext);
40
41 template <typename DEVICE_CONTEXT>
42 static CLPatchTable * Create(Far::PatchTable const *patchTable,
43 DEVICE_CONTEXT context) {
44 return Create(patchTable, context->GetContext());
45 }
46
49
51 cl_mem GetPatchArrayBuffer() const { return _patchArrays; }
52
54 cl_mem GetPatchIndexBuffer() const { return _indexBuffer; }
55
57 cl_mem GetPatchParamBuffer() const { return _patchParamBuffer; }
58
61
64
66 int GetNumFVarChannels() const { return (int)_fvarPatchArrays.size(); }
67
69 cl_mem GetFVarPatchArrayBuffer(int fvarChannel = 0) const { return _fvarPatchArrays[fvarChannel]; }
70
72 cl_mem GetFVarPatchIndexBuffer(int fvarChannel = 0) const { return _fvarIndexBuffers[fvarChannel]; }
73
75 cl_mem GetFVarPatchParamBuffer(int fvarChannel = 0) const { return _fvarParamBuffers[fvarChannel]; }
76
77protected:
79
80 bool allocate(Far::PatchTable const *patchTable, cl_context clContext);
81
85
88
89 std::vector<cl_mem> _fvarPatchArrays;
90 std::vector<cl_mem> _fvarIndexBuffers;
91 std::vector<cl_mem> _fvarParamBuffers;
92
93};
94
95} // end namespace Osd
96
97} // end namespace OPENSUBDIV_VERSION
98using namespace OPENSUBDIV_VERSION;
99
100} // end namespace OpenSubdiv
101
102#endif // OPENSUBDIV3_OSD_CL_PATCH_TABLE_H
Container for arrays of parametric patches.
Definition patchTable.h:38
cl_mem GetPatchParamBuffer() const
Returns the CL memory of the array of Osd::PatchParam buffer.
cl_mem GetFVarPatchArrayBuffer(int fvarChannel=0) const
Returns the CL memory of the array of Osd::PatchArray buffer.
cl_mem GetPatchArrayBuffer() const
Returns the CL memory of the array of Osd::PatchArray buffer.
static CLPatchTable * Create(Far::PatchTable const *patchTable, cl_context clContext)
Creator. Returns NULL if error.
cl_mem GetFVarPatchIndexBuffer(int fvarChannel=0) const
Returns the CL memory of the face-varying control vertices.
cl_mem GetVaryingPatchIndexBuffer() const
Returns the CL memory of the varying control vertices.
int GetNumFVarChannels() const
Returns the number of face-varying channel buffers.
cl_mem GetPatchIndexBuffer() const
Returns the CL memory of the patch control vertices.
static CLPatchTable * Create(Far::PatchTable const *patchTable, DEVICE_CONTEXT context)
cl_mem GetFVarPatchParamBuffer(int fvarChannel=0) const
Returns the CL memory of the array of Osd::PatchParam buffer.
bool allocate(Far::PatchTable const *patchTable, cl_context clContext)
cl_mem GetVaryingPatchArrayBuffer() const
Returns the CL memory of the array of Osd::PatchArray buffer.