本文整理汇总了C++中PrimInfo::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ PrimInfo::reset方法的具体用法?C++ PrimInfo::reset怎么用?C++ PrimInfo::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrimInfo
的用法示例。
在下文中一共展示了PrimInfo::reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gen
void PrimRefArrayGenFromGeometry<Ty>::generate_parallel(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, const Ty* geom, PrimRef* prims_o, PrimInfo& pinfo_o)
{
PrimRefArrayGenFromGeometry gen(geom,prims_o,pinfo_o);
/* calculate initial destination for each thread */
size_t numPrimitives = geom->size();
gen.dst = new size_t[threadCount];
for (size_t i=0; i<threadCount; i++)
gen.dst[i] = i*numPrimitives/threadCount;
/* first try to generate primref array */
pinfo_o.reset();
scheduler->dispatchTask(task_task_gen_parallel, &gen, threadIndex, threadCount);
assert(pinfo_o.size() <= numPrimitives);
/* calculate new destinations */
size_t cnt = 0;
for (size_t i=0; i<threadCount; i++) {
size_t n = gen.dst[i]; gen.dst[i] = cnt; cnt += n;
}
/* if primitive got filtered out, run again */
if (cnt < numPrimitives)
{
pinfo_o.reset();
scheduler->dispatchTask(task_task_gen_parallel, &gen, threadIndex, threadCount);
assert(pinfo_o.size() == cnt);
}
delete[] gen.dst; gen.dst = NULL;
}
示例2: dst
PrimRefArrayGen::PrimRefArrayGen(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, const Scene* scene, GeometryTy ty, size_t numTimeSteps, PrimRef* prims_o, PrimInfo& pinfo_o, bool parallel)
: dst(NULL), scene(scene), ty(ty), numTimeSteps(numTimeSteps), numPrimitives(0), prims_o(prims_o), pinfo_o(pinfo_o)
{
/*! calculate number of primitives */
if ((ty & TRIANGLE_MESH) && (numTimeSteps & 1)) numPrimitives += scene->numTriangles;
if ((ty & TRIANGLE_MESH) && (numTimeSteps & 2)) numPrimitives += scene->numTriangles2;
if ((ty & SUBDIV_MESH ) && (numTimeSteps & 1)) numPrimitives += scene->numSubdivPatches;
if ((ty & SUBDIV_MESH ) && (numTimeSteps & 2)) numPrimitives += scene->numSubdivPatches2;
if ((ty & BEZIER_CURVES) && (numTimeSteps & 1)) numPrimitives += scene->numBezierCurves;
if ((ty & BEZIER_CURVES) && (numTimeSteps & 2)) numPrimitives += scene->numBezierCurves2;
if ((ty & USER_GEOMETRY) ) numPrimitives += scene->numUserGeometries1;
/*! parallel generation of primref array */
if (parallel)
{
/* calculate initial destination for each thread */
dst = new size_t[threadCount];
for (size_t i=0; i<threadCount; i++)
dst[i] = i*numPrimitives/threadCount;
/* first try to generate primref array */
pinfo_o.reset();
scheduler->dispatchTask(task_task_gen_parallel, this, threadIndex, threadCount);
assert(pinfo_o.size() <= numPrimitives);
/* calculate new destinations */
size_t cnt = 0;
for (size_t i=0; i<threadCount; i++) {
size_t n = dst[i]; dst[i] = cnt; cnt += n;
}
/* if primitive got filtered out, run again */
if (cnt < numPrimitives)
{
pinfo_o.reset();
scheduler->dispatchTask(task_task_gen_parallel, this, threadIndex, threadCount);
assert(pinfo_o.size() == cnt);
}
delete[] dst; dst = NULL;
}
/*! sequential generation of primref array */
else
{
pinfo_o.reset();
task_gen_parallel(0,1);
assert(pinfo_o.size() <= numPrimitives);
}
}
示例3: find
FallBackSplit FallBackSplit::find(size_t threadIndex, PrimRefBlockAlloc<PrimRef>& alloc, PrimRefList& prims,
PrimRefList& lprims_o, PrimInfo& linfo_o,
PrimRefList& rprims_o, PrimInfo& rinfo_o)
{
size_t num = 0;
BBox3fa lbounds = empty, rbounds = empty;
PrimRefList::item* lblock = lprims_o.insert(alloc.malloc(threadIndex));
PrimRefList::item* rblock = rprims_o.insert(alloc.malloc(threadIndex));
linfo_o.reset();
rinfo_o.reset();
while (PrimRefList::item* block = prims.take())
{
for (size_t i=0; i<block->size(); i++)
{
const PrimRef& prim = block->at(i);
const BBox3fa bounds = prim.bounds();
if ((num++)%2)
{
linfo_o.add(bounds,prim.center2());
if (likely(lblock->insert(prim))) continue;
lblock = lprims_o.insert(alloc.malloc(threadIndex));
lblock->insert(prim);
}
else
{
rinfo_o.add(bounds,prim.center2());
if (likely(rblock->insert(prim))) continue;
rblock = rprims_o.insert(alloc.malloc(threadIndex));
rblock->insert(prim);
}
}
alloc.free(threadIndex,block);
}
return FallBackSplit(linfo_o.geomBounds,linfo_o.size(),rinfo_o.geomBounds,rinfo_o.size());
}
示例4: while
void StrandSplit::Split::split<false>(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, PrimRefBlockAlloc<BezierPrim>& alloc,
BezierRefList& prims,
BezierRefList& lprims_o, PrimInfo& linfo_o,
BezierRefList& rprims_o, PrimInfo& rinfo_o) const
{
BezierRefList::item* lblock = lprims_o.insert(alloc.malloc(threadIndex));
BezierRefList::item* rblock = rprims_o.insert(alloc.malloc(threadIndex));
linfo_o.reset();
rinfo_o.reset();
while (BezierRefList::item* block = prims.take())
{
for (size_t i=0; i<block->size(); i++)
{
const BezierPrim& prim = block->at(i);
const Vec3fa axisi = normalize(prim.p3-prim.p0);
const float cos0 = abs(dot(axisi,axis0));
const float cos1 = abs(dot(axisi,axis1));
if (cos0 > cos1)
{
linfo_o.add(prim.bounds(),prim.center());
if (likely(lblock->insert(prim))) continue;
lblock = lprims_o.insert(alloc.malloc(threadIndex));
lblock->insert(prim);
}
else
{
rinfo_o.add(prim.bounds(),prim.center());
if (likely(rblock->insert(prim))) continue;
rblock = rprims_o.insert(alloc.malloc(threadIndex));
rblock->insert(prim);
}
}
alloc.free(threadIndex,block);
}
}
示例5: scene
PrimRefListGen::PrimRefListGen(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, PrimRefBlockAlloc<PrimRef>* alloc, const Scene* scene, GeometryTy ty, size_t numTimeSteps, PrimRefList& prims, PrimInfo& pinfo)
: scene(scene), ty(ty), numTimeSteps(numTimeSteps), alloc(alloc), numPrimitives(0), prims_o(prims), pinfo_o(pinfo)
{
/*! calculate number of primitives */
if ((ty & TRIANGLE_MESH) && (numTimeSteps & 1)) numPrimitives += scene->numTriangles;
if ((ty & TRIANGLE_MESH) && (numTimeSteps & 2)) numPrimitives += scene->numTriangles2;
if ((ty & SUBDIV_MESH ) && (numTimeSteps & 1)) numPrimitives += scene->numSubdivPatches;
if ((ty & SUBDIV_MESH ) && (numTimeSteps & 2)) numPrimitives += scene->numSubdivPatches2;
if ((ty & BEZIER_CURVES) && (numTimeSteps & 1)) numPrimitives += scene->numBezierCurves;
if ((ty & BEZIER_CURVES) && (numTimeSteps & 2)) numPrimitives += scene->numBezierCurves2;
if ((ty & USER_GEOMETRY) ) numPrimitives += scene->numUserGeometries1;
pinfo.reset();
if (numPrimitives <= single_threaded_primrefgen_threshold)
task_gen_parallel(threadIndex,threadCount,0,1);
else
scheduler->dispatchTask(threadIndex,threadCount,_task_gen_parallel,this,threadCount,"build::trirefgen");
assert(pinfo_o.size() <= numPrimitives);
}
示例6: assert
void SpatialSplit::Split::split<false>(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, PrimRefBlockAlloc<PrimRef>& alloc,
Scene* scene, TriRefList& prims,
TriRefList& lprims_o, PrimInfo& linfo_o,
TriRefList& rprims_o, PrimInfo& rinfo_o) const
{
assert(valid());
TriRefList::item* lblock = lprims_o.insert(alloc.malloc(threadIndex));
TriRefList::item* rblock = rprims_o.insert(alloc.malloc(threadIndex));
linfo_o.reset();
rinfo_o.reset();
/* sort each primitive to left, right, or left and right */
while (atomic_set<PrimRefBlock>::item* block = prims.take())
{
for (size_t i=0; i<block->size(); i++)
{
const PrimRef& prim = block->at(i);
const BBox3fa bounds = prim.bounds();
const int bin0 = mapping.bin(bounds.lower)[dim];
const int bin1 = mapping.bin(bounds.upper)[dim];
/* sort to the left side */
if (bin1 < pos)
{
linfo_o.add(bounds,center2(bounds));
if (likely(lblock->insert(prim))) continue;
lblock = lprims_o.insert(alloc.malloc(threadIndex));
lblock->insert(prim);
continue;
}
/* sort to the right side */
if (bin0 >= pos)
{
rinfo_o.add(bounds,center2(bounds));
if (likely(rblock->insert(prim))) continue;
rblock = rprims_o.insert(alloc.malloc(threadIndex));
rblock->insert(prim);
continue;
}
/* split and sort to left and right */
TriangleMesh* mesh = (TriangleMesh*) scene->get(prim.geomID());
TriangleMesh::Triangle tri = mesh->triangle(prim.primID());
const Vec3fa v0 = mesh->vertex(tri.v[0]);
const Vec3fa v1 = mesh->vertex(tri.v[1]);
const Vec3fa v2 = mesh->vertex(tri.v[2]);
PrimRef left,right;
float fpos = mapping.pos(pos,dim);
splitTriangle(prim,dim,fpos,v0,v1,v2,left,right);
if (!left.bounds().empty()) {
linfo_o.add(left.bounds(),center2(left.bounds()));
if (!lblock->insert(left)) {
lblock = lprims_o.insert(alloc.malloc(threadIndex));
lblock->insert(left);
}
}
if (!right.bounds().empty()) {
rinfo_o.add(right.bounds(),center2(right.bounds()));
if (!rblock->insert(right)) {
rblock = rprims_o.insert(alloc.malloc(threadIndex));
rblock->insert(right);
}
}
}
alloc.free(threadIndex,block);
}
}