📄 perfrag.c
字号:
*****************************************************************************/
FGL_Error
fglSetBlendParams ( pFGL_BlendParam blendParam )
{
FGL_BOOL bValidParam = FGL_FALSE;
unsigned int nBlendVal =0;
bValidParam = ( BLEND_EQUATION_VALID(blendParam->colorEqua) &
BLEND_EQUATION_VALID(blendParam->alphaEqua) &
BLEND_DEST_ALPHA_FUNC_VALID(blendParam->dstAlpha) &
BLEND_DEST_FUNC_VALID(blendParam->dstColor) &
BLEND_SOURCE_ALPHA_FUNC_VALID(blendParam->srcAlpha) &
BLEND_SOURCE_FUNC_VALID(blendParam->srcColor));
if(bValidParam)
{
READREGP(FGPF_BLEND, nBlendVal);
FGL_SET_BITFIELD(nBlendVal, 22:20, blendParam->alphaEqua);
FGL_SET_BITFIELD(nBlendVal, 19:17, blendParam->colorEqua);
FGL_SET_BITFIELD(nBlendVal, 16:13, blendParam->dstAlpha);
FGL_SET_BITFIELD(nBlendVal, 12:9, blendParam->dstColor);
FGL_SET_BITFIELD(nBlendVal, 8:5, blendParam->srcAlpha);
FGL_SET_BITFIELD(nBlendVal, 4:1, blendParam->srcColor);
WRITEREG(FGPF_BLEND_COLOR, blendParam->constColor);
WRITEREG(FGPF_BLEND, nBlendVal);
return FGL_ERR_NO_ERROR;
}
else
{
return FGL_ERR_INVALID_PARAMETER;
}
}
/* thomas-20050921@comment: opengl|es 2.0 not supported */
/*****************************************************************************
* FUNCTIONS: fglSetLogicalOpParams
* SYNOPSIS: A logical operation can be applied the fragment and value stored
* at the corresponding location in the framebuffer; the result
* replaces the current framebuffer value.
* PARAMETERS: [in] colorOp - specifies an enumeration value that selects
* a logical operation.
* RETURNS: FGL_ERR_NO_ERROR - if successful
* FGL_ERR_INVALID_PARAMETER - The colorOp was not an accepted value.
* ERRNO: FGL_ERR_NO_ERROR 1
* FGL_ERR_INVALID_PARAMETER 2
*****************************************************************************/
FGL_Error
fglSetLogicalOpParams ( FGL_LogicalOp colorOp )
{
unsigned int nLogicOpVal = 0;
if (LOGIC_OP_FUNC_VALID(colorOp))
{
READREGP(FGPF_LOGIC_OP, nLogicOpVal);
FGL_SET_BITFIELD(nLogicOpVal, 8:5, colorOp);
FGL_SET_BITFIELD(nLogicOpVal, 4:1, colorOp);
WRITEREG(FGPF_LOGIC_OP, nLogicOpVal);
return FGL_ERR_NO_ERROR;
}
else
{
//printf((DBG_ERROR, "Cannot set logical operation color function - invalid colorOp."));
return FGL_ERR_INVALID_PARAMETER;
}
}
/*****************************************************************************
* FUNCTIONS: fglSetColorBufWriteMask
* SYNOPSIS: enable and disable writing of frame(color) buffer color components
* PARAMETERS: [in] r - whether red can or cannot be written into the frame buffer.
* [in] g - whether green can or cannot be written into the frame buffer.
* [in] b - whether blue can or cannot be written into the frame buffer.
* [in] a - whether alpha can or cannot be written into the frame buffer.
* RETURNS: FGL_ERR_NO_ERROR, if successful
* ERRNO: FGL_ERR_NO_ERROR 1
*****************************************************************************/
FGL_Error
fglSetColorBufWriteMask (
FGL_BOOL r,
FGL_BOOL g,
FGL_BOOL b,
FGL_BOOL a
)
{
unsigned int nWriteMaskVal = 0;
if(r) nWriteMaskVal |= SET_BIT(3);
if(g) nWriteMaskVal |= SET_BIT(2);
if(b) nWriteMaskVal |= SET_BIT(1);
if(a) nWriteMaskVal |= SET_BIT(0);
WRITEREG(FGPF_COLOR_MASK, nWriteMaskVal);
return FGL_ERR_NO_ERROR;
}
/*****************************************************************************
* FUNCTIONS: fglSetStencilBufWriteMask
* SYNOPSIS: control the front and/or back writing of individual bits
* in the stencil buffer.
* PARAMETERS: [in] face - specifies whether the front and/or back stencil
* writemask is updated.
* [in] mask - A bit mask to enable and disable writing of individual
* bits in the stencil buffer.
* RETURNS: FGL_ERR_NO_ERROR - if successful
* FGL_ERR_INVALID_PARAMETER - The face and mask were not an accepted value.
* ERRNO: FGL_ERR_NO_ERROR 1
* FGL_ERR_INVALID_PARAMETER 2
*****************************************************************************/
#if TARGET_FIMG_VERSION == _FIMG3DSE_VER_1_2_1
FGL_Error
fglSetStencilBufWriteMask ( FGL_Face face, unsigned int mask )
{
FGL_BOOL bValidParam = (STENCIL_FACE_VALID(face) & STENCIL_MASK_VALID(mask));
//unsigned int nStencilMaskVal = READREG(FGPF_STENCIL_DEPTH_MASK);
unsigned int nStencilMaskVal;
READREGP(FGPF_STENCIL_DEPTH_MASK, nStencilMaskVal);
if(bValidParam)
{
switch((FGL_Face)face)
{
case FGL_FACE_BACK:
FGL_SET_BITFIELD(nStencilMaskVal, 31:24, mask);
WRITEREG(FGPF_STENCIL_DEPTH_MASK, nStencilMaskVal);
break;
case FGL_FACE_FRONT:
FGL_SET_BITFIELD(nStencilMaskVal, 23:16, mask);
WRITEREG(FGPF_STENCIL_DEPTH_MASK, nStencilMaskVal);
break;
case FGL_FACE_FRONT_AND_BACK:
FGL_SET_BITFIELD(nStencilMaskVal, 23:16, mask);
FGL_SET_BITFIELD(nStencilMaskVal, 31:24, mask);
WRITEREG(FGPF_STENCIL_DEPTH_MASK, nStencilMaskVal);
break;
default:
return FGL_ERR_INVALID_PARAMETER;
}
return FGL_ERR_NO_ERROR;
}
else
{
return FGL_ERR_INVALID_PARAMETER;
}
}
#endif
/*****************************************************************************
* FUNCTIONS: fglSetZBufWriteMask
* SYNOPSIS: enables or disables writing into the depth buffer.
* PARAMETERS: [in] enable - specifies whether the depth buffer is enabled
* for writing.
* RETURNS: FGL_ERR_NO_ERROR - if successful
* ERRNO: FGL_ERR_NO_ERROR 1
*****************************************************************************/
FGL_Error
fglSetZBufWriteMask ( FGL_BOOL enable )
{
//unsigned int nDepthMaskVal = READREG(FGPF_STENCIL_DEPTH_MASK);
unsigned int nDepthMaskVal;
READREGP(FGPF_STENCIL_DEPTH_MASK, nDepthMaskVal);
FGL_SET_BITFIELD(nDepthMaskVal, 0:0, enable);
WRITEREG(FGPF_STENCIL_DEPTH_MASK, nDepthMaskVal);
return FGL_ERR_NO_ERROR;
}
/*****************************************************************************
* FUNCTIONS: fglSetFrameBufParams
* SYNOPSIS: specifies the value used for frame buffer control.
* PARAMETERS: [in] fbctrlParam - the pointer parameter of FGL_FBCtrlParam.
* opaqueAlpha - after alpha blending, the alpha value is
* forced to opaque.
* thresholdAlpha - specifies an alpha value in the frame buffer
* ARGB1555 format.
* constAlpha - specifies constant alpha value in the frame
* buffer ARGB0888 format.
* dither - specifies whether the dither is enable or disable.
* format - specifies the format used for the frame buffer.
* RETURNS: FGL_ERR_NO_ERROR - if successful
* FGL_ERR_INVALID_PARAMETER - The parameters were not an accepted value.
* ERRNO: FGL_ERR_NO_ERROR 1
* FGL_ERR_INVALID_PARAMETER 2
*****************************************************************************/
FGL_Error
fglSetFrameBufParams ( pFGL_FBCtrlParam fbctrlParam )
{
FGL_BOOL bValidParam = FGL_FALSE;
unsigned int nBufCtrlVal =0 ;
bValidParam = ( ALPHA_THRESHOLD_VALUE_VALID(fbctrlParam->thresholdAlpha) &
ALPHA_CONSTANT_VALUE_VALID(fbctrlParam->constAlpha) &
PIXEL_FORMAT_VALID(fbctrlParam->format));
if(bValidParam)
{
FGL_SET_BITFIELD(nBufCtrlVal, 20:20, fbctrlParam->opaqueAlpha);
if((FGL_PixelFormat)fbctrlParam->format == FGL_PIXEL_ARGB1555)
FGL_SET_BITFIELD(nBufCtrlVal, 19:12, fbctrlParam->thresholdAlpha);
if((FGL_PixelFormat)fbctrlParam->format == FGL_PIXEL_ARGB0888)
FGL_SET_BITFIELD(nBufCtrlVal, 11:4, fbctrlParam->constAlpha);
FGL_SET_BITFIELD(nBufCtrlVal, 3:3, fbctrlParam->dither);
FGL_SET_BITFIELD(nBufCtrlVal, 2:0, fbctrlParam->format);
WRITEREG(FGPF_COLORBUF_CTRL, nBufCtrlVal);
return FGL_ERR_NO_ERROR;
}
else
{
return FGL_ERR_INVALID_PARAMETER;
}
}
/*****************************************************************************
* FUNCTIONS: fglSetZBufBaseAddr
* SYNOPSIS: Depth and Stencil buffer base address
* PARAMETERS: [in] addr - specifies the value used for stencil/depth buffer
* address.
* RETURNS: FGL_ERR_NO_ERROR, if successful
* ERRNO: FGL_ERR_NO_ERROR 1
*****************************************************************************/
FGL_Error
fglSetZBufBaseAddr ( unsigned int addr )
{
WRITEREG(FGPF_DEPTHBUF_ADDR, addr);
return FGL_ERR_NO_ERROR;
}
/*****************************************************************************
* FUNCTIONS: fglSetColorBufBaseAddr
* SYNOPSIS: color buffer base address
* PARAMETERS: [in] addr - specifies the value used for frame buffer address.
* RETURNS: FGL_ERR_NO_ERROR, if successful
* ERRNO: FGL_ERR_NO_ERROR 1
*****************************************************************************/
FGL_Error
fglSetColorBufBaseAddr ( unsigned int addr )
{
WRITEREG(FGPF_COLORBUF_ADDR, addr);
return FGL_ERR_NO_ERROR;
}
/*****************************************************************************
* FUNCTIONS: fglSetFrameBufWidth
* SYNOPSIS: frame buffer width
* PARAMETERS: [in] width - specifies the value used for frame buffer width.
* RETURNS: FGL_ERR_NO_ERROR - if successful
* FGL_ERR_INVALID_VALUE -
* ERRNO: FGL_ERR_NO_ERROR 1
* FGL_ERR_INVALID_VALUE 7
*****************************************************************************/
FGL_Error
fglSetFrameBufWidth ( unsigned int width )
{
if (width > FGL_ZERO && width <= FGPF_FB_MAX_STRIDE)
{
WRITEREG(FGPF_COLORBUF_WIDTH, width);
return FGL_ERR_NO_ERROR;
}
else
{
//printf((DBG_ERROR, "Cannot set frame buffer width - invalid width value."));
return FGL_ERR_INVALID_VALUE;
}
}
/*-----------------------< End of file >----------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -