// // Copyright 2013 Pixar // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License // and the following modification to it: Section 6 Trademarks. // deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the // trade names, trademarks, service marks, or product names of the // Licensor and its affiliates, except as required for reproducing // the content of the NOTICE file. // // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific // language governing permissions and limitations under the // License. // #include "../osd/cpuComputeContext.h" #include "../osd/gcdComputeController.h" #include "../osd/gcdKernel.h" namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { OsdGcdComputeController::OsdGcdComputeController() { _gcd_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); } void OsdGcdComputeController::ApplyBilinearFaceVerticesKernel( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeFace( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(), (const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyBilinearEdgeVerticesKernel( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeBilinearEdge( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyBilinearVertexVerticesKernel( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeBilinearVertex( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyCatmarkFaceVerticesKernel( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeFace( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(), (const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyCatmarkEdgeVerticesKernel( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeEdge( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelB( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeVertexB( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelA1( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeVertexA( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false, _gcd_queue); } void OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelA2( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeVertexA( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true, _gcd_queue); } void OsdGcdComputeController::ApplyLoopEdgeVerticesKernel( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeEdge( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyLoopVertexVerticesKernelB( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeLoopVertexB( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), _gcd_queue); } void OsdGcdComputeController::ApplyLoopVertexVerticesKernelA1( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeVertexA( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false, _gcd_queue); } void OsdGcdComputeController::ApplyLoopVertexVerticesKernelA2( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); OsdGcdComputeVertexA( context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), context->GetCurrentVaryingBuffer(), (const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(), (const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true, _gcd_queue); } void OsdGcdComputeController::ApplyVertexEdits( FarKernelBatch const &batch, void * clientdata) const { OsdCpuComputeContext * context = static_cast(clientdata); assert(context); const OsdCpuHEditTable *edit = context->GetEditTable(batch.GetTableIndex()); assert(edit); const OsdCpuTable * primvarIndices = edit->GetPrimvarIndices(); const OsdCpuTable * editValues = edit->GetEditValues(); if (edit->GetOperation() == FarVertexEdit::Add) { OsdGcdEditVertexAdd(context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), edit->GetPrimvarOffset(), edit->GetPrimvarWidth(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), static_cast(primvarIndices->GetBuffer()), static_cast(editValues->GetBuffer()), _gcd_queue); } else if (edit->GetOperation() == FarVertexEdit::Set) { OsdGcdEditVertexSet(context->GetVertexDescriptor(), context->GetCurrentVertexBuffer(), edit->GetPrimvarOffset(), edit->GetPrimvarWidth(), batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), static_cast(primvarIndices->GetBuffer()), static_cast(editValues->GetBuffer()), _gcd_queue); } } void OsdGcdComputeController::Synchronize() { } } // end namespace OPENSUBDIV_VERSION } // end namespace OpenSubdiv