📄 textool.c
字号:
uLCtl1 = 0;
ui32LCtl3 = MBX1_TSPPL3_CBEOP1X;
break;
}
case GLES_COMBINEOP_MODULATE:
{
/*
Arg1*Arg2 + Zero*Current
*/
ui32Sources[0] = ui32Arg1;
ui32Sources[1] = ui32Arg2;
ui32Sources[2] = GLES_COLORSOURCE_ZERO;
ui32Sources[3] = GLES_COLORSOURCE_ANY;
uLCtl1 = 0;
ui32LCtl3 = MBX1_TSPPL3_CBEOP1X;
break;
}
case GLES_COMBINEOP_ADD:
{
/*
One*Arg1 + One*Arg2
*/
ui32Sources[0] = GLES_COLORSOURCE_ONE;
ui32Sources[1] = ui32Arg1;
ui32Sources[2] = GLES_COLORSOURCE_ONE;
ui32Sources[3] = ui32Arg2;
uLCtl1 = 0;
ui32LCtl3 = MBX1_TSPPL3_CBEOP1X;
break;
}
case GLES_COMBINEOP_ADD_SIGNED:
{
/*
One*(Arg1-0.5) + One*(Arg2-0.5)
*/
ui32Sources[0] = GLES_COLORSOURCE_ONE;
ui32Sources[1] = ui32Arg1;
ui32Sources[2] = GLES_COLORSOURCE_ONE;
ui32Sources[3] = ui32Arg2;
uLCtl1 = 0;
ui32LCtl3 = MBX1_TSPPL3_COFF | MBX1_TSPPL3_CBEOP1X;
break;
}
case GLES_COMBINEOP_SUBTRACT:
{
/*
(One*-Arg1 + One*Arg2) * -1
*/
ui32Sources[0] = GLES_COLORSOURCE_ONE;
ui32Sources[1] = ui32Arg1;
ui32Sources[2] = GLES_COLORSOURCE_ONE;
ui32Sources[3] = ui32Arg2;
uLCtl1 = 0;
ui32LCtl3 = MBX1_TSPPL3_CBEOPINV;
break;
}
case GLES_COMBINEOP_DOT3_RGB:
{
/*
SUM(Arg1*Arg2): Set CS4 to 11 = x4, don't replicate Alpha
*/
ui32Sources[0] = ui32Arg1;
ui32Sources[1] = ui32Arg2;
ui32Sources[2] = GLES_COLORSOURCE_ZERO;
ui32Sources[3] = GLES_COLORSOURCE_FACTOR;
uLCtl1 = MBX1_TSPPL1_CSUM;
ui32LCtl3 = MBX1_TSPPL3_CBEOP1X;
break;
}
case GLES_COMBINEOP_DOT3_RGBA:
{
/*
SUM(Arg1*Arg2): Set CS4 to 01 = x4, replicate Alpha
*/
ui32Sources[0] = ui32Arg1;
ui32Sources[1] = ui32Arg2;
ui32Sources[2] = GLES_COLORSOURCE_ZERO;
ui32Sources[3] = GLES_COLORSOURCE_CURRENT;
uLCtl1 = MBX1_TSPPL1_CSUM;
ui32LCtl3 = MBX1_TSPPL3_CBEOP1X;
break;
}
}
/*
Setup valid HW color sources
*/
if (SetupColorArgs(ui32Sources, &uLCtl1, &ui32LCtl3))
{
*pui32LCtl3 = ui32LCtl3;
return IMG_TRUE;
}
return IMG_FALSE;
}
/*****************************************************************************
FUNCTION : SetupAlphaOp
PURPOSE : Attempts to calculate the HW TSP layer control words for a
given alpha-op and arguments. If the requested arguments
cannot be supplied, the control word is not changed.
PARAMETERS : ui32Op - Alpha Op
ui32Arg1 - Alpha Arg 1
ui32Arg2 - Alpha Arg 2
RETURNS : void
*****************************************************************************/
IMG_BOOL SetupAlphaOp(IMG_UINT32 ui32Op, IMG_UINT32 ui32Arg1, IMG_UINT32 ui32Arg2, IMG_UINT32 ui32Arg3, IMG_UINT32 *pui32LCtl3)
{
IMG_UINT32 ui32Sources[4];
IMG_UINT32 ui32LCtl3=0;
/*
Choose the required args and setup the base control words to
produce the correct behaviour for this Op
*/
switch (ui32Op)
{
case GLES_COMBINEOP_INTERPOLATE:
{
/*
Arg3*Arg1 + (1-Arg3)*Arg2
*/
ui32Sources[0] = ui32Arg1;
ui32Sources[1] = ui32Arg3;
ui32Sources[2] = ui32Arg2;
ui32Sources[3] = ui32Arg3;
ui32LCtl3 = MBX1_TSPPL3_ABEOP1X;
break;
}
case GLES_COMBINEOP_REPLACE:
{
/*
One*Arg1 + Zero*Any
*/
ui32Sources[0] = GLES_ALPHASOURCE_ONE;
ui32Sources[1] = ui32Arg1;
ui32Sources[2] = GLES_ALPHASOURCE_ZERO;
ui32Sources[3] = GLES_ALPHASOURCE_ANY;
ui32LCtl3 = MBX1_TSPPL3_ABEOP1X;
break;
}
case GLES_COMBINEOP_MODULATE:
{
/*
Arg1*Arg2 + Zero*Any
*/
ui32Sources[0] = ui32Arg1;
ui32Sources[1] = ui32Arg2;
ui32Sources[2] = GLES_ALPHASOURCE_ZERO;
ui32Sources[3] = GLES_ALPHASOURCE_ANY;
ui32LCtl3 = MBX1_TSPPL3_ABEOP1X;
break;
}
case GLES_COMBINEOP_ADD:
{
/*
One*Arg1 + One*Arg2
*/
ui32Sources[0] = GLES_ALPHASOURCE_ONE;
ui32Sources[1] = ui32Arg1;
ui32Sources[2] = GLES_ALPHASOURCE_ONE;
ui32Sources[3] = ui32Arg2;
ui32LCtl3 = MBX1_TSPPL3_ABEOP1X;
break;
}
case GLES_COMBINEOP_ADD_SIGNED:
{
/*
One*(Arg1-0.5) + One*(Arg2-0.5)
*/
ui32Sources[0] = GLES_ALPHASOURCE_ONE;
ui32Sources[1] = ui32Arg1;
ui32Sources[2] = GLES_ALPHASOURCE_ONE;
ui32Sources[3] = ui32Arg2;
ui32LCtl3 = MBX1_TSPPL3_AOFF | MBX1_TSPPL3_ABEOP1X;
break;
}
case GLES_COMBINEOP_SUBTRACT:
{
/*
(One*-Arg1 + One*Arg2) * -1
*/
ui32Sources[0] = GLES_ALPHASOURCE_ONE;
ui32Sources[1] = ui32Arg1;
ui32Sources[2] = GLES_ALPHASOURCE_ONE;
ui32Sources[3] = ui32Arg2;
ui32LCtl3 = MBX1_TSPPL3_ABEOPINV;
break;
}
}
/*
MBX1 can't do ONE/ZERO * ONE/ZERO as ONE is not available as an
alpha source for AS2/4. So check for some 'special' cases.
*/
if (
((ui32Sources[0] == GLES_ALPHASOURCE_ZERO) || (ui32Sources[1] == GLES_ALPHASOURCE_ZERO))
&& ((ui32Sources[2] == GLES_ALPHASOURCE_ZERO) || (ui32Sources[3] == GLES_ALPHASOURCE_ZERO))
)
{
/*
A null blend. Change it to one we can definitely do.
*/
ui32Sources[0] = GLES_ALPHASOURCE_ZERO;
ui32Sources[1] = GLES_ALPHASOURCE_DIFFUSEALPHA;
ui32Sources[2] = GLES_ALPHASOURCE_ZERO;
ui32Sources[1] = GLES_ALPHASOURCE_DIFFUSEALPHA;
}
if (
((ui32Sources[0] == GLES_ALPHASOURCE_ONE) && (ui32Sources[1] == GLES_ALPHASOURCE_ONE))
&& ((ui32Sources[2] == GLES_ALPHASOURCE_ZERO) || (ui32Sources[3] == GLES_ALPHASOURCE_ZERO))
&& ((ui32LCtl3 & (~MBX1_TSPPL3_ABEOPCLRMASK)) == MBX1_TSPPL3_ABEOP1X)
)
{
/*
ONE*ONE + ZERO = ONE: translate to INV(ZERO * ZERO) as we can do that
*/
ui32Sources[0] = GLES_ALPHASOURCE_ZERO;
ui32Sources[1] = GLES_ALPHASOURCE_DIFFUSEALPHA;
ui32Sources[2] = GLES_ALPHASOURCE_ZERO;
ui32Sources[1] = GLES_ALPHASOURCE_DIFFUSEALPHA;
ui32LCtl3 &= MBX1_TSPPL3_ABEOPCLRMASK;
ui32LCtl3 |= MBX1_TSPPL3_ABEOPINV;
}
if (
((ui32Sources[2] == GLES_ALPHASOURCE_ONE) && (ui32Sources[3] == GLES_ALPHASOURCE_ONE))
&& ((ui32Sources[0] == GLES_ALPHASOURCE_ZERO) || (ui32Sources[1] == GLES_ALPHASOURCE_ZERO))
&& ((ui32LCtl3 & (~MBX1_TSPPL3_ABEOPCLRMASK)) == MBX1_TSPPL3_ABEOP1X)
)
{
/*
ZERO + ONE*ONE = ONE: translate to INV(ZERO * ZERO) as we can do that
*/
ui32Sources[0] = GLES_ALPHASOURCE_ZERO;
ui32Sources[1] = GLES_ALPHASOURCE_DIFFUSEALPHA;
ui32Sources[2] = GLES_ALPHASOURCE_ZERO;
ui32Sources[1] = GLES_ALPHASOURCE_DIFFUSEALPHA;
ui32LCtl3 &= MBX1_TSPPL3_ABEOPCLRMASK;
ui32LCtl3 |= MBX1_TSPPL3_ABEOPINV;
}
/*
Setup valid HW alpha sources
*/
if (SetupAlphaArgs(ui32Sources, &ui32LCtl3))
{
*pui32LCtl3 = ui32LCtl3;
return IMG_TRUE;
}
return IMG_FALSE;
}
/*****************************************************************************
FUNCTION : main
PURPOSE : Fills the color/alpha op lookup tables.
PARAMETERS : void
RETURNS : void
*****************************************************************************/
int main(int argc, char *argv[])
{
IMG_UINT32 ui32Entry;
IMG_UINT32 ui32Op;
IMG_UINT32 ui32Arg1;
IMG_UINT32 ui32Arg2;
IMG_UINT32 ui32Arg3;
IMG_UINT32 ui32LCtl3;
IMG_UINT32 i,j;
FILE* stream;
printf("\nGenerating table for MBX1\n");
if(argc < 2)
{
printf("Using default filename: texcombine.h\n");
stream = fopen("texcombine.h", "w");
}
else if (argc == 2)
{
stream = fopen(argv[1], "w");
}
fprintf(stream,"/**********************************************************************************\n");
fprintf(stream,"* Title : Texture stage lookup table *\n");
fprintf(stream,"* *\n");
fprintf(stream,"* Copyright : 2003 by Imaginations Technologies Limited. All rights reserved. *\n");
fprintf(stream,"* No part of this software, either material or conceptual *\n");
fprintf(stream,"* may be copied or distributed, transmitted, transcribed, *\n");
fprintf(stream,"* stored in a retrieval system or translated into any *\n");
fprintf(stream,"* human or computer language in any form by any means, *\n");
fprintf(stream,"* electronic, mechanical, manual or other-wise, or *\n");
fprintf(stream,"* disclosed to third parties without the express written *\n");
fprintf(stream,"* permission of Imaginations Technologies Limited, HomePark *\n");
fprintf(stream,"* Industrial Estate, King's Langley, Hertfordshire, *\n");
fprintf(stream,"* WD4 8LZ, U.K. *\n");
fprintf(stream,"* *\n");
fprintf(stream,"* *\n");
fprintf(stream,"* This is an autogenerated file (by textool.exe). DO NOT EDIT! *\n");
fprintf(stream,"**********************************************************************************/\n\n\n");
/*
Setup the color texture-op table for 3 arg operands
*/
fprintf(stream,"const static IMG_UINT32 ui32ColorOp3LCtlTable[] = {\n");
for (i = 0, j=1; i < GLES_COLOROP3LCTLTABLE_SIZE; i++,j++)
{
/*
Extract the Args and Op for this entry
*/
ui32Entry = i;
ui32Arg1 = ui32Entry % GLES_COLORARG_COUNT;
ui32Entry /= GLES_COLORARG_COUNT;
ui32Arg2 = ui32Entry % GLES_COLORARG_COUNT;
ui32Entry /= GLES_COLORARG_COUNT;
ui32Arg3 = ui32Entry % GLES_COLORARG_COUNT;
ui32Entry /= GLES_COLORARG_COUNT;
ui32Op = ui32Entry;
/*
Setup the color-op table control words for these Args and Op
*/
ui32LCtl3 = 0xffffffff;
SetupColorOp(ui32Op, ui32Arg1, ui32Arg2, ui32Arg3, &ui32LCtl3);
fprintf(stream, "0x%08x,\t", (int)ui32LCtl3);
if(j >9)
{
j=0;
fprintf(stream, "\n");
}
}
fprintf(stream,"0};\n\n\n\n");
/*
Setup the alpha texture-op table for 3 arg operands
*/
fprintf(stream,"const static IMG_UINT32 ui32AlphaOp3LCtlTable[] = {\n");
for (i = 0,j=1; i < GLES_ALPHAOP3LCTLTABLE_SIZE; i++,j++)
{
/*
Extract the Args and Op for this entry
*/
ui32Entry = i;
ui32Arg1 = ui32Entry % GLES_ALPHAARG_COUNT;
ui32Entry /= GLES_ALPHAARG_COUNT;
ui32Arg2 = ui32Entry % GLES_ALPHAARG_COUNT;
ui32Entry /= GLES_ALPHAARG_COUNT;
ui32Arg3 = ui32Entry % GLES_ALPHAARG_COUNT;
ui32Entry /= GLES_ALPHAARG_COUNT;
ui32Op = ui32Entry;
/*
Setup the alpha-op table control word for these Args and Op
*/
ui32LCtl3 = 0xffffffff;
SetupAlphaOp(ui32Op, ui32Arg1, ui32Arg2, ui32Arg3, &ui32LCtl3);
fprintf(stream, "0x%08x,\t", (int)ui32LCtl3);
if(j >9)
{
j=0;
fprintf(stream, "\n");
}
}
fprintf(stream,"0};\n\n\n\n");
/*
Setup the color texture-op table for 2 arg operands
*/
fprintf(stream,"const static IMG_UINT32 ui32ColorOp2LCtlTable[] = {\n");
for (i = 0, j=1; i < GLES_COLOROP2LCTLTABLE_SIZE; i++,j++)
{
/*
Extract the Args and Op for this entry
*/
ui32Entry = i;
ui32Arg1 = ui32Entry % GLES_COLORARG_COUNT;
ui32Entry /= GLES_COLORARG_COUNT;
ui32Arg2 = ui32Entry % GLES_COLORARG_COUNT;
ui32Entry /= GLES_COLORARG_COUNT;
ui32Op = ui32Entry + GLES_COLOROP3_COUNT;
/*
Setup the color-op table control words for these Args and Op
*/
ui32LCtl3 = 0xffffffff;
SetupColorOp(ui32Op, ui32Arg1, ui32Arg2, GLES_COLORSOURCE_ANY, &ui32LCtl3);
fprintf(stream, "0x%08x,\t", (int)ui32LCtl3);
if(j >9)
{
j=0;
fprintf(stream, "\n");
}
}
fprintf(stream,"0};\n\n\n\n");
/*
Setup the alpha texture-op table for 2 arg operands
*/
fprintf(stream,"const static IMG_UINT32 ui32AlphaOp2LCtlTable[] = {\n");
for (i = 0,j=1; i < GLES_ALPHAOP2LCTLTABLE_SIZE; i++,j++)
{
/*
Extract the Args and Op for this entry
*/
ui32Entry = i;
ui32Arg1 = ui32Entry % GLES_ALPHAARG_COUNT;
ui32Entry /= GLES_ALPHAARG_COUNT;
ui32Arg2 = ui32Entry % GLES_ALPHAARG_COUNT;
ui32Entry /= GLES_ALPHAARG_COUNT;
ui32Op = ui32Entry + GLES_ALPHAOP3_COUNT;
/*
Setup the alpha-op table control word for these Args and Op
*/
ui32LCtl3 = 0xffffffff;
SetupAlphaOp(ui32Op, ui32Arg1, ui32Arg2, GLES_ALPHASOURCE_ANY, &ui32LCtl3);
fprintf(stream, "0x%08x,\t", (int)ui32LCtl3);
if(j >9)
{
j=0;
fprintf(stream, "\n");
}
}
fprintf(stream,"0};\n\n\n\n");
fclose(stream);
printf("\nCreated texture blend table for MBX1\n");
return 0;
}
/*****************************************************************************
End of file (Textool.C)
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -