Skip to content
Snippets Groups Projects

Support for SIMD operations for RGG1555

Merged João Magalhães requested to merge joamag/simd into master
Files
3
+ 15
5
@@ -12,7 +12,7 @@ use std::{
use crate::{
gb::{GameBoyConfig, GameBoyMode},
mmu::BusComponent,
util::SharedThread,
util::{copy_fast, SharedThread},
warnln,
};
@@ -2091,6 +2091,9 @@ impl Ppu {
(r << 11) | (g << 5) | b
}
/// Converts an array of RGB888 pixels to RGB565 format using a scalar implementation.
///
/// This method should provide the same results as the SIMD implementation.
pub fn rgb888_to_rgb1555_scalar(rgb888_pixels: &[u8], rgb1555_pixels: &mut [u8]) {
for index in 0..rgb888_pixels.len() / RGB_SIZE {
let (r, g, b) = (
@@ -2099,12 +2102,16 @@ impl Ppu {
rgb888_pixels[index * RGB_SIZE + 2],
);
let rgb1555 = Self::rgb888_to_rgb1555(r, g, b);
rgb1555_pixels[index * RGB1555_SIZE] = rgb1555[0];
rgb1555_pixels[index * RGB1555_SIZE + 1] = rgb1555[1];
copy_fast(
&rgb1555,
&mut rgb1555_pixels[index * RGB1555_SIZE..index * RGB1555_SIZE + 1],
RGB565_SIZE,
)
}
}
/// Converts an array of RGB888 pixels to RGB1555 format using SIMD.
///
/// This method is only available when the `simd` feature is enabled.
///
/// Note: The length of `rgb888_pixels` must be a multiple of 3, and
@@ -2215,8 +2222,11 @@ impl Ppu {
);
let rgb1555 = Self::rgb888_to_rgb1555(r, g, b);
let output_offset = offset_rgb1555 + i * RGB565_SIZE;
rgb1555_pixels[output_offset] = rgb1555[0];
rgb1555_pixels[output_offset + 1] = rgb1555[1];
copy_fast(
&rgb1555,
&mut rgb1555_pixels[output_offset..output_offset + 1],
RGB565_SIZE,
);
}
}
}
Loading