# OpenExec question: how to compute mesh points? No VtArray allowed

**URL:** <https://forum.aousd.org/t/openexec-question-how-to-compute-mesh-points-no-vtarray-allowed/2739>\
**Category:** OpenExec\
**Created:** [October 16, 2025, 9:19pm UTC](https://forum.aousd.org/t/openexec-question-how-to-compute-mesh-points-no-vtarray-allowed/2739 "2025-10-16T21:19:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![barbalt](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@barbalt](https://forum.aousd.org/u/barbalt)\
**Post date:** [October 16, 2025, 9:19pm UTC](https://forum.aousd.org/t/openexec-question-how-to-compute-mesh-points-no-vtarray-allowed/2739/1 "2025-10-16T21:19:48Z")

</div>

Hello,  
I’m trying to learn about open exec and created a simple function based on the documentation:

```c
static VtVec3fArray _ChangeVerts(const VdfContext& ctx)
{
    const VtVec3fArray* const originalPoints = ctx.GetInputValuePtr(TfToken(“points”));
    VtVec3fArray res;
    if (originalPoints) {
        res.resize(originalPoints->size());
        if (originalPoints) {
            for (size_t i = 0; i < originalPoints->size(); ++i) {
                auto p = (*originalPoints)[i];
                res[i] = p * std::rand() * 10;
            }
        }
    }

    return res;

}

EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(UsdGeomXformable)
{
    self.PrimComputation(TfToken(“computePoints”))
        .Callback<VtVec3fArray>(&_ChangeVerts)
        .Inputs(AttributeValue<VtVec3fArray>(TfToken(“points”)));
}

```

This failed during compilation saying that VtVec3fArray is not an allowed type.

Is it possible to assign the points attribute of a mesh to compute values on it? If not, is there another way to achieve this?

---

<div class="post-metadata">

**Author:** ![florianz](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@florianz](https://forum.aousd.org/u/florianz)\
**Post date:** [October 17, 2025, 12:45am UTC](https://forum.aousd.org/t/openexec-question-how-to-compute-mesh-points-no-vtarray-allowed/2739/2 "2025-10-17T00:45:51Z")

</div>

Hi @barbalt.

First off, thanks for playing with OpenExec. That’s really exciting!

Second, our apologies for the lack of documentation (and test cases to draw inspiration from) for array-valued `AttributeValue` inputs. We’re adding this to the list of upcoming tasks for OpenExec.

To answer your question: As a rule-of-thumb, the type to use for array-valued attributes in OpenExec is always the **array element type.** This is because OpenExec has the ability to encode arrays in different ways, depending on how it chooses to optimize the storage of the array in memory (and later, which device it chooses to offload the data to). This functionality is not currently leveraged in OpenExec today, but it is an important aspect of how we plan to accelerate mesh deformation in the future. As a consequence the specific array encoding is an implementation detail of OpenExec, and it might be different for different array-valued attribute in the same scene. Callbacks and inputs need to be generalized to not rely on the array encoding, hence the need for using array element types and iterator patterns.

In summary, this means your code must be modified in two ways:

1. The input should be `AttributeValue<GfVec3f>` in accordance with the rule of using the array element type.
2. In the callback, the input value must be retrieved using the element type to match the type used in the input: `VdfContext::GetInputValue<GfVec3f>` (and friends) only give you the first entry in the array. If you need to iterate over all entries the `VdfReadIterator<GfVec3f>` is the right construct. If you want random access, you can also take a look at `VdfInputValuesPtr<GfVec3f>` (with caveats explained in its doxygen documentation).

I took the liberty of rewriting your code with these changes. My changes are untested, but you should get the general idea:

```cpp
TF_DEFINE_PRIVATE_TOKENS(
    _tokens,
    (computePoints),
    (points)
);

TF_REGISTRY_FUNCTION(ExecTypeRegistry)
{
    ExecTypeRegistry::RegisterType(std::vector<GfVec3f>{});
}

static std::vector<GfVec3f> _ChangeVerts(const VdfContext& ctx)
{
    VdfReadIterator<GfVec3f> it(ctx, _tokens->points);

    std::vector<GfVec3f> res;
    res.reserve(it.ComputeSize());

    for (; !it.IsAtEnd(); ++it) {
        res.push_back(*it * std::rand() * 10);
    }

    return res;
}

EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(UsdGeomXformable)
{
    self.PrimComputation(_tokens->computePoints)
        .Callback<std::vector<GfVec3f>>(&_ChangeVerts)
        .Inputs(AttributeValue<GfVec3f>(_tokens->points));
}

```

PS: Note that because of [this TODO item](https://github.com/PixarAnimationStudios/OpenUSD/blob/43b8c713427fac6eb1230d8f4933d1358b9746b2/pxr/exec/exec/computationDefinition.cpp#L34), extracting array results from OpenExec is currently a bit of a pain, which is why I changed your code to produce a `std::vector<GfVec3f>` instead of a `VtVec3fArray`, but this will be fixed soon.

Hope this helps! Please, let us know of any other hiccups you run into, so that we can prioritize the fixes!

---

<div class="post-metadata">

**Author:** ![barbalt](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@barbalt](https://forum.aousd.org/u/barbalt)\
**Post date:** [October 17, 2025, 3:15pm UTC](https://forum.aousd.org/t/openexec-question-how-to-compute-mesh-points-no-vtarray-allowed/2739/3 "2025-10-17T15:15:17Z")

</div>

Thank you very much, @florianz  
This worked perfectly. The change to std::vector and registering it were the key missing pieces.

One thing that was not very clear to me is that [documentation here](https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/exec/execUsd/docs/tutorial2DefiningComputations.md#plugin-metadata) it says that I need to update the `plugInfo.json` to `allowsPluginComputation`, but I was able to change the UsdGeom without it. Is that a requirement only for custom schemas?

---

<div class="post-metadata">

**Author:** ![florianz](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@florianz](https://forum.aousd.org/u/florianz)\
**Post date:** [October 17, 2025, 3:45pm UTC](https://forum.aousd.org/t/openexec-question-how-to-compute-mesh-points-no-vtarray-allowed/2739/4 "2025-10-17T15:45:55Z")

</div>

Setting `allowsPluginComputation` is required for any schema that advertises exec computations. Having said that, [it should already be set](https://github.com/PixarAnimationStudios/OpenUSD/blob/43b8c713427fac6eb1230d8f4933d1358b9746b2/pxr/exec/execGeom/plugInfo.json#L8) on `UsdGeomXformable` , since one of our early examples registers computations on that schema.

---

<div class="post-metadata">

**Author:** ![barbalt](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@barbalt](https://forum.aousd.org/u/barbalt)\
**Post date:** [October 17, 2025, 3:57pm UTC](https://forum.aousd.org/t/openexec-question-how-to-compute-mesh-points-no-vtarray-allowed/2739/5 "2025-10-17T15:57:20Z")

</div>

That makes sense! Thanks for all the help once again
