2012-06-09 00:06:35 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-06-09 00:06:35 +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:
|
2012-06-09 00:06:35 +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.
|
2012-06-09 00:06:35 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-06-09 00:06:35 +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.
|
2012-06-09 00:06:35 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
|
2015-05-19 18:22:37 +00:00
|
|
|
#ifndef OPENSUBDIV3_OSD_CPU_KERNEL_H
|
|
|
|
#define OPENSUBDIV3_OSD_CPU_KERNEL_H
|
2012-06-09 00:06:35 +00:00
|
|
|
|
2012-06-12 00:02:27 +00:00
|
|
|
#include "../version.h"
|
2015-05-07 23:11:00 +00:00
|
|
|
#include <cstring>
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2012-06-09 00:06:35 +00:00
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
namespace Osd {
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2015-05-29 16:21:14 +00:00
|
|
|
struct BufferDescriptor;
|
2014-05-13 23:06:58 +00:00
|
|
|
|
2015-05-07 23:11:00 +00:00
|
|
|
void
|
2015-05-29 16:21:14 +00:00
|
|
|
CpuEvalStencils(float const * src, BufferDescriptor const &srcDesc,
|
|
|
|
float * dst, BufferDescriptor const &dstDesc,
|
2015-05-19 17:16:56 +00:00
|
|
|
int const * sizes,
|
2015-05-09 00:31:26 +00:00
|
|
|
int const * offsets,
|
|
|
|
int const * indices,
|
|
|
|
float const * weights,
|
|
|
|
int start, int end);
|
2014-05-13 23:06:58 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
void
|
2015-05-29 16:21:14 +00:00
|
|
|
CpuEvalStencils(float const * src, BufferDescriptor const &srcDesc,
|
|
|
|
float * dst, BufferDescriptor const &dstDesc,
|
|
|
|
float * dstDu, BufferDescriptor const &dstDuDesc,
|
|
|
|
float * dstDv, BufferDescriptor const &dstDvDesc,
|
2015-05-19 17:16:56 +00:00
|
|
|
int const * sizes,
|
2015-05-09 00:31:26 +00:00
|
|
|
int const * offsets,
|
|
|
|
int const * indices,
|
|
|
|
float const * weights,
|
|
|
|
float const * duWeights,
|
|
|
|
float const * dvWeights,
|
|
|
|
int start, int end);
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
//
|
|
|
|
// SIMD ICC optimization of the stencil kernel
|
|
|
|
//
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2016-02-19 09:02:07 +00:00
|
|
|
#if defined ( __INTEL_COMPILER ) || defined ( __ICC )
|
2014-09-05 22:07:46 +00:00
|
|
|
#define __ALIGN_DATA __declspec(align(32))
|
|
|
|
#else
|
|
|
|
#define __ALIGN_DATA
|
2013-08-15 22:23:12 +00:00
|
|
|
#endif
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
// Note : this function is re-used in the TBB Compute kernel
|
|
|
|
template <int numElems> void
|
|
|
|
ComputeStencilKernel(float const * vertexSrc,
|
|
|
|
float * vertexDst,
|
2015-05-19 17:16:56 +00:00
|
|
|
int const * sizes,
|
2014-09-05 22:07:46 +00:00
|
|
|
int const * indices,
|
|
|
|
float const * weights,
|
|
|
|
int start,
|
|
|
|
int end) {
|
2014-05-27 22:25:54 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
__ALIGN_DATA float result[numElems],
|
|
|
|
result1[numElems];
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
float const * src;
|
|
|
|
float * dst, weight;
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
for (int i=start; i<end; ++i) {
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
// Clear
|
2016-02-19 09:02:07 +00:00
|
|
|
#if defined ( __INTEL_COMPILER ) || defined ( __ICC )
|
2014-09-05 22:07:46 +00:00
|
|
|
#pragma simd
|
2013-08-15 22:23:12 +00:00
|
|
|
#pragma vector aligned
|
|
|
|
#endif
|
2014-09-05 22:07:46 +00:00
|
|
|
for (int k = 0; k<numElems; ++k)
|
|
|
|
result[k] = 0.0f;
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
for (int j=0; j<sizes[i]; ++j, ++indices, ++weights) {
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
src = vertexSrc + (*indices)*numElems;
|
|
|
|
weight = *weights;
|
2013-08-14 23:41:35 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
// AddWithWeight
|
2016-02-19 09:02:07 +00:00
|
|
|
#if defined ( __INTEL_COMPILER ) || defined ( __ICC )
|
2014-09-05 22:07:46 +00:00
|
|
|
#pragma simd
|
2013-08-15 22:23:12 +00:00
|
|
|
#pragma vector aligned
|
|
|
|
#endif
|
2014-09-05 22:07:46 +00:00
|
|
|
for (int k=0; k<numElems; ++k) {
|
|
|
|
result[k] += src[k] * weight;
|
|
|
|
}
|
2013-08-14 23:41:35 +00:00
|
|
|
}
|
2012-06-11 14:54:26 +00:00
|
|
|
|
2016-02-19 09:02:07 +00:00
|
|
|
#if defined ( __INTEL_COMPILER ) || defined ( __ICC )
|
2014-09-05 22:07:46 +00:00
|
|
|
#pragma simd
|
2013-08-15 22:23:12 +00:00
|
|
|
#pragma vector aligned
|
|
|
|
#endif
|
2014-09-05 22:07:46 +00:00
|
|
|
for (int k=0; k<numElems; ++k) {
|
|
|
|
result1[k] = result[k];
|
2013-08-14 23:41:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
dst = vertexDst + i*numElems;
|
|
|
|
memcpy(dst, result1, numElems*sizeof(float));
|
2013-08-14 23:41:35 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
} // end namespace Osd
|
2012-06-09 00:06:35 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
2012-06-09 00:06:35 +00:00
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
} // end namespace OpenSubdiv
|
2012-06-09 00:06:35 +00:00
|
|
|
|
2015-05-19 18:22:37 +00:00
|
|
|
#endif // OPENSUBDIV3_OSD_CPU_KERNEL_H
|