Program Listing for File playback-engine.h

Return to documentation for file (include\playback\playback-engine.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 "igpa-config.h"
#include "playback/experiments/experimentor.h"
#include "playback/metadata-extraction/metadata-extractor.h"
#include "playback/metadata-extraction/metadata-types.h"
#include "playback/data-collection/metrics-extractor.h"
#include "playback/range-player.h"
#include "playback/resource-extraction/resource-extractor.h"
#include "playback/geometry-extraction/geometry-extractor.h"
#include "playback/isa-code-extraction/isa-code-extractor.h"

#include <unordered_set>
#include <vector>

namespace gpa {
namespace playback {

class Experimentor;
class GeometryExtractor;
class MetadataExtractor;
class MetricsExtractor;
class ResourceExtractor;
class ShaderProfileExtractor;
class ISACodeExtractor;

struct Services
{
    GeometryExtractor* geometryExtractor = nullptr;
    MetadataExtractor* metadataExtractor = nullptr;
    Experimentor* experimentor = nullptr;
    ResourceExtractor* resourceExtractor = nullptr;
    MetricsExtractor* metricsExtractor = nullptr;
    ShaderProfileExtractor* shaderProfileExtractor = nullptr;
    ISACodeExtractor* isaCodeExtractor = nullptr;
};

struct PlaybackEngineParameters
{
    bool isShaderProfilerEnabled = true;
};

class PlaybackEngine
{
public:
    PlaybackEngine(RangePlayer* rangePlayer);

    virtual ~PlaybackEngine();

    PlaybackEngine(RangePlayer* rangePlayer, Services* serviceOverrides);

    PlaybackEngine(RangePlayer* rangePlayer, Services* serviceOverrides, const PlaybackEngineParameters& parameters);

public:
    MetadataExtractor const& GetMetadataExtractor() const;

    Experimentor& GetExperimentor();

    Experimentor const& GetExperimentor() const;

    MetricsExtractor& GetMetricsExtractor();

    MetricsExtractor const& GetMetricsExtractor() const;

    bool IsShaderProfilerAvailable() const;

    ResourceExtractor const& GetResourceExtractor() const;

    ResourceExtractor& GetResourceExtractor();

    GeometryExtractor& GetGeometryExtractor();

    GeometryExtractor const& GetGeometryExtractor() const;

    void DisableCalls(uint64_t const* callIndices, uint64_t count);

    void EnableCalls(uint64_t const* callIndices, uint64_t count);

    void EnableAllCalls();

    void Execute();

    void Execute(ResourceExtractor::Request& request);

    data_collection::MetricsQueryResult Execute(data_collection::MetricsRequest const* request);

    void Execute(ProfileShaderRequest const& request, ProfileShaderResult& result);

    void Execute(ProfileShaderRequest const& request, ShaderMetricsResult& result);

    void Execute(GeometryExtractor::Request& request);

    void Execute(ISACodeExtractor::Request& request, ISACodeExtractor::Result& result);

private:
    bool ExecuteCallCondition(Callable* callable, uint64_t callIndex) const;
    ExecutionCallbacks CreateExecutionCallbacks(CallableReceiver* receiver, CallableCallbacks* callbacks = nullptr);

    RangePlayer* mRangePlayer{nullptr};
    std::unique_ptr<MetadataExtractor> mMetadataExtractor;
    std::unique_ptr<Experimentor> mExperimentor;
    std::unique_ptr<ResourceExtractor> mResourceExtractor;
    std::unique_ptr<MetricsExtractor> mMetricsExtractor;
    std::unique_ptr<ShaderProfileExtractor> mShaderProfileExtractor;
    std::unique_ptr<GeometryExtractor> mGeometryExtractor;
    std::unique_ptr<ISACodeExtractor> mISACodeExtractor;
    std::unordered_set<uint64_t> mDisabledCalls;
    bool mAssistedDisable{false};

    PlaybackEngine(PlaybackEngine const&) = delete;
    PlaybackEngine& operator=(PlaybackEngine const&) = delete;
};

}  // namespace playback
}  // namespace gpa