Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
def readHeader(self):
#Create array
texList = []
#Check for PVMH file header
iff = self.bs.readUInt()
if iff != PvmArchive.PVMH:
return 0
#Offset of first texture entry
texOfs = self.bs.readUInt()
self.bs.setOffset()
#Read flags and number of textures
flags = self.bs.readUShort()
nbTex = self.bs.readUShort()
for i in range(nbTex):
tex = { 'id' : self.bs.readUShort() }
if flags & BIT_3:
#Filename bit flag
tex['name'] = self.bs.readStr(0x1C)
if flags & BIT_2:
#File format bitflag
tex['format'] = self.bs.readUShort()
if flags & BIT_1:
#File dimensions bit flag
tex['size'] = self.bs.readUShort()
if flags & BIT_0:
#Global Index bit flag
tex['index'] = self.bs.readUInt()
texList.append(tex)
self.bs.seek_set(texOfs)
return texList
struct pvr_header_t {
uint8_t encode_format;
uint8_t pixel_format;
uint8_t nop[2];
uint16_t width;
uint16_t height;
}
TWIDDLED = 0x01
TWIDDLED_MM = 0x02
VQ = 0x03
VQ_MM = 0x04
PALETTIZE4 = 0x05
PALETTIZE4_MM = 0x06
PALETTIZE8 = 0x07
PALETTIZE8_MM = 0x08
RECTANGLE = 0x09
STRIDE = 0x0B
TWIDDLED_RECTANGLE = 0x0D
ABGR = 0x0E
ABGR_MM = 0x0F
SMALLVQ = 0x10
SMALLVQ_MM = 0x11
TWIDDLED_MM_ALIAS = 0x12
ARGB_1555 = 0x00
RGB_565 = 0x01
ARGB_4444 = 0x02
YUV_422 = 0x03
BUMP = 0x04
RGB_555 = 0x05
YUV_420 = 0x06
struct pvp_header_t {
uint16_t pixel_format;
uint16_t nop[2];
uint16_t count;
}
The resulting order of which is shown above, where it produces these blocks of four pixels that cascade over the image. I think the reasoning is that this allows for the graphics card to split up texel's to be rendered to a face faster, or something like that.
This is usually done to improve memory locality. Pixels close to each other will also be close in-memory this way. I think GPUs also store textures in this order or Z-order. See https://en.wikipedia.org/wiki/Z-order_curve#Texture_mapping for more info.
Wikipedia said:Some GPUs store texture maps in Z-order to increase spatial locality of reference during texture mapped rasterization. This allows cache lines to represent square tiles, increasing the probability that nearby accesses are in the cache. This is important because 3d rendering involves arbitrary transformations (rotations, scaling, perspective, and distortion by animated surfaces). These are referred to as swizzled textures or twidled textures. Other tiled formats may also be used.