Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion drivers/amlogic/npu/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_context.o \
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o \
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_async_fe.o \
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_mc_fe.o \
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_waitlink_fe.o
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_waitlink_fe.o \
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_func.o

ifeq ($(VIVANTE_ENABLE_3D),1)
OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_recorder.o
Expand Down
29 changes: 18 additions & 11 deletions drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_interface.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved.
* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
Expand Down Expand Up @@ -55,8 +55,11 @@
/* 0.0.1.32 Add extension flag in VIR_Symbol 05/27/2019 */
/* 0.0.1.33 Add a new opcode LOGICAL_RSHIFT 05/28/2019 */
/* 0.0.1.34 Add WorkGroupSizeFactor in VIR_ComputeLayout on 07/18/2019 */
#define gcdVIR_SHADER_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 34)
#define gcdVIR_PROGRAM_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 34)
/* 0.0.1.35 Add skhp flag in VIR_Instruction */
/* 0.0.1.36 Add a function to patch clipDistance in GL VIR lib shader */
/* 0.0.1.37 Add the sampled image information on 03/11/2020 */
#define gcdVIR_SHADER_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 37)
#define gcdVIR_PROGRAM_BINARY_FILE_VERSION gcmCC(SHADER_64BITMODE, 0, 1, 37)

#if !defined(gcdTARGETHOST_BIGENDIAN)
#define gcdTARGETHOST_BIGENDIAN 0 /* default host little endian, to change the
Expand Down Expand Up @@ -491,8 +494,8 @@ typedef VSC_TyQualifier VIR_TyQualifier;
* to achieve best performance */
typedef enum {
VSC_OCLImgLibKind_UseLoadStore = 0, /* for v54x GC chips, use LOAD/STORE/TEXLD */
VSC_OCLImgLibKind_UseImgLoadTexldU = 1, /* for v55 GC chips, use IMG_LOAD/IMG_STORE/TEXLD_U */
VSC_OCLImgLibKind_UseImgLoadTexldUXY = 2, /* for v60 GC and v620 GC chips */
VSC_OCLImgLibKind_UseImgLoadTexldU = 1, /* for v55 GC chips, use IMG_LOAD/IMG_STORE/TEXLD_U -- unused now */
VSC_OCLImgLibKind_UseImgLoadTexldUXY = 2, /* for v60 GC and v620 GC chips -- unused now*/
VSC_OCLImgLibKind_UseImgLoadVIP = 3, /* v60 VIP chip, use IMG_LOAD/IMG_STORE */
VSC_OCLImgLibKind_Counts, /* count of img libs */
VSC_OCLImgLibKind_BasedOnHWFeature /* select library based on HW feature */
Expand Down Expand Up @@ -732,7 +735,10 @@ typedef struct _VSC_HW_CONFIG
/* word 3 */
gctUINT hasPointSizeFix : 1;
gctUINT supportVectorB0 : 1;
gctUINT reserved1 : 30;
gctUINT hasAtomTimingFix : 1;
gctUINT hasUSCAtomicFix2 : 1;
gctUINT hasFloatingMadFix : 1;
gctUINT reserved1 : 27;

/* Last word */
/* Followings will be removed after shader programming is removed out of VSC */
Expand All @@ -750,16 +756,15 @@ typedef struct _VSC_HW_CONFIG
gctUINT robustAtomic : 1;
gctUINT newGPIPE : 1;
gctUINT FEDrawDirect : 1;

gctUINT hasUSCAtomicFix2 : 1;
gctUINT reserved2 : 18;
gctUINT reserved2 : 19;
} hwFeatureFlags;

gctUINT chipModel;
gctUINT chipRevision;
gctUINT productID;
gctUINT customerID;
gctUINT maxCoreCount;
gctUINT maxClusterCount;
gctUINT maxThreadCountPerCore;
gctUINT maxVaryingCount;
gctUINT maxAttributeCount;
Expand Down Expand Up @@ -841,8 +846,9 @@ typedef gcsGLSLCaps VSC_GL_API_CONFIG, *PVSC_GL_API_CONFIG;
#define VSC_COMPILER_OPT_FULL_ACTIVE_IO 0x0000000000008000ULL
#define VSC_COMPILER_OPT_DUAL16 0x0000000000010000ULL
#define VSC_COMPILER_OPT_ILF_LINK 0x0000000000020000ULL
#define VSC_COMPILER_OPT_LOOP 0x0000000000040000ULL

#define VSC_COMPILER_OPT_FULL 0x000000000003FFFFULL
#define VSC_COMPILER_OPT_FULL 0x000000000007FFFFULL

#define VSC_COMPILER_OPT_NO_ALGE_SIMP 0x0000000100000000ULL
#define VSC_COMPILER_OPT_NO_GCP 0x0000000200000000ULL
Expand All @@ -862,8 +868,9 @@ typedef gcsGLSLCaps VSC_GL_API_CONFIG, *PVSC_GL_API_CONFIG;
#define VSC_COMPILER_OPT_NO_FULL_ACTIVE_IO 0x0000800000000000ULL
#define VSC_COMPILER_OPT_NO_DUAL16 0x0001000000000000ULL
#define VSC_COMPILER_OPT_NO_ILF_LINK 0x0002000000000000ULL
#define VSC_COMPILER_OPT_NO_LOOP 0x0004000000000000ULL

#define VSC_COMPILER_OPT_NO_OPT 0x0003FFFF00000000ULL
#define VSC_COMPILER_OPT_NO_OPT 0x0007FFFF00000000ULL

/* Compiler flag for special purpose */
#define VSC_COMPILER_FLAG_COMPILE_TO_HL 0x00000001 /* Compile IR to HL, including doing all opts in HL */
Expand Down
2 changes: 1 addition & 1 deletion drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_kernel_profile.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved.
* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
Expand Down
40 changes: 29 additions & 11 deletions drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_lib_link.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved.
* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
Expand All @@ -25,6 +25,10 @@ typedef union _SPECIALIZATION_CONSTANT_VALUE

typedef struct _VSC_LIB_SPECIALIZATION_CONSTANT
{
/*
** Some specialized variables for a function parameter, note that a name of the function parameter may be padding with "#dup%d",
** so we need to use gcoOS_StrNCmp to compare with the function parameter.
*/
gctCONST_STRING varName;
SPECIALIZATION_CONSTANT_VALUE value;
VSC_SHADER_DATA_TYPE type;
Expand Down Expand Up @@ -114,12 +118,14 @@ typedef enum _VSC_RES_ACT_BIT

typedef enum _VSC_LINK_POINT_RESOURCE_SUBTYPE
{
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXLD_EXTRA_LATYER = 1,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXGRAD_EXTRA_LATYER = 2,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXFETCH_REPLACE_WITH_IMGLD = 3,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXGATHER_EXTRA_LAYTER = 4,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXGATHERPCF_D32F = 5,
VSC_LINK_POINT_RESOURCE_SUBTYPE_NORMALIZE_TEXCOORD = 6,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXLD_EXTRA_LAYER = 1,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXLD_EXTRA_LAYER_SPECIFIED_OP = 2,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXGRAD_EXTRA_LAYER = 3,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXFETCH_REPLACE_WITH_IMGLD = 4,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXGATHER_EXTRA_LAYTER = 5,
VSC_LINK_POINT_RESOURCE_SUBTYPE_TEXGATHERPCF_D32F = 6,
VSC_LINK_POINT_RESOURCE_SUBTYPE_NORMALIZE_TEXCOORD = 7,
VSC_LINK_POINT_RESOURCE_SUBTYPE_YCBCR_TEXTURE = 8,
} VSC_LINK_POINT_RESOURCE_SUBTYPE;

typedef struct _VSC_LIB_LINK_POINT_FUNC_NAME
Expand All @@ -140,6 +146,7 @@ typedef struct _VSC_LIB_LINK_POINT_RESOURCE
gctUINT arrayIndex;
VSC_RES_OP_BIT opTypeBits;
VSC_RES_ACT_BIT actBits;
void* pPrivData;
VSC_LINK_POINT_RESOURCE_SUBTYPE subType;
} VSC_LIB_LINK_POINT_RESOURCE;

Expand All @@ -165,12 +172,21 @@ typedef struct _VSC_LIB_LINK_IMAGE_READ_WRITE
VSC_SAMPLER_INFO * samplerInfo;
} VSC_LIB_LINK_IMAGE_READ_WRITE;

/* Same value with VIR_IMAGE_ACCESS_STRATEGY. */
typedef enum _VSC_LIB_LINK_IMAGE_ACCESS_STRATEGY
{
VSC_LIB_LINK_IMAGE_ACCESS_STRATEGY_USE_FORMAT = 0,
VSC_LIB_LINK_IMAGE_ACCESS_STRATEGY_LOAD_ZERO_STORE_NOP = 1,
VSC_LIB_LINK_IMAGE_ACCESS_STRATEGY_LOAD_ZERO_STORE_ZERO = 2,
} VSC_LIB_LINK_IMAGE_ACCESS_STRATEGY;

typedef struct _VSC_LIB_LINK_IMAGE_FORMAT
{
gctUINT set;
gctUINT binding;
gctUINT arrayIndex;
VSC_IMAGE_FORMAT imageFormat;
gctUINT set;
gctUINT binding;
gctUINT arrayIndex;
VSC_IMAGE_FORMAT imageFormat;
VSC_LIB_LINK_IMAGE_ACCESS_STRATEGY replaceStrategy;
} VSC_LIB_LINK_IMAGE_FORMAT;

typedef struct _VSC_LIB_LINK_POINT
Expand All @@ -194,13 +210,15 @@ typedef struct _VSC_LIB_LINK_POINT
} u;
}VSC_LIB_LINK_POINT;

#define LIB_NUM 2
typedef struct _VSC_SHADER_LIB_LINK_ENTRY
{
/* Which level this link entry should be applied. */
VSC_SH_LEVEL applyLevel;

/* Lib shader */
SHADER_HANDLE hShaderLib;
SHADER_HANDLE hShaderLibs[LIB_NUM];

/* vreg map from libShader to the current shader */
void* pTempHashTable;
Expand Down
74 changes: 46 additions & 28 deletions drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_program_profile.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved.
* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
Expand Down Expand Up @@ -469,6 +469,30 @@ PROG_GL_XFB_OUT_TABLE;
********************************** VK program mapping table definitions *********************************
**********************************************************************************************************************/

typedef struct PROG_VK_IMAGE_FORMAT_INFO
{
VSC_IMAGE_FORMAT imageFormat;
gctBOOL bSetInSpriv;
}
PROG_VK_IMAGE_FORMAT_INFO;

typedef struct PROG_VK_IMAGE_DERIVED_INFO
{
/* For a image, it might need a image-size attached. As each image in
Binding::arraySize array has image-size, so this is the first entry
of image-size array. */
SHADER_PRIV_CONSTANT_ENTRY* pImageSize;

/* Extra layer HW mapping. As currently, for images in in tBinding::arraySize
array, if one image has extra image, all other images must have extra image, so
this is the first entry of extra-image */
SHADER_PRIV_UAV_ENTRY* pExtraLayer;

/* ImageFormat, can be NONE. */
PROG_VK_IMAGE_FORMAT_INFO imageFormatInfo;
}
PROG_VK_IMAGE_DERIVED_INFO;

typedef struct PROG_VK_SUB_RESOURCE_BINDING
{
/* Pointer to original API resource binding */
Expand Down Expand Up @@ -528,6 +552,7 @@ typedef struct PROG_VK_PRIV_COMB_TEX_SAMP_HW_MAPPING_LIST
VSC_SHADER_RESOURCE_TYPE_COMBINED_IMAGE_SAMPLER
*/

#define __YCBCR_PLANE_COUNT__ 3
typedef struct PROG_VK_COMBINED_TEXTURE_SAMPLER_HW_MAPPING
{
/* For the case
Expand All @@ -541,6 +566,9 @@ typedef struct PROG_VK_COMBINED_TEXTURE_SAMPLER_HW_MAPPING
combTsBinding::arraySize */
SHADER_PRIV_SAMPLER_ENTRY** ppExtraSamplerArray;

/* For the ycbcr texture recompilation. */
SHADER_PRIV_UAV_ENTRY* pYcbcrPlanes[__YCBCR_PLANE_COUNT__];

/* For the case that HW natively supports separated texture, so texture part of API
combined texture sampler will be directly mapped to HW separated texture */
SHADER_RESOURCE_SLOT_MAPPING texMapping;
Expand Down Expand Up @@ -663,15 +691,7 @@ typedef union PROG_VK_SEPARATED_TEXTURE_HW_MAPPING
/* For HW does not natively supports separated texture */
struct
{
/* For a separated image, it might need a image-size attached. As each image in
storageBinding::arraySize array has image-size, so this is the first entry
of image-size array. */
SHADER_PRIV_CONSTANT_ENTRY* pImageSize;

/* Extra layer HW mapping. As currently, for images in in texBinding::arraySize
array, if one image has extra image, all other images must have extra image, so
this is the first entry of extra-image */
SHADER_PRIV_UAV_ENTRY* pExtraLayer;
PROG_VK_IMAGE_DERIVED_INFO imageDerivedInfo;

/* We still need to allocate a constant image for this separated texture for the imageFetch operation.*/
SHADER_UAV_SLOT_MAPPING hwMapping;
Expand Down Expand Up @@ -749,6 +769,13 @@ typedef struct PROG_VK_UNIFORM_TEXEL_BUFFER_HW_MAPPING
}
PROG_VK_UNIFORM_TEXEL_BUFFER_HW_MAPPING;

typedef enum PROG_VK_UNIFORM_TEXEL_BUFFER_ENTRY_FLAG
{
PROG_VK_UTB_ENTRY_FLAG_NONE = 0x0000,
/* Treat a texelBuffer as an image, now from a recompilation only. */
PROG_VK_UTB_ENTRY_FLAG_TREAT_TEXELBUFFER_AS_IMAGE = 0x0002,
} PROG_VK_UNIFORM_TEXEL_BUFFER_ENTRY_FLAG;

typedef struct PROG_VK_UNIFORM_TEXEL_BUFFER_TABLE_ENTRY
{
/* API resource binding */
Expand All @@ -763,14 +790,16 @@ typedef struct PROG_VK_UNIFORM_TEXEL_BUFFER_TABLE_ENTRY
/* Is this entry really used by shader */
gctUINT activeStageMask;

PROG_VK_UNIFORM_TEXEL_BUFFER_ENTRY_FLAG utbEntryFlag;

/*----------------------------------Sampler-related----------------------------------*/
/* For texel buffer, it might need a texture-size attached. As each texel buffer in
utbBinding::arraySize array has texture-size, so this is the first entry
of texture-size array. */
SHADER_PRIV_CONSTANT_ENTRY* pTextureSize[VSC_MAX_SHADER_STAGE_COUNT][2];

/*----------------------------------Image-related----------------------------------*/
VSC_IMAGE_FORMAT imageFormat;
PROG_VK_IMAGE_DERIVED_INFO imageDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT];

/* Which kinds of inst operation acting on texture. The count of this
resOpBit is same as utbBinding::arraySize */
Expand Down Expand Up @@ -826,15 +855,7 @@ typedef struct PROG_VK_INPUT_ATTACHMENT_TABLE_ENTRY
** it is treated as a sampler, otherwise it is treated as an image.
*/
/*----------------------------------Image-related----------------------------------*/
/* For image storage, it might need a image-size attached. As each image in
iaBinding::arraySize array has image-size, so this is the first entry
of image-size array. */
SHADER_PRIV_CONSTANT_ENTRY* pImageSize[VSC_MAX_SHADER_STAGE_COUNT];

/* Extra layer HW mapping. As currently, for images in in iaBinding::arraySize
array, if one image has extra image, all other images must have extra image, so
this is the first entry of extra-image */
SHADER_PRIV_UAV_ENTRY* pExtraLayer[VSC_MAX_SHADER_STAGE_COUNT];
PROG_VK_IMAGE_DERIVED_INFO imageDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT];

/*----------------------------------Sampler-related----------------------------------*/
/* For texel buffer, it might need a texture-size attached. As each texel buffer in
Expand Down Expand Up @@ -888,15 +909,12 @@ typedef struct PROG_VK_STORAGE_TABLE_ENTRY
/* Is this entry really used by shader */
gctUINT activeStageMask;

/* For image storage, it might need a image-size attached. As each image in
storageBinding::arraySize array has image-size, so this is the first entry
of image-size array. */
SHADER_PRIV_CONSTANT_ENTRY* pImageSize[VSC_MAX_SHADER_STAGE_COUNT];
/*----------------------------------Image-related----------------------------------*/
PROG_VK_IMAGE_DERIVED_INFO imageDerivedInfo[VSC_MAX_SHADER_STAGE_COUNT];

/* Extra layer HW mapping. As currently, for images in in storageBinding::arraySize
array, if one image has extra image, all other images must have extra image, so
this is the first entry of extra-image */
SHADER_PRIV_UAV_ENTRY* pExtraLayer[VSC_MAX_SHADER_STAGE_COUNT];
/* Which kinds of inst operation acting on texture. The count of this
resOpBit is same as storageBinding::arraySize */
VSC_RES_OP_BIT* pResOpBits;

/* Different shader stage may have different HW mappings. */
SHADER_UAV_SLOT_MAPPING hwMappings[VSC_MAX_SHADER_STAGE_COUNT];
Expand Down
21 changes: 13 additions & 8 deletions drivers/amlogic/npu/inc/drvi/gc_vsc_drvi_shader_priv_mapping.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2019 by Vivante Corp. All rights reserved.
* Copyright (c) 2005 - 2020 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
Expand Down Expand Up @@ -61,13 +61,16 @@ typedef enum SHS_PRIV_CONSTANT_KIND
/* Shader mem static priv-mapping kind */
typedef enum SHS_PRIV_MEM_KIND
{
SHS_PRIV_MEM_KIND_GPR_SPILLED_MEMORY = 0, /* For gpr register spillage */
SHS_PRIV_MEM_KIND_CONSTANT_SPILLED_MEMORY = 1, /* For constant register spillage */
SHS_PRIV_MEM_KIND_STREAMOUT_BY_STORE = 2, /* Stream buffer for SO */
SHS_PRIV_MEM_KIND_CL_PRIVATE_MEMORY = 3, /* For CL private mem */
SHS_PRIV_MEM_KIND_SHARED_MEMORY = 4, /* For CL local memory or DirectCompute shared mem */
SHS_PRIV_MEM_KIND_EXTRA_UAV_LAYER = 5,
SHS_PRIV_MEM_KIND_COUNT = 6,
SHS_PRIV_MEM_KIND_NONE = 0,
SHS_PRIV_MEM_KIND_GPR_SPILLED_MEMORY = 1, /* For gpr register spillage */
SHS_PRIV_MEM_KIND_CONSTANT_SPILLED_MEMORY = 2, /* For constant register spillage */
SHS_PRIV_MEM_KIND_STREAMOUT_BY_STORE = 3, /* Stream buffer for SO */
SHS_PRIV_MEM_KIND_CL_PRIVATE_MEMORY = 4, /* For CL private mem */
SHS_PRIV_MEM_KIND_SHARED_MEMORY = 5, /* For CL local memory or DirectCompute shared mem */
SHS_PRIV_MEM_KIND_EXTRA_UAV_LAYER = 6,
SHS_PRIV_MEM_KIND_THREAD_ID_MEM_ADDR = 7, /* The global memory to save the consecutive thread ID. */
SHS_PRIV_MEM_KIND_YCBCR_PLANE = 8, /* The YCBCR plane. */
SHS_PRIV_MEM_KIND_COUNT = 9,
}SHS_PRIV_MEM_KIND;

/* !!!!!NOTE: For dynamic (lib-link) patch, the priv-mapping flag will directly use VSC_LIB_LINK_TYPE!!!!! */
Expand Down Expand Up @@ -154,6 +157,8 @@ typedef struct SHADER_PRIV_MEM_DATA_MAPPING

typedef struct SHADER_PRIV_UAV_ENTRY
{
gctUINT uavEntryIndex;

SHADER_PRIV_MAPPING_COMMON_ENTRY commonPrivm;

/* The data which will be set to this memory */
Expand Down
Loading