Program Listing for File vulkan-range-repeat-cache-descriptors.h

Return to documentation for file (include\playback\vulkan-range-repeat-cache-descriptors.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/range-repeat-cache.h"
#include "playback/vulkan-range-repeat-cache.h"
#include "vk-state-tracking/VkStateTracker.h"

#include <vector>

#define VK_NO_PROTOTYPES
#include <vulkan/vulkan.h>
#undef VK_NO_PROTOTYPES

// Disabling due to issues observed on Suntemple workload
// Most of the workloads work fine without descriptorsets recreation anyway
#define USE_VK_DESCRIPTOR_REPEAT_CACHE 0

namespace gpa {
namespace playback {

class Callable;

namespace repeat {
namespace vulkan {

// =============================== RangeRepeatCacheVkDescriptorSet ==============================
class RangeRepeatCacheVkDescriptorSet : public RangeRepeatCacheVK
{
public:
    typedef std::shared_ptr<RangeRepeatCacheVkDescriptorSet> Ptr;
    RangeRepeatCacheVkDescriptorSet(void* object, uint64_t captureKey,
                                    playback::Context* context, playback::Callable* callable);
    virtual ~RangeRepeatCacheVkDescriptorSet();

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

    void SetDirty(GPADispatchTable const*& table);

private:
    VkDevice mDevice;
    RangeRepeatCacheVK::Ptr mPoolRepeatCache;
    RangeRepeatCacheVK::Ptr mLayoutRepeatCache;
    bool mDirty = false;

    VkDescriptorPool mMirrorPool = VK_NULL_HANDLE;
    VkDescriptorSet mMirror = VK_NULL_HANDLE;
    std::vector<VkCopyDescriptorSet> mMirrorCopies;

    std::vector<gpa::vulkan_state::Descriptor> mState;
    std::vector<std::vector<bool>> mInfoValidVec;
    std::vector<std::vector<VkDescriptorImageInfo>> mImageInfoVec;
    std::vector<std::vector<VkDescriptorBufferInfo>> mBufferInfoVec;
    std::vector<std::vector<VkBufferView>> mTexelBufferViewVec;
};

// =============================== RangeRepeatCacheVkDescriptorPool ==============================
class RangeRepeatCacheVkDescriptorPool : public RangeRepeatCacheVK
{
public:
    RangeRepeatCacheVkDescriptorPool(void* object, uint64_t captureKey,
                                     playback::Context* context, playback::Callable* callable);
    virtual ~RangeRepeatCacheVkDescriptorPool();

    void OnRangeRepeatRecreateObject(GPADispatchTable const*& table, uint64_t repeatPass) override;
    void OnRangeRepeatDestroyObject(GPADispatchTable const*& table, uint64_t repeatPass) override;

private:
    VkDevice mDevice;
};

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