float* PooledDataStore::CreateData(uint64_t id, size_t length) { lock_guard<mutex> lck(access_mutex_); DLOG(INFO) << "create data #" << id << " length " << length; auto it = data_states_.emplace(id, DataState()); CHECK(it.second) << "data already existed"; auto& ds = it.first->second; ds.length = length; auto find_free_space_ = free_space_.find(length); if (find_free_space_ != free_space_.end()) { // Reuse ds.ptr = find_free_space_->second.front(); find_free_space_->second.pop(); if (!find_free_space_->second.size()) { free_space_.erase(find_free_space_); } } else { ds.ptr = allocator_(length); total_ += length; if (threshold_ < total_) { ReleaseFreeSpace(); } } return static_cast<float*>(ds.ptr); }
bool GetLighterDirtyState(ICENodeContext& in_ctxt ) { CICEPortState DataState( in_ctxt, ID_IN_ToonixData ); bool dataDirty = DataState.IsDirty( CICEPortState::siAnyDirtyState ); CICEPortState LightState( in_ctxt, ID_IN_LightPosition ); bool lightDirty = LightState.IsDirty( CICEPortState::siAnyDirtyState ); LightState.ClearState(); CICEPortState ViewState( in_ctxt, ID_IN_ViewPosition ); bool viewDirty = ViewState.IsDirty( CICEPortState::siAnyDirtyState ); ViewState.ClearState(); CICEPortState RevertState( in_ctxt, ID_IN_Revert ); bool revertDirty = RevertState.IsDirty( CICEPortState::siAnyDirtyState ); RevertState.ClearState(); CICEPortState BiasState( in_ctxt, ID_IN_LightBias ); bool biasDirty = BiasState.IsDirty( CICEPortState::siAnyDirtyState ); BiasState.ClearState(); CICEPortState DistanceState( in_ctxt, ID_IN_LightDistance ); bool distanceDirty = DistanceState.IsDirty( CICEPortState::siAnyDirtyState ); DistanceState.ClearState(); CICEPortState PushState( in_ctxt, ID_IN_LightDistance ); bool pushDirty = PushState.IsDirty( CICEPortState::siAnyDirtyState ); PushState.ClearState(); CICEPortState ByTriangleState( in_ctxt, ID_IN_ByTriangle ); bool byTriangleDirty = ByTriangleState.IsDirty( CICEPortState::siAnyDirtyState ); ByTriangleState.ClearState(); return(dataDirty||viewDirty||lightDirty||revertDirty||biasDirty||distanceDirty||byTriangleDirty); }