Skip to content

Commit e87256b

Browse files
committed
shared/textures: Implement GX RGBA8 format
1 parent 10d4e6c commit e87256b

File tree

1 file changed

+26
-3
lines changed
  • eurochef/shared/src/platform/texture

1 file changed

+26
-3
lines changed

eurochef/shared/src/platform/texture/gx.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,30 @@ impl TextureDecoder for GxTextureDecoder {
111111
.into()
112112
}
113113
}
114+
InternalFormat::RGBA8 => {
115+
let mut input_offset = 0;
116+
for y in (0..height).step_by(4) {
117+
for x in (0..width).step_by(4) {
118+
let src1 = &input[input_offset..input_offset + 32];
119+
let src2 = &input[input_offset + 32..input_offset + 64];
120+
input_offset += 64;
121+
for iy in 0..4 {
122+
for ix in 0..4 {
123+
let offset2 = (y + iy as u32) * width + x + ix as u32;
124+
let (bx, by) = (offset2 % width, offset2 / width);
125+
126+
let a = src1[iy * 8 + ix * 2];
127+
let r = src1[iy * 8 + ix * 2 + 1];
128+
let g = src2[iy * 8 + ix * 2];
129+
let b = src2[iy * 8 + ix * 2 + 1];
130+
buffer[(bx, by)] = [r, g, b, a].into();
131+
}
132+
}
133+
}
134+
}
135+
136+
output.copy_from_slice(&buffer);
137+
}
114138
InternalFormat::CMPR => {
115139
let mut index = 0;
116140
let mut buffer = vec![0u8; output.len()];
@@ -150,7 +174,7 @@ impl TextureDecoder for GxTextureDecoder {
150174
}
151175
}
152176

153-
if fmt != InternalFormat::CMPR {
177+
if fmt != InternalFormat::CMPR && fmt != InternalFormat::RGBA8 {
154178
let mut src_index = 0;
155179
let (blockw, blockh) = fmt.block_size();
156180
for y in (0..height as u32).step_by(blockh) {
@@ -232,8 +256,7 @@ impl InternalFormat {
232256
7 => Self::IA4,
233257
8 => Self::IA8,
234258
_ => {
235-
Self::I4
236-
// anyhow::bail!("Unknown exformat 0x{fmt:x}");
259+
anyhow::bail!("Unknown exformat 0x{fmt:x}");
237260
}
238261
})
239262
}

0 commit comments

Comments
 (0)