430 if (refiner ==
nullptr) {
435 const bool has_varying_data =
false;
436 const int num_face_varying_channels = refiner->GetNumFVarChannels();
437 const bool has_face_varying_data = (num_face_varying_channels != 0);
441 const bool stencil_generate_intermediate_levels = is_adaptive;
442 const bool stencil_generate_offsets =
true;
443 const bool use_inf_sharp_patch =
true;
447 TopologyRefiner::AdaptiveOptions
options(level);
448 options.considerFVarChannels = has_face_varying_data;
449 options.useInfSharpPatch = use_inf_sharp_patch;
450 refiner->RefineAdaptive(
options);
453 TopologyRefiner::UniformOptions
options(level);
454 refiner->RefineUniform(
options);
459 auto delete_stencil_table = [](
const StencilTable *table) {
460 static_assert(std::is_base_of_v<StencilTableReal<float>, StencilTable>);
461 delete reinterpret_cast<const StencilTableReal<float> *
>(table);
468 StencilTableFactory::Options vertex_stencil_options;
469 vertex_stencil_options.generateOffsets = stencil_generate_offsets;
470 vertex_stencil_options.generateIntermediateLevels = stencil_generate_intermediate_levels;
471 const StencilTable *vertex_stencils = StencilTableFactory::Create(*refiner,
472 vertex_stencil_options);
477 const StencilTable *varying_stencils =
nullptr;
478 if (has_varying_data) {
479 StencilTableFactory::Options varying_stencil_options;
480 varying_stencil_options.generateOffsets = stencil_generate_offsets;
481 varying_stencil_options.generateIntermediateLevels = stencil_generate_intermediate_levels;
482 varying_stencil_options.interpolationMode = StencilTableFactory::INTERPOLATE_VARYING;
483 varying_stencils = StencilTableFactory::Create(*refiner, varying_stencil_options);
486 std::vector<const StencilTable *> all_face_varying_stencils;
487 all_face_varying_stencils.reserve(num_face_varying_channels);
488 for (
int face_varying_channel = 0; face_varying_channel < num_face_varying_channels;
489 ++face_varying_channel)
491 StencilTableFactory::Options face_varying_stencil_options;
492 face_varying_stencil_options.generateOffsets = stencil_generate_offsets;
493 face_varying_stencil_options.generateIntermediateLevels = stencil_generate_intermediate_levels;
494 face_varying_stencil_options.interpolationMode = StencilTableFactory::INTERPOLATE_FACE_VARYING;
495 face_varying_stencil_options.fvarChannel = face_varying_channel;
496 all_face_varying_stencils.push_back(
497 StencilTableFactory::Create(*refiner, face_varying_stencil_options));
500 PatchTableFactory::Options patch_options(level);
501 patch_options.SetEndCapType(PatchTableFactory::Options::ENDCAP_GREGORY_BASIS);
502 patch_options.useInfSharpPatch = use_inf_sharp_patch;
503 patch_options.generateFVarTables = has_face_varying_data;
504 patch_options.generateFVarLegacyLinearPatches =
false;
505 const PatchTable *patch_table = PatchTableFactory::Create(*refiner, patch_options);
508 const StencilTable *local_point_stencil_table = patch_table->GetLocalPointStencilTable();
509 if (local_point_stencil_table !=
nullptr) {
510 const StencilTable *table = StencilTableFactory::AppendLocalPointStencilTable(
511 *refiner, vertex_stencils, local_point_stencil_table);
512 delete_stencil_table(vertex_stencils);
513 vertex_stencils = table;
516 if (has_varying_data) {
517 const StencilTable *local_point_varying_stencil_table =
518 patch_table->GetLocalPointVaryingStencilTable();
519 if (local_point_varying_stencil_table !=
nullptr) {
520 const StencilTable *table = StencilTableFactory::AppendLocalPointStencilTable(
521 *refiner, varying_stencils, local_point_varying_stencil_table);
522 delete_stencil_table(varying_stencils);
523 varying_stencils = table;
526 for (
int face_varying_channel = 0; face_varying_channel < num_face_varying_channels;
527 ++face_varying_channel)
529 const StencilTable *table = StencilTableFactory::AppendLocalPointStencilTableFaceVarying(
531 all_face_varying_stencils[face_varying_channel],
532 patch_table->GetLocalPointFaceVaryingStencilTable(face_varying_channel),
533 face_varying_channel);
534 if (table !=
nullptr) {
535 delete_stencil_table(all_face_varying_stencils[face_varying_channel]);
536 all_face_varying_stencils[face_varying_channel] = table;
543 if (use_gpu_evaluator) {
545 if (evaluator_cache_descr) {
552 all_face_varying_stencils,
559 vertex_stencils, varying_stencils, all_face_varying_stencils, 2, patch_table);
565 evaluator->
type = evaluator_type;
571 delete_stencil_table(vertex_stencils);
572 delete_stencil_table(varying_stencils);
573 for (
const StencilTable *table : all_face_varying_stencils) {
574 delete_stencil_table(table);