From d960990063a03903438b1d962123263c0ae67775 Mon Sep 17 00:00:00 2001 From: Takahito Tejima Date: Fri, 28 Mar 2014 12:10:13 -0700 Subject: [PATCH] Remove FarMesh dependency from Osd*Context. The context constructor takes subdivision tables and vertex edit tables directly. --- examples/facePartition/viewer.cpp | 3 +- examples/limitEval/main.cpp | 4 +- examples/osdPolySmooth/osdPolySmooth.cpp | 2 +- examples/simpleCpu/simpleCpuSubdivision.cpp | 3 +- opensubdiv/far/dispatcher.h | 2 +- opensubdiv/far/mesh.h | 2 +- opensubdiv/far/subdivisionTablesFactory.h | 4 +- opensubdiv/far/vertexEditTablesFactory.h | 2 +- opensubdiv/osd/clComputeContext.cpp | 39 +++++++++---------- opensubdiv/osd/clComputeContext.h | 12 ++++-- opensubdiv/osd/cpuComputeContext.cpp | 37 ++++++++---------- opensubdiv/osd/cpuComputeContext.h | 11 ++++-- opensubdiv/osd/cpuEvalLimitContext.cpp | 13 +++---- opensubdiv/osd/cpuEvalLimitContext.h | 10 ++--- opensubdiv/osd/cudaComputeContext.cpp | 36 ++++++++--------- opensubdiv/osd/cudaComputeContext.h | 12 ++++-- opensubdiv/osd/d3d11ComputeContext.cpp | 37 +++++++++--------- opensubdiv/osd/d3d11ComputeContext.h | 13 +++++-- opensubdiv/osd/d3d11DrawContext.h | 2 +- opensubdiv/osd/d3d11DrawRegistry.h | 2 +- opensubdiv/osd/d3d11Mesh.h | 7 +++- opensubdiv/osd/evalLimitContext.cpp | 4 +- opensubdiv/osd/evalLimitContext.h | 4 +- opensubdiv/osd/glDrawContext.h | 2 +- opensubdiv/osd/glDrawRegistry.h | 1 - opensubdiv/osd/glMesh.h | 4 +- opensubdiv/osd/glslComputeContext.cpp | 35 ++++++++--------- opensubdiv/osd/glslComputeContext.h | 13 +++++-- .../glslTransformFeedbackComputeContext.cpp | 35 ++++++++--------- .../osd/glslTransformFeedbackComputeContext.h | 12 ++++-- opensubdiv/osdutil/adaptiveEvaluator.cpp | 8 ++-- opensubdiv/osdutil/batch.h | 2 +- opensubdiv/osdutil/batchCL.h | 2 +- opensubdiv/osdutil/uniformEvaluator.cpp | 2 +- regression/osd_regression/main.cpp | 6 +-- 35 files changed, 201 insertions(+), 182 deletions(-) diff --git a/examples/facePartition/viewer.cpp b/examples/facePartition/viewer.cpp index cf9635c8..f226e71b 100644 --- a/examples/facePartition/viewer.cpp +++ b/examples/facePartition/viewer.cpp @@ -69,7 +69,8 @@ public: int numVertices = farMesh->GetNumVertices(); _vertexBuffer = OpenSubdiv::OsdCpuGLVertexBuffer::Create(3, numVertices); - _computeContext = OpenSubdiv::OsdCpuComputeContext::Create(farMesh); + _computeContext = OpenSubdiv::OsdCpuComputeContext::Create( + farMesh->GetSubdivisionTables(), farMesh->GetVertexEditTables()); _kernelBatches = farMesh->GetKernelBatches(); OpenSubdiv::OsdUtilPatchPartitioner partitioner(farMesh->GetPatchTables(), partitionPerFace); diff --git a/examples/limitEval/main.cpp b/examples/limitEval/main.cpp index f20010ac..55df5c88 100644 --- a/examples/limitEval/main.cpp +++ b/examples/limitEval/main.cpp @@ -518,7 +518,7 @@ createOsdMesh( const std::string &shape, int level, Scheme scheme=kCatmark ) { // Create a Compute context, used to "pose" the vertices delete g_computeCtx; - g_computeCtx = OsdCpuComputeContext::Create(g_fmesh); + g_computeCtx = OsdCpuComputeContext::Create(g_fmesh->GetSubdivisionTables(), g_fmesh->GetVertexEditTables()); g_computeCtrl.Refine( g_computeCtx, g_fmesh->GetKernelBatches(), g_vertexData, g_varyingData ); @@ -526,7 +526,7 @@ createOsdMesh( const std::string &shape, int level, Scheme scheme=kCatmark ) { // Create eval context & data buffers delete g_evalCtx; - g_evalCtx = OsdCpuEvalLimitContext::Create(g_fmesh, /*requireFVarData*/ true); + g_evalCtx = OsdCpuEvalLimitContext::Create(g_fmesh->GetPatchTables(), /*requireFVarData*/ true); delete g_Q; g_Q = OsdCpuGLVertexBuffer::Create(6,nsamples); diff --git a/examples/osdPolySmooth/osdPolySmooth.cpp b/examples/osdPolySmooth/osdPolySmooth.cpp index f46654ce..4b930958 100644 --- a/examples/osdPolySmooth/osdPolySmooth.cpp +++ b/examples/osdPolySmooth/osdPolySmooth.cpp @@ -843,7 +843,7 @@ MStatus OsdPolySmooth::compute( const MPlug& plug, MDataBlock& data ) { static OpenSubdiv::OsdCpuComputeController computeController = OpenSubdiv::OsdCpuComputeController(); OpenSubdiv::OsdCpuComputeController::ComputeContext *computeContext = - OpenSubdiv::OsdCpuComputeController::ComputeContext::Create(farMesh); + OpenSubdiv::OsdCpuComputeController::ComputeContext::Create(farMesh->GetSubdivisionTables(), farMesh->GetVertexEditTables()); OpenSubdiv::OsdCpuVertexBuffer *vertexBuffer = OpenSubdiv::OsdCpuVertexBuffer::Create(numVertexElements, numFarVerts ); diff --git a/examples/simpleCpu/simpleCpuSubdivision.cpp b/examples/simpleCpu/simpleCpuSubdivision.cpp index cf151ab6..2dec440a 100644 --- a/examples/simpleCpu/simpleCpuSubdivision.cpp +++ b/examples/simpleCpu/simpleCpuSubdivision.cpp @@ -338,7 +338,8 @@ createOsdContext(int level) g_farmesh = meshFactory.Create(); - g_osdComputeContext = OpenSubdiv::OsdCpuComputeContext::Create(g_farmesh); + g_osdComputeContext = OpenSubdiv::OsdCpuComputeContext::Create( + g_farmesh->GetSubdivisionTables(), g_farmesh->GetVertexEditTables()); delete hmesh; diff --git a/opensubdiv/far/dispatcher.h b/opensubdiv/far/dispatcher.h index e1f4cb74..82c2da4f 100644 --- a/opensubdiv/far/dispatcher.h +++ b/opensubdiv/far/dispatcher.h @@ -397,7 +397,7 @@ FarComputeController::ApplyVertexEdits(FarKernelBatch const &batch, CONTEXT *con typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0); - FarVertexEditTables const * vertEdit = context->GetVertexEdit(); + FarVertexEditTables const * vertEdit = context->GetVertexEditTables(); if (vertEdit) vertEdit->computeVertexEdits( batch.GetTableIndex(), diff --git a/opensubdiv/far/mesh.h b/opensubdiv/far/mesh.h index 4f10f3c1..e2c21333 100644 --- a/opensubdiv/far/mesh.h +++ b/opensubdiv/far/mesh.h @@ -77,7 +77,7 @@ public: U & GetVertex(int index) { return _vertices[index]; } /// \brief Returns vertex edit tables - FarVertexEditTables const * GetVertexEdit() const { return _vertexEditTables; } + FarVertexEditTables const * GetVertexEditTables() const { return _vertexEditTables; } /// \brief True if the mesh tables support the feature-adaptive mode. bool IsFeatureAdaptive() const { return _patchTables->IsFeatureAdaptive(); } diff --git a/opensubdiv/far/subdivisionTablesFactory.h b/opensubdiv/far/subdivisionTablesFactory.h index 662a22a8..433de257 100644 --- a/opensubdiv/far/subdivisionTablesFactory.h +++ b/opensubdiv/far/subdivisionTablesFactory.h @@ -565,8 +565,8 @@ FarSubdivisionTablesFactory::Splice(FarMeshVector const &meshes, FarKernelB } batches->push_back(batch); } - editTableIndexOffset += meshes[i]->GetVertexEdit() ? - meshes[i]->GetVertexEdit()->GetNumBatches() : 0; + editTableIndexOffset += meshes[i]->GetVertexEditTables() ? + meshes[i]->GetVertexEditTables()->GetNumBatches() : 0; } // count verts offsets diff --git a/opensubdiv/far/vertexEditTablesFactory.h b/opensubdiv/far/vertexEditTablesFactory.h index 721803c8..52dbf1b6 100644 --- a/opensubdiv/far/vertexEditTablesFactory.h +++ b/opensubdiv/far/vertexEditTablesFactory.h @@ -215,7 +215,7 @@ FarVertexEditTablesFactory::Splice(FarMeshVector const &meshes) { // at this moment, don't merge vertex edit tables (separate batch) for (size_t i = 0; i < meshes.size(); ++i) { - const FarVertexEditTables *vertexEditTables = meshes[i]->GetVertexEdit(); + const FarVertexEditTables *vertexEditTables = meshes[i]->GetVertexEditTables(); if (not vertexEditTables) continue; // copy each edit batch XXX:inefficient copy diff --git a/opensubdiv/osd/clComputeContext.cpp b/opensubdiv/osd/clComputeContext.cpp index e57d4747..a02301a7 100644 --- a/opensubdiv/osd/clComputeContext.cpp +++ b/opensubdiv/osd/clComputeContext.cpp @@ -22,7 +22,6 @@ // language governing permissions and limitations under the Apache License. // -#include "../far/mesh.h" #include "../osd/clComputeContext.h" #include "../osd/clKernelBundle.h" @@ -100,34 +99,32 @@ OsdCLHEditTable::GetPrimvarWidth() const { // ---------------------------------------------------------------------------- -OsdCLComputeContext::OsdCLComputeContext(FarMesh const *farMesh, - cl_context clContext) +OsdCLComputeContext::OsdCLComputeContext(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, + cl_context clContext) : _clQueue(NULL), _kernelBundle(NULL) { - FarSubdivisionTables const * farTables = farMesh->GetSubdivisionTables(); - // allocate 5 or 7 tables - _tables.resize(farTables->GetNumTables(), 0); + _tables.resize(subdivisionTables->GetNumTables(), 0); - _tables[FarSubdivisionTables::E_IT] = new OsdCLTable(farTables->Get_E_IT(), clContext); - _tables[FarSubdivisionTables::V_IT] = new OsdCLTable(farTables->Get_V_IT(), clContext); - _tables[FarSubdivisionTables::V_ITa] = new OsdCLTable(farTables->Get_V_ITa(), clContext); - _tables[FarSubdivisionTables::E_W] = new OsdCLTable(farTables->Get_E_W(), clContext); - _tables[FarSubdivisionTables::V_W] = new OsdCLTable(farTables->Get_V_W(), clContext); + _tables[FarSubdivisionTables::E_IT] = new OsdCLTable(subdivisionTables->Get_E_IT(), clContext); + _tables[FarSubdivisionTables::V_IT] = new OsdCLTable(subdivisionTables->Get_V_IT(), clContext); + _tables[FarSubdivisionTables::V_ITa] = new OsdCLTable(subdivisionTables->Get_V_ITa(), clContext); + _tables[FarSubdivisionTables::E_W] = new OsdCLTable(subdivisionTables->Get_E_W(), clContext); + _tables[FarSubdivisionTables::V_W] = new OsdCLTable(subdivisionTables->Get_V_W(), clContext); - if (farTables->GetNumTables() > 5) { - _tables[FarSubdivisionTables::F_IT] = new OsdCLTable(farTables->Get_F_IT(), clContext); - _tables[FarSubdivisionTables::F_ITa] = new OsdCLTable(farTables->Get_F_ITa(), clContext); + if (subdivisionTables->GetNumTables() > 5) { + _tables[FarSubdivisionTables::F_IT] = new OsdCLTable(subdivisionTables->Get_F_IT(), clContext); + _tables[FarSubdivisionTables::F_ITa] = new OsdCLTable(subdivisionTables->Get_F_ITa(), clContext); } // create hedit tables - FarVertexEditTables const *editTables = farMesh->GetVertexEdit(); - if (editTables) { - int numEditBatches = editTables->GetNumBatches(); + if (vertexEditTables) { + int numEditBatches = vertexEditTables->GetNumBatches(); _editTables.reserve(numEditBatches); for (int i = 0; i < numEditBatches; ++i) { const FarVertexEditTables::VertexEditBatch & edit = - editTables->GetBatch(i); + vertexEditTables->GetBatch(i); _editTables.push_back(new OsdCLHEditTable(edit, clContext)); } } @@ -198,9 +195,11 @@ OsdCLComputeContext::GetCommandQueue() const { } OsdCLComputeContext * -OsdCLComputeContext::Create(FarMesh const *farmesh, cl_context clContext) { +OsdCLComputeContext::Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, + cl_context clContext) { - return new OsdCLComputeContext(farmesh, clContext); + return new OsdCLComputeContext(subdivisionTables, vertexEditTables, clContext); } } // end namespace OPENSUBDIV_VERSION diff --git a/opensubdiv/osd/clComputeContext.h b/opensubdiv/osd/clComputeContext.h index a11670be..81109aa1 100644 --- a/opensubdiv/osd/clComputeContext.h +++ b/opensubdiv/osd/clComputeContext.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/subdivisionTables.h" #include "../far/vertexEditTables.h" #include "../osd/vertex.h" #include "../osd/nonCopyable.h" @@ -103,11 +103,14 @@ class OsdCLComputeContext : public OsdNonCopyable { public: /// Creates an OsdCLComputeContext instance /// - /// @param farmesh the FarMesh used for this Context. + /// @param subdivisionTables the FarSubdivisionTables used for this Context. + /// + /// @param vertexEditTables the FarVertexEditTables used for this Context. /// /// @param clContext a valid active OpenCL context /// - static OsdCLComputeContext * Create(FarMesh const *farmesh, + static OsdCLComputeContext * Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, cl_context clContext); /// Destructor @@ -170,7 +173,8 @@ public: void SetCommandQueue(cl_command_queue queue); protected: - explicit OsdCLComputeContext(FarMesh const *farMesh, + explicit OsdCLComputeContext(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, cl_context clContext); private: diff --git a/opensubdiv/osd/cpuComputeContext.cpp b/opensubdiv/osd/cpuComputeContext.cpp index df3aa3ee..cc3ceff2 100644 --- a/opensubdiv/osd/cpuComputeContext.cpp +++ b/opensubdiv/osd/cpuComputeContext.cpp @@ -22,7 +22,6 @@ // language governing permissions and limitations under the Apache License. // -#include "../far/mesh.h" #include "../far/dispatcher.h" #include "../far/subdivisionTables.h" @@ -103,33 +102,30 @@ OsdCpuHEditTable::GetPrimvarWidth() const { return _primvarWidth; } -OsdCpuComputeContext::OsdCpuComputeContext(FarMesh const *farMesh) { - - FarSubdivisionTables const * farTables = - farMesh->GetSubdivisionTables(); +OsdCpuComputeContext::OsdCpuComputeContext(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) { // allocate 5 or 7 tables - _tables.resize(farTables->GetNumTables(), 0); + _tables.resize(subdivisionTables->GetNumTables(), 0); - _tables[FarSubdivisionTables::E_IT] = new OsdCpuTable(farTables->Get_E_IT()); - _tables[FarSubdivisionTables::V_IT] = new OsdCpuTable(farTables->Get_V_IT()); - _tables[FarSubdivisionTables::V_ITa] = new OsdCpuTable(farTables->Get_V_ITa()); - _tables[FarSubdivisionTables::E_W] = new OsdCpuTable(farTables->Get_E_W()); - _tables[FarSubdivisionTables::V_W] = new OsdCpuTable(farTables->Get_V_W()); + _tables[FarSubdivisionTables::E_IT] = new OsdCpuTable(subdivisionTables->Get_E_IT()); + _tables[FarSubdivisionTables::V_IT] = new OsdCpuTable(subdivisionTables->Get_V_IT()); + _tables[FarSubdivisionTables::V_ITa] = new OsdCpuTable(subdivisionTables->Get_V_ITa()); + _tables[FarSubdivisionTables::E_W] = new OsdCpuTable(subdivisionTables->Get_E_W()); + _tables[FarSubdivisionTables::V_W] = new OsdCpuTable(subdivisionTables->Get_V_W()); - if (farTables->GetNumTables() > 5) { - _tables[FarSubdivisionTables::F_IT] = new OsdCpuTable(farTables->Get_F_IT()); - _tables[FarSubdivisionTables::F_ITa] = new OsdCpuTable(farTables->Get_F_ITa()); + if (subdivisionTables->GetNumTables() > 5) { + _tables[FarSubdivisionTables::F_IT] = new OsdCpuTable(subdivisionTables->Get_F_IT()); + _tables[FarSubdivisionTables::F_ITa] = new OsdCpuTable(subdivisionTables->Get_F_ITa()); } // create hedit tables - FarVertexEditTables const *editTables = farMesh->GetVertexEdit(); - if (editTables) { - int numEditBatches = editTables->GetNumBatches(); + if (vertexEditTables) { + int numEditBatches = vertexEditTables->GetNumBatches(); _editTables.reserve(numEditBatches); for (int i = 0; i < numEditBatches; ++i) { const FarVertexEditTables::VertexEditBatch & edit = - editTables->GetBatch(i); + vertexEditTables->GetBatch(i); _editTables.push_back(new OsdCpuHEditTable(edit)); } @@ -179,9 +175,10 @@ OsdCpuComputeContext::GetCurrentVaryingBuffer() const { } OsdCpuComputeContext * -OsdCpuComputeContext::Create(FarMesh const *farmesh) { +OsdCpuComputeContext::Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) { - return new OsdCpuComputeContext(farmesh); + return new OsdCpuComputeContext(subdivisionTables, vertexEditTables); } } // end namespace OPENSUBDIV_VERSION diff --git a/opensubdiv/osd/cpuComputeContext.h b/opensubdiv/osd/cpuComputeContext.h index 7e87c347..88e1f2a2 100644 --- a/opensubdiv/osd/cpuComputeContext.h +++ b/opensubdiv/osd/cpuComputeContext.h @@ -27,7 +27,6 @@ #include "../version.h" -#include "../far/mesh.h" #include "../far/subdivisionTables.h" #include "../far/vertexEditTables.h" #include "../osd/vertex.h" @@ -97,9 +96,12 @@ class OsdCpuComputeContext : OsdNonCopyable { public: /// Creates an OsdCpuComputeContext instance /// - /// @param farmesh the FarMesh used for this Context. + /// @param subdivisionTables the FarSubdivisionTables used for this Context. /// - static OsdCpuComputeContext * Create(FarMesh const *farmesh); + /// @param vertexEditTables the FarVertexEditTables used for this Context. + /// + static OsdCpuComputeContext * Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables); /// Destructor virtual ~OsdCpuComputeContext(); @@ -160,7 +162,8 @@ public: float * GetCurrentVaryingBuffer() const; protected: - explicit OsdCpuComputeContext(FarMesh const *farMesh); + explicit OsdCpuComputeContext(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables); private: std::vector _tables; diff --git a/opensubdiv/osd/cpuEvalLimitContext.cpp b/opensubdiv/osd/cpuEvalLimitContext.cpp index 4effbf34..000f7ac0 100644 --- a/opensubdiv/osd/cpuEvalLimitContext.cpp +++ b/opensubdiv/osd/cpuEvalLimitContext.cpp @@ -34,21 +34,20 @@ namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { OsdCpuEvalLimitContext * -OsdCpuEvalLimitContext::Create(FarMesh const * farmesh, bool requireFVarData) { +OsdCpuEvalLimitContext::Create(FarPatchTables const *patchTables, bool requireFVarData) { - assert(farmesh); + assert(patchTables); // we do not support uniform yet - if (not farmesh->GetPatchTables()) + if (not patchTables->IsFeatureAdaptive()) return NULL; - return new OsdCpuEvalLimitContext(farmesh, requireFVarData); + return new OsdCpuEvalLimitContext(patchTables, requireFVarData); } -OsdCpuEvalLimitContext::OsdCpuEvalLimitContext(FarMesh const * farmesh, bool requireFVarData) : - OsdEvalLimitContext(farmesh) { +OsdCpuEvalLimitContext::OsdCpuEvalLimitContext(FarPatchTables const *patchTables, bool requireFVarData) : + OsdEvalLimitContext(patchTables) { - FarPatchTables const * patchTables = farmesh->GetPatchTables(); assert(patchTables); // copy the data from the FarTables diff --git a/opensubdiv/osd/cpuEvalLimitContext.h b/opensubdiv/osd/cpuEvalLimitContext.h index 9506324a..71465fae 100644 --- a/opensubdiv/osd/cpuEvalLimitContext.h +++ b/opensubdiv/osd/cpuEvalLimitContext.h @@ -42,15 +42,15 @@ class OsdCpuEvalLimitContext : public OsdEvalLimitContext { public: /// \brief Factory - /// Returns an EvalLimitContext from the given farmesh. - /// Note : the farmesh is expected to be feature-adaptive and have ptex + /// Returns an EvalLimitContext from the given far patch tables. + /// Note : the patchtables is expected to be feature-adaptive and have ptex /// coordinates tables. /// - /// @param farmesh a pointer to an initialized farmesh + /// @param patchTables a pointer to an initialized FarPatchTables /// /// @param requireFVarData flag for generating face-varying data /// - static OsdCpuEvalLimitContext * Create(FarMesh const * farmesh, + static OsdCpuEvalLimitContext * Create(FarPatchTables const *patchTables, bool requireFVarData=false); virtual ~OsdCpuEvalLimitContext(); @@ -315,7 +315,7 @@ public: } protected: - explicit OsdCpuEvalLimitContext(FarMesh const * farmesh, bool requireFVarData); + explicit OsdCpuEvalLimitContext(FarPatchTables const *patchTables, bool requireFVarData); private: diff --git a/opensubdiv/osd/cudaComputeContext.cpp b/opensubdiv/osd/cudaComputeContext.cpp index 24a08c14..6ca3daff 100644 --- a/opensubdiv/osd/cudaComputeContext.cpp +++ b/opensubdiv/osd/cudaComputeContext.cpp @@ -22,7 +22,6 @@ // language governing permissions and limitations under the Apache License. // -#include "../far/mesh.h" #include "../osd/cudaComputeContext.h" #include @@ -136,22 +135,21 @@ OsdCudaComputeContext::~OsdCudaComputeContext() { } bool -OsdCudaComputeContext::initialize(FarMesh const *farMesh) { - - FarSubdivisionTables const * farTables = farMesh->GetSubdivisionTables(); +OsdCudaComputeContext::initialize(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) { // allocate 5 or 7 tables - _tables.resize(farTables->GetNumTables(), 0); + _tables.resize(subdivisionTables->GetNumTables(), 0); - _tables[FarSubdivisionTables::E_IT] = OsdCudaTable::Create(farTables->Get_E_IT()); - _tables[FarSubdivisionTables::V_IT] = OsdCudaTable::Create(farTables->Get_V_IT()); - _tables[FarSubdivisionTables::V_ITa] = OsdCudaTable::Create(farTables->Get_V_ITa()); - _tables[FarSubdivisionTables::E_W] = OsdCudaTable::Create(farTables->Get_E_W()); - _tables[FarSubdivisionTables::V_W] = OsdCudaTable::Create(farTables->Get_V_W()); + _tables[FarSubdivisionTables::E_IT] = OsdCudaTable::Create(subdivisionTables->Get_E_IT()); + _tables[FarSubdivisionTables::V_IT] = OsdCudaTable::Create(subdivisionTables->Get_V_IT()); + _tables[FarSubdivisionTables::V_ITa] = OsdCudaTable::Create(subdivisionTables->Get_V_ITa()); + _tables[FarSubdivisionTables::E_W] = OsdCudaTable::Create(subdivisionTables->Get_E_W()); + _tables[FarSubdivisionTables::V_W] = OsdCudaTable::Create(subdivisionTables->Get_V_W()); - if (farTables->GetNumTables() > 5) { - _tables[FarSubdivisionTables::F_IT] = OsdCudaTable::Create(farTables->Get_F_IT()); - _tables[FarSubdivisionTables::F_ITa] = OsdCudaTable::Create(farTables->Get_F_ITa()); + if (subdivisionTables->GetNumTables() > 5) { + _tables[FarSubdivisionTables::F_IT] = OsdCudaTable::Create(subdivisionTables->Get_F_IT()); + _tables[FarSubdivisionTables::F_ITa] = OsdCudaTable::Create(subdivisionTables->Get_F_ITa()); } // error check @@ -162,13 +160,12 @@ OsdCudaComputeContext::initialize(FarMesh const *farMesh) { } // create hedit tables - FarVertexEditTables const *editTables = farMesh->GetVertexEdit(); - if (editTables) { - int numEditBatches = editTables->GetNumBatches(); + if (vertexEditTables) { + int numEditBatches = vertexEditTables->GetNumBatches(); _editTables.reserve(numEditBatches); for (int i = 0; i < numEditBatches; ++i) { const FarVertexEditTables::VertexEditBatch & edit = - editTables->GetBatch(i); + vertexEditTables->GetBatch(i); _editTables.push_back(OsdCudaHEditTable::Create(edit)); } @@ -213,11 +210,12 @@ OsdCudaComputeContext::GetCurrentVaryingBuffer() const { } OsdCudaComputeContext * -OsdCudaComputeContext::Create(FarMesh const *farmesh) { +OsdCudaComputeContext::Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) { OsdCudaComputeContext *result = new OsdCudaComputeContext(); - if (result->initialize(farmesh) == false) { + if (result->initialize(subdivisionTables, vertexEditTables) == false) { delete result; return NULL; } diff --git a/opensubdiv/osd/cudaComputeContext.h b/opensubdiv/osd/cudaComputeContext.h index 72d317f8..b95da713 100644 --- a/opensubdiv/osd/cudaComputeContext.h +++ b/opensubdiv/osd/cudaComputeContext.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/subdivisionTables.h" #include "../far/vertexEditTables.h" #include "../osd/vertex.h" #include "../osd/vertexDescriptor.h" @@ -104,9 +104,12 @@ class OsdCudaComputeContext : public OsdNonCopyable { public: /// Creates an OsdCudaComputeContext instance /// - /// @param farmesh the FarMesh used for this Context. + /// @param subdivisionTables the FarSubdivisionTables used for this Context. /// - static OsdCudaComputeContext * Create(FarMesh const *farmesh); + /// @param vertexEditTables the FarVertexEditTables used for this Context. + /// + static OsdCudaComputeContext * Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables); /// Destructor virtual ~OsdCudaComputeContext(); @@ -178,7 +181,8 @@ public: protected: OsdCudaComputeContext(); - bool initialize(FarMesh const *farMesh); + bool initialize(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables); private: std::vector _tables; diff --git a/opensubdiv/osd/d3d11ComputeContext.cpp b/opensubdiv/osd/d3d11ComputeContext.cpp index d4f6a0e0..8312d5db 100644 --- a/opensubdiv/osd/d3d11ComputeContext.cpp +++ b/opensubdiv/osd/d3d11ComputeContext.cpp @@ -22,8 +22,8 @@ // language governing permissions and limitations under the Apache License. // -#include "../far/mesh.h" #include "../far/subdivisionTables.h" +#include "../far/vertexEditTables.h" #include "../osd/debug.h" #include "../osd/error.h" #include "../osd/d3d11ComputeContext.h" @@ -145,40 +145,39 @@ OsdD3D11ComputeHEditTable::GetPrimvarWidth() const { // ---------------------------------------------------------------------------- OsdD3D11ComputeContext::OsdD3D11ComputeContext( - FarMesh const *farMesh, ID3D11DeviceContext *deviceContext) + FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, + ID3D11DeviceContext *deviceContext) : _deviceContext(deviceContext), _currentVertexBufferUAV(0), _currentVaryingBufferUAV(0) { - FarSubdivisionTables const * farTables = farMesh->GetSubdivisionTables(); - // allocate 5 or 7 tables // XXXtakahito: Although _tables size depends on table type, F_IT is set // to NULL even in loop case, to determine the condition in // bindShaderStorageBuffer()... _tables.resize(7, 0); - _tables[FarSubdivisionTables::E_IT] = new OsdD3D11ComputeTable(farTables->Get_E_IT(), deviceContext, DXGI_FORMAT_R32_SINT); - _tables[FarSubdivisionTables::V_IT] = new OsdD3D11ComputeTable(farTables->Get_V_IT(), deviceContext, DXGI_FORMAT_R32_UINT); - _tables[FarSubdivisionTables::V_ITa] = new OsdD3D11ComputeTable(farTables->Get_V_ITa(), deviceContext, DXGI_FORMAT_R32_SINT); - _tables[FarSubdivisionTables::E_W] = new OsdD3D11ComputeTable(farTables->Get_E_W(), deviceContext, DXGI_FORMAT_R32_FLOAT); - _tables[FarSubdivisionTables::V_W] = new OsdD3D11ComputeTable(farTables->Get_V_W(), deviceContext, DXGI_FORMAT_R32_FLOAT); + _tables[FarSubdivisionTables::E_IT] = new OsdD3D11ComputeTable(subdivisionTables->Get_E_IT(), deviceContext, DXGI_FORMAT_R32_SINT); + _tables[FarSubdivisionTables::V_IT] = new OsdD3D11ComputeTable(subdivisionTables->Get_V_IT(), deviceContext, DXGI_FORMAT_R32_UINT); + _tables[FarSubdivisionTables::V_ITa] = new OsdD3D11ComputeTable(subdivisionTables->Get_V_ITa(), deviceContext, DXGI_FORMAT_R32_SINT); + _tables[FarSubdivisionTables::E_W] = new OsdD3D11ComputeTable(subdivisionTables->Get_E_W(), deviceContext, DXGI_FORMAT_R32_FLOAT); + _tables[FarSubdivisionTables::V_W] = new OsdD3D11ComputeTable(subdivisionTables->Get_V_W(), deviceContext, DXGI_FORMAT_R32_FLOAT); - if (farTables->GetNumTables() > 5) { - _tables[FarSubdivisionTables::F_IT] = new OsdD3D11ComputeTable(farTables->Get_F_IT(), deviceContext, DXGI_FORMAT_R32_UINT); - _tables[FarSubdivisionTables::F_ITa] = new OsdD3D11ComputeTable(farTables->Get_F_ITa(), deviceContext, DXGI_FORMAT_R32_SINT); + if (subdivisionTables->GetNumTables() > 5) { + _tables[FarSubdivisionTables::F_IT] = new OsdD3D11ComputeTable(subdivisionTables->Get_F_IT(), deviceContext, DXGI_FORMAT_R32_UINT); + _tables[FarSubdivisionTables::F_ITa] = new OsdD3D11ComputeTable(subdivisionTables->Get_F_ITa(), deviceContext, DXGI_FORMAT_R32_SINT); } else { _tables[FarSubdivisionTables::F_IT] = NULL; _tables[FarSubdivisionTables::F_ITa] = NULL; } // create hedit tables - FarVertexEditTables const *editTables = farMesh->GetVertexEdit(); - if (editTables) { - int numEditBatches = editTables->GetNumBatches(); + if (vertexEditTables) { + int numEditBatches = vertexEditTables->GetNumBatches(); _editTables.reserve(numEditBatches); for (int i = 0; i < numEditBatches; ++i) { const FarVertexEditTables::VertexEditBatch & edit = - editTables->GetBatch(i); + vertexEditTables->GetBatch(i); _editTables.push_back(new OsdD3D11ComputeHEditTable(edit, deviceContext)); } } @@ -248,9 +247,11 @@ OsdD3D11ComputeContext::SetDeviceContext(ID3D11DeviceContext *deviceContext) { } OsdD3D11ComputeContext * -OsdD3D11ComputeContext::Create(FarMesh const *farmesh, ID3D11DeviceContext *deviceContext) { +OsdD3D11ComputeContext::Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, + ID3D11DeviceContext *deviceContext) { - return new OsdD3D11ComputeContext(farmesh, deviceContext); + return new OsdD3D11ComputeContext(subdivisionTables, vertexEditTables, deviceContext); } void diff --git a/opensubdiv/osd/d3d11ComputeContext.h b/opensubdiv/osd/d3d11ComputeContext.h index 11b48a4b..c5b5d55b 100644 --- a/opensubdiv/osd/d3d11ComputeContext.h +++ b/opensubdiv/osd/d3d11ComputeContext.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/subdivisionTables.h" #include "../far/vertexEditTables.h" #include "../osd/vertex.h" #include "../osd/vertexDescriptor.h" @@ -105,11 +105,14 @@ class OsdD3D11ComputeContext : public OsdNonCopyable { public: /// Creates an OsdD3D11ComputeContext instance /// - /// @param farmesh the FarMesh used for this Context. + /// @param subdivisionTables the FarSubdivisionTables used for this Context. + /// + /// @param vertexEditTables the FarVertexEditTables used for this Context. /// /// @param deviceContext D3D device /// - static OsdD3D11ComputeContext * Create(FarMesh const *farmesh, + static OsdD3D11ComputeContext * Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, ID3D11DeviceContext *deviceContext); /// Destructor @@ -185,7 +188,9 @@ public: void UnbindEditShaderStorageBuffers(); protected: - explicit OsdD3D11ComputeContext(FarMesh const *farMesh, ID3D11DeviceContext *deviceContext); + explicit OsdD3D11ComputeContext(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables, + ID3D11DeviceContext *deviceContext); void bindShaderStorageBuffers(); diff --git a/opensubdiv/osd/d3d11DrawContext.h b/opensubdiv/osd/d3d11DrawContext.h index b255224e..7454c27d 100644 --- a/opensubdiv/osd/d3d11DrawContext.h +++ b/opensubdiv/osd/d3d11DrawContext.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/patchTables.h" #include "../osd/drawContext.h" #include "../osd/vertex.h" diff --git a/opensubdiv/osd/d3d11DrawRegistry.h b/opensubdiv/osd/d3d11DrawRegistry.h index 8a648261..c775df1f 100644 --- a/opensubdiv/osd/d3d11DrawRegistry.h +++ b/opensubdiv/osd/d3d11DrawRegistry.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/patchTables.h" #include "../osd/drawRegistry.h" #include "../osd/vertex.h" diff --git a/opensubdiv/osd/d3d11Mesh.h b/opensubdiv/osd/d3d11Mesh.h index 18c77186..c2d47ce9 100644 --- a/opensubdiv/osd/d3d11Mesh.h +++ b/opensubdiv/osd/d3d11Mesh.h @@ -72,7 +72,8 @@ public: _vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices, pd3d11Device); if (numVaryingElements) _vertexBuffer = VertexBuffer::Create(numVaryingElements, numVertices, pd3d11Device); - _computeContext = ComputeContext::Create(_farMesh); + _computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(), + _farMesh->GetVertexEditTables()); _drawContext = DrawContext::Create(_farMesh->GetPatchTables(), _pd3d11DeviceContext, bits.test(MeshFVarData)); @@ -158,7 +159,9 @@ public: _vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices, pd3d11Device); if (numVaryingElements) _varyingBuffer = VertexBuffer::Create(numVaryingElements, numVertices, pd3d11Device); - _computeContext = ComputeContext::Create(_farMesh, _pd3d11DeviceContext); + _computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(), + _farMesh->GetVertexEditTables(), + _pd3d11DeviceContext); _drawContext = DrawContext::Create(_farMesh->GetPatchTables(), _pd3d11DeviceContext, bits.test(MeshFVarData)); diff --git a/opensubdiv/osd/evalLimitContext.cpp b/opensubdiv/osd/evalLimitContext.cpp index 70364215..a2ee7881 100644 --- a/opensubdiv/osd/evalLimitContext.cpp +++ b/opensubdiv/osd/evalLimitContext.cpp @@ -28,9 +28,9 @@ namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { -OsdEvalLimitContext::OsdEvalLimitContext(FarMesh const * farmesh) { +OsdEvalLimitContext::OsdEvalLimitContext(FarPatchTables const *patchTables) { - _adaptive = farmesh->GetPatchTables()->IsFeatureAdaptive(); + _adaptive = patchTables->IsFeatureAdaptive(); } OsdEvalLimitContext::~OsdEvalLimitContext() { diff --git a/opensubdiv/osd/evalLimitContext.h b/opensubdiv/osd/evalLimitContext.h index 9281dfff..6de904e5 100644 --- a/opensubdiv/osd/evalLimitContext.h +++ b/opensubdiv/osd/evalLimitContext.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/patchTables.h" #include "../osd/nonCopyable.h" #include "../osd/vertex.h" @@ -70,7 +70,7 @@ public: virtual ~OsdEvalLimitContext(); protected: - explicit OsdEvalLimitContext(FarMesh const * farmesh); + explicit OsdEvalLimitContext(FarPatchTables const *patchTables); private: bool _adaptive; diff --git a/opensubdiv/osd/glDrawContext.h b/opensubdiv/osd/glDrawContext.h index dfcdeb53..b69a640d 100644 --- a/opensubdiv/osd/glDrawContext.h +++ b/opensubdiv/osd/glDrawContext.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/patchTables.h" #include "../osd/drawContext.h" #include "../osd/drawRegistry.h" #include "../osd/vertex.h" diff --git a/opensubdiv/osd/glDrawRegistry.h b/opensubdiv/osd/glDrawRegistry.h index 980cc215..403cc838 100644 --- a/opensubdiv/osd/glDrawRegistry.h +++ b/opensubdiv/osd/glDrawRegistry.h @@ -27,7 +27,6 @@ #include "../version.h" -#include "../far/mesh.h" #include "../osd/drawRegistry.h" #include "../osd/vertex.h" diff --git a/opensubdiv/osd/glMesh.h b/opensubdiv/osd/glMesh.h index e1849729..ef06d7b5 100644 --- a/opensubdiv/osd/glMesh.h +++ b/opensubdiv/osd/glMesh.h @@ -143,7 +143,7 @@ private: _vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices); if (numVaryingElements) _varyingBuffer = VertexBuffer::Create(numVaryingElements, numVertices); - _computeContext = ComputeContext::Create(_farMesh); + _computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(), _farMesh->GetVertexEditTables()); _drawContext = DrawContext::Create(_farMesh->GetPatchTables(), bits.test(MeshFVarData)); _drawContext->UpdateVertexTexture(_vertexBuffer); } @@ -264,7 +264,7 @@ private: _vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices, _clContext); if (numVaryingElements) _varyingBuffer = VertexBuffer::Create(numVaryingElements, numVertices, _clContext); - _computeContext = ComputeContext::Create(_farMesh, _clContext); + _computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(), _farMesh->GetVertexEditTables(), _clContext); _drawContext = DrawContext::Create(_farMesh->GetPatchTables(), bits.test(MeshFVarData)); _drawContext->UpdateVertexTexture(_vertexBuffer); } diff --git a/opensubdiv/osd/glslComputeContext.cpp b/opensubdiv/osd/glslComputeContext.cpp index 3f865cd4..b304d786 100644 --- a/opensubdiv/osd/glslComputeContext.cpp +++ b/opensubdiv/osd/glslComputeContext.cpp @@ -22,7 +22,6 @@ // language governing permissions and limitations under the Apache License. // -#include "../far/mesh.h" #include "../osd/debug.h" #include "../osd/error.h" #include "../osd/glslComputeContext.h" @@ -110,28 +109,26 @@ OsdGLSLComputeHEditTable::GetPrimvarWidth() const { // ---------------------------------------------------------------------------- OsdGLSLComputeContext::OsdGLSLComputeContext( - FarMesh const *farMesh) + FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) : _vertexTexture(0), _varyingTexture(0) { - FarSubdivisionTables const * farTables = - farMesh->GetSubdivisionTables(); - // allocate 5 or 7 tables // XXXtakahito: Although _tables size depends on table type, F_IT is set // to NULL even in loop case, to determine the condition in // bindShaderStorageBuffer()... _tables.resize(7, 0); - _tables[FarSubdivisionTables::E_IT] = new OsdGLSLComputeTable(farTables->Get_E_IT()); - _tables[FarSubdivisionTables::V_IT] = new OsdGLSLComputeTable(farTables->Get_V_IT()); - _tables[FarSubdivisionTables::V_ITa] = new OsdGLSLComputeTable(farTables->Get_V_ITa()); - _tables[FarSubdivisionTables::E_W] = new OsdGLSLComputeTable(farTables->Get_E_W()); - _tables[FarSubdivisionTables::V_W] = new OsdGLSLComputeTable(farTables->Get_V_W()); + _tables[FarSubdivisionTables::E_IT] = new OsdGLSLComputeTable(subdivisionTables->Get_E_IT()); + _tables[FarSubdivisionTables::V_IT] = new OsdGLSLComputeTable(subdivisionTables->Get_V_IT()); + _tables[FarSubdivisionTables::V_ITa] = new OsdGLSLComputeTable(subdivisionTables->Get_V_ITa()); + _tables[FarSubdivisionTables::E_W] = new OsdGLSLComputeTable(subdivisionTables->Get_E_W()); + _tables[FarSubdivisionTables::V_W] = new OsdGLSLComputeTable(subdivisionTables->Get_V_W()); - if (farTables->GetNumTables() > 5) { + if (subdivisionTables->GetNumTables() > 5) { // catmark, bilinear - _tables[FarSubdivisionTables::F_IT] = new OsdGLSLComputeTable(farTables->Get_F_IT()); - _tables[FarSubdivisionTables::F_ITa] = new OsdGLSLComputeTable(farTables->Get_F_ITa()); + _tables[FarSubdivisionTables::F_IT] = new OsdGLSLComputeTable(subdivisionTables->Get_F_IT()); + _tables[FarSubdivisionTables::F_ITa] = new OsdGLSLComputeTable(subdivisionTables->Get_F_ITa()); } else { // loop _tables[FarSubdivisionTables::F_IT] = NULL; @@ -139,13 +136,12 @@ OsdGLSLComputeContext::OsdGLSLComputeContext( } // create hedit tables - FarVertexEditTables const *editTables = farMesh->GetVertexEdit(); - if (editTables) { - int numEditBatches = editTables->GetNumBatches(); + if (vertexEditTables) { + int numEditBatches = vertexEditTables->GetNumBatches(); _editTables.reserve(numEditBatches); for (int i = 0; i < numEditBatches; ++i) { const FarVertexEditTables::VertexEditBatch & edit = - editTables->GetBatch(i); + vertexEditTables->GetBatch(i); _editTables.push_back(new OsdGLSLComputeHEditTable(edit)); } } @@ -205,9 +201,10 @@ OsdGLSLComputeContext::SetKernelBundle( } OsdGLSLComputeContext * -OsdGLSLComputeContext::Create(FarMesh const *farmesh) { +OsdGLSLComputeContext::Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) { - return new OsdGLSLComputeContext(farmesh); + return new OsdGLSLComputeContext(subdivisionTables, vertexEditTables); } void diff --git a/opensubdiv/osd/glslComputeContext.h b/opensubdiv/osd/glslComputeContext.h index b9454166..1bdef708 100644 --- a/opensubdiv/osd/glslComputeContext.h +++ b/opensubdiv/osd/glslComputeContext.h @@ -27,7 +27,8 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/subdivisionTables.h" +#include "../far/vertexEditTables.h" #include "../far/vertexEditTables.h" #include "../osd/vertex.h" #include "../osd/vertexDescriptor.h" @@ -102,9 +103,12 @@ class OsdGLSLComputeContext { public: /// Creates an OsdGLSLComputeContext instance /// - /// @param farmesh the FarMesh used for this Context. + /// @param subdivisionTables the FarSubdivisionTables used for this Context. /// - static OsdGLSLComputeContext * Create(FarMesh const *farmesh); + /// @param vertexEditTables the FarVertexEditTables used for this Context. + /// + static OsdGLSLComputeContext * Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables); /// Destructor virtual ~OsdGLSLComputeContext(); @@ -197,7 +201,8 @@ public: void UnbindEditShaderStorageBuffers(); protected: - explicit OsdGLSLComputeContext(FarMesh const *farMesh); + explicit OsdGLSLComputeContext(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables); void bindShaderStorageBuffers(); diff --git a/opensubdiv/osd/glslTransformFeedbackComputeContext.cpp b/opensubdiv/osd/glslTransformFeedbackComputeContext.cpp index fe6a5024..9c47d1f5 100644 --- a/opensubdiv/osd/glslTransformFeedbackComputeContext.cpp +++ b/opensubdiv/osd/glslTransformFeedbackComputeContext.cpp @@ -24,7 +24,6 @@ #include "../version.h" -#include "../far/mesh.h" #include "../far/subdivisionTables.h" #include "../osd/debug.h" #include "../osd/glslTransformFeedbackComputeContext.h" @@ -118,25 +117,23 @@ OsdGLSLTransformFeedbackHEditTable::GetPrimvarWidth() const { // ---------------------------------------------------------------------------- OsdGLSLTransformFeedbackComputeContext::OsdGLSLTransformFeedbackComputeContext( - FarMesh const *farMesh) : + FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) : _vertexTexture(0), _varyingTexture(0) { - FarSubdivisionTables const * farTables = - farMesh->GetSubdivisionTables(); - // allocate 5 or 7 tables _tables.resize(7, 0); - _tables[FarSubdivisionTables::E_IT] = new OsdGLSLTransformFeedbackTable(farTables->Get_E_IT(), GL_R32I); - _tables[FarSubdivisionTables::V_IT] = new OsdGLSLTransformFeedbackTable(farTables->Get_V_IT(), GL_R32UI); - _tables[FarSubdivisionTables::V_ITa] = new OsdGLSLTransformFeedbackTable(farTables->Get_V_ITa(), GL_R32I); - _tables[FarSubdivisionTables::E_W] = new OsdGLSLTransformFeedbackTable(farTables->Get_E_W(), GL_R32F); - _tables[FarSubdivisionTables::V_W] = new OsdGLSLTransformFeedbackTable(farTables->Get_V_W(), GL_R32F); + _tables[FarSubdivisionTables::E_IT] = new OsdGLSLTransformFeedbackTable(subdivisionTables->Get_E_IT(), GL_R32I); + _tables[FarSubdivisionTables::V_IT] = new OsdGLSLTransformFeedbackTable(subdivisionTables->Get_V_IT(), GL_R32UI); + _tables[FarSubdivisionTables::V_ITa] = new OsdGLSLTransformFeedbackTable(subdivisionTables->Get_V_ITa(), GL_R32I); + _tables[FarSubdivisionTables::E_W] = new OsdGLSLTransformFeedbackTable(subdivisionTables->Get_E_W(), GL_R32F); + _tables[FarSubdivisionTables::V_W] = new OsdGLSLTransformFeedbackTable(subdivisionTables->Get_V_W(), GL_R32F); - if (farTables->GetNumTables() > 5) { + if (subdivisionTables->GetNumTables() > 5) { // catmark, bilinear - _tables[FarSubdivisionTables::F_IT] = new OsdGLSLTransformFeedbackTable(farTables->Get_F_IT(), GL_R32UI); - _tables[FarSubdivisionTables::F_ITa] = new OsdGLSLTransformFeedbackTable(farTables->Get_F_ITa(), GL_R32I); + _tables[FarSubdivisionTables::F_IT] = new OsdGLSLTransformFeedbackTable(subdivisionTables->Get_F_IT(), GL_R32UI); + _tables[FarSubdivisionTables::F_ITa] = new OsdGLSLTransformFeedbackTable(subdivisionTables->Get_F_ITa(), GL_R32I); } else { // loop _tables[FarSubdivisionTables::F_IT] = NULL; @@ -144,12 +141,11 @@ OsdGLSLTransformFeedbackComputeContext::OsdGLSLTransformFeedbackComputeContext( } // create hedit tables - FarVertexEditTables const *editTables = farMesh->GetVertexEdit(); - if (editTables) { - int numEditBatches = editTables->GetNumBatches(); + if (vertexEditTables) { + int numEditBatches = vertexEditTables->GetNumBatches(); _editTables.reserve(numEditBatches); for (int i = 0; i < numEditBatches; ++i) { - const FarVertexEditTables::VertexEditBatch & edit = editTables->GetBatch(i); + const FarVertexEditTables::VertexEditBatch & edit = vertexEditTables->GetBatch(i); _editTables.push_back(new OsdGLSLTransformFeedbackHEditTable(edit)); } } @@ -210,9 +206,10 @@ OsdGLSLTransformFeedbackComputeContext::SetKernelBundle(OsdGLSLTransformFeedback } OsdGLSLTransformFeedbackComputeContext * -OsdGLSLTransformFeedbackComputeContext::Create(FarMesh const *farmesh) { +OsdGLSLTransformFeedbackComputeContext::Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTables) { - return new OsdGLSLTransformFeedbackComputeContext(farmesh); + return new OsdGLSLTransformFeedbackComputeContext(subdivisionTables, vertexEditTables); } void diff --git a/opensubdiv/osd/glslTransformFeedbackComputeContext.h b/opensubdiv/osd/glslTransformFeedbackComputeContext.h index 55677d69..6d17ce4d 100644 --- a/opensubdiv/osd/glslTransformFeedbackComputeContext.h +++ b/opensubdiv/osd/glslTransformFeedbackComputeContext.h @@ -27,7 +27,7 @@ #include "../version.h" -#include "../far/mesh.h" +#include "../far/subdivisionTables.h" #include "../far/vertexEditTables.h" #include "../osd/vertex.h" #include "../osd/vertexDescriptor.h" @@ -99,9 +99,12 @@ class OsdGLSLTransformFeedbackComputeContext { public: /// Creates an OsdGLSLTransformFeedbackComputeContext instance /// - /// @param farmesh the FarMesh used for this Context. + /// @param subdivisionTables the FarSubdivisionTables used for this Context. /// - static OsdGLSLTransformFeedbackComputeContext * Create(FarMesh const *farmesh); + /// @param vertexEditTables the FarVertexEditTables used for this Context. + /// + static OsdGLSLTransformFeedbackComputeContext * Create(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTabes); /// Destructor virtual ~OsdGLSLTransformFeedbackComputeContext(); @@ -171,7 +174,8 @@ public: void UnbindEditTextures(); protected: - explicit OsdGLSLTransformFeedbackComputeContext(FarMesh const *farMesh); + explicit OsdGLSLTransformFeedbackComputeContext(FarSubdivisionTables const *subdivisionTables, + FarVertexEditTables const *vertexEditTabes); void bindTexture(GLint samplerUniform, GLuint texture, int unit); diff --git a/opensubdiv/osdutil/adaptiveEvaluator.cpp b/opensubdiv/osdutil/adaptiveEvaluator.cpp index b49d87a4..1f98c51f 100644 --- a/opensubdiv/osdutil/adaptiveEvaluator.cpp +++ b/opensubdiv/osdutil/adaptiveEvaluator.cpp @@ -126,7 +126,8 @@ OsdUtilAdaptiveEvaluator::Initialize( } - _computeContext = OsdCpuComputeContext::Create(fmesh); + _computeContext = OsdCpuComputeContext::Create(fmesh->GetSubdivisionTables(), + fmesh->GetVertexEditTables()); // Three elements (x/y/z) per refined point at every subdivision level // defined by the farMesh. The coarse vertices seed the beginning of @@ -156,14 +157,15 @@ OsdUtilAdaptiveEvaluator::Initialize( */ // A context object used to store data used in refinement - _computeContext = OsdCpuComputeContext::Create(fmesh); + _computeContext = OsdCpuComputeContext::Create(fmesh->GetSubdivisionTables(), + fmesh->GetVertexEditTables()); // A context object used to store data used in fast limit surface // evaluation. This contains vectors of patches and associated // tables pulled and computed from the adaptive farMesh. // It also holds onto vertex buffer data through binds _evalLimitContext = OsdCpuEvalLimitContext::Create( - fmesh, /*requierFVarData*/ false); + fmesh->GetPatchTables(), /*requierFVarData*/ false); // A buffer with one float per target point to use when // evaluating interpolated weights diff --git a/opensubdiv/osdutil/batch.h b/opensubdiv/osdutil/batch.h index 3961553a..1c2f5ec0 100644 --- a/opensubdiv/osdutil/batch.h +++ b/opensubdiv/osdutil/batch.h @@ -359,7 +359,7 @@ OsdUtilMeshBatch::initialize(Co Base::setKernelBatches(farMultiMesh->GetKernelBatches()); // create compute contexts - _computeContext = ComputeContext::Create(farMultiMesh); + _computeContext = ComputeContext::Create(farMultiMesh->GetSubdivisionTables(), farMultiMesh->GetVertexEditTables()); if (not _computeContext) return false; diff --git a/opensubdiv/osdutil/batchCL.h b/opensubdiv/osdutil/batchCL.h index a3d2c714..912155d9 100644 --- a/opensubdiv/osdutil/batchCL.h +++ b/opensubdiv/osdutil/batchCL.h @@ -156,7 +156,7 @@ OsdUtilMeshBatch::initializ Base::setKernelBatches(farMultiMesh->GetKernelBatches()); // create compute contexts - _computeContext = ComputeContext::Create(farMultiMesh, _computeController->GetContext()); + _computeContext = ComputeContext::Create(farMultiMesh->GetSubdivisionTables(), farMultiMesh->GetVertexEditTables(), _computeController->GetContext()); if (not _computeContext) return false; diff --git a/opensubdiv/osdutil/uniformEvaluator.cpp b/opensubdiv/osdutil/uniformEvaluator.cpp index f774d70f..63183f3f 100644 --- a/opensubdiv/osdutil/uniformEvaluator.cpp +++ b/opensubdiv/osdutil/uniformEvaluator.cpp @@ -136,7 +136,7 @@ OsdUtilUniformEvaluator::Initialize( return true; } - _computeContext = OsdCpuComputeContext::Create(fmesh); + _computeContext = OsdCpuComputeContext::Create(fmesh->GetSubdivisionTables(), fmesh->GetVertexEditTables()); // Three elements per refined point _vertexBuffer = OsdCpuVertexBuffer::Create( diff --git a/regression/osd_regression/main.cpp b/regression/osd_regression/main.cpp index 8d5f3bec..39321fca 100644 --- a/regression/osd_regression/main.cpp +++ b/regression/osd_regression/main.cpp @@ -315,7 +315,7 @@ checkMeshCPU( OpenSubdiv::FarMesh* farmesh, static OpenSubdiv::OsdCpuComputeController *controller = new OpenSubdiv::OsdCpuComputeController(); - OpenSubdiv::OsdCpuComputeContext *context = OpenSubdiv::OsdCpuComputeContext::Create(farmesh); + OpenSubdiv::OsdCpuComputeContext *context = OpenSubdiv::OsdCpuComputeContext::Create(farmesh->GetSubdivisionTables(), farmesh->GetVertexEditTables()); OpenSubdiv::OsdCpuVertexBuffer * vb = OpenSubdiv::OsdCpuVertexBuffer::Create(3, farmesh->GetNumVertices()); @@ -335,7 +335,7 @@ checkMeshCPUGL( OpenSubdiv::FarMesh* farmesh, static OpenSubdiv::OsdCpuComputeController *controller = new OpenSubdiv::OsdCpuComputeController(); - OpenSubdiv::OsdCpuComputeContext *context = OpenSubdiv::OsdCpuComputeContext::Create(farmesh); + OpenSubdiv::OsdCpuComputeContext *context = OpenSubdiv::OsdCpuComputeContext::Create(farmesh->GetSubdivisionTables(), farmesh->GetVertexEditTables()); OpenSubdiv::OsdCpuGLVertexBuffer * vb = OpenSubdiv::OsdCpuGLVertexBuffer::Create(3, farmesh->GetNumVertices()); @@ -357,7 +357,7 @@ checkMeshCL( OpenSubdiv::FarMesh* farmesh, static OpenSubdiv::OsdCLComputeController *controller = new OpenSubdiv::OsdCLComputeController(g_clContext, g_clQueue); - OpenSubdiv::OsdCLComputeContext *context = OpenSubdiv::OsdCLComputeContext::Create(farmesh, g_clContext); + OpenSubdiv::OsdCLComputeContext *context = OpenSubdiv::OsdCLComputeContext::Create(farmesh->GetSubdivisionTables(), farmesh->GetVertexEditTables(), g_clContext); OpenSubdiv::OsdCLGLVertexBuffer * vb = OpenSubdiv::OsdCLGLVertexBuffer::Create(3, farmesh->GetNumVertices(), g_clContext);