Loading...
Searching...
No Matches
maskedOutputVector.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_VDF_MASKED_OUTPUT_VECTOR_H
8#define PXR_EXEC_VDF_MASKED_OUTPUT_VECTOR_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/api.h"
16#include "pxr/exec/vdf/types.h"
17
18#include "pxr/base/tf/hash.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class VdfNetwork;
23
26typedef std::vector<VdfMaskedOutput> VdfMaskedOutputVector;
27
31 size_t operator()(const VdfMaskedOutputVector& vector) const
32 {
33 size_t hash = TfHash::Combine(vector.size());
34
35 // Instead of hashing on the complete request we just do it on the
36 // first three outputs (if any).
37 size_t num = std::min<size_t>(vector.size(), 3);
38
39 for(size_t i = 0; i < num; ++i) {
40 hash = TfHash::Combine(hash, VdfMaskedOutput::Hash()(vector[i]));
41 }
42
43 // Also add the last entry.
44 if (vector.size() > 3) {
45 hash = TfHash::Combine(
46 hash, VdfMaskedOutput::Hash()(vector.back()));
47 }
48
49 return hash;
50 }
51};
52
55VDF_API
56void VdfSortAndUniqueMaskedOutputVector(VdfMaskedOutputVector* vector);
57
62VDF_API
64 const VdfMaskedOutputVector& vector);
65
66PXR_NAMESPACE_CLOSE_SCOPE
67
68#endif /* PXR_EXEC_VDF_MASKED_OUTPUT_VECTOR_H */
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:487
A VdfNetwork is a collection of VdfNodes and their connections.
Definition: network.h:60
VDF_API void VdfSortAndUniqueMaskedOutputVector(VdfMaskedOutputVector *vector)
Sorts and uniques the given vector.
VDF_API const VdfNetwork * VdfGetMaskedOutputVectorNetwork(const VdfMaskedOutputVector &vector)
Returns a pointer to the network if the vector is not empty.
std::vector< VdfMaskedOutput > VdfMaskedOutputVector
A vector of VdfMaskedOutputs.
Hashing functor for VdfMaskedOutputVectors.