Program Listing for File cross-gpu-common.h

Return to documentation for file (include\cross-gpu\cross-gpu-common.h)

/******************************************************************************
(C) Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.


 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/
#pragma once

#include <d3d12.h>

#include <memory>
#include <map>
#include <unordered_map>

#include "reflection/struct-data-manager.h"

namespace gpa {
namespace cross_gpu {

using Ptr = uint64_t;
using Size = uint64_t;
using Offset = uint64_t;
using GpuVA = D3D12_GPU_VIRTUAL_ADDRESS;
using Offsets = std::map<Offset, Offset>;

template<typename T>
using ResourceTo = std::unordered_map<Ptr, T>;

template<typename T>
using VirtualAddressTo = std::map<GpuVA, T>;

struct AllocationInfo
{
    D3D12_RESOURCE_ALLOCATION_INFO heap{};
    std::vector<D3D12_RESOURCE_ALLOCATION_INFO1> resources;
};

enum class ResourceType {
    kPlaced = 0,
    kReserved,
    kCommited
};

struct HeapRegionInfo
{
    uint32_t heapRangeStartOffsets;
    uint32_t rangeTileCounts;
};

struct RegionInfo
{
    D3D12_TILED_RESOURCE_COORDINATE resourceRegionStartCoordinate{};
    D3D12_TILE_REGION_SIZE resourceRegionSize{};
};

struct TileMappingInfo
{
    std::vector<RegionInfo> resourceRegions;
    std::vector<HeapRegionInfo> heapRegions;
};

enum class DxrDataType {
    kAccelerationStructure,
    kScratchStorage
};

struct DxrData
{
    DxrDataType type = {};
    uint64_t offset = {};
    std::unique_ptr<serialization::StructDataManager> accelerationStructureInputs;
};

struct AllocationManager
{
    virtual ~AllocationManager() = default;
    virtual Size GetResourceSize(const D3D12_RESOURCE_DESC* desc, ResourceType resourceType) = 0;
    virtual AllocationInfo GetResourceAllocationInfo1(const std::vector<D3D12_RESOURCE_DESC>& pResourceDescs) = 0;
    virtual D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO GetRaytracingPrebuildInfo(const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS& inputsDesc) = 0;
};

}  // namespace cross_gpu
}  // namespace gpa