Program Listing for File keyframe.h

Return to documentation for file (include\metadata\keyframe.h)

/******************************************************************************
© Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.


 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/

#pragma once

#include "serialization/common.h"
#include "subcapture-support/subcapture-support.h"
#include "utility/data-desc.h"

#include <cstdint>
#include <vector>

namespace gpa {
namespace serialization {
namespace metadata {

struct KeyframeContext;

class Keyframe
{
public:
    Keyframe(uint64_t timestamp = 0, uint32_t flags = 0);
    ~Keyframe();

    struct ResourceUpdate
    {
        uint64_t threadId{};
        uint64_t copyCallLocation{};
    };

    struct ApiCallReference
    {
        uint64_t threadId{};
        uint64_t offset{};
        uint64_t timestamp{};
    };

    struct ThreadRestart
    {
        uint64_t threadId{};
        uint64_t offset{};
    };

    void AddApiCallReference(ApiCallReference const& apiCallReference);
    void AddResourceUpdate(ResourceUpdate const& update);
    void AddThreadRestart(ThreadRestart const& restart);
    void SetFrameNumber(int64_t frameNumber);

    uint64_t Timestamp() const;
    int64_t FrameNumber() const;
    bool IsDeferredCaptureKeyframe() const;
    bool IsSubcaptureKeyframe() const;

    size_t ApiCallReferenceCount() const;
    ApiCallReference const* GetApiCallReference(size_t index) const;
    size_t ResourceUpdateCount() const;
    ResourceUpdate const* GetResourceUpdate(size_t index) const;
    size_t ThreadRestartCount() const;
    ThreadRestart const* GetThreadRestart(size_t index) const;
    uint64_t GetRestartOffsetForThread(uint64_t threadId) const;

    SubcaptureReverseMapsData const& GetSubcaptureData() const;
    SubcaptureReverseMapsData& GetSubcaptureData();

private:
    int64_t mFrameNumber{};
    uint64_t mTimestamp{};
    uint32_t mFlags{};
    std::vector<ApiCallReference> mApiCalls;
    std::vector<ResourceUpdate> mResourceUpdates;

    std::vector<ThreadRestart> mRestarts;

    SubcaptureReverseMapsData mSubcaptureData;

    bool mInitialized{};

    void SortApiCalls(KeyframeContext* context);
    void SortResourceUpdates();
};

}  // namespace metadata
}  // namespace serialization
}  // namespace gpa