Blender V5.0
gpu_patch_table.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Foundation
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
9#include <opensubdiv/version.h>
10
11#include <opensubdiv/osd/nonCopyable.h>
12#include <opensubdiv/osd/types.h>
13
14using OpenSubdiv::Far::PatchTable;
15using OpenSubdiv::Osd::NonCopyable;
16using OpenSubdiv::Osd::PatchArrayVector;
17
18namespace blender::opensubdiv {
19
20// TODO: use Blenlib NonCopyable.
21class GPUPatchTable : private OpenSubdiv::Osd::NonCopyable<GPUPatchTable> {
22 public:
24
25 static GPUPatchTable *Create(PatchTable const *farPatchTable, void *deviceContext = NULL);
26
28 PatchArrayVector const &GetPatchArrays() const
29 {
30 return _patchArrays;
31 }
32
38
44
46 PatchArrayVector const &GetVaryingPatchArrays() const
47 {
49 }
50
56
59 {
60 return (int)_fvarPatchArrays.size();
61 }
62
64 PatchArrayVector const &GetFVarPatchArrays(int fvarChannel = 0) const
65 {
66 return _fvarPatchArrays[fvarChannel];
67 }
68
70 gpu::StorageBuf *GetFVarPatchIndexBuffer(int fvarChannel = 0) const
71 {
72 return _fvarIndexBuffers[fvarChannel];
73 }
74
76 gpu::StorageBuf *GetFVarPatchParamBuffer(int fvarChannel = 0) const
77 {
78 return _fvarParamBuffers[fvarChannel];
79 }
80
81 protected:
83
84 // allocate buffers from patchTable
85 bool allocate(PatchTable const *farPatchTable);
86
87 PatchArrayVector _patchArrays;
88
91
92 PatchArrayVector _varyingPatchArrays;
94
95 std::vector<PatchArrayVector> _fvarPatchArrays;
96 std::vector<gpu::StorageBuf *> _fvarIndexBuffers;
97 std::vector<gpu::StorageBuf *> _fvarParamBuffers;
98};
99
100} // namespace blender::opensubdiv
std::vector< gpu::StorageBuf * > _fvarParamBuffers
PatchArrayVector const & GetVaryingPatchArrays() const
Returns the patch arrays for varying index buffer data.
std::vector< gpu::StorageBuf * > _fvarIndexBuffers
gpu::StorageBuf * GetFVarPatchParamBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying patch params.
static GPUPatchTable * Create(PatchTable const *farPatchTable, void *deviceContext=NULL)
PatchArrayVector const & GetFVarPatchArrays(int fvarChannel=0) const
Returns the patch arrays for face-varying index buffer data.
gpu::StorageBuf * GetPatchParamBuffer() const
Returns the GL index buffer containing the patch parameter.
PatchArrayVector const & GetPatchArrays() const
Returns the patch arrays for vertex index buffer data.
bool allocate(PatchTable const *farPatchTable)
gpu::StorageBuf * GetFVarPatchIndexBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying control vertices.
gpu::StorageBuf * GetPatchIndexBuffer() const
Returns the GL index buffer containing the patch control vertices.
gpu::StorageBuf * GetVaryingPatchIndexBuffer() const
Returns the GL index buffer containing the varying control vertices.
std::vector< PatchArrayVector > _fvarPatchArrays
int GetNumFVarChannels() const
Returns the number of face-varying channel buffers.