Refactor opdesc allocation algorithm
This commit is contained in:
parent
e6e92aff48
commit
e47de22f60
@ -36,6 +36,10 @@ enum
|
|||||||
#define DEFAULT_SWIZZLE (SWIZZLE_COMP(0,COMP_X) | SWIZZLE_COMP(1,COMP_Y) | SWIZZLE_COMP(2,COMP_Z) | SWIZZLE_COMP(3,COMP_W))
|
#define DEFAULT_SWIZZLE (SWIZZLE_COMP(0,COMP_X) | SWIZZLE_COMP(1,COMP_Y) | SWIZZLE_COMP(2,COMP_Z) | SWIZZLE_COMP(3,COMP_W))
|
||||||
#define DEFAULT_OPSRC OPSRC_MAKE(0, DEFAULT_SWIZZLE)
|
#define DEFAULT_OPSRC OPSRC_MAKE(0, DEFAULT_SWIZZLE)
|
||||||
|
|
||||||
|
#define OPDESC_MASK_ALL OPDESC_MAKE(0xF, 0x1FF, 0x1FF)
|
||||||
|
#define OPDESC_MASK_NOSRC2 OPDESC_MAKE(0xF, 0x1FF, 0)
|
||||||
|
#define OPDESC_MASK_ONLYSRC1 OPDESC_MAKE(0, 0x1FF, 0)
|
||||||
|
|
||||||
extern std::vector<u32> g_outputBuf;
|
extern std::vector<u32> g_outputBuf;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -62,6 +66,7 @@ extern int g_stackPos;
|
|||||||
|
|
||||||
#define MAX_OPDESC 128
|
#define MAX_OPDESC 128
|
||||||
extern int g_opdescTable[MAX_OPDESC];
|
extern int g_opdescTable[MAX_OPDESC];
|
||||||
|
extern int g_opdeskMasks[MAX_OPDESC]; // used to keep track of used bits
|
||||||
extern int g_opdescCount;
|
extern int g_opdescCount;
|
||||||
|
|
||||||
struct Uniform
|
struct Uniform
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "picasso.h"
|
#include "picasso.h"
|
||||||
|
|
||||||
|
//#define DEBUG
|
||||||
#define BUF g_outputBuf
|
#define BUF g_outputBuf
|
||||||
#define NO_MORE_STACK (g_stackPos==MAX_STACK)
|
#define NO_MORE_STACK (g_stackPos==MAX_STACK)
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ int g_stackPos;
|
|||||||
|
|
||||||
int g_opdescTable[MAX_OPDESC];
|
int g_opdescTable[MAX_OPDESC];
|
||||||
int g_opdescCount;
|
int g_opdescCount;
|
||||||
|
int g_opdescMasks[MAX_OPDESC];
|
||||||
|
|
||||||
Uniform g_uniformTable[MAX_UNIFORM];
|
Uniform g_uniformTable[MAX_UNIFORM];
|
||||||
int g_uniformCount;
|
int g_uniformCount;
|
||||||
@ -184,9 +186,6 @@ int AssembleString(char* str, const char* initialFilename)
|
|||||||
if (g_stackPos)
|
if (g_stackPos)
|
||||||
return throwError("unclosed block(s)\n");
|
return throwError("unclosed block(s)\n");
|
||||||
|
|
||||||
for (int i = 0; i < g_opdescCount; i ++)
|
|
||||||
g_opdescTable[i] &= ~BIT(31);
|
|
||||||
|
|
||||||
//safe_call(FixupRelocations());
|
//safe_call(FixupRelocations());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -353,36 +352,24 @@ static int maskFromSwizzling(int sw)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int findOrAddOpdesc(int& out, int opdesc, bool ignoreOp2=false)
|
static int findOrAddOpdesc(int& out, int opdesc, int mask = OPDESC_MASK_ALL)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < g_opdescCount; i ++)
|
for (int i = 0; i < g_opdescCount; i ++)
|
||||||
{
|
{
|
||||||
int cur_opdesc = g_opdescTable[i];
|
int minMask = mask & g_opdescMasks[i];
|
||||||
if (ignoreOp2)
|
if ((opdesc&minMask) == (g_opdescTable[i]&minMask))
|
||||||
cur_opdesc &= ~((0x1FF << (4+9)) | BIT(31)); // clear bits we don't want to compare
|
|
||||||
else if (cur_opdesc & BIT(31))
|
|
||||||
{
|
|
||||||
// We can recycle this opdesc which didn't have an explicit Op2
|
|
||||||
cur_opdesc &= ~BIT(31);
|
|
||||||
int cmp = opdesc &~ (0x1FF << (4+9)); // partial opdesc used for comparison
|
|
||||||
if (cmp == cur_opdesc)
|
|
||||||
{
|
|
||||||
g_opdescTable[i] = cur_opdesc | (opdesc & (0x1FF << (4+9)));
|
|
||||||
out = i;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (opdesc == cur_opdesc)
|
|
||||||
{
|
{
|
||||||
|
// Save extra bits, if any
|
||||||
|
g_opdescTable[i] |= opdesc & (mask^minMask);
|
||||||
|
g_opdescMasks[i] |= mask;
|
||||||
out = i;
|
out = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g_opdescCount == MAX_OPDESC)
|
if (g_opdescCount == MAX_OPDESC)
|
||||||
return throwError("too many operand descriptors (limit is %d)\n", MAX_OPDESC);
|
return throwError("too many operand descriptors (limit is %d)\n", MAX_OPDESC);
|
||||||
if (ignoreOp2)
|
|
||||||
opdesc |= BIT(31); // will be removed
|
|
||||||
g_opdescTable[g_opdescCount] = opdesc;
|
g_opdescTable[g_opdescCount] = opdesc;
|
||||||
|
g_opdescMasks[g_opdescCount] = mask;
|
||||||
out = g_opdescCount++;
|
out = g_opdescCount++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -511,7 +498,7 @@ DEF_COMMAND(format2)
|
|||||||
ARG_TO_SRC1_REG(rSrc1, src1Name);
|
ARG_TO_SRC1_REG(rSrc1, src1Name);
|
||||||
|
|
||||||
int opdesc = 0;
|
int opdesc = 0;
|
||||||
safe_call(findOrAddOpdesc(opdesc, OPDESC_MAKE(maskFromSwizzling(rDestSw), rSrc1Sw, 0), true));
|
safe_call(findOrAddOpdesc(opdesc, OPDESC_MAKE(maskFromSwizzling(rDestSw), rSrc1Sw, 0), OPDESC_MASK_NOSRC2));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("%s:%02X d%02X, d%02X (0x%X)\n", cmdName, opcode, rDest, rSrc1, opdesc);
|
printf("%s:%02X d%02X, d%02X (0x%X)\n", cmdName, opcode, rDest, rSrc1, opdesc);
|
||||||
|
Loading…
Reference in New Issue
Block a user