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

Return to documentation for file (include\playback\directx12-range-repeat-cache-resource.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>
#include <vector>
#include <map>

namespace gpa {
namespace d3d12_state_tracker {
struct MapInfo;
}

namespace playback {

class Callable;

namespace repeat {
namespace directx {

class ID3D12ResourceRangeRepeatCache : public RangeRepeatCacheCOM
{
    bool mIsBackBuffer = false;
    uint32_t mBbIndex = 0;
    IDXGISwapChain3* mSc = nullptr;
    uint32_t mBackBufferIndexAtRangeStart = 0;
    std::vector<D3D12_RESOURCE_STATES> mStatesAtRangeStart;
    std::vector<D3D12_BARRIER_LAYOUT> mLayoutsAtRangeStart;
    std::vector<uint64_t> mBbFamilyKeys;
    std::vector<ID3D12Resource*> mBbFamily;
    RangeRepeatCacheCOM::Ptr mHeapCache;

    std::map<uint32_t, std::list<d3d12_state_tracker::MapInfo>> mMapState;

    CComPtr<ID3D12Resource> mMirror;

    Callable mGetGpuAddressCallable;

public:
    typedef std::shared_ptr<ID3D12ResourceRangeRepeatCache> Ptr;

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

    void OnRangeEnter(GPADispatchTable const*& table) override;
    void OnRangeCollected(GPADispatchTable const*& table) override;
    void OnRangeRepeatDestroyObject(GPADispatchTable const*& table, uint64_t repeatPass) 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 OnGetGPUVirtualAddress(Callable* callable);
};

class ID3D12BackBufferResourceRangeRepeatCache : public RangeRepeatCacheCOM
{
public:
    typedef std::shared_ptr<ID3D12BackBufferResourceRangeRepeatCache> Ptr;

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

    void OnRangeEnter(GPADispatchTable const*& table) override;
    void OnRangeCollected(GPADispatchTable const*& table) override;
    void OnRangeRepeatDestroyObject(GPADispatchTable const*& table, uint64_t repeatPass) 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;
};

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