Skip to content

Instantly share code, notes, and snippets.

@TellowKrinkle
Created April 16, 2023 02:11
Show Gist options
  • Save TellowKrinkle/9e9f1f56a2756864c3814471f45ff064 to your computer and use it in GitHub Desktop.
Save TellowKrinkle/9e9f1f56a2756864c3814471f45ff064 to your computer and use it in GitHub Desktop.
Melty Molten Galaxy Clear Shader
vertex shader prolog:
0: 05a1840d03c8f200 device_load 0, i32, xyzw, r20_r21_r22_r23, u2_u3, 56, signed, lsl 2
8: 0581940d03c8f200 device_load 0, i32, xyzw, r16_r17_r18_r19, u2_u3, 57, signed, lsl 2
10: 0561d40d0ec8f200 device_load 0, i32, xyzw, r12_r13_r14_r15, u2_u3, 237, signed, lsl 2
18: 0541e40d0ec8f200 device_load 0, i32, xyzw, r8_r9_r10_r11, u2_u3, 238, signed, lsl 2
20: 0521f40d0ec8f200 device_load 0, i32, xyzw, r4_r5_r6_r7, u2_u3, 239, signed, lsl 2
28: 0501040d0fc8f200 device_load 0, i32, xyzw, r0_r1_r2_r3, u2_u3, 240, signed, lsl 2
30: 3800 wait 0
32: e265003c00bc mov_imm r25.cache, 3154131968
38: 8260800200b20050 fcmpsel gt, r24l.cache, r0.cache, 0.0, r25l.cache, 0
40: 8262400200b3002f fcmpsel lt, r24h.cache, r0, 0.0, r25h.cache, r24l.discard
48: 82e0820200f200300002 fcmpsel lt, r24l.cache, r1.cache, -0.0, r25l.discard, 0
52: 82e0420200f3004f0002 fcmpsel gt, r24l.cache, r1, -0.0, r25h.discard, r24l.discard
5c: 2ae5f1000002 fadd32 r25, r24h.discard, -0.0
62: 2ae1f0000002 fadd32 r24, r24l.discard, -0.0
68: 2ad9eec22e00 fadd32 r22, r23.discard, r22.discard
6e: 2ac9e6422e00 fadd32 r18, r19.discard, r18.discard
74: 2ab9dec22d00 fadd32 r14, r15.discard, r14.discard
7a: 2aa9d6422d00 fadd32 r10, r11.discard, r10.discard
80: 2a99cec22c00 fadd32 r6, r7.discard, r6.discard
86: c5a0803d00803000 uniform_store 2, i16, xy, 0, r20l_r20h, 8
8e: c5a8a03d00803000 uniform_store 2, i16, xy, 0, r21l_r21h, 10
96: c5b0c03d00803000 uniform_store 2, i16, xy, 0, r22l_r22h, 12
9e: c580e03d00803000 uniform_store 2, i16, xy, 0, r16l_r16h, 14
a6: c588003d01803000 uniform_store 2, i16, xy, 0, r17l_r17h, 16
ae: c590203d01803000 uniform_store 2, i16, xy, 0, r18l_r18h, 18
b6: c560403d01803000 uniform_store 2, i16, xy, 0, r12l_r12h, 20
be: c568603d01803000 uniform_store 2, i16, xy, 0, r13l_r13h, 22
c6: c540803d01803000 uniform_store 2, i16, xy, 0, r8l_r8h, 24
ce: c548a03d01803000 uniform_store 2, i16, xy, 0, r9l_r9h, 26
d6: c520c03d01803000 uniform_store 2, i16, xy, 0, r4l_r4h, 28
de: c528e03d01803000 uniform_store 2, i16, xy, 0, r5l_r5h, 30
e6: c570003d02803000 uniform_store 2, i16, xy, 0, r14l_r14h, 32
ee: c550203d02803000 uniform_store 2, i16, xy, 0, r10l_r10h, 34
f6: c530403d02803000 uniform_store 2, i16, xy, 0, r6l_r6h, 36
fe: c500603d02803000 uniform_store 2, i16, xy, 0, r0l_r0h, 38
106: c508803d02803000 uniform_store 2, i16, xy, 0, r1l_r1h, 40
10e: c510a03d02803000 uniform_store 2, i16, xy, 0, r2l_r2h, 42
116: c518c03d02803000 uniform_store 2, i16, xy, 0, r3l_r3h, 44
11e: c5c8e03d02803000 uniform_store 2, i16, xy, 0, r25l_r25h, 46
126: c5c0003d03803000 uniform_store 2, i16, xy, 0, r24l_r24h, 48
12e: 8800 stop
vertex shader:
0: 0501a00e00c8f200 device_load 0, i32, xyzw, r0_r1_r2_r3, u0_u1, r5, unsigned, lsl 2
8: 3800 wait 0
a: ba95bc2128804100 fmadd32 r5.cache, u30, r1.cache, u32
12: ba99842128884104 fmadd32 r6.cache, u34, r1.cache, u36
1a: ba91b4212cb80100 fmadd32 r4.cache, u26, r1.discard, u28
22: ba85820128cc0204 fmadd32 r1.cache, u33, r0.cache, r6.discard
2a: ba91b20128c80200 fmadd32 r4.cache, u25, r0.cache, r4.discard
32: ba9dba012cca0200 fmadd32 r7.cache, u29, r0.discard, r5.discard
3a: fe1586e29a01 and r5.cache, r3.cache, u55
40: fe0184e29a01 and r0.cache, r2.cache, u55
46: 9295cac21aaa614c4001 icmpsel ugt, r5.cache, r5.discard, u54, u53, r3.discard
50: 928dc0c21aaa414c4001 icmpsel ugt, r3.cache, r0.discard, u54, u53, r2.discard
5a: ba8190a128920100 fmadd32 r0.cache, u8, r5.cache, u9
62: ba898aa12c8c0100 fmadd32 r2.cache, u5, r5.discard, u6
6a: ba818e6128c00200 fmadd32 r0.cache, u7, r3.cache, r0.discard
72: ba9988612cc40200 fmadd32 r6.cache, u4, r3.discard, r2.discard
7a: ba8da4e128a84104 fmadd32 r3.cache, u50, r7.cache, u52
82: ba898a8128904104 fmadd32 r2.cache, u37, r4.cache, u40
8a: ba8da28128c60204 fmadd32 r3.cache, u49, r4.cache, r3.discard
92: ba898ec218c40201 fmadd32 r2.cache, r7.cache, u38, r2.discard
9a: ba95a62128c60204 fmadd32 r5.cache, u51, r1.cache, r3.discard
a2: baa182e218c40201 fmadd32 r8.cache, r1.cache, u39, r2.discard
aa: 9a8da6a1a800 fmul32 r3.cache, u19, r5.cache.neg
b0: ba899ce124a04104 fmadd32 r2.cache, u46, r7, u48
b8: 3aa1ae012dc60200 fmadd32 r8, u23, r8.discard, r3.discard
c0: ba899a8124c40204 fmadd32 r2.cache, u45, r4, r2.discard
c8: ba8d9cc124a40100 fmadd32 r3.cache, u14, r6, u18
d0: ba899e2124c40204 fmadd32 r2.cache, u47, r1, r2.discard
d8: 3a8d40e219c60200 fmadd32 r3, r0, u15, r3.discard
e0: 3aa984221b4a0201 fmadd32 r10, r2.cache, u57, r5
e8: 1aa544421b01 fmul32 r9, r2, u58
ee: 622d00000000 mov_imm r11, 0
f4: 112c8780 st_var 1, r11, 7
f8: 11288880 st_var 1, r10, 8
fc: 11248980 st_var 1, r9, 9
100: 11148380 st_var 1, r5, 3
104: 110c8680 st_var 1, r3, 6
108: 11208080 st_var 1, r8, 0
10c: ba9d94e12c984104 fmadd32 r7.cache, u42, r7.discard, u44
114: ba9192812cce0204 fmadd32 r4.cache, u41, r4.discard, r7.discard
11c: ba91c26219c80201 fmadd32 r4.cache, r1.discard, u43, r4.discard
124: ba858c4219a00100 fmadd32 r1.cache, r6.cache, u10, u16
12c: ba99cc8219a20100 fmadd32 r6.cache, r6.discard, u12, u17
134: ba85806219c20200 fmadd32 r1.cache, r0.cache, u11, r1.discard
13c: ba81c0a219cc0200 fmadd32 r0.cache, r0.discard, u13, r6.discard
144: 9a89aa41ac00 fmul32 r2.cache, u21, r2.discard.neg
14a: 9a9d82020200 fmul32 r7.cache, r1.cache, 0.5
150: 9a9980020200 fmul32 r6.cache, r0.cache, 0.5
156: 829dce0203ce00fb1002 fcmpsel gtn, r7.cache, r7.discard, -1.0, r7.discard, u56
160: 8299cc0203cc00fb1002 fcmpsel gtn, r6.cache, r6.discard, -1.0, r6.discard, u56
16a: 829dce0203cea07a1000 fcmpsel ltn, r7.cache, r7.discard, 1.0, r7.discard, u53
174: 8299cc0203cca07a1000 fcmpsel ltn, r6.cache, r6.discard, 1.0, r6.discard, u53
17e: 0205860200ce200c fcmpsel eq, r1, r3.cache, 0.0, r7.discard, r1.discard
186: 0201c60200cc000c fcmpsel eq, r0, r3.discard, 0.0, r6.discard, r0.discard
18e: 9a8da8a1a800 fmul32 r3.cache, u20, r5.cache.neg
194: 3a89aca12cc40200 fmadd32 r2, u22, r5.discard, r2.discard
19c: 3a8db0812cc60200 fmadd32 r3, u24, r4.discard, r3.discard
1a4: 110c8180 st_var 1, r3, 1
1a8: 11088280 st_var 1, r2, 2
1ac: 11048480 st_var 1, r1, 4
1b0: 91008580 st_var_final 1, r0, 5
1b4: 8800 stop
fragment shader prolog:
0: 0541100d00c87200 device_load 0, i32, xyz, r8_r9_r10, u0_u1, 1, signed, lsl 2
8: 0521800d00c8f200 device_load 0, i32, xyzw, r4_r5_r6_r7, u0_u1, 8, signed, lsl 2
10: 0501900d00c8f200 device_load 0, i32, xyzw, r0_r1_r2_r3, u0_u1, 9, signed, lsl 2
18: 0559500d03c87200 device_load 0, i32, xyz, r11_r12_r13, u0_u1, 53, signed, lsl 2
20: 0571044d00c01200 device_load 1, i32, x, r14, u2_u3, 0, signed
28: 3800 wait 0
2a: ae91ce2600000000 asr r4.cache, r7.discard, 2
32: 8e090040ac001000 iadd r2.cache, 0, r2.discard, lsl 3
3a: e2152108823c mov_imm r5.cache, 1015154721
40: 8e1900402c002000 iadd r6.cache, 0, r2.discard, lsl 4
48: be910b842c00 convert s32_to_f, r4.cache, r4.discard, rte
4e: 8e090020ac001000 iadd r2.cache, 0, r1.discard, lsl 3
56: 3ebd0bc42c00 convert s32_to_f, r15, r6.discard, rte
5c: 1a85c8a22c00 fmul32 r1, r4.discard, r5.discard
62: 8e0d0060ac001000 iadd r3.cache, 0, r3.discard, lsl 3
6a: 8e0900402c002000 iadd r2.cache, 0, r2.discard, lsl 4
72: 0e1d00602c002000 iadd r7, 0, r3.discard, lsl 4
7a: 3e950b442c00 convert s32_to_f, r5, r2.discard, rte
80: e211003c001c mov_imm r4.cache, 469777408
86: 9209d20200d200d0 icmpsel sgt, r2.cache, r9.discard, 0, r9.discard, 0
8e: 12108c010000818c icmpsel seq, r4l, u6, 0, 0, r4l.discard
96: 9289c4f203c4f0b33003 icmpsel slt, r2.cache, r2.discard, 255, r2.discard, 255
a0: 8e010000ac001000 iadd r0.cache, 0, r0.discard, lsl 3
a8: fe09c4f28303 and r2.cache, r2.discard, 255
ae: 8e0d00002c002000 iadd r3.cache, 0, r0.discard, lsl 4
b6: 9201d40200d400d0 icmpsel sgt, r0.cache, r10.discard, 0, r10.discard, 0
be: be990b642c00 convert s32_to_f, r6.cache, r3.discard, rte
c4: 9281c0f203c0f0b33003 icmpsel slt, r0.cache, r0.discard, 255, r0.discard, 255
ce: aea900a029080000 bfeil r10.cache, 0, r13.cache, 8
d6: fe01c0f28303 and r0.cache, r0.discard, 255
dc: ae8d00a029080080 bfeil r3.cache, 0, r13.cache, 8, mask 0xFFFF
e4: e22500008000 mov_imm r9.cache, 8388608
ea: e22d0000ffff mov_imm r11.cache, 4294901760
f0: fe25da22ad00 and r9.cache, r13.discard, r9.discard
f6: fe29d46aed00 or r10.cache, r10.discard, r11.discard
fc: 9225d20200c6408d icmpsel seq, r9.cache, r9.discard, 0, r3.discard, r10.discard
104: 920dd00200d000d0 icmpsel sgt, r3.cache, r8.discard, 0, r8.discard, 0
10c: bea10b242d00 convert s32_to_f, r8.cache, r9.discard, rte
112: 928dc6f203c6f0b33003 icmpsel slt, r3.cache, r3.discard, 255, r3.discard, 255
11c: 0a19cc82 rcp r6, r6.discard
120: fe0dc6f28303 and r3.cache, r3.discard, 255
126: 1a92d0920c00 fmul32 r4h, r8.discard, r4h.discard
12c: be8d0b642c00 convert s32_to_f, r3.cache, r3.discard, rte
132: e2218180803b mov_imm r8.cache, 998277249
138: be890b442c00 convert s32_to_f, r2.cache, r2.discard, rte
13e: 1a8dc6022900 fmul32 r3, r3.discard, r8.cache
144: be810b042c00 convert s32_to_f, r0.cache, r0.discard, rte
14a: 1a89c4022900 fmul32 r2, r2.discard, r8.cache
150: 3e9d0be42c00 convert s32_to_f, r7, r7.discard, rte
156: 1a81c0022d00 fmul32 r0, r0.discard, r8.discard
15c: 0a15ca82 rcp r5, r5.discard
160: c578e03d00803000 uniform_store 2, i16, xy, 0, r15l_r15h, 14
168: c538003d01803000 uniform_store 2, i16, xy, 0, r7l_r7h, 16
170: c530203d01803000 uniform_store 2, i16, xy, 0, r6l_r6h, 18
178: c528403d01803000 uniform_store 2, i16, xy, 0, r5l_r5h, 20
180: c520003d02803000 uniform_store 2, i16, xy, 0, r4l_r4h, 32
188: c518603d01803000 uniform_store 2, i16, xy, 0, r3l_r3h, 22
190: c510803d01803000 uniform_store 2, i16, xy, 0, r2l_r2h, 24
198: c500a03d01803000 uniform_store 2, i16, xy, 0, r0l_r0h, 26
1a0: c508c03d01803000 uniform_store 2, i16, xy, 0, r1l_r1h, 28
1a8: 3801 wait 1
1aa: c570e03d01803000 uniform_store 2, i16, xy, 0, r14l_r14h, 30
1b2: 8800 stop
fragment shader:
0: 618101c000400000 iterproj r0_r1_r2, cf1, cf0, center, 0b0
8: a18d044000400000 TODO.ldcf r3_r4_r5, cf4
10: 8a198482 rcp r6.cache, r2.cache
14: 820d200100ca800c fcmpsel eq, r3.cache, u16l, 0.0, r5.discard, r4.discard
1c: 9a9180c22800 fmul32 r4.cache, r0.cache, r6.cache
22: 9a9582c22c00 fmul32 r5.cache, r1.cache, r6.discard
28: 8205840200c2a00c fcmpsel eq, r1.cache, r2.cache, 0.0, r1.discard, r5.discard
30: 8201c40200c0800c fcmpsel eq, r0.cache, r2.discard, 0.0, r0.discard, r4.discard
38: 9a85c2021900 fmul32 r1.cache, r1.discard, u8
3e: 9a81c0e21800 fmul32 r0.cache, r0.discard, u7
44: be8509202c00 convert f_to_s32, r1.cache, r1.discard, rtz
4a: 9209c6e219c60030 icmpsel ult, r2.cache, r3.discard, u15, r3.discard, 0
52: be8109002c00 convert f_to_s32, r0.cache, r0.discard, rtz
58: 8e138441ec001000 iadd r4_r5.cache, u2, r2.discard.sx, lsl 3
60: 8e0100002c002000 iadd r0.cache, 0, r0.discard, lsl 4
68: 8e0500202c002000 iadd r1.cache, 0, r1.discard, lsl 4
70: 8e0100002c002000 iadd r0.cache, 0, r0.discard, lsl 4
78: 8e0500202c002000 iadd r1.cache, 0, r1.discard, lsl 4
80: ae81c08600000000 asr r0.cache, r0.discard, 8
88: ae85c28600000000 asr r1.cache, r1.discard, 8
90: be810b042c00 convert s32_to_f, r0.cache, r0.discard, rte
96: 7e0c21098000 mov r3l, u16h
9c: be850b242c00 convert s32_to_f, r1.cache, r1.discard, rte
a2: 0e15ca6218000000 iadd r5, r5.discard, u3
aa: 1a81c0221900 fmul32 r0, r0.discard, u9
b0: 1a85c2421900 fmul32 r1, r1.discard, u10
b6: 62080000 mov_imm r2l, 0
ba: 4800c200 writeout 512, 3
be: 3181404600635f0020000000 texture_sample 0, 0b01, 0b01100, 0b0, 0b00000, xyzw, 0b001, r0_r1_r2_r3, None, ts0, ss0, tex_2d_array, r0l_r0h_r1l_r1h_r2l.discard, auto_lod_bias, r3l
ca: 0521184500c03200 device_load 1, i32, xy, r4_r5, r4_r5, 1, signed
d2: 3800 wait 0
d4: 9a99c6321300 fmul32 r6.cache, r3.discard, u25h
da: 9aa5c0321300 fmul32 r9.cache, r0.discard, u25h
e0: 82008c0200b241bb fcmpsel gte, r0l.cache, r6.cache, 0.0, u25l, u26l
e8: 821c920200b241bb fcmpsel gte, r7l.cache, r9.cache, 0.0, u25l, u26l
f0: 9a8dc2321300 fmul32 r3.cache, r1.discard, u25h
f6: 82008c060200012c fcmpsel lt, r0l.cache, r6.cache.abs, 0.5, 0, r0l.discard
fe: 8202860200b241bb fcmpsel gte, r0h.cache, r3.cache, 0.0, u25l, u26l
106: 821c92060200e12c fcmpsel lt, r7l.cache, r9.cache.abs, 0.5, 0, r7l.discard
10e: 822086060200112c fcmpsel lt, r8l.cache, r3.cache.abs, 0.5, 0, r0h.discard
116: aa81c0c02800 fadd32 r0.cache, r0l.discard, r6.cache
11c: 9a85c4321300 fmul32 r1.cache, r2.discard, u25h
122: be8109002c00 convert f_to_s32, r0.cache, r0.discard, rtz
128: aa89ce202900 fadd32 r2.cache, r7l.discard, r9.cache
12e: 821c820200b241bb fcmpsel gte, r7l.cache, r1.cache, 0.0, u25l, u26l
136: be8909402c00 convert f_to_s32, r2.cache, r2.discard, rtz
13c: 822882060200e12c fcmpsel lt, r10l.cache, r1.cache.abs, 0.5, 0, r7l.discard
144: aa9dd0602800 fadd32 r7.cache, r8l.discard, r3.cache
14a: bea109e02c00 convert f_to_s32, r8.cache, r7.discard, rtz
150: aa9dd4202800 fadd32 r7.cache, r10l.discard, r1.cache
156: be890b442c00 convert s32_to_f, r2.cache, r2.discard, rte
15c: be9d09e02c00 convert f_to_s32, r7.cache, r7.discard, rtz
162: 8209d2661bc4202d fcmpsel lt, r2.cache, r9.discard.abs, u27, r2.discard, r9.discard
16a: bea10b042d00 convert s32_to_f, r8.cache, r8.discard, rte
170: be8909402c00 convert f_to_s32, r2.cache, r2.discard, rtz
176: 820dc6661bd0602c fcmpsel lt, r3.cache, r3.discard.abs, u27, r8.discard, r3.discard
17e: be8d09602c00 convert f_to_s32, r3.cache, r3.discard, rtz
184: be9d0be42c00 convert s32_to_f, r7.cache, r7.discard, rte
18a: 9e0da4612cb00100 imadd r3.cache, u18, r3.discard, u24
192: 8205c2661bce202c fcmpsel lt, r1.cache, r1.discard.abs, u27, r7.discard, r1.discard
19a: be810b042c00 convert s32_to_f, r0.cache, r0.discard, rte
1a0: be8509202c00 convert f_to_s32, r1.cache, r1.discard, rtz
1a6: 8201cc661bc0c02c fcmpsel lt, r0.cache, r6.discard.abs, u27, r0.discard, r6.discard
1ae: 9e09a2412cc60200 imadd r2.cache, u17, r2.discard, r3.discard
1b6: 3e8109002c00 convert f_to_s32, r0, r0.discard, rtz
1bc: 1e05a6212cc40200 imadd r1, u19, r1.discard, r2.discard
1c4: 3801 wait 1
1c6: 9e01a8012cc20200 imadd r0.cache, u20, r0.discard, r1.discard
1ce: fe01c0829b00 and r0.cache, r0.discard, u28
1d4: be810b042c00 convert s32_to_f, r0.cache, r0.discard, rte
1da: ba01c0a21b30 fmadd32 r0.cache, r0.discard, u29, 1.0
1e0: 8205c0822cc8002c fcmpsel lt, r1.cache, r0.discard, r4.discard, r4.discard, r0.discard
1e8: 7e0196098000 mov r0, u11
1ee: 0211c2a22cca204c fcmpsel gt, r4, r1.discard, r5.discard, r5.discard, r1.discard
1f6: 7e0598098000 mov r1, u12
1fc: 7e099a098000 mov r2, u13
202: 7e0d9c098000 mov r3, u14
208: 48010000 writeout 1, 0
20c: 417f <disassembly failed>
20e: 0823 <disassembly failed>
210: 5801 <disassembly failed>
212: 0000 <disassembly failed>
214: 480c0000 writeout 12, 0
218: 09010004f0fc8003 st_tile r0_r1_r2_r3, u8norm, 0, xyzw, 0, 255, 0
220: 8800 stop
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wreturn-type"
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct PSBlock
{
int4 color[4];
int4 k[4];
int4 alphaRef;
int4 texdim[8];
int4 czbias[2];
int4 cindscale[2];
int4 cindmtx[6];
int4 cfogcolor;
int4 cfogi;
float4 cfogf;
float4 cfogrange[3];
float4 czslope;
float2 cefbscale;
uint bpmem_genmode;
uint bpmem_alphaTest;
uint bpmem_fogParam3;
uint bpmem_fogRangeBase;
uint bpmem_dstalpha;
uint bpmem_ztex_op;
uint bpmem_late_ztest;
uint bpmem_rgba6_format;
uint bpmem_dither;
uint bpmem_bounding_box;
uint4 bpmem_pack1[16];
uint4 bpmem_pack2[8];
int4 konstLookup[32];
uint blend_enable;
uint blend_src_factor;
uint blend_src_factor_alpha;
uint blend_dst_factor;
uint blend_dst_factor_alpha;
uint blend_subtract;
uint blend_subtract_alpha;
uint logic_op_enable;
uint logic_op_mode;
};
struct main0_out
{
float4 ocol0 [[color(0), index(0)]];
float4 ocol1 [[color(0), index(1)]];
float gl_FragDepth [[depth(any)]];
};
struct main0_in
{
float4 colors_0 [[user(locn0)]];
float4 colors_1 [[user(locn1)]];
float3 tex0 [[user(locn2)]];
};
static inline __attribute__((always_inline))
int4 iround(thread const float4& x)
{
return int4(round(x));
}
static inline __attribute__((always_inline))
int4 sampleTexture(thread const uint& texmap, texture2d_array<float> tex, sampler texSmplr, thread const int2& uv, thread const int& layer, constant PSBlock& v_83)
{
float size_s = float(v_83.texdim[texmap].x * 128);
float size_t = float(v_83.texdim[texmap].y * 128);
float3 coords = float3(float(uv.x) / size_s, float(uv.y) / size_t, float(layer));
uint texmode0 = v_83.bpmem_pack2[texmap].z;
float lod_bias = float(extract_bits(int(texmode0), uint(8), uint(16))) / 256.0;
float4 param = tex.sample(texSmplr, coords.xy, uint(round(coords.z)), bias(lod_bias)) * 255.0;
return iround(param);
}
static inline __attribute__((always_inline))
int idot(thread const int4& x, thread const int4& y)
{
int4 tmp = x * y;
return ((tmp.x + tmp.y) + tmp.z) + tmp.w;
}
fragment main0_out fs(main0_in in [[stage_in]], constant PSBlock& v_83 [[buffer(0)]], array<texture2d_array<float>, 8> samp [[texture(0)]], array<sampler, 8> sampSmplr [[sampler(0)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
float4 rawpos = gl_FragCoord;
int layer = 0;
int4 c0 = v_83.color[1];
int4 c1 = v_83.color[2];
int4 c2 = v_83.color[3];
int4 prev = v_83.color[0];
int4 rastemp = int4(0);
int4 textemp = int4(0);
int4 konsttemp = int4(0);
int3 comp16 = int3(1, 256, 0);
int3 comp24 = int3(1, 256, 65536);
int alphabump = 0;
int3 tevcoord = int3(0);
int2 wrappedcoord = int2(0);
int2 tempcoord = int2(0);
int4 tevin_a = int4(0);
int4 tevin_b = int4(0);
int4 tevin_c = int4(0);
int4 tevin_d = int4(0);
float4 col0 = in.colors_0;
float4 col1 = in.colors_1;
float2 _198;
if (in.tex0.z == 0.0)
{
_198 = in.tex0.xy;
}
else
{
_198 = in.tex0.xy / float2(in.tex0.z);
}
int2 fixpoint_uv0 = int2(_198 * float2(v_83.texdim[0].zw * int2(128)));
int2 indtevtrans0 = int2(0);
wrappedcoord.x = fixpoint_uv0.x;
wrappedcoord.y = fixpoint_uv0.y;
int2 _228 = wrappedcoord + indtevtrans0;
tevcoord.x = _228.x;
tevcoord.y = _228.y;
int3 _233 = tevcoord;
int2 _238 = (_233.xy << int2(8)) >> int2(8);
tevcoord.x = _238.x;
tevcoord.y = _238.y;
uint param = 0u;
int2 param_1 = tevcoord.xy;
int param_2 = layer;
textemp = sampleTexture(param, samp[0], sampSmplr[0], param_1, param_2, v_83);
tevin_a = int4(0);
tevin_b = int4(0);
tevin_c = int4(0);
tevin_d = int4(c0.xyz, c0.w);
int3 _290 = clamp(tevin_d.xyz + ((((tevin_a.xyz << int3(8)) + ((tevin_b.xyz - tevin_a.xyz) * (tevin_c.xyz + (tevin_c.xyz >> int3(7))))) + int3(128)) >> int3(8)), int3(0), int3(255));
prev.x = _290.x;
prev.y = _290.y;
prev.z = _290.z;
prev.w = clamp(tevin_d.w + ((((tevin_a.w << 8) + ((tevin_b.w - tevin_a.w) * (tevin_c.w + (tevin_c.w >> 7)))) + 128) >> 8), 0, 255);
prev &= int4(255);
if (prev.w == 1)
{
prev.w = 0;
}
int zCoord = int((1.0 - rawpos.z) * 16777216.0);
zCoord = clamp(zCoord, 0, 16777215);
int4 param_3 = v_83.czbias[0];
int4 param_4 = textemp;
zCoord = idot(param_3, param_4) + v_83.czbias[1].w;
zCoord &= 16777215;
out.gl_FragDepth = 1.0 - (float(zCoord) / 16777216.0);
float3 _364 = float3(prev.xyz) / float3(255.0);
out.ocol0.x = _364.x;
out.ocol0.y = _364.y;
out.ocol0.z = _364.z;
out.ocol0.w = float(v_83.alphaRef.w >> 2) / 63.0;
out.ocol1 = float4(0.0, 0.0, 0.0, float(prev.w) / 255.0);
return out;
}
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wreturn-type"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Light
{
int4 color;
float4 cosatt;
float4 distatt;
float4 pos;
float4 dir;
};
struct VSBlock
{
uint components;
uint xfmem_dualTexInfo;
uint xfmem_numColorChans;
uint missing_color_hex;
float4 missing_color_value;
float4 cpnmtx[6];
float4 cproj[4];
int4 cmtrl[4];
Light clights[8];
float4 ctexmtx[24];
float4 ctrmtx[64];
float4 cnmtx[32];
float4 cpostmtx[64];
float4 cpixelcenter;
float2 cviewport;
uint4 xfmem_pack1[8];
float4 ctangent;
float4 cbinormal;
uint vertex_stride;
uint vertex_offset_rawnormal;
uint vertex_offset_rawtangent;
uint vertex_offset_rawbinormal;
uint vertex_offset_rawpos;
uint vertex_offset_posmtx;
uint vertex_offset_rawcolor0;
uint vertex_offset_rawcolor1;
uint4 vertex_offset_rawtex[2];
};
struct VS_OUTPUT
{
float4 pos;
float4 colors_0;
float4 colors_1;
float3 tex0;
};
struct main0_out
{
float4 colors_0 [[user(locn0)]];
float4 colors_1 [[user(locn1)]];
float3 tex0 [[user(locn2)]];
float4 gl_Position [[position]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
struct main0_in
{
float4 rawpos [[attribute(0)]];
float2 rawtex0 [[attribute(8)]];
};
vertex main0_out vs(main0_in in [[stage_in]], constant VSBlock& _35 [[buffer(1)]])
{
main0_out out = {};
float4 vertex_color_0 = _35.missing_color_value;
float4 vertex_color_1 = _35.missing_color_value;
float4 P0 = _35.cpnmtx[0];
float4 P1 = _35.cpnmtx[1];
float4 P2 = _35.cpnmtx[2];
float4 pos = float4(dot(P0, in.rawpos), dot(P1, in.rawpos), dot(P2, in.rawpos), 1.0);
float3 _normal = float3(0.0);
float3 _binormal = float3(0.0);
float3 _tangent = float3(0.0);
VS_OUTPUT o;
o.pos = float4(dot(_35.cproj[0], pos), dot(_35.cproj[1], pos), dot(_35.cproj[2], pos), dot(_35.cproj[3], pos));
int4 mat = _35.cmtrl[2];
int4 lacc = int4(255);
lacc.w = 255;
lacc = clamp(lacc, int4(0), int4(255));
o.colors_0 = float4((mat * (lacc + (lacc >> int4(7)))) >> int4(8)) / float4(255.0);
int4 mat_1 = _35.cmtrl[3];
lacc = int4(255);
lacc.w = 255;
lacc = clamp(lacc, int4(0), int4(255));
o.colors_1 = float4((mat_1 * (lacc + (lacc >> int4(7)))) >> int4(8)) / float4(255.0);
float4 coord = float4(0.0, 0.0, 1.0, 1.0);
coord = float4(0.0, 0.0, 1.0, 1.0);
coord = float4(in.rawtex0.x, in.rawtex0.y, 1.0, 1.0);
coord.z = 1.0;
if (isnan(coord.x))
{
coord.x = 1.0;
}
if (isnan(coord.y))
{
coord.y = 1.0;
}
if (isnan(coord.z))
{
coord.z = 1.0;
}
o.tex0 = float3(dot(coord, _35.ctexmtx[0]), dot(coord, _35.ctexmtx[1]), 1.0);
float4 P0_1 = _35.cpostmtx[61];
float4 P1_1 = _35.cpostmtx[62];
float4 P2_1 = _35.cpostmtx[63];
o.tex0 = float3(dot(P0_1.xyz, o.tex0) + P0_1.w, dot(P1_1.xyz, o.tex0) + P1_1.w, dot(P2_1.xyz, o.tex0) + P2_1.w);
if (o.tex0.z == 0.0)
{
float3 _241 = o.tex0;
float2 _249 = fast::clamp(_241.xy / float2(2.0), float2(-1.0), float2(1.0));
o.tex0.x = _249.x;
o.tex0.y = _249.y;
}
o.colors_0 = float4(0.0);
o.colors_1 = float4(0.0);
float clipDepth = o.pos.z * 0.99999988079071044921875;
float clipDist0 = clipDepth + o.pos.w;
float clipDist1 = -clipDepth;
o.pos.z = (o.pos.w * _35.cpixelcenter.w) - (o.pos.z * _35.cpixelcenter.z);
float4 _291 = o.pos;
float2 _293 = _291.xy * sign(_35.cpixelcenter.xy * float2(1.0, -1.0));
o.pos.x = _293.x;
o.pos.y = _293.y;
float4 _299 = o.pos;
float _302 = o.pos.w;
float2 _307 = _299.xy - (_35.cpixelcenter.xy * _302);
o.pos.x = _307.x;
o.pos.y = _307.y;
out.tex0 = o.tex0;
out.colors_0 = o.colors_0;
out.colors_1 = o.colors_1;
out.gl_ClipDistance[0] = clipDist0;
out.gl_ClipDistance[1] = clipDist1;
out.gl_Position = o.pos;
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment