Change uniform index syntax to [] instead of ()
This commit is contained in:
parent
9d8ec29538
commit
d41106a672
18
example.vsh
18
example.vsh
@ -2,7 +2,7 @@
|
||||
; Also serves as an example of picasso syntax
|
||||
|
||||
; Uniforms
|
||||
.uniform projMtx(4), mdlvMtx(4)
|
||||
.uniform projMtx[4], mdlvMtx[4]
|
||||
|
||||
; Constants
|
||||
.const myconst(0.0, 1.0, -1.0, 0.0)
|
||||
@ -29,16 +29,16 @@
|
||||
mov r0.w, ones
|
||||
|
||||
; r1 = mdlvMtx * r0
|
||||
dp4 r1.x, mdlvMtx(0), r0
|
||||
dp4 r1.y, mdlvMtx(1), r0
|
||||
dp4 r1.z, mdlvMtx(2), r0
|
||||
dp4 r1.w, mdlvMtx(3), r0
|
||||
dp4 r1.x, mdlvMtx[0], r0
|
||||
dp4 r1.y, mdlvMtx[1], r0
|
||||
dp4 r1.z, mdlvMtx[2], r0
|
||||
dp4 r1.w, mdlvMtx[3], r0
|
||||
|
||||
; outpos = projMtx * r1
|
||||
dp4 outpos.x, projMtx(0), r1
|
||||
dp4 outpos.y, projMtx(1), r1
|
||||
dp4 outpos.z, projMtx(2), r1
|
||||
dp4 outpos.w, projMtx(3), r1
|
||||
dp4 outpos.x, projMtx[0], r1
|
||||
dp4 outpos.y, projMtx[1], r1
|
||||
dp4 outpos.z, projMtx[2], r1
|
||||
dp4 outpos.w, projMtx[3], r1
|
||||
|
||||
; Set texcoords
|
||||
mov outtc0, intex
|
||||
|
@ -386,6 +386,12 @@ static int findOrAddOpdesc(int& out, int opdesc, bool ignoreOp2=false)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool isregp(int x)
|
||||
{
|
||||
x = tolower(x);
|
||||
return x=='o' || x=='v' || x=='r' || x=='c';
|
||||
}
|
||||
|
||||
static int parseReg(char* pos, int& outReg, int& outSw)
|
||||
{
|
||||
outReg = 0;
|
||||
@ -399,19 +405,19 @@ static int parseReg(char* pos, int& outReg, int& outSw)
|
||||
return throwError("invalid swizzling mask: %s\n", dotPos);
|
||||
}
|
||||
int regOffset = 0;
|
||||
auto parenPos = strchr(pos, '(');
|
||||
if (parenPos)
|
||||
auto offPos = strchr(pos, '[');
|
||||
if (offPos)
|
||||
{
|
||||
auto closePos = strchr(parenPos, ')');
|
||||
auto closePos = strchr(offPos, ']');
|
||||
if (!closePos)
|
||||
return throwError("missing close paren: %s\n", pos);
|
||||
return throwError("missing closing bracket: %s\n", pos);
|
||||
*closePos = 0;
|
||||
*parenPos++ = 0;
|
||||
parenPos = trim_whitespace(parenPos);
|
||||
*offPos++ = 0;
|
||||
offPos = trim_whitespace(offPos);
|
||||
// TODO: support (idx1[+n]), (idx2[+n]), (lcnt[+n])
|
||||
regOffset = atoi(parenPos);
|
||||
regOffset = atoi(offPos);
|
||||
if (regOffset < 0)
|
||||
return throwError("invalid register offset: %s\n", parenPos);
|
||||
return throwError("invalid register offset: %s\n", offPos);
|
||||
}
|
||||
auto it = g_aliases.find(pos);
|
||||
if (it != g_aliases.end())
|
||||
@ -432,6 +438,9 @@ static int parseReg(char* pos, int& outReg, int& outSw)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!isregp(pos[0]) || !isdigit(pos[1]))
|
||||
return throwError("invalid register: %s\n", pos);
|
||||
|
||||
safe_call(parseInt(pos+1, outReg, 0, 255));
|
||||
switch (*pos)
|
||||
{
|
||||
@ -450,8 +459,6 @@ static int parseReg(char* pos, int& outReg, int& outSw)
|
||||
if (outReg < 0x20 || outReg >= 0x80)
|
||||
return throwError("invalid vector uniform register: %s(%d)\n", pos);
|
||||
break;
|
||||
default:
|
||||
return throwError("invalid register: %s\n", pos);
|
||||
}
|
||||
outReg += regOffset;
|
||||
return 0;
|
||||
@ -577,12 +584,6 @@ DEF_DIRECTIVE(end)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool isregp(int x)
|
||||
{
|
||||
x = tolower(x);
|
||||
return x=='o' || x=='v' || x=='r' || x=='c';
|
||||
}
|
||||
|
||||
DEF_DIRECTIVE(alias)
|
||||
{
|
||||
NEXT_ARG_SPC(aliasName);
|
||||
@ -610,25 +611,25 @@ DEF_DIRECTIVE(uniform)
|
||||
if (!argText) break;
|
||||
|
||||
int uSize = 1;
|
||||
char* parenPos = strchr(argText, '(');
|
||||
if (parenPos)
|
||||
char* sizePos = strchr(argText, '[');
|
||||
if (sizePos)
|
||||
{
|
||||
char* closePos = strchr(parenPos, ')');
|
||||
char* closePos = strchr(sizePos, ']');
|
||||
if (!closePos)
|
||||
return throwError("missing close paren: %s\n", argText);
|
||||
return throwError("missing closing bracket: %s\n", argText);
|
||||
*closePos = 0;
|
||||
*parenPos++ = 0;
|
||||
parenPos = trim_whitespace(parenPos);
|
||||
uSize = atoi(parenPos);
|
||||
*sizePos++ = 0;
|
||||
sizePos = trim_whitespace(sizePos);
|
||||
uSize = atoi(sizePos);
|
||||
if (uSize < 1)
|
||||
return throwError("invalid uniform size: %s(%s)\n", argText, parenPos);
|
||||
return throwError("invalid uniform size: %s[%s]\n", argText, sizePos);
|
||||
}
|
||||
if (!validateIdentifier(argText))
|
||||
return throwError("invalid uniform name: %s\n", argText);
|
||||
if ((uniformPos+uSize) >= 0x80)
|
||||
return throwError("not enough uniform registers: %s(%d)\n", argText, uSize);
|
||||
return throwError("not enough uniform registers: %s[%d]\n", argText, uSize);
|
||||
if (g_uniformCount == MAX_UNIFORM)
|
||||
return throwError("too many uniforms: %s(%d)\n", argText, uSize);
|
||||
return throwError("too many uniforms: %s[%d]\n", argText, uSize);
|
||||
if (g_aliases.find(argText) != g_aliases.end())
|
||||
return throwError("identifier already used: %s\n", argText);
|
||||
|
||||
@ -640,7 +641,7 @@ DEF_DIRECTIVE(uniform)
|
||||
g_aliases.insert( std::pair<std::string,int>(argText, uniform.pos | (DEFAULT_SWIZZLE<<8)) );
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("uniform %s(%d) @ d%02X:d%02X\n", argText, uSize, uniform.pos, uniform.pos+uSize-1);
|
||||
printf("uniform %s[%d] @ d%02X:d%02X\n", argText, uSize, uniform.pos, uniform.pos+uSize-1);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user