// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Data/RawBuffer.h" #include "DeviceBuffer.h" #include #include class Blob; class DeviceNativeTask; typedef std::shared_ptr DeviceNativeTaskPtr; typedef std::weak_ptr DeviceNativeTaskPtrW; struct JobResult; typedef std::shared_ptr JobResultPtr; typedef cti::continuable AsyncJobResultPtr; ////////////////////////////////////////////////////////////////////////// class TEXTUREGRAPHENGINE_API DeviceObserverSource { public: struct HashNDesc { uint64 Raw = 0; HashType First = 0; BufferDescriptor Second; }; using HashNDescArray = std::vector; using HashArray = std::vector; void AddBuffer(const DeviceBuffer* Buffer, HashType Hash, const BufferDescriptor& Desc); void RemoveBuffer(const DeviceBuffer* buffer, HashType hash, HashType prevHash); protected: /// Protected interface of emitters called by the scheduler to notify the observers friend class Device; FCriticalSection ObserverLock; HashNDescArray AddedBufferStack; HashArray RemovedBufferStack; uint32 Version = 1; /// Trigger the broadcast of the changes, this call is issued from the Device::Update function void Broadcast(); /// The customisable handler method triggered from Broadcast if any buffers were added or removed virtual void DeviceBuffersUpdated(HashNDescArray&& AddedBuffers, HashArray&& RemovedBuffers) {} public: DeviceObserverSource() = default; virtual ~DeviceObserverSource() {} uint32 GetVersion() const { return Version; } /// THe version of the current state of the Device Cache. Incremented when Broadcast trigger }; typedef std::shared_ptr DeviceObserverSourcePtr;