blob: d811e04d999385c93d85c2b8a6c069346db3a986 [file] [log] [blame]
/*************************************************************************/ /*!
@File
@Title RGX Common Types and Defines Header
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Common types and definitions for RGX software
@License MIT
The contents of this file are subject to the MIT license as set out below.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ /**************************************************************************/
#ifndef RGX_COMMON_H_
#define RGX_COMMON_H_
#if defined (__cplusplus)
extern "C" {
#endif
#include "img_defs.h"
/* Included to get the BVNC_KM_N defined and other feature defs */
#include "km/rgxdefs_km.h"
/*! This macro represents a mask of LSBs that must be zero on data structure
* sizes and offsets to ensure they are 8-byte granular on types shared between
* the FW and host driver */
#define RGX_FW_ALIGNMENT_LSB (7)
/*! Macro to test structure size alignment */
#define RGX_FW_STRUCT_SIZE_ASSERT(_a) \
static_assert((sizeof(_a) & RGX_FW_ALIGNMENT_LSB) == 0, \
"Size of " #_a " is not properly aligned")
/*! Macro to test structure member alignment */
#define RGX_FW_STRUCT_OFFSET_ASSERT(_a, _b) \
static_assert((offsetof(_a, _b) & RGX_FW_ALIGNMENT_LSB) == 0, \
"Offset of " #_a "." #_b " is not properly aligned")
/* The following enum assumes only one of RGX_FEATURE_TLA or RGX_FEATURE_FASTRENDER_DM feature
* is present. In case this is no more true, fail build to fix code */
#if defined (RGX_FEATURE_TLA) && defined (RGX_FEATURE_FASTRENDER_DM)
#error "Both RGX_FEATURE_TLA and RGX_FEATURE_FASTRENDER_DM defined. Fix code to handle this!"
#endif
/*! The master definition for data masters known to the firmware of RGX.
* When a new DM is added to this enum, relevant entry should be added to
* RGX_HWPERF_DM enum list.
* The DM in a V1 HWPerf packet uses this definition. */
typedef enum _RGXFWIF_DM_
{
RGXFWIF_DM_GP = 0,
/* Either TDM or 2D DM is present. The above build time error is present to verify this */
RGXFWIF_DM_2D = 1, /* when RGX_FEATURE_TLA defined */
RGXFWIF_DM_TDM = 1, /* when RGX_FEATURE_FASTRENDER_DM defined */
RGXFWIF_DM_TA = 2,
RGXFWIF_DM_3D = 3,
RGXFWIF_DM_CDM = 4,
/* present on Ray cores only */
RGXFWIF_DM_RTU = 5,
RGXFWIF_DM_SHG = 6,
RGXFWIF_DM_LAST,
RGXFWIF_DM_FORCE_I32 = 0x7fffffff /*!< Force enum to be at least 32-bits wide */
} RGXFWIF_DM;
typedef enum _RGX_KICK_TYPE_DM_
{
RGX_KICK_TYPE_DM_GP = 1 << 0,
RGX_KICK_TYPE_DM_TDM_2D = 1 << 1,
RGX_KICK_TYPE_DM_TA = 1 << 2,
RGX_KICK_TYPE_DM_3D = 1 << 3,
RGX_KICK_TYPE_DM_CDM = 1 << 4,
RGX_KICK_TYPE_DM_RTU = 1 << 5,
RGX_KICK_TYPE_DM_SHG = 1 << 6,
RGX_KICK_TYPE_DM_TQ2D = 1 << 7,
RGX_KICK_TYPE_DM_TQ3D = 1 << 8,
RGX_KICK_TYPE_DM_LAST = 1 << 9
} RGX_KICK_TYPE_DM;
/* Maximum number of DM in use: GP, 2D/TDM, TA, 3D, CDM, SHG, RTU */
#define RGXFWIF_DM_DEFAULT_MAX (7)
#if !defined(__KERNEL__)
#if defined(RGX_FEATURE_RAY_TRACING)
#define RGXFWIF_DM_MAX_MTS 8
#else
#define RGXFWIF_DM_MAX_MTS 6
#endif
#if defined(RGX_FEATURE_RAY_TRACING)
/* Maximum number of DM in use: GP, 2D/TDM, TA, 3D, CDM, SHG, RTU */
#define RGXFWIF_DM_MAX (7)
#else
/* Maximum number of DM in use: GP, 2D/TDM, TA, 3D, CDM*/
#define RGXFWIF_DM_MAX (5)
#endif
#define RGXFWIF_HWDM_MAX (RGXFWIF_DM_MAX)
#else
#define RGXFWIF_DM_MIN_MTS_CNT (6)
#define RGXFWIF_RAY_TRACING_DM_MTS_CNT (2)
#define RGXFWIF_DM_MIN_CNT (5)
#define RGXFWIF_RAY_TRACING_DM_CNT (2)
#define RGXFWIF_DM_MAX (RGXFWIF_DM_MIN_CNT + RGXFWIF_RAY_TRACING_DM_CNT)
#endif
/* Min/Max number of HW DMs (all but GP) */
#if defined(RGX_FEATURE_TLA)
#define RGXFWIF_HWDM_MIN (1)
#else
#if defined(RGX_FEATURE_FASTRENDER_DM)
#define RGXFWIF_HWDM_MIN (1)
#else
#define RGXFWIF_HWDM_MIN (2)
#endif
#endif
/*
* Data Master Tags to be appended to resources created on behalf of each RGX
* Context.
*/
#define RGX_RI_DM_TAG_KS 'K'
#define RGX_RI_DM_TAG_CDM 'C'
#define RGX_RI_DM_TAG_RC 'R' // To be removed once TA/3D Timelines are split
#define RGX_RI_DM_TAG_TA 'V'
#define RGX_RI_DM_TAG_3D 'P'
#define RGX_RI_DM_TAG_TDM 'T'
#define RGX_RI_DM_TAG_TQ2D '2'
#define RGX_RI_DM_TAG_TQ3D 'Q'
/*
* Client API Tags to be appended to resources created on behalf of each
* Client API.
*/
#define RGX_RI_CLIENT_API_GLES1 '1'
#define RGX_RI_CLIENT_API_GLES3 '3'
#define RGX_RI_CLIENT_API_VULKAN 'V'
#define RGX_RI_CLIENT_API_EGL 'E'
#define RGX_RI_CLIENT_API_OPENCL 'C'
#define RGX_RI_CLIENT_API_OPENGL 'G'
#define RGX_RI_CLIENT_API_SERVICES 'S'
#define RGX_RI_CLIENT_API_WSEGL 'W'
#define RGX_RI_CLIENT_API_ANDROID 'A'
#define RGX_RI_CLIENT_API_LWS 'L'
/*
* Format a RI annotation for a given RGX Data Master context
*/
#define RGX_RI_FORMAT_DM_ANNOTATION(annotation, dmTag, clientAPI) do \
{ \
annotation[0] = dmTag; \
annotation[1] = clientAPI; \
annotation[2] = '\0'; \
} while (0)
/*!
******************************************************************************
* RGXFW Compiler alignment definitions
*****************************************************************************/
#if defined(__GNUC__) || defined(HAS_GNUC_ATTRIBUTES)
#define RGXFW_ALIGN __attribute__ ((aligned (8)))
#elif defined(_MSC_VER)
#define RGXFW_ALIGN __declspec(align(8))
#pragma warning (disable : 4324)
#else
#error "Align MACROS need to be defined for this compiler"
#endif
/*!
******************************************************************************
* Force 8-byte alignment for structures allocated uncached.
*****************************************************************************/
#define UNCACHED_ALIGN RGXFW_ALIGN
#if defined (__cplusplus)
}
#endif
#endif /* RGX_COMMON_H_ */
/******************************************************************************
End of file
******************************************************************************/