/*
** Copyright (c) 2026 LunarG, Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
** to deal in the Software without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Software, and to permit persons to whom the
** Software is furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
** DEALINGS IN THE SOFTWARE.
*/

#ifndef GFXRECON_INFO_VULKAN_FEATURE_H
#define GFXRECON_INFO_VULKAN_FEATURE_H

#include "info_feature.h"

#include "decode/vulkan_detection_consumer.h"
#include "decode/vulkan_stats_consumer.h"
#include "generated/generated_vulkan_decoder.h"

GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(info)

class InfoVulkanFeature : public InfoFeature
{
  public:
    InfoVulkanFeature() : vulkan_detection_consumer_(decode::VulkanDetectionConsumer::kNoBlockLimit) {}
    virtual ~InfoVulkanFeature() = default;

    // Simple "getter" style methods
    std::string Label() const override { return "Vulkan"; }
    bool        WasDetected() override { return vulkan_detection_consumer_.WasVulkanAPIDetected(); }
    std::string CompiledHeaderVersionString() const override;

    // Output methods
    std::string    GenerateText() override;
    nlohmann::json GenerateJson() override;

    // Frame-specific methods
    uint32_t GetFrameStart() const override;

    // Method to register this feature's decoder elements with the containers
    // FileProcessor
    void RegisterDecodeComponents(decode::FileProcessor&      file_processor,
                                  const decode::InfoConsumer& info_consumer) override;

  private:
    nlohmann::json GetDeviceMemoryStatsJson(uint64_t alloc_count,
                                            uint64_t min_alloc,
                                            uint64_t max_alloc,
                                            uint64_t gfx_pipelines,
                                            uint64_t comp_pipelines,
                                            uint64_t rt_pipelines);
    std::string    GetDeviceTypeString(VkPhysicalDeviceType device_type);
    std::string    GetVersionString(uint32_t api_version);

    decode::VulkanDetectionConsumer vulkan_detection_consumer_;
    decode::VulkanStatsConsumer     vulkan_stats_consumer_;
    decode::VulkanDecoder           vulkan_decoder_;
};

GFXRECON_END_NAMESPACE(info)
GFXRECON_END_NAMESPACE(gfxrecon)

#endif // GFXRECON_INFO_VULKAN_FEATURE_H
