Program Listing for File range-repeat-stream-builder.h

Return to documentation for file (include\playback\range-repeat-stream-builder.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 <vector>
#include "playback/range-repeat-cache.h"
#include "playback/sync-handler.h"
#include <map>
#include <memory>
#include <vector>

namespace gpa {

namespace serialization {
struct Context;
struct Marker;
}  // namespace serialization

namespace playback {

class CallableCache;

namespace repeat {

typedef std::vector<gpa::playback::repeat::RangeRepeatCache::Ptr> Snapshot;

// @brief Class resposible for creating repeat-ready flattened callable cache
// @details In process of preparing the repeat-ready callable cahce, the command buffer
//  allocations are placed just before the command buffer submission calls. Such cache
//  represents the gpu-order api log.
class StreamBuilder
{
public:
    StreamBuilder();
    ~StreamBuilder();

    // @brief Add the callable in GPU order
    void AddCallable(Callable& callable);

    // @brief Process callables for execution with secondary command buffer calls transfered to primary
    void ProcessSecondaryCommandBuffers();

    // @brief Returns cache containing callables prepared for execution in repeat cycle
    CallableCache* Callables();

    bool FlattenedSecondaryCommandBuffers() const;

    Callable SpawnMarkerCallable(uint32_t markerType, uint64_t object = 0);

private:
    // @brief Cache containing callables prepared for execution in repeat cycle
    CallableCache mCallables;

    // @brief Vector of spawned markers for deinitialization purposes
    std::vector<std::unique_ptr<serialization::Marker>> mSpawnedMarkers;

    bool mFlattenedSecondaryCmdBuffers = false;
};

}  // namespace repeat
}  // namespace playback
}  // namespace gpa