2013-02-02 20:53:33 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2013-02-02 20:53:33 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
// with the following modification; you may not use this file except in
|
|
|
|
// compliance with the Apache License and the following modification to it:
|
|
|
|
// Section 6. Trademarks. is deleted and replaced with:
|
2013-02-02 20:53:33 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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 to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2013-02-02 20:53:33 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2013-02-02 20:53:33 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the Apache License with the above modification is
|
|
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the Apache License for the specific
|
|
|
|
// language governing permissions and limitations under the Apache License.
|
2013-02-02 20:53:33 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "../osd/cpuComputeContext.h"
|
|
|
|
#include "../osd/gcdComputeController.h"
|
2013-03-08 01:50:15 +00:00
|
|
|
#include "../osd/gcdKernel.h"
|
2013-02-02 20:53:33 +00:00
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
|
|
|
|
2014-05-09 00:20:54 +00:00
|
|
|
OsdGcdComputeController::OsdGcdComputeController() {
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
2013-02-02 20:53:33 +00:00
|
|
|
}
|
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
void
|
2014-03-19 18:51:54 +00:00
|
|
|
OsdGcdComputeController::ApplyBilinearFaceVerticesKernel(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeFace(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
|
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyBilinearEdgeVerticesKernel(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeBilinearEdge(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyBilinearVertexVerticesKernel(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeBilinearVertex(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkFaceVerticesKernel(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeFace(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
|
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-13 23:06:58 +00:00
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkQuadFaceVerticesKernel(
|
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeQuadFace(
|
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
|
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
|
|
|
_gcd_queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkTriQuadFaceVerticesKernel(
|
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeTriQuadFace(
|
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
|
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
|
|
|
_gcd_queue);
|
|
|
|
}
|
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkEdgeVerticesKernel(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeEdge(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 22:25:54 +00:00
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkRestrictedEdgeVerticesKernel(
|
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeRestrictedEdge(
|
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
|
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
|
|
|
_gcd_queue);
|
|
|
|
}
|
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelB(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeVertexB(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
|
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelA1(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeVertexA(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false,
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelA2(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeVertexA(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true,
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyLoopEdgeVerticesKernel(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeEdge(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyLoopVertexVerticesKernelB(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeLoopVertexB(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
|
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyLoopVertexVerticesKernelA1(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeVertexA(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false,
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyLoopVertexVerticesKernelA2(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
|
|
|
OsdGcdComputeVertexA(
|
2014-05-09 00:20:54 +00:00
|
|
|
_currentBindState.vertexBuffer, _currentBindState.varyingBuffer,
|
|
|
|
_currentBindState.vertexDesc, _currentBindState.varyingDesc,
|
2014-03-19 18:44:51 +00:00
|
|
|
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
|
|
|
|
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true,
|
2013-03-08 06:43:47 +00:00
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OsdGcdComputeController::ApplyVertexEdits(
|
2014-05-06 15:53:36 +00:00
|
|
|
FarKernelBatch const &batch, OsdCpuComputeContext const *context) const {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
assert(context);
|
|
|
|
|
2013-05-07 06:17:36 +00:00
|
|
|
const OsdCpuHEditTable *edit = context->GetEditTable(batch.GetTableIndex());
|
2013-03-08 01:50:15 +00:00
|
|
|
assert(edit);
|
|
|
|
|
|
|
|
const OsdCpuTable * primvarIndices = edit->GetPrimvarIndices();
|
|
|
|
const OsdCpuTable * editValues = edit->GetEditValues();
|
|
|
|
|
|
|
|
if (edit->GetOperation() == FarVertexEdit::Add) {
|
2014-05-09 00:20:54 +00:00
|
|
|
OsdGcdEditVertexAdd(_currentBindState.vertexBuffer,
|
|
|
|
_currentBindState.vertexDesc,
|
2013-03-08 01:50:15 +00:00
|
|
|
edit->GetPrimvarOffset(),
|
|
|
|
edit->GetPrimvarWidth(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(),
|
|
|
|
batch.GetTableOffset(),
|
|
|
|
batch.GetStart(),
|
|
|
|
batch.GetEnd(),
|
2013-03-08 01:50:15 +00:00
|
|
|
static_cast<unsigned int*>(primvarIndices->GetBuffer()),
|
2013-03-08 06:43:47 +00:00
|
|
|
static_cast<float*>(editValues->GetBuffer()),
|
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
} else if (edit->GetOperation() == FarVertexEdit::Set) {
|
2014-05-09 00:20:54 +00:00
|
|
|
OsdGcdEditVertexSet(_currentBindState.vertexBuffer,
|
|
|
|
_currentBindState.vertexDesc,
|
2013-03-08 01:50:15 +00:00
|
|
|
edit->GetPrimvarOffset(),
|
|
|
|
edit->GetPrimvarWidth(),
|
2013-05-07 06:17:36 +00:00
|
|
|
batch.GetVertexOffset(),
|
|
|
|
batch.GetTableOffset(),
|
|
|
|
batch.GetStart(),
|
|
|
|
batch.GetEnd(),
|
2013-03-08 01:50:15 +00:00
|
|
|
static_cast<unsigned int*>(primvarIndices->GetBuffer()),
|
2013-03-08 06:43:47 +00:00
|
|
|
static_cast<float*>(editValues->GetBuffer()),
|
|
|
|
_gcd_queue);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-02 20:53:33 +00:00
|
|
|
void
|
|
|
|
OsdGcdComputeController::Synchronize() {
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|