(ptr:PtrDType, arch:str)
| 139 | # get list of (height, width) that do not require pitch padding |
| 140 | @staticmethod |
| 141 | def valid_dims(ptr:PtrDType, arch:str) -> list[tuple[int,int]]: |
| 142 | if (ALIGN:=next((int(p.split('=')[1]) for p in arch.split(',') if p.startswith("IMAGE_PITCH_ALIGNMENT=")), 0)) == 0: return [] |
| 143 | MAXW, pxls = 16384, ptr.size // 4 |
| 144 | if ptr.base not in (dtypes.half, dtypes.float) or ptr.size > 4*MAXW*MAXW: return [] |
| 145 | # height=1 images just need to abide by alignment requirements in bytes, not pixels! |
| 146 | if ptr.size % (ALIGN * 4) != 0: return [] if ptr.nbytes() % (64 if OSX else ALIGN) != 0 or pxls > MAXW else [(1, pxls)] |
| 147 | return [(pxls//ALIGN//k, ALIGN*k) for k in range(ceildiv(pxls//ALIGN, MAXW), min(pxls//ALIGN, MAXW//ALIGN)+1) if (pxls//ALIGN)%k == 0] |
| 148 | |
| 149 | class dtypes: |
| 150 | @staticmethod |
no test coverage detected