// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto.  Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once

#include <carb/Defines.h>
#include <carb/events/IEvents.h>
#include <carb/Types.h>

namespace omni
{
namespace resourcemonitor
{

/**
 * This interface wraps the wraps the memory queries of the graphics and
 * GpuFoundation APIs. Clients can subscribe to the resource monitor's
 * event stream to be notified when memory resources fall below user-specified
 * thresholds.
 */
struct IResourceMonitor
{
    CARB_PLUGIN_INTERFACE("omni::resourcemonitor::IResourceMonitor", 1, 0)

    /**
     * Call into GpuFoundation's SystemInfo interface and returns available main memory
     *
     * @return available main memory (in bytes)
     */
    uint64_t(CARB_ABI* getAvailableHostMemory)();

    /**
     * Call into GpuFoundation's SystemInfo interface and returns total main memory
     *
     * @return total main memory (in bytes)
     */
    uint64_t(CARB_ABI* getTotalHostMemory)();

    /**
     * Call into the Graphics API and returns available GPU memory for the
     * specified device.
     *
     * @param deviceIndex Index of the device to query.
     *
     * @return available GPU memory for the specified device (in bytes)
     */
    uint64_t(CARB_ABI* getAvailableDeviceMemory)(uint32_t deviceIndex);

    /**
     * Call into the Graphics API and returns total GPU memory for the
     * specified device.
     *
     * @param deviceIndex Index of the device to query.
     *
     * @return total GPU memory for the specified device (in bytes)
     */
    uint64_t(CARB_ABI* getTotalDeviceMemory)(uint32_t deviceIndex);

    /**
     * Get the resource monitor's event stream in order to subscribe to
     * updates and warnings.
     *
     * @return Pointer to resource monitor's event stream
     */
    carb::events::IEventStream*(CARB_ABI* getEventStream)();
};

} // namespace resourcemonitor
} // namespace omni
