/*
** Copyright (c) 2020-2026 LunarG, Inc.
** Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
**
** 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.
*/

#include "convert_feature.h"

#include "decode/vulkan_detection_consumer.h"
#include "generated/generated_vulkan_decoder.h"
#include "generated/generated_vulkan_json_consumer.h"
#include "util/api_version_info.h"
#include "util/feature_module_registry.h"

GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(convert)

using VulkanJsonConsumer = gfxrecon::decode::MetadataJsonConsumer<
    gfxrecon::decode::MarkerJsonConsumer<gfxrecon::decode::VulkanExportJsonConsumer>>;

class VulkanConvertFeature
    : public ConvertFeature<VulkanJsonConsumer, gfxrecon::decode::VulkanDecoder, decode::VulkanDetectionConsumer>
{
  public:
    VulkanConvertFeature() : ConvertFeature(decode::VulkanDetectionConsumer::kNoBlockLimit) {}
    bool        WasDetected() const final { return detect_consumer_.WasVulkanAPIDetected(); }
    std::string Label() const final { return "Vulkan"; }
    std::string CompiledHeaderVersionString() const final
    {
#if defined(GFXRECON_ENABLE_VULKAN)
        return util::GetVulkanHeaderVersionString();
#else
        return "";
#endif
    }
};

// Register this class as a feature in a module registry
GFXR_UTIL_REGISTER_FEATURE_CREATOR(ConvertFeatureBase, VulkanConvertFeature);

GFXRECON_END_NAMESPACE(convert)
GFXRECON_END_NAMESPACE(gfxrecon)
