// Copyright (c) 2020, 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 <unordered_map>
#include <carb/graphics/GraphicsTypes.h>

namespace omni
{

namespace usd
{
namespace hydra
{
    struct HydraRenderProduct;
} // namespace hydra
} // namespace usd

namespace graph
{
namespace core
{

// Less than ideal, but GpuInteropCudaEntryUserData + GpuInteropRpEntryUserData
// are filled out by RenderGraphScheduler.cpp and passed to the top level GpuInterop
// CudaEntry or RenderProductEntry nodes marking the head of post-processing chain
// for RTX Hydra Renderer

struct GpuInteropCudaResourceData
{
    void* cudaResource;
    uint32_t width;
    uint32_t height;
    uint32_t depthOrArraySize;
    uint16_t mipCount;
    carb::graphics::Format format;
    bool isBuffer;
    uint32_t deviceIndex;
};

typedef std::unordered_map<std::string, GpuInteropCudaResourceData> GpuInteropCudaResourceMap;

struct GpuInteropCudaEntryUserData
{
    void* cudaStream;
    double simTime;
    double hydraTime;
    int64_t frameId;
    int64_t externalTimeOfSimFrame;
    GpuInteropCudaResourceMap cudaRsrcMap;
};

// Gpu Foundations initialization inside Kit remains a trainwreck, since unresolved
// we pass

struct GpuFoundationsInterfaces
{
    void* graphics;
    void* graphicsMux;
    void* deviceGroup;
    void* renderGraphBuilder;
    void* resourceManager;
    void* resourceManagerContext;
    void* renderGraph;
};

struct GpuInteropRpEntryUserData
{
    double simTime;
    double hydraTime;
    GpuFoundationsInterfaces* gpu;
    omni::usd::hydra::HydraRenderProduct* rp;
};

} // namespace core
} // namespace graph
} // namespace omni
