// 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 <carb/graphics/Graphics.h>

using namespace carb::graphics;

namespace omni
{
namespace gpucompute
{
// TODO: move out of public API
struct ContextD3D
{
    std::unique_ptr<Device, GfxResult (*)(Device*)> device;
    CommandQueue* commandQueue; // Not unique_ptr because we don't own it
    std::unique_ptr<CommandAllocator, void (*)(CommandAllocator*)> commandAllocator;
    std::unique_ptr<CommandList, void (*)(CommandList*)> commandList;
    std::unique_ptr<Fence, void (*)(Fence*)> fence;

    ContextD3D(DeviceDesc deviceDesc, carb::graphics::Graphics* graphics)
        : device(graphics->createDevice(deviceDesc), graphics->destroyDevice),
          commandQueue(graphics->getCommandQueue(device.get(), CommandQueueType::eRender, 0)),
          commandAllocator(graphics->createCommandAllocator(commandQueue), graphics->destroyCommandAllocator),
          commandList(graphics->createCommandList(commandAllocator.get()), graphics->destroyCommandList),
          fence(graphics->createFence(device.get(), carb::graphics::FenceDesc { kFenceCreateFlagNone, "GPU compute context fence" }), graphics->destroyFence)
    {
    }
};
}
}
