mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 07:32:02 +00:00
[gamecode] Add 2- and 3-component swizzles
VM side of the work needed for #58. Tests are still only 4-component, but the geometric algebra tests seem to have 2-component covered at least a little bit.
This commit is contained in:
parent
a416e9c060
commit
e61be2f80f
8 changed files with 638 additions and 594 deletions
|
@ -3,6 +3,7 @@ bitmap_txt = """
|
|||
0 0001 mmss store
|
||||
0 0010 mmss push
|
||||
0 0011 mmss pop
|
||||
0 0111 00ts swizzle2
|
||||
0 0111 01t0 wedge2
|
||||
0 1ccc ttss compare
|
||||
0 0000 00nn
|
||||
|
@ -510,15 +511,27 @@ string_formats = {
|
|||
},
|
||||
}
|
||||
swizzle_formats = {
|
||||
"opcode": "OP_SWIZZLE_{swiz_type[t]}",
|
||||
"opcode": "OP_SWIZZLE_{swiz_type[t]}_4",
|
||||
"mnemonic": "swizzle.{swiz_type[t]}",
|
||||
"opname": "swizzle",
|
||||
"format": "%Ga.%Sb %gc",
|
||||
"widths": "4, 0, 4",
|
||||
"types": "{swizzle_types[t]}",
|
||||
"types": "{swizzle_types[t]}, ev_short, {swizzle_types[t]}",
|
||||
"args": {
|
||||
"swiz_type": ['F', 'D'],
|
||||
"swizzle_types": float_t,
|
||||
"swizzle_types": unsigned_t,
|
||||
},
|
||||
}
|
||||
swizzle2_formats = {
|
||||
"opcode": "OP_SWIZZLE_{swiz_type[t]}_{s+2}",
|
||||
"mnemonic": "swizzle.{swiz_type[t]}",
|
||||
"opname": "swizzle",
|
||||
"format": "%Ga.%Sb %gc",
|
||||
"widths": "{s+2}, 0, {s+2}",
|
||||
"types": "{swizzle_types[t]}, ev_short, {swizzle_types[t]}",
|
||||
"args": {
|
||||
"swiz_type": ['F', 'D'],
|
||||
"swizzle_types": unsigned_t,
|
||||
},
|
||||
}
|
||||
wedge2_formats = {
|
||||
|
@ -628,6 +641,7 @@ group_map = {
|
|||
"store64": store64_formats,
|
||||
"string": string_formats,
|
||||
"swizzle": swizzle_formats,
|
||||
"swizzle2": swizzle2_formats,
|
||||
"return": return_formats,
|
||||
"udivops": udivops_formats,
|
||||
"vecops": vecops_formats,
|
||||
|
|
|
@ -1518,7 +1518,7 @@ pr_debug_ulong_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
if (i) {
|
||||
dstring_appendstr (dstr, ", ");
|
||||
}
|
||||
dasprintf (dstr, "%" PRIu64, *(uint64_t *)value);
|
||||
dasprintf (dstr, "%" PRIx64, *(uint64_t *)value);
|
||||
}
|
||||
if (type->basic.width > 1) {
|
||||
dstring_appendstr (dstr, "]");
|
||||
|
|
|
@ -2291,6 +2291,36 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
// 0 0110
|
||||
// spare
|
||||
// 0 0111
|
||||
case OP_SWIZZLE_F_2:
|
||||
{
|
||||
auto s2 = OPA(ivec2);
|
||||
pr_ivec4_t s4 = { s2[0], s2[1] };
|
||||
s4 = pr_swizzle_f (s4, (pr_ushort_t) st->b);
|
||||
OPC(ivec2) = (pr_ivec2_t) { s4[0], s4[1] };
|
||||
}
|
||||
break;
|
||||
case OP_SWIZZLE_F_3:
|
||||
{
|
||||
auto s4 = loadvec3i (&OPA(int));
|
||||
s4 = pr_swizzle_f (s4, (pr_ushort_t) st->b);
|
||||
storevec3i (&OPA(int), s4);
|
||||
}
|
||||
break;
|
||||
case OP_SWIZZLE_D_2:
|
||||
{
|
||||
auto s2 = OPA(lvec2);
|
||||
pr_lvec4_t s4 = { s2[0], s2[1] };
|
||||
s4 = pr_swizzle_d (s4, (pr_ushort_t) st->b);
|
||||
OPC(lvec2) = (pr_lvec2_t) { s4[0], s4[1] };
|
||||
}
|
||||
break;
|
||||
case OP_SWIZZLE_D_3:
|
||||
{
|
||||
auto s4 = loadvec3l (&OPA(long));
|
||||
s4 = pr_swizzle_d (s4, (pr_ushort_t) st->b);
|
||||
storevec3l (&OPC(long), s4);
|
||||
}
|
||||
break;
|
||||
case OP_WEDGE_F_2:
|
||||
{
|
||||
auto a = OPA(vec2);
|
||||
|
@ -2598,7 +2628,7 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
// 1 1010
|
||||
OP_cmp_T (GT, u, int, ivec2, ivec4, >, uint, uivec2, uivec4);
|
||||
case OP_SWIZZLE_F:
|
||||
case OP_SWIZZLE_F_4:
|
||||
OPC(ivec4) = pr_swizzle_f (OPA(ivec4), (pr_ushort_t) st->b);
|
||||
break;
|
||||
case OP_SCALE_F_2:
|
||||
|
@ -2611,7 +2641,7 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
|||
OPC(vec4) = OPA(vec4) * OPB(float);
|
||||
break;
|
||||
OP_cmp_T (GT, U, long, lvec2, lvec4, >, ulong, ulvec2, ulvec4);
|
||||
case OP_SWIZZLE_D:
|
||||
case OP_SWIZZLE_D_4:
|
||||
OPC(lvec4) = pr_swizzle_d (OPA(lvec4), (pr_ushort_t) st->b);
|
||||
break;
|
||||
case OP_SCALE_D_2:
|
||||
|
|
|
@ -67,13 +67,13 @@ static dstatement_t callret_statements[] = {
|
|||
#define c 20 // in locals int
|
||||
{ OP(2, 0, 1, OP_STORE_A_1), xn+1,0, x }, // init xn to [1, x, 0, 0]
|
||||
{ OP(2, 0, 0, OP_STORE_A_1), xn, 0, 4 },
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F), xn, 0x0044, xn }, // xn -> [1, x, 1, x]
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F_4), xn, 0x0044, xn },// xn -> [1, x, 1, x]
|
||||
{ OP(1, 1, 2, OP_MUL_F_1), x, x, x2 }, // x2 -> [x*x, ?, ?, ?]
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F), x2, 0x0300, x2},//x2 -> [-x*x, -x*x, x*x, x*x]
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F_4), x2, 0x0300, x2},//x2 -> [-x*x, -x*x, x*x, x*x]
|
||||
{ OP(2, 0, 0, OP_STORE_A_1), fa, 0, 4 }, // init factorial
|
||||
{ OP(2, 0, 0, OP_STORE_A_1), fa+1,0, 5 },
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F), fa, 0x0044, fa }, // fa -> [1, 2, 1, 2]
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F), fa, 0x0000, fi }, // init fi -> [1, 1, 1, 1]
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F_4), fa, 0x0044, fa },// fa -> [1, 2, 1, 2]
|
||||
{ OP(2, 0, 2, OP_SWIZZLE_F_4), fa, 0x0000, fi },// init fi -> [1, 1, 1, 1]
|
||||
{ OP(2, 2, 2, OP_SUB_F_4), ac, ac, ac }, // init acc (output) to 0
|
||||
{ OP(0, 0, 2, OP_LEA_A), 25, 0, c }, // init count
|
||||
// loop:
|
||||
|
|
|
@ -117,9 +117,9 @@ static pr_dvec4_t double_cossin_expect[] = {
|
|||
static dstatement_t double_cossin_statements[] = {
|
||||
{ OP(0, 0, 0, OP_STORE_A_2), 42, 0, 8 }, // init xn -> [?, x]
|
||||
{ OP(0, 0, 0, OP_STORE_A_2), 40, 0, 16 }, // init xn -> [1, x]
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D), 8,0xc000, 32 }, // init x2 -> [x, x, 0, 0]
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D_4), 8,0xc000, 32 }, // init x2 -> [x, x, 0, 0]
|
||||
{ OP(0, 0, 0, OP_MUL_D_2), 32, 32, 32 }, // x2 -> [x*x, x*x, 0, 0]
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D), 32,0xc3e4, 32 }, // init x2 -> -x2
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D_4), 32,0xc3e4, 32 }, // init x2 -> -x2
|
||||
{ OP(0, 0, 0, OP_SUB_D_4), 0, 0, 0 }, // init acc (output) to 0
|
||||
// loop:
|
||||
{ OP(0, 0, 0, OP_ADD_D_2), 0, 40, 0 }, // acc += xn
|
||||
|
|
|
@ -117,9 +117,9 @@ static pr_vec4_t float_cossin_expect[] = {
|
|||
static dstatement_t float_cossin_statements[] = {
|
||||
{ OP(0, 0, 0, OP_STORE_A_1), 21, 0, 4 }, // init xn -> [?, x]
|
||||
{ OP(0, 0, 0, OP_STORE_A_1), 20, 0, 8 }, // init xn -> [1, x]
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F), 4, 0xc000, 16 },// init x2 -> [x, x, 0, 0]
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F_4), 4, 0xc000, 16 },// init x2 -> [x, x, 0, 0]
|
||||
{ OP(0, 0, 0, OP_MUL_F_2), 16, 16, 16 }, // x2 -> [x*x, x*x, 0, 0]
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F), 16, 0xc3e4, 16 },// init x2 -> -x2
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F_4), 16, 0xc3e4, 16 },// init x2 -> -x2
|
||||
{ OP(0, 0, 0, OP_SUB_F_4), 0, 0, 0 }, // init acc (output) to 0
|
||||
// loop:
|
||||
{ OP(0, 0, 0, OP_ADD_F_2), 0, 20, 0 }, // acc += xn
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -64,10 +64,10 @@ static dstatement_t float_vector_statements[] = {
|
|||
{ OP(0, 0, 0, OP_VQMUL_F), 32, 24, 48 },
|
||||
|
||||
{ OP(0, 0, 0, OP_QMUL_F), 24, 32, 52 },
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F), 24, 0x07e4, 60 },
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F_4), 24, 0x07e4, 60 },
|
||||
{ OP(0, 0, 0, OP_QMUL_F), 52, 60, 52 },
|
||||
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F), 24, 0x07e4, 64 },
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_F_4), 24, 0x07e4, 64 },
|
||||
{ OP(0, 0, 0, OP_QMUL_F), 64, 32, 56 },
|
||||
{ OP(0, 0, 0, OP_QMUL_F), 56, 24, 56 },
|
||||
|
||||
|
@ -139,10 +139,10 @@ static dstatement_t double_vector_statements[] = {
|
|||
{ OP(0, 0, 0, OP_VQMUL_D), 64, 48, 96 },
|
||||
|
||||
{ OP(0, 0, 0, OP_QMUL_D), 48, 64, 104 },
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D), 48, 0x07e4, 120 },
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D_4), 48, 0x07e4, 120 },
|
||||
{ OP(0, 0, 0, OP_QMUL_D), 104, 120, 104 },
|
||||
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D), 48, 0x07e4, 128 },
|
||||
{ OP(0, 0, 0, OP_SWIZZLE_D_4), 48, 0x07e4, 128 },
|
||||
{ OP(0, 0, 0, OP_QMUL_D), 128, 64, 112 },
|
||||
{ OP(0, 0, 0, OP_QMUL_D), 112, 48, 112 },
|
||||
|
||||
|
|
Loading…
Reference in a new issue