Program Listing for File resource-info/resource-info.h

Return to documentation for file (include\playback\resource-info\resource-info.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 "api-types/api-types.h"
#include "playback/resource-info/detail/convertible.h"
#include "playback/resource-info/create-info.h"
#include "playback/resource-info/enumerator.h"
#include "utility/enum-class-operators.h"

#include <cstddef>
#include <cstdint>
#include <limits>
#include <tuple>
#include <utility>
#include <functional>

namespace gpa {
namespace playback {
namespace detail {

class ResourceInfoRegistry;

}  // namespace detail

using ResourceId = uint64_t;

class BlendStateInfo;
class BufferInfo;
class DespthStencilStateInfo;
class EmbeddedPipelineInfo;
class InputLayoutInfo;
class PipelineDescriptorSet;
class PipelineInfo;
class PipelineSignatureInfo;
class RasterizerStateInfo;
class RaytracingShaderGroupInfo;
class RenderPassInfo;
class SamplerInfo;
class ShaderInfo;
class SwapchainInfo;
class TextureInfo;
class ViewInfo;
class ViewportInfo;
class ScissorRectInfo;

class ResourceInfo
    : public detail::Convertible<
          ResourceInfo,
          BlendStateInfo,
          BufferInfo,
          DespthStencilStateInfo,
          EmbeddedPipelineInfo,
          InputLayoutInfo,
          PipelineDescriptorSet,
          PipelineInfo,
          PipelineSignatureInfo,
          RasterizerStateInfo,
          RaytracingShaderGroupInfo,
          RenderPassInfo,
          SamplerInfo,
          ShaderInfo,
          SwapchainInfo,
          TextureInfo,
          ViewInfo,
          ViewportInfo,
          ScissorRectInfo>
{
public:
    class Ex;

    enum class Usage {
        UNKNOWN,
        ARGUMENT,
        COMPUTE_DESCRIPTOR,
        COMPUTE_PIPELINE,
        GRAPHICS_DESCRIPTOR,
        GRAPHICS_INPUT_ASSEMBLY,
        GRAPHICS_OUTPUT,
        GRAPHICS_PIPELINE,
        GRAPHICS_RASTERIZATION_STATE,
        RAYTRACING_DESCRIPTOR,
        RAYTRACING_PIPELINE,
        COUNT,
        BEGIN = UNKNOWN,
        END = COUNT,
        ALL,
    };

    ResourceInfo() = default;

    virtual ~ResourceInfo();

    Enumerator<ResourceInfo::Ex> GetResourceInfoExs(ResourceInfo::Usage usage, uint64_t callIndex) const;

    std::pair<uint64_t, uint64_t> GetBindingInterval(ResourceInfo::Usage usage, uint64_t callIndex) const;

    ResourceId id{0};
    ResourceId playbackHandle{0};
    char const* pName{nullptr};
    CreateInfo createInfo{};

protected:
    virtual void OnRegister();

    ResourceInfo(ResourceInfo const&) = default;
    ResourceInfo& operator=(ResourceInfo const&) = default;

    class Storage final
    {
    public:
        using CreateInfoDeleter = std::function<void()>;
        CreateInfoDeleter deleter;
        std::string name;
    } mStorage;

private:
    detail::ResourceInfoRegistry* mRegistry{nullptr};
    friend class detail::ResourceInfoRegistry;
    friend bool operator==(ResourceInfo const&, ResourceInfo const&);
    friend bool operator<(ResourceInfo const&, ResourceInfo const&);
};

GPA_DEFINE_ENUM_CLASS_OPERATORS(ResourceInfo::Usage)


bool operator==(ResourceInfo const& lhs, ResourceInfo const& rhs);

bool operator!=(ResourceInfo const& lhs, ResourceInfo const& rhs);

bool operator<(ResourceInfo const& lhs, ResourceInfo const& rhs);

namespace detail {

template<typename ResourceInfoType>
inline auto MakeTuple(const ResourceInfoType& resourceInfo)
{
    (void)resourceInfo;
    return std::tuple<>{};
}

}  // namespace detail
}  // namespace playback
}  // namespace gpa