mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-23 00:53:02 -05:00
A CMASK that was neither all fast-cleared nor all expanded threw, so a title that fast clears a target and then draws over part of it before the eliminate could not run past it. The CMASK is now decoded tile by tile: one nibble per 8x8 tile in 1024x512 metablocks of 4 KiB, addressed with the pipe-aligned SW_64KB_Z_X CMASK equation for 16 pipes (addrlib GFX10_CMASK_SW_PATTERN, Gfx10Lib::HwlComputeCmaskAddrFromCoord). Code 0 stores CB_COLOR_CLEAR_WORD into the tile's texels, 0xF keeps them; any other code, a cleared tile of a DCC target and any other CMASK swizzle mode throw. Edge tiles are included and the CMASK is then stored as expanded. For a resident target whose CMASK is host-imported the clear is a compute pass recorded in stream order: it reads the nibbles from the import, stores the clear into the cleared tiles through a UINT view of the image and fills the CMASK expanded, so nothing waits for pending GPU writes of the CMASK. Invalid codes it reads set a bit that the next materialization throws on. Otherwise the CPU reads the CMASK and stores the cleared tiles into guest memory, or fills the resident image when every tile is cleared. A CMASK nothing has stored over since it was expanded is skipped. The decode requires CB_COLOR_ATTRIB3 FMASK_SW_MODE SW_64KB_Z_X with CMASK_PIPE_ALIGNED, a 4 KiB aligned writable CMASK and texels of at most 64 bits, and CMASK_BASE_EXT is part of the draw key. Tests: CMASK sizes and nibble addresses against addrlib; decode rejections and draw key coverage; CPU eliminate of full, partial, out-of-range-nibble and DCC decompress cases and invalid codes. The new agc_driver_cmask_fast_clear GPU test draws over fast-cleared and partly fast-cleared linear and SW_64KB_R_X targets, eliminates partial, edge and checkerboard CMASKs through the compute pass and checks that an invalid code it reads throws.