Program Listing for File directx12-range-repeat-cache-cmdlist.h

Return to documentation for file (include\playback\directx12-range-repeat-cache-cmdlist.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 "playback/directx-range-repeat-cache.h"
#include <d3d12.h>

namespace gpa {
namespace playback {

class Callable;

namespace repeat {
namespace directx {

class ID3D12GraphicsCommandListRangeRepeatCache : public RangeRepeatCacheForCommandBuffersCOM
{
public:
    typedef std::shared_ptr<ID3D12GraphicsCommandListRangeRepeatCache> Ptr;

    ID3D12GraphicsCommandListRangeRepeatCache(playback::Context* context, playback::Callable* callable);
    ~ID3D12GraphicsCommandListRangeRepeatCache();

    void OnRangeEnter(GPADispatchTable const*& table) override;
    void OnRangeCollected(GPADispatchTable const*& table) override;
    void OnRangeRepeatRecreateObject(GPADispatchTable const*& table, uint64_t repeatPass) override;
    void OnRangeRepeatRestoreState(GPADispatchTable const*& table, uint64_t repeatPass) override;
    void OnRangeExit(GPADispatchTable const*& table) override;

    void AddCall(Callable* callable) override;
    void SetUsedInRange(bool value) override;
    void ClearCallables() override;

    void OnReincarnation(playback::Callable* callable);
    void EnumerateCallablesFromIncarnation(uint64_t timestamp, CallableCache::EnumerateCallablesCallback callback, void* userData);
    void SetRecordedBeforeRange();
    bool IsRecordedBeforeRange() const;
    ID3D12CommandAllocator* GetReplacementAllocator(GPADispatchTable const*& table);

private:
    void ReleaseReplacementObjects();
    void InitializeReplacementObjects(GPADispatchTable const*& table, ID3D12CommandAllocator** ppReplacementAllocator, ID3D12GraphicsCommandList** ppReplacementCmdList);
    bool ShouldResetReplacementCmdList();
    void ResetReplacementCmdList(GPADispatchTable const*& table);
    bool TryCloseCmdList(GPADispatchTable const*& table, ID3D12GraphicsCommandList* commandList);

    std::vector<CmdBufferIncarnation> mIncarnations;
    bool mArtificiallyClosed = false;
    bool mIsRecordedBeforeRange = false;

    UINT mNodeMask = 0;
    ID3D12GraphicsCommandList* mReplacementCmdList = nullptr;
    ID3D12CommandAllocator* mReplacementAllocator = nullptr;
    ID3D12PipelineState* mCreationPipelineState = nullptr;
    uint64_t mEarliestIncarnationIndexUsedInRange = UINT64_MAX;
};

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