Program Listing for File experimentor.h

Return to documentation for file (include\playback\experiments\experimentor.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/callable-broadcaster.h"
#include "playback/callable-receiver.h"
#include "playback/experiments/experiment.h"
#include "playback/experiments/experiment-collection.h"
#include "playback/experiments/shader-compiler.h"

namespace gpa {
namespace playback {

class Experimentor
    : public CallableReceiver,
      public CallableBroadcaster,
      public CallableCallbacks
{
public:
    Experimentor();

    virtual ~Experimentor() = 0;

    virtual Shader::Compiler const& GetShaderCompiler() const = 0;

    void Apply(
        uint64_t startIndex,
        uint64_t endIndex,
        BaseExperiment const& experiment,
        size_t prefabCount = 0,
        BaseExperiment::Prefab const* pPrefabs = nullptr);

    void Apply(
        uint64_t callIndex,
        BaseExperiment const& experiment,
        size_t prefabCount = 0,
        BaseExperiment::Prefab const* pPrefabs = nullptr);

    void Apply(
        uint64_t startIndex,
        uint64_t endIndex,
        size_t prefabCount,
        BaseExperiment::Prefab const* pPrefabs);

    void Apply(
        uint64_t callIndex,
        size_t prefabCount,
        BaseExperiment::Prefab const* pPrefabs);

    virtual void Clear(uint64_t startIndex, uint64_t endIndex);

    virtual void Clear(uint64_t callIndex);

    virtual void Clear();

    void ConnectExecutionCallbacks(ExecutionCallbacks const& callbacks) override;

    void DisconnectExecutionCallbacks() override;

    bool IsEnabled() const;

    void IsEnabled(bool enabled);

    void GetMessages(size_t* pMessageCount, char const** pMessages) const;

protected:
    virtual void ApplyPrefabs(
        uint64_t startIndex,
        uint64_t endIndex,
        size_t prefabCount,
        BaseExperiment::Prefab const* pPrefabs);

    virtual void OnPostSetupRange(CallableCache* range);

    virtual void OnPreExecuteRange(CallableCache* range);

    virtual void OnPreExecuteCall(Callable* callable, uint64_t callIndex);

    virtual void OnPostExecuteCall(Callable* callable, uint64_t callIndex);

    virtual void OnPostExecuteRange(CallableCache* range);

    virtual void PushMessage(char const* msg);

    struct Messages;

    Collection<PipelineExperiment> mGraphicsPipelineExperiments;
    Collection<ResourceExperiment> mResourceExperiments;
    Messages* mMessages = nullptr;

private:
    void PostSetupRange(CallableCache* range) override final;
    void PreExecuteRange(CallableCache* range) override final;
    void PreExecuteCall(Callable* callable, uint64_t callIndex) override final;
    void PostExecuteCall(Callable* callable, uint64_t callIndex) override final;
    void PostExecuteRange(CallableCache* range) override final;
    void BeforePostExecuteRange(QueuesRequiringGpuSynchronization& queuesToSynchronize) override;

    ExecutionCallbacks mCallbacks{};
    bool mEnabled{true};

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

}  // namespace playback
}  // namespace gpa