7#ifndef PXR_IMAGING_HD_CACHING_SAMPLED_DATASOURCE_H
8#define PXR_IMAGING_HD_CACHING_SAMPLED_DATASOURCE_H
10#include "pxr/imaging/hd/dataSource.h"
12#include <tbb/concurrent_hash_map.h>
22PXR_NAMESPACE_OPEN_SCOPE
41 using Time = HdSampledDataSource::Time;
42 using TimeValueMap = tbb::concurrent_hash_map<Time, VtValue>;
52 TimeValueMap::const_accessor const_acc;
53 if (_cache.find(const_acc, shutterOffset)) {
54 return const_acc->second;
57 TimeValueMap::accessor acc;
58 if (_cache.insert(acc, shutterOffset)) {
59 acc->second = _input->GetValue(shutterOffset);
68 std::vector<Time> * outSampleTimes)
override
74 return _input->GetContributingSampleTimesForInterval(
75 startTime, endTime, outSampleTimes
83 const HdSampledDataSourceHandle _input;
107 using Time = HdSampledDataSource::Time;
108 using TimeValueMap = tbb::concurrent_hash_map<Time, T>;
117 typename TimeValueMap::const_accessor const_acc;
118 if (_cache.find(const_acc, shutterOffset)) {
119 return const_acc->second;
122 typename TimeValueMap::accessor acc;
123 if (_cache.insert(acc, shutterOffset)) {
124 acc->second = _input->GetTypedValue(shutterOffset);
137 std::vector<Time> * outSampleTimes)
override
143 return _input->GetContributingSampleTimesForInterval(
144 startTime, endTime, outSampleTimes
156PXR_NAMESPACE_CLOSE_SCOPE
A sampled data source which maintains a cache of values from the upstream sampled data source,...
bool GetContributingSampleTimesForInterval(Time startTime, Time endTime, std::vector< Time > *outSampleTimes) override
Given a shutter window of interest (startTime and endTime relative to the current frame),...
VtValue GetValue(Time shutterOffset) override
Returns the value of this data source at frame-relative time shutterOffset.
A typed sampled data source which maintains a cache of values from the upstream sampled data source,...
bool GetContributingSampleTimesForInterval(Time startTime, Time endTime, std::vector< Time > *outSampleTimes) override
Given a shutter window of interest (startTime and endTime relative to the current frame),...
VtValue GetValue(Time shutterOffset) override
Returns the value of this data source at frame-relative time shutterOffset.
T GetTypedValue(Time shutterOffset) override
Returns the value of this data source at frame-relative time shutterOffset, as type T.
A datasource representing time-sampled values.
A datasource representing a concretely-typed sampled value.
Provides a container which may hold any type, and provides introspection and iteration over array typ...