gatherscatter_dataflow.h#

Fully qualified name: src/device/vpu_runtime/include/cupva_device/gatherscatter_dataflow.h

File members: src/device/vpu_runtime/include/cupva_device/gatherscatter_dataflow.h

/*
 * Copyright (c) 2023 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.
 */

#ifndef CUPVA_DEVICE_GATHERSCATTER_DATAFLOW_H
#define CUPVA_DEVICE_GATHERSCATTER_DATAFLOW_H

#include "impl/gsdf_impl_swseq.h"

#include <cupva_types.h>
#if CUPVA_PVA_GEN_NUMBER > 2
#    include "impl/gsdf_impl_hwseq.h"
#endif

#define GSDF_SURFACE_MIN_TILE_PITCH(_type, _tw) ((_tw) + GSDF_BL_X_OFFSET(_type))

#define GSDF_SURFACE_MIN_TILE_HEIGHT(_th) ((_th) + GSDF_BL_Y_OFFSET)

#define GSDF_SURFACE_MIN_TILE_STRIDE(_type, _tw, _th) \
    (GSDF_SURFACE_MIN_TILE_PITCH(_type, _tw) * GSDF_SURFACE_MIN_TILE_HEIGHT(_th))

#define GSDF_SURFACE_MIN_TILEBUFFER_SIZE(_type, _tw, _th, _nt) (GSDF_SURFACE_MIN_TILE_STRIDE(_type, _tw, _th) * (_nt))

#define GSDF_SURFACE_TILE_OFFSET(_type, _tile_pitch) ((GSDF_BL_Y_OFFSET) * (_tile_pitch) + GSDF_BL_X_OFFSET(_type))

#define VMEM_GSDF_HANDLER(bank, name, numTiles, ...)                                             \
    VMEM_GSDF_HANDLER_MACRO(bank, name, numTiles, ##__VA_ARGS__, VMEM_GSDF_HANDLER_UNIFORM_IMPL, \
                            VMEM_GSDF_HANDLER_IMPL)                                              \
    (bank, name, numTiles, ##__VA_ARGS__)

#define GSDF_UNIFORM (1)

struct GSDFHandler
{
    GSDFParams params;
    uint8_t planeIndices[GSDF_MAX_NUM_TILES];
    union
    {
        GSDFSwseqPriv swseq;
#if CUPVA_PVA_GEN_NUMBER > 2
        GSDFHwseqPriv hwseq;
#endif
    } priv;
    uint8_t data[1];
};

struct GSDFHandlerUniform
{
    GSDFParams params;
    uint8_t planeIndices[GSDF_MAX_NUM_TILES];
    union
    {
        GSDFSwseqPriv swseq;
#if CUPVA_PVA_GEN_NUMBER > 2
        GSDFHwseqPriv hwseq;
#endif
    } priv;
    uint8_t data[1];
};

inline bool cupvaGSDFResetExtBase(GSDFHandler *handler, ExtMemPointer const *addr, uint16_t width, uint16_t height,
                                  uint16_t linePitch)
{
    bool retVal;
    GSDF_IMPL_FUNC_RET(ResetExtBase, retVal, handler, addr, width, height, linePitch);
    return retVal;
}

inline bool cupvaGSDFResetExtBase(GSDFHandler *handler, VPUSurfaceData const *surfObj)
{
    bool retVal = false;
    GSDF_IMPL_FUNC_RET(ResetExtBase, retVal, handler, surfObj);
    return retVal;
}

inline bool cupvaGSDFResetExtBase(GSDFHandler *handler, VPUSurfaceData const *surfObj, PlanarGeometry const *geom)
{
    bool retVal = false;
    GSDF_IMPL_FUNC_RET(ResetExtBase, retVal, handler, surfObj, geom);
    return retVal;
}

inline bool cupvaGSDFResetExtBase(GSDFHandler *handler, ExtMemPointer const *addr, PlanarGeometry const *geom)
{
    bool retVal = false;
    GSDF_IMPL_FUNC_RET(ResetExtBase, retVal, handler, addr, geom);
    return retVal;
}

inline void cupvaGSDFUpdateOffsets1D(GSDFHandler *handler, int32_t const *offsets)
{
    GSDF_IMPL_FUNC(UpdateOffsets1D, handler, offsets);
}

inline void cupvaGSDFUpdateOffsets2D(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords)
{
    GSDF_IMPL_FUNC(UpdateOffsets2D, handler, xCoords, yCoords);
}

inline void cupvaGSDFUpdateVmemAddr(GSDFHandler *handler, void *addr, uint16_t linePitch, uint32_t stride)
{
    GSDF_IMPL_FUNC(UpdateVmemAddr, handler, addr, linePitch, stride);
}

inline void cupvaGSDFUpdateSize2D(GSDFHandler *handler, uint16_t const *tx, uint16_t const *ty, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateSize2D, handler, tx, ty, size);
}

inline void cupvaGSDFUpdateSize2D(GSDFHandler *handler, uint16_t tx, uint16_t ty, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateSize2D, handler, tx, ty, size);
}

inline void cupvaGSDFUpdateSize1D(GSDFHandler *handler, uint16_t const *transferSizes, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateSize1D, handler, transferSizes, size);
}

inline void cupvaGSDFUpdateSize1D(GSDFHandler *handler, uint16_t transferSize, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateSize1D, handler, transferSize, size);
}

inline void cupvaGSDFUpdateTiles(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
                                 uint16_t const *tx, uint16_t const *ty, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateTiles, handler, xCoords, yCoords, tx, ty, size);
}

inline void cupvaGSDFUpdateTiles(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
                                 uint16_t const tx, uint16_t const ty, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateTiles, handler, xCoords, yCoords, tx, ty, size);
}

inline void cupvaGSDFUpdateTiles(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateTiles, handler, xCoords, yCoords, size);
}

inline void cupvaGSDFUpdateTilesWithOffsets(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
                                            int32_t const *offsets, uint16_t const *tx, uint16_t const *ty,
                                            int32_t size)
{
    GSDF_IMPL_FUNC(UpdateTilesWithOffsets, handler, xCoords, yCoords, offsets, tx, ty, size);
}

inline void cupvaGSDFUpdateTilesWithOffsets(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
                                            int32_t const *offsets, uint16_t const tx, uint16_t const ty, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateTilesWithOffsets, handler, xCoords, yCoords, offsets, tx, ty, size);
}

inline void cupvaGSDFUpdateTilesWithOffsets(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
                                            int32_t const *offsets, int32_t size)
{
    GSDF_IMPL_FUNC(UpdateTilesWithOffsets, handler, xCoords, yCoords, offsets, size);
}

inline void cupvaGSDFUpdatePlaneIndices(GSDFHandler *handler, uint8_t const *planeIndices, int32_t size)
{
    GSDF_IMPL_FUNC(UpdatePlaneIndices, handler, planeIndices, size);
}

inline bool cupvaGSDFOpen(GSDFHandler *handler, void *addr, uint16_t linePitch, uint32_t stride)
{
    bool retVal = false;
    GSDF_IMPL_FUNC_RET(Open, retVal, handler, addr, linePitch, stride);
    return retVal;
}

inline void cupvaGSDFTrig(GSDFHandler *handler)
{
    GSDF_IMPL_FUNC(Trig, handler, &handler->params, POINTER_CAST(void, &handler->priv));
}

inline void cupvaGSDFSync(GSDFHandler *handler)
{
    GSDF_IMPL_FUNC(Sync, handler, &handler->params, POINTER_CAST(void, &handler->priv));
}

inline void cupvaGSDFCycleBuffers(GSDFHandler *handler)
{
    GSDF_IMPL_FUNC(CycleBuffers, handler, POINTER_CAST(void, &handler->priv));
}

inline void cupvaGSDFClose(GSDFHandler *handler)
{
    GSDF_IMPL_FUNC(Close, handler);
}

inline bool cupvaGSDFResetExtBase(GSDFHandlerUniform *handler, ExtMemPointer const *addr, uint16_t width,
                                  uint16_t height, uint16_t linePitch)
{
    bool retVal = false;
    GSDF_IMPL_FUNC_RET(ResetExtBase, retVal, handler, addr, width, height, linePitch);
    return retVal;
}

inline bool cupvaGSDFResetExtBase(GSDFHandlerUniform *handler, ExtMemPointer const *addr, PlanarGeometry *geometry)
{
    bool retVal = false;
    GSDF_IMPL_FUNC_RET(ResetExtBase, retVal, handler, addr, geometry);
    return retVal;
}

inline void cupvaGSDFUpdateOffsets1D(GSDFHandlerUniform *handler, int32_t const *offsets)
{
    GSDF_IMPL_FUNC(UpdateOffsets1D, handler, offsets);
}

inline void cupvaGSDFUpdateOffsets2D(GSDFHandlerUniform *handler, int32_t const *xCoords, int32_t const *yCoords)
{
    GSDF_IMPL_FUNC(UpdateOffsets2D, handler, xCoords, yCoords);
}

inline void cupvaGSDFUpdateVmemAddr(GSDFHandlerUniform *handler, void *addr, uint16_t linePitch, uint32_t stride)
{
    GSDF_IMPL_FUNC(UpdateVmemAddr, handler, addr, linePitch, stride);
}

inline void cupvaGSDFUpdateSize2D(GSDFHandlerUniform *handler, uint16_t tx, uint16_t ty)
{
    GSDF_IMPL_FUNC(UpdateSize2D, handler, tx, ty);
}

inline void cupvaGSDFUpdateSize1D(GSDFHandlerUniform *handler, uint16_t transferSize)
{
    GSDF_IMPL_FUNC(UpdateSize1D, handler, transferSize);
}

inline void cupvaGSDFUpdatePlaneIndices(GSDFHandlerUniform *handler, uint8_t const *planeIndices)
{
    GSDF_IMPL_FUNC(UpdatePlaneIndices, handler, planeIndices);
}

inline bool cupvaGSDFOpen(GSDFHandlerUniform *handler, void *addr, uint16_t linePitch, uint32_t stride)
{
    bool retVal = false;
    GSDF_IMPL_FUNC_RET(Open, retVal, handler, addr, linePitch, stride);
    return retVal;
}

inline void cupvaGSDFTrig(GSDFHandlerUniform *handler)
{
    GSDF_IMPL_FUNC(Trig, handler, &handler->params, POINTER_CAST(void, &handler->priv));
}

inline void cupvaGSDFSync(GSDFHandlerUniform *handler)
{
    GSDF_IMPL_FUNC(Sync, handler, &handler->params, POINTER_CAST(void, &handler->priv));
}

inline void cupvaGSDFCycleBuffers(GSDFHandlerUniform *handler)
{
    GSDF_IMPL_FUNC(CycleBuffers, handler, POINTER_CAST(void, &handler->priv));
}

inline void cupvaGSDFClose(GSDFHandlerUniform *handler)
{
    GSDF_IMPL_FUNC(Close, handler);
}

#endif // CUPVA_GATHERSCATTER_DATAFLOW_H