Skip to content

Commit 2b0e022

Browse files
hoshinolinamarcan
authored andcommitted
m1n1.agx: Port rendering to G14
Signed-off-by: Asahi Lina <[email protected]>
1 parent 696cdee commit 2b0e022

3 files changed

Lines changed: 42 additions & 34 deletions

File tree

proxyclient/m1n1/agx/render.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,11 @@ def submit(self, cmdbuf, wait_for=None):
580580
wc_3d.struct_2.unk_48 = 0x0
581581
# ISP_ZLSCTL
582582
wc_3d.struct_2.depth_flags = cmdbuf.ds_flags
583+
wc_3d.struct_2.unk_58_g14_0 = 0x4040404
584+
wc_3d.struct_2.unk_58_g14_8 = 0
583585
wc_3d.struct_2.depth_buffer_ptr1 = cmdbuf.depth_buffer
584586
wc_3d.struct_2.depth_buffer_ptr2 = cmdbuf.depth_buffer
587+
wc_3d.struct_2.unk_68_g14_0 = 0
585588
wc_3d.struct_2.stencil_buffer_ptr1 = cmdbuf.stencil_buffer
586589
wc_3d.struct_2.stencil_buffer_ptr2 = cmdbuf.stencil_buffer
587590
wc_3d.struct_2.unk_78 = [0] * 4
@@ -609,6 +612,7 @@ def submit(self, cmdbuf, wait_for=None):
609612
wc_3d.struct_2.unk_158 = 0x1c
610613
wc_3d.struct_2.unk_160 = 0
611614
wc_3d.struct_2.unk_168_padding = bytes(0x1d8)
615+
wc_3d.struct_2.unk_198_padding = bytes(0x1a8)
612616

613617
if True:
614618
wc_3d.struct_6 = Start3DStruct6()
@@ -742,6 +746,7 @@ def submit(self, cmdbuf, wait_for=None):
742746
finish_3d.unk_7c = 0
743747
finish_3d.unk_84 = 0
744748
finish_3d.unk_8c = 0
749+
finish_3d.unk_8c_g14 = 0
745750
finish_3d.restart_branch_offset = start_3d_offset - ms.off
746751
finish_3d.unk_98 = 0
747752
finish_3d.unk_9c = bytes(0x10)
@@ -831,30 +836,30 @@ def submit(self, cmdbuf, wait_for=None):
831836
wc_ta.struct_2.unk_8 = 0x1e3ce508 # fixed
832837
wc_ta.struct_2.unk_c = 0x1e3ce508 # fixed
833838
wc_ta.struct_2.tvb_tilemap = tvb_tilemap._addr
834-
wc_ta.struct_2.unkptr_18 = unk_tile_buf1._addr
835-
wc_ta.struct_2.unkptr_20 = self.tpc._addr
839+
wc_ta.struct_2.tvb_cluster_tilemaps = unk_tile_buf1._addr
840+
wc_ta.struct_2.tpc = self.tpc._addr
836841
wc_ta.struct_2.tvb_heapmeta_addr = tvb_heapmeta._addr | 0x8000_0000_0000_0000
837842
wc_ta.struct_2.iogpu_unk_54 = 0x6b0003 # fixed
838843
wc_ta.struct_2.iogpu_unk_55 = 0x3a0012 # fixed
839844
wc_ta.struct_2.iogpu_unk_56 = 0x1 # fixed
840-
wc_ta.struct_2.unk_40 = unk_tile_buf2._addr | 0x4_0000_0000_0000
845+
wc_ta.struct_2.tvb_cluster_meta1 = unk_tile_buf2._addr | 0x4_0000_0000_0000
841846
wc_ta.struct_2.unk_48 = 0xa000
842847
wc_ta.struct_2.unk_50 = 0x88 # fixed
843848
wc_ta.struct_2.tvb_heapmeta_addr2 = tvb_heapmeta._addr
844849
wc_ta.struct_2.unk_60 = 0x0 # fixed
845-
wc_ta.struct_2.unk_68 = 0xffffffffffffffff
850+
wc_ta.struct_2.core_mask = 0xffffffffffffffff
846851
#wc_ta.struct_2.unk_68 = 0xff << (8 * (self.buffer_mgr_slot % 8))
847852
wc_ta.struct_2.iogpu_deflake_1 = deflake_1._addr
848853
wc_ta.struct_2.iogpu_deflake_2 = deflake_2._addr
849854
wc_ta.struct_2.unk_80 = 0x1 # fixed
850855
wc_ta.struct_2.iogpu_deflake_3 = deflake_3._addr | 0x4_0000_0000_0000 # check
851856
wc_ta.struct_2.encoder_addr = cmdbuf.encoder_ptr
852-
wc_ta.struct_2.unk_98 = [unk_tile_buf3._addr,
853-
unk_tile_buf4._addr]
854-
wc_ta.struct_2.unk_a8 = 0xa040 #0xa041 # fixed
857+
wc_ta.struct_2.tvb_cluster_meta2 = unk_tile_buf3._addr
858+
wc_ta.struct_2.tvb_cluster_meta3 = unk_tile_buf4._addr
859+
wc_ta.struct_2.tiling_control = 0xa040 #0xa041 # fixed
855860
wc_ta.struct_2.unk_b0 = [0x0, 0x0, 0x0, 0x0, 0x0, 0x0] # fixed
856861
wc_ta.struct_2.pipeline_base = self.ctx.pipeline_base
857-
wc_ta.struct_2.unk_e8 = unk_tile_buf5._addr | 0x3000_0000_0000_0000
862+
wc_ta.struct_2.tvb_cluster_meta4 = unk_tile_buf5._addr | 0x3000_0000_0000_0000
858863
wc_ta.struct_2.unk_f0 = 0x20 # fixed
859864
wc_ta.struct_2.unk_f8 = 0x8c60 # fixed
860865
wc_ta.struct_2.unk_100 = [0x0, 0x0, 0x0] # fixed
@@ -989,6 +994,7 @@ def submit(self, cmdbuf, wait_for=None):
989994
finish_ta.unk_60 = 0x0 # fixed
990995
finish_ta.unk_64 = 0x0 # fixed
991996
finish_ta.unk_68 = 0x0 # fixed
997+
finish_ta.unk_6c_g14 = 0 # fixed
992998
finish_ta.restart_branch_offset = start_ta_offset - ms.off
993999
finish_ta.unk_70 = 0x0 # fixed
9941000
finish_ta.unk_74 = bytes(0x10) # Ventura
@@ -1042,11 +1048,11 @@ def wait(self):
10421048

10431049
#if work.fb is not None and work.width and work.height:
10441050
if work.fb is not None and work.width and work.height and work.width == 1920:
1045-
1051+
agx = self.agx
10461052
self.agx.log(f"Render {work.width}x{work.height} @ {work.fb:#x}")
10471053
base, obj = self.agx.find_object(work.fb, self.ctx_id)
10481054

1049-
#unswizzle(agx, obj._paddr, width, height, 4, "fb.bin", grid=False)
1055+
#unswizzle(agx, obj._paddr, work.width, work.height, 4, "fb.bin", grid=False)
10501056
#open("fb.bin", "wb").write(self.agx.u.iface.readmem(obj._paddr, work.width*work.height*4))
10511057
#os.system(f"convert -size {work.width}x{work.height} -depth 8 rgba:fb.bin -alpha off frame{self.frames}.png")
10521058
self.agx.p.fb_blit(0, 0, work.width, work.height, obj._paddr, work.width, PIX_FMT.XBGR)

proxyclient/m1n1/fw/agx/cmdqueue.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,34 @@ class EventControl(ConstructClass):
7373
"unk_14" / Int32ul,
7474
"unk_18" / Int64ul,
7575
"unk_20" / Int32ul,
76-
"unk_24" / Int32ul,
76+
"vm_slot" / Int32ul,
7777
"has_ta" / Int32ul,
7878
"pstamp_ta" / Array(4, Int64ul),
7979
"has_3d" / Int32ul,
8080
"pstamp_3d" / Array(4, Int64ul),
8181
"has_cp" / Int32ul,
8282
"pstamp_cp" / Array(4, Int64ul),
8383
"in_list" / Int32ul,
84+
Ver("G >= G14", "unk_98_g14_0" / HexDump(Bytes(0x14))),
8485
"list_head" / LinkedListHead,
85-
"unk_buf" / EventControlUnkBuf,
86+
Ver("G >= G14", "unk_a8_g14_0" / Padding(4)),
87+
Ver("V >= V13_0B4", "unk_buf" / EventControlUnkBuf),
8688
)
8789

8890
def __init__(self):
8991
super().__init__()
9092
self.unk_14 = 0
9193
self.unk_18 = 0
9294
self.unk_20 = 0
93-
self.unk_24 = 0
95+
self.vm_slot = 0
9496
self.has_ta = 0
9597
self.pstamp_ta = [0]*4
9698
self.has_3d = 0
9799
self.pstamp_3d = [0]*4
98100
self.has_cp = 0
99101
self.pstamp_cp = [0]*4
100102
self.in_list = 0
103+
self.unk_98_g14_0 = bytes(0x14)
101104
self.list_head = LinkedListHead()
102105
self.unk_buf = EventControlUnkBuf()
103106

proxyclient/m1n1/fw/agx/microsequence.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,13 @@ class Start3DStruct2(ConstructClass):
274274
"depth_dimensions" / Int64ul,
275275
"unk_48" / Int64ul,
276276
"depth_flags" / Int64ul, # 0x40000 - has stencil 0x80000 - has depth
277+
Ver("G >= G14", "unk_58_g14_0" / Int64ul),
278+
Ver("G >= G14", "unk_58_g14_8" / Int64ul),
277279
"depth_buffer_ptr1" / Int64ul,
278280
"depth_buffer_ptr2" / Int64ul,
279281
"stencil_buffer_ptr1" / Int64ul,
280282
"stencil_buffer_ptr2" / Int64ul,
283+
Ver("G >= G14", "unk_68_g14_0" / HexDump(Bytes(0x20))),
281284
"unk_78" / Array(4, Int64ul),
282285
"depth_aux_buffer_ptr1" / Int64ul,
283286
"unk_a0" / Int64ul,
@@ -300,7 +303,8 @@ class Start3DStruct2(ConstructClass):
300303
"unk_150" / Int64ul,
301304
"unk_158" / Int64ul,
302305
"unk_160" / Int64ul,
303-
"unk_168_padding" / HexDump(Bytes(0x1d8)),
306+
Ver("G < G14", "unk_168_padding" / HexDump(Bytes(0x1d8))),
307+
Ver("G >= G14", "unk_198_padding" / HexDump(Bytes(0x1a8))),
304308
Ver("V < V13_0B4", ZPadding(8)),
305309
)
306310

@@ -432,6 +436,7 @@ class Finalize3DCmd(ConstructClass):
432436
"unk_7c" / Int64ul, # 0
433437
"unk_84" / Int64ul, # 0
434438
"unk_8c" / Int64ul, # 0
439+
Ver("G >= G14", "unk_8c_g14" / Int64ul),
435440
"restart_branch_offset" / Int32sl,
436441
"unk_98" / Int32ul, # 1
437442
Ver("V >= V13_0B4", "unk_9c" / HexDump(Bytes(0x10))),
@@ -459,32 +464,34 @@ class StartTACmdStruct2(ConstructClass):
459464
"unk_8" / Hex(Int32ul),
460465
"unk_c" / Hex(Int32ul),
461466
"tvb_tilemap" / Hex(Int64ul),
462-
"unkptr_18" / Hex(Int64ul),
463-
"unkptr_20" / Hex(Int64ul),
467+
Ver("G < G14", "tvb_cluster_tilemaps" / Hex(Int64ul)),
468+
"tpc" / Hex(Int64ul),
464469
"tvb_heapmeta_addr" / Hex(Int64ul), # like Start3DStruct2.tvb_end_addr with bit 63 set?
465470
"iogpu_unk_54" / Int32ul,
466471
"iogpu_unk_55" / Int32ul,
467472
"iogpu_unk_56" / Int64ul,
468-
"unk_40" / Int64ul,
473+
Ver("G < G14", "tvb_cluster_meta1" / Int64ul),
469474
"unk_48" / Int64ul,
470475
"unk_50" / Int64ul,
471476
"tvb_heapmeta_addr2" / Int64ul,
472-
"unk_60" / Int64ul,
473-
"unk_68" / Int64ul,
477+
Ver("G < G14", "unk_60" / Int64ul),
478+
Ver("G < G14", "core_mask" / Int64ul),
474479
"iogpu_deflake_1" / Int64ul,
475480
"iogpu_deflake_2" / Int64ul,
476481
"unk_80" / Int64ul,
477-
"iogpu_deflake_3" / Int64ul, # context_id in bits 55:48
482+
"iogpu_deflake_3" / Int64ul, # bit 50 set
478483
"encoder_addr" / Int64ul,
479-
"unk_98" / Array(2, Hex(Int64ul)),
480-
"unk_a8" / Int64ul,
484+
Ver("G < G14", "tvb_cluster_meta2" / Int64ul),
485+
Ver("G < G14", "tvb_cluster_meta3" / Int64ul),
486+
Ver("G < G14", "tiling_control" / Int64ul),
481487
"unk_b0" / Array(6, Hex(Int64ul)),
482488
"pipeline_base" / Int64ul,
483-
"unk_e8" / Int64ul,
484-
"unk_f0" / Int64ul,
489+
Ver("G < G14", "tvb_cluster_meta4" / Int64ul),
490+
Ver("G < G14", "unk_f0" / Int64ul),
485491
"unk_f8" / Int64ul,
486492
"unk_100" / Array(3, Hex(Int64ul)),
487493
"unk_118" / Int32ul,
494+
Ver("G >= G14", Padding(8 * 9)),
488495
)
489496

490497
class StartTACmdStruct3(ConstructClass):
@@ -593,6 +600,7 @@ class FinalizeTACmd(ConstructClass):
593600
"unk_60" / Int32ul,
594601
"unk_64" / Int32ul,
595602
"unk_68" / Int32ul,
603+
Ver("G >= G14", "unk_6c_g14" / Int64ul),
596604
"restart_branch_offset" / Int32sl,
597605
"unk_70" / Int32ul,
598606
Ver("V >= V13_0B4", "unk_74" / HexDump(Bytes(0x10))),
@@ -675,16 +683,6 @@ class StartComputeCmd(ConstructClass):
675683
"padding" / Bytes(0x154 - 0x4c),
676684
)
677685

678-
def parsed(self, ctx):
679-
try:
680-
if self.padding != b"\x00" * (0x154 - 0x4c):
681-
raise ExplicitError("padding is not zero")
682-
del self.padding
683-
self._keys = [x for x in self._keys if x != "padding"]
684-
except AttributeError:
685-
pass
686-
687-
688686
class FinalizeComputeCmd(ConstructClass):
689687
subcon = Struct( # 0x64 bytes''''
690688
"magic" / Const(0x2a, Int32ul),
@@ -706,6 +704,7 @@ class FinalizeComputeCmd(ConstructClass):
706704
"unk_50" / Int32ul,
707705
"unk_54" / Int32ul,
708706
"unk_58" / Int32ul,
707+
Ver("G >= G14", "unk_5c_g14" / Int64ul),
709708
"restart_branch_offset" / Int32sl, # realative offset from start of Finalize to StartComputeCmd
710709
"unk_60" / Int32ul,
711710
)

0 commit comments

Comments
 (0)