Merge pull request #5526 from FearlessTobi/port-4535-4548
Port yuzu-emu/yuzu#4535 and yuzu-emu/yuzu#4548: Changes to the Common namespace
This commit is contained in:
commit
d89a6d491e
7 changed files with 68 additions and 67 deletions
|
@ -315,31 +315,31 @@ void GraphicsSurfaceWidget::Pick(int x, int y) {
|
||||||
auto GetText = [offset](Format format, const u8* pixel) {
|
auto GetText = [offset](Format format, const u8* pixel) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case Format::RGBA8: {
|
case Format::RGBA8: {
|
||||||
auto value = Color::DecodeRGBA8(pixel) / 255.0f;
|
auto value = Common::Color::DecodeRGBA8(pixel) / 255.0f;
|
||||||
return QStringLiteral("Red: %1, Green: %2, Blue: %3, Alpha: %4")
|
return QStringLiteral("Red: %1, Green: %2, Blue: %3, Alpha: %4")
|
||||||
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
||||||
QString::number(value.b(), 'f', 2), QString::number(value.a(), 'f', 2));
|
QString::number(value.b(), 'f', 2), QString::number(value.a(), 'f', 2));
|
||||||
}
|
}
|
||||||
case Format::RGB8: {
|
case Format::RGB8: {
|
||||||
auto value = Color::DecodeRGB8(pixel) / 255.0f;
|
auto value = Common::Color::DecodeRGB8(pixel) / 255.0f;
|
||||||
return QStringLiteral("Red: %1, Green: %2, Blue: %3")
|
return QStringLiteral("Red: %1, Green: %2, Blue: %3")
|
||||||
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
||||||
QString::number(value.b(), 'f', 2));
|
QString::number(value.b(), 'f', 2));
|
||||||
}
|
}
|
||||||
case Format::RGB5A1: {
|
case Format::RGB5A1: {
|
||||||
auto value = Color::DecodeRGB5A1(pixel) / 255.0f;
|
auto value = Common::Color::DecodeRGB5A1(pixel) / 255.0f;
|
||||||
return QStringLiteral("Red: %1, Green: %2, Blue: %3, Alpha: %4")
|
return QStringLiteral("Red: %1, Green: %2, Blue: %3, Alpha: %4")
|
||||||
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
||||||
QString::number(value.b(), 'f', 2), QString::number(value.a(), 'f', 2));
|
QString::number(value.b(), 'f', 2), QString::number(value.a(), 'f', 2));
|
||||||
}
|
}
|
||||||
case Format::RGB565: {
|
case Format::RGB565: {
|
||||||
auto value = Color::DecodeRGB565(pixel) / 255.0f;
|
auto value = Common::Color::DecodeRGB565(pixel) / 255.0f;
|
||||||
return QStringLiteral("Red: %1, Green: %2, Blue: %3")
|
return QStringLiteral("Red: %1, Green: %2, Blue: %3")
|
||||||
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
||||||
QString::number(value.b(), 'f', 2));
|
QString::number(value.b(), 'f', 2));
|
||||||
}
|
}
|
||||||
case Format::RGBA4: {
|
case Format::RGBA4: {
|
||||||
auto value = Color::DecodeRGBA4(pixel) / 255.0f;
|
auto value = Common::Color::DecodeRGBA4(pixel) / 255.0f;
|
||||||
return QStringLiteral("Red: %1, Green: %2, Blue: %3, Alpha: %4")
|
return QStringLiteral("Red: %1, Green: %2, Blue: %3, Alpha: %4")
|
||||||
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2),
|
||||||
QString::number(value.b(), 'f', 2), QString::number(value.a(), 'f', 2));
|
QString::number(value.b(), 'f', 2), QString::number(value.a(), 'f', 2));
|
||||||
|
@ -347,7 +347,7 @@ void GraphicsSurfaceWidget::Pick(int x, int y) {
|
||||||
case Format::IA8:
|
case Format::IA8:
|
||||||
return QStringLiteral("Index: %1, Alpha: %2").arg(pixel[0], pixel[1]);
|
return QStringLiteral("Index: %1, Alpha: %2").arg(pixel[0], pixel[1]);
|
||||||
case Format::RG8: {
|
case Format::RG8: {
|
||||||
auto value = Color::DecodeRG8(pixel) / 255.0f;
|
auto value = Common::Color::DecodeRG8(pixel) / 255.0f;
|
||||||
return QStringLiteral("Red: %1, Green: %2")
|
return QStringLiteral("Red: %1, Green: %2")
|
||||||
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2));
|
.arg(QString::number(value.r(), 'f', 2), QString::number(value.g(), 'f', 2));
|
||||||
}
|
}
|
||||||
|
@ -370,17 +370,17 @@ void GraphicsSurfaceWidget::Pick(int x, int y) {
|
||||||
// TODO: Display block information or channel values?
|
// TODO: Display block information or channel values?
|
||||||
return QStringLiteral("Compressed data");
|
return QStringLiteral("Compressed data");
|
||||||
case Format::D16: {
|
case Format::D16: {
|
||||||
auto value = Color::DecodeD16(pixel);
|
auto value = Common::Color::DecodeD16(pixel);
|
||||||
return QStringLiteral("Depth: %1").arg(QString::number(value / (float)0xFFFF, 'f', 4));
|
return QStringLiteral("Depth: %1").arg(QString::number(value / (float)0xFFFF, 'f', 4));
|
||||||
}
|
}
|
||||||
case Format::D24: {
|
case Format::D24: {
|
||||||
auto value = Color::DecodeD24(pixel);
|
auto value = Common::Color::DecodeD24(pixel);
|
||||||
return QStringLiteral("Depth: %1")
|
return QStringLiteral("Depth: %1")
|
||||||
.arg(QString::number(value / (float)0xFFFFFF, 'f', 4));
|
.arg(QString::number(value / (float)0xFFFFFF, 'f', 4));
|
||||||
}
|
}
|
||||||
case Format::D24X8:
|
case Format::D24X8:
|
||||||
case Format::X24S8: {
|
case Format::X24S8: {
|
||||||
auto values = Color::DecodeD24S8(pixel);
|
auto values = Common::Color::DecodeD24S8(pixel);
|
||||||
return QStringLiteral("Depth: %1, Stencil: %2")
|
return QStringLiteral("Depth: %1, Stencil: %2")
|
||||||
.arg(QString::number(values[0] / (float)0xFFFFFF, 'f', 4), values[1]);
|
.arg(QString::number(values[0] / (float)0xFFFFFF, 'f', 4), values[1]);
|
||||||
}
|
}
|
||||||
|
@ -604,27 +604,27 @@ void GraphicsSurfaceWidget::OnUpdate() {
|
||||||
|
|
||||||
switch (surface_format) {
|
switch (surface_format) {
|
||||||
case Format::D16: {
|
case Format::D16: {
|
||||||
u32 data = Color::DecodeD16(pixel);
|
u32 data = Common::Color::DecodeD16(pixel);
|
||||||
color.r() = data & 0xFF;
|
color.r() = data & 0xFF;
|
||||||
color.g() = (data >> 8) & 0xFF;
|
color.g() = (data >> 8) & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Format::D24: {
|
case Format::D24: {
|
||||||
u32 data = Color::DecodeD24(pixel);
|
u32 data = Common::Color::DecodeD24(pixel);
|
||||||
color.r() = data & 0xFF;
|
color.r() = data & 0xFF;
|
||||||
color.g() = (data >> 8) & 0xFF;
|
color.g() = (data >> 8) & 0xFF;
|
||||||
color.b() = (data >> 16) & 0xFF;
|
color.b() = (data >> 16) & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Format::D24X8: {
|
case Format::D24X8: {
|
||||||
Common::Vec2<u32> data = Color::DecodeD24S8(pixel);
|
Common::Vec2<u32> data = Common::Color::DecodeD24S8(pixel);
|
||||||
color.r() = data.x & 0xFF;
|
color.r() = data.x & 0xFF;
|
||||||
color.g() = (data.x >> 8) & 0xFF;
|
color.g() = (data.x >> 8) & 0xFF;
|
||||||
color.b() = (data.x >> 16) & 0xFF;
|
color.b() = (data.x >> 16) & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Format::X24S8: {
|
case Format::X24S8: {
|
||||||
Common::Vec2<u32> data = Color::DecodeD24S8(pixel);
|
Common::Vec2<u32> data = Common::Color::DecodeD24S8(pixel);
|
||||||
color.r() = color.g() = color.b() = data.y;
|
color.r() = color.g() = color.b() = data.y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "common/vector_math.h"
|
#include "common/vector_math.h"
|
||||||
|
|
||||||
namespace Color {
|
namespace Common::Color {
|
||||||
|
|
||||||
/// Convert a 1-bit color component to 8 bit
|
/// Convert a 1-bit color component to 8 bit
|
||||||
[[nodiscard]] constexpr u8 Convert1To8(u8 value) {
|
[[nodiscard]] constexpr u8 Convert1To8(u8 value) {
|
||||||
|
@ -268,4 +268,4 @@ inline void EncodeX24S8(u8 stencil, u8* bytes) {
|
||||||
bytes[3] = stencil;
|
bytes[3] = stencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Color
|
} // namespace Common::Color
|
||||||
|
|
|
@ -50,19 +50,19 @@ inline void Read(T& var, const u32 raw_addr) {
|
||||||
static Common::Vec4<u8> DecodePixel(Regs::PixelFormat input_format, const u8* src_pixel) {
|
static Common::Vec4<u8> DecodePixel(Regs::PixelFormat input_format, const u8* src_pixel) {
|
||||||
switch (input_format) {
|
switch (input_format) {
|
||||||
case Regs::PixelFormat::RGBA8:
|
case Regs::PixelFormat::RGBA8:
|
||||||
return Color::DecodeRGBA8(src_pixel);
|
return Common::Color::DecodeRGBA8(src_pixel);
|
||||||
|
|
||||||
case Regs::PixelFormat::RGB8:
|
case Regs::PixelFormat::RGB8:
|
||||||
return Color::DecodeRGB8(src_pixel);
|
return Common::Color::DecodeRGB8(src_pixel);
|
||||||
|
|
||||||
case Regs::PixelFormat::RGB565:
|
case Regs::PixelFormat::RGB565:
|
||||||
return Color::DecodeRGB565(src_pixel);
|
return Common::Color::DecodeRGB565(src_pixel);
|
||||||
|
|
||||||
case Regs::PixelFormat::RGB5A1:
|
case Regs::PixelFormat::RGB5A1:
|
||||||
return Color::DecodeRGB5A1(src_pixel);
|
return Common::Color::DecodeRGB5A1(src_pixel);
|
||||||
|
|
||||||
case Regs::PixelFormat::RGBA4:
|
case Regs::PixelFormat::RGBA4:
|
||||||
return Color::DecodeRGBA4(src_pixel);
|
return Common::Color::DecodeRGBA4(src_pixel);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(HW_GPU, "Unknown source framebuffer format {:x}", input_format);
|
LOG_ERROR(HW_GPU, "Unknown source framebuffer format {:x}", input_format);
|
||||||
|
@ -274,23 +274,23 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
|
||||||
u8* dst_pixel = dst_pointer + dst_offset;
|
u8* dst_pixel = dst_pointer + dst_offset;
|
||||||
switch (config.output_format) {
|
switch (config.output_format) {
|
||||||
case Regs::PixelFormat::RGBA8:
|
case Regs::PixelFormat::RGBA8:
|
||||||
Color::EncodeRGBA8(src_color, dst_pixel);
|
Common::Color::EncodeRGBA8(src_color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Regs::PixelFormat::RGB8:
|
case Regs::PixelFormat::RGB8:
|
||||||
Color::EncodeRGB8(src_color, dst_pixel);
|
Common::Color::EncodeRGB8(src_color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Regs::PixelFormat::RGB565:
|
case Regs::PixelFormat::RGB565:
|
||||||
Color::EncodeRGB565(src_color, dst_pixel);
|
Common::Color::EncodeRGB565(src_color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Regs::PixelFormat::RGB5A1:
|
case Regs::PixelFormat::RGB5A1:
|
||||||
Color::EncodeRGB5A1(src_color, dst_pixel);
|
Common::Color::EncodeRGB5A1(src_color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Regs::PixelFormat::RGBA4:
|
case Regs::PixelFormat::RGBA4:
|
||||||
Color::EncodeRGBA4(src_color, dst_pixel);
|
Common::Color::EncodeRGBA4(src_color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -115,19 +115,19 @@ static void SendData(Memory::MemorySystem& memory, const u32* input, ConversionB
|
||||||
|
|
||||||
switch (output_format) {
|
switch (output_format) {
|
||||||
case OutputFormat::RGBA8:
|
case OutputFormat::RGBA8:
|
||||||
Color::EncodeRGBA8(col_vec, output);
|
Common::Color::EncodeRGBA8(col_vec, output);
|
||||||
output += 4;
|
output += 4;
|
||||||
break;
|
break;
|
||||||
case OutputFormat::RGB8:
|
case OutputFormat::RGB8:
|
||||||
Color::EncodeRGB8(col_vec, output);
|
Common::Color::EncodeRGB8(col_vec, output);
|
||||||
output += 3;
|
output += 3;
|
||||||
break;
|
break;
|
||||||
case OutputFormat::RGB5A1:
|
case OutputFormat::RGB5A1:
|
||||||
Color::EncodeRGB5A1(col_vec, output);
|
Common::Color::EncodeRGB5A1(col_vec, output);
|
||||||
output += 2;
|
output += 2;
|
||||||
break;
|
break;
|
||||||
case OutputFormat::RGB565:
|
case OutputFormat::RGB565:
|
||||||
Color::EncodeRGB565(col_vec, output);
|
Common::Color::EncodeRGB565(col_vec, output);
|
||||||
output += 2;
|
output += 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,23 +35,23 @@ void DrawPixel(int x, int y, const Common::Vec4<u8>& color) {
|
||||||
|
|
||||||
switch (framebuffer.color_format) {
|
switch (framebuffer.color_format) {
|
||||||
case FramebufferRegs::ColorFormat::RGBA8:
|
case FramebufferRegs::ColorFormat::RGBA8:
|
||||||
Color::EncodeRGBA8(color, dst_pixel);
|
Common::Color::EncodeRGBA8(color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGB8:
|
case FramebufferRegs::ColorFormat::RGB8:
|
||||||
Color::EncodeRGB8(color, dst_pixel);
|
Common::Color::EncodeRGB8(color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGB5A1:
|
case FramebufferRegs::ColorFormat::RGB5A1:
|
||||||
Color::EncodeRGB5A1(color, dst_pixel);
|
Common::Color::EncodeRGB5A1(color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGB565:
|
case FramebufferRegs::ColorFormat::RGB565:
|
||||||
Color::EncodeRGB565(color, dst_pixel);
|
Common::Color::EncodeRGB565(color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGBA4:
|
case FramebufferRegs::ColorFormat::RGBA4:
|
||||||
Color::EncodeRGBA4(color, dst_pixel);
|
Common::Color::EncodeRGBA4(color, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -76,19 +76,19 @@ const Common::Vec4<u8> GetPixel(int x, int y) {
|
||||||
|
|
||||||
switch (framebuffer.color_format) {
|
switch (framebuffer.color_format) {
|
||||||
case FramebufferRegs::ColorFormat::RGBA8:
|
case FramebufferRegs::ColorFormat::RGBA8:
|
||||||
return Color::DecodeRGBA8(src_pixel);
|
return Common::Color::DecodeRGBA8(src_pixel);
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGB8:
|
case FramebufferRegs::ColorFormat::RGB8:
|
||||||
return Color::DecodeRGB8(src_pixel);
|
return Common::Color::DecodeRGB8(src_pixel);
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGB5A1:
|
case FramebufferRegs::ColorFormat::RGB5A1:
|
||||||
return Color::DecodeRGB5A1(src_pixel);
|
return Common::Color::DecodeRGB5A1(src_pixel);
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGB565:
|
case FramebufferRegs::ColorFormat::RGB565:
|
||||||
return Color::DecodeRGB565(src_pixel);
|
return Common::Color::DecodeRGB565(src_pixel);
|
||||||
|
|
||||||
case FramebufferRegs::ColorFormat::RGBA4:
|
case FramebufferRegs::ColorFormat::RGBA4:
|
||||||
return Color::DecodeRGBA4(src_pixel);
|
return Common::Color::DecodeRGBA4(src_pixel);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG_CRITICAL(Render_Software, "Unknown framebuffer color format {:x}",
|
LOG_CRITICAL(Render_Software, "Unknown framebuffer color format {:x}",
|
||||||
|
@ -115,11 +115,11 @@ u32 GetDepth(int x, int y) {
|
||||||
|
|
||||||
switch (framebuffer.depth_format) {
|
switch (framebuffer.depth_format) {
|
||||||
case FramebufferRegs::DepthFormat::D16:
|
case FramebufferRegs::DepthFormat::D16:
|
||||||
return Color::DecodeD16(src_pixel);
|
return Common::Color::DecodeD16(src_pixel);
|
||||||
case FramebufferRegs::DepthFormat::D24:
|
case FramebufferRegs::DepthFormat::D24:
|
||||||
return Color::DecodeD24(src_pixel);
|
return Common::Color::DecodeD24(src_pixel);
|
||||||
case FramebufferRegs::DepthFormat::D24S8:
|
case FramebufferRegs::DepthFormat::D24S8:
|
||||||
return Color::DecodeD24S8(src_pixel).x;
|
return Common::Color::DecodeD24S8(src_pixel).x;
|
||||||
default:
|
default:
|
||||||
LOG_CRITICAL(HW_GPU, "Unimplemented depth format {}",
|
LOG_CRITICAL(HW_GPU, "Unimplemented depth format {}",
|
||||||
static_cast<u32>(framebuffer.depth_format.Value()));
|
static_cast<u32>(framebuffer.depth_format.Value()));
|
||||||
|
@ -144,7 +144,7 @@ u8 GetStencil(int x, int y) {
|
||||||
|
|
||||||
switch (framebuffer.depth_format) {
|
switch (framebuffer.depth_format) {
|
||||||
case FramebufferRegs::DepthFormat::D24S8:
|
case FramebufferRegs::DepthFormat::D24S8:
|
||||||
return Color::DecodeD24S8(src_pixel).y;
|
return Common::Color::DecodeD24S8(src_pixel).y;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG_WARNING(
|
LOG_WARNING(
|
||||||
|
@ -171,15 +171,15 @@ void SetDepth(int x, int y, u32 value) {
|
||||||
|
|
||||||
switch (framebuffer.depth_format) {
|
switch (framebuffer.depth_format) {
|
||||||
case FramebufferRegs::DepthFormat::D16:
|
case FramebufferRegs::DepthFormat::D16:
|
||||||
Color::EncodeD16(value, dst_pixel);
|
Common::Color::EncodeD16(value, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FramebufferRegs::DepthFormat::D24:
|
case FramebufferRegs::DepthFormat::D24:
|
||||||
Color::EncodeD24(value, dst_pixel);
|
Common::Color::EncodeD24(value, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FramebufferRegs::DepthFormat::D24S8:
|
case FramebufferRegs::DepthFormat::D24S8:
|
||||||
Color::EncodeD24X8(value, dst_pixel);
|
Common::Color::EncodeD24X8(value, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -211,7 +211,7 @@ void SetStencil(int x, int y, u8 value) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Pica::FramebufferRegs::DepthFormat::D24S8:
|
case Pica::FramebufferRegs::DepthFormat::D24S8:
|
||||||
Color::EncodeX24S8(value, dst_pixel);
|
Common::Color::EncodeX24S8(value, dst_pixel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -86,18 +86,18 @@ union ETC1Tile {
|
||||||
ret.g() += static_cast<int>(differential.dg);
|
ret.g() += static_cast<int>(differential.dg);
|
||||||
ret.b() += static_cast<int>(differential.db);
|
ret.b() += static_cast<int>(differential.db);
|
||||||
}
|
}
|
||||||
ret.r() = Color::Convert5To8(ret.r());
|
ret.r() = Common::Color::Convert5To8(ret.r());
|
||||||
ret.g() = Color::Convert5To8(ret.g());
|
ret.g() = Common::Color::Convert5To8(ret.g());
|
||||||
ret.b() = Color::Convert5To8(ret.b());
|
ret.b() = Common::Color::Convert5To8(ret.b());
|
||||||
} else {
|
} else {
|
||||||
if (x < 2) {
|
if (x < 2) {
|
||||||
ret.r() = Color::Convert4To8(static_cast<u8>(separate.r1));
|
ret.r() = Common::Color::Convert4To8(static_cast<u8>(separate.r1));
|
||||||
ret.g() = Color::Convert4To8(static_cast<u8>(separate.g1));
|
ret.g() = Common::Color::Convert4To8(static_cast<u8>(separate.g1));
|
||||||
ret.b() = Color::Convert4To8(static_cast<u8>(separate.b1));
|
ret.b() = Common::Color::Convert4To8(static_cast<u8>(separate.b1));
|
||||||
} else {
|
} else {
|
||||||
ret.r() = Color::Convert4To8(static_cast<u8>(separate.r2));
|
ret.r() = Common::Color::Convert4To8(static_cast<u8>(separate.r2));
|
||||||
ret.g() = Color::Convert4To8(static_cast<u8>(separate.g2));
|
ret.g() = Common::Color::Convert4To8(static_cast<u8>(separate.g2));
|
||||||
ret.b() = Color::Convert4To8(static_cast<u8>(separate.b2));
|
ret.b() = Common::Color::Convert4To8(static_cast<u8>(separate.b2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,27 +80,27 @@ Common::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned in
|
||||||
|
|
||||||
switch (info.format) {
|
switch (info.format) {
|
||||||
case TextureFormat::RGBA8: {
|
case TextureFormat::RGBA8: {
|
||||||
auto res = Color::DecodeRGBA8(source + MortonInterleave(x, y) * 4);
|
auto res = Common::Color::DecodeRGBA8(source + MortonInterleave(x, y) * 4);
|
||||||
return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())};
|
return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())};
|
||||||
}
|
}
|
||||||
|
|
||||||
case TextureFormat::RGB8: {
|
case TextureFormat::RGB8: {
|
||||||
auto res = Color::DecodeRGB8(source + MortonInterleave(x, y) * 3);
|
auto res = Common::Color::DecodeRGB8(source + MortonInterleave(x, y) * 3);
|
||||||
return {res.r(), res.g(), res.b(), 255};
|
return {res.r(), res.g(), res.b(), 255};
|
||||||
}
|
}
|
||||||
|
|
||||||
case TextureFormat::RGB5A1: {
|
case TextureFormat::RGB5A1: {
|
||||||
auto res = Color::DecodeRGB5A1(source + MortonInterleave(x, y) * 2);
|
auto res = Common::Color::DecodeRGB5A1(source + MortonInterleave(x, y) * 2);
|
||||||
return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())};
|
return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())};
|
||||||
}
|
}
|
||||||
|
|
||||||
case TextureFormat::RGB565: {
|
case TextureFormat::RGB565: {
|
||||||
auto res = Color::DecodeRGB565(source + MortonInterleave(x, y) * 2);
|
auto res = Common::Color::DecodeRGB565(source + MortonInterleave(x, y) * 2);
|
||||||
return {res.r(), res.g(), res.b(), 255};
|
return {res.r(), res.g(), res.b(), 255};
|
||||||
}
|
}
|
||||||
|
|
||||||
case TextureFormat::RGBA4: {
|
case TextureFormat::RGBA4: {
|
||||||
auto res = Color::DecodeRGBA4(source + MortonInterleave(x, y) * 2);
|
auto res = Common::Color::DecodeRGBA4(source + MortonInterleave(x, y) * 2);
|
||||||
return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())};
|
return {res.r(), res.g(), res.b(), static_cast<u8>(disable_alpha ? 255 : res.a())};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ Common::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned in
|
||||||
}
|
}
|
||||||
|
|
||||||
case TextureFormat::RG8: {
|
case TextureFormat::RG8: {
|
||||||
auto res = Color::DecodeRG8(source + MortonInterleave(x, y) * 2);
|
auto res = Common::Color::DecodeRG8(source + MortonInterleave(x, y) * 2);
|
||||||
return {res.r(), res.g(), 0, 255};
|
return {res.r(), res.g(), 0, 255};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +138,8 @@ Common::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned in
|
||||||
case TextureFormat::IA4: {
|
case TextureFormat::IA4: {
|
||||||
const u8* source_ptr = source + MortonInterleave(x, y);
|
const u8* source_ptr = source + MortonInterleave(x, y);
|
||||||
|
|
||||||
u8 i = Color::Convert4To8(((*source_ptr) & 0xF0) >> 4);
|
u8 i = Common::Color::Convert4To8(((*source_ptr) & 0xF0) >> 4);
|
||||||
u8 a = Color::Convert4To8((*source_ptr) & 0xF);
|
u8 a = Common::Color::Convert4To8((*source_ptr) & 0xF);
|
||||||
|
|
||||||
if (disable_alpha) {
|
if (disable_alpha) {
|
||||||
// Show intensity as red, alpha as green
|
// Show intensity as red, alpha as green
|
||||||
|
@ -154,7 +154,7 @@ Common::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned in
|
||||||
const u8* source_ptr = source + morton_offset / 2;
|
const u8* source_ptr = source + morton_offset / 2;
|
||||||
|
|
||||||
u8 i = (morton_offset % 2) ? ((*source_ptr & 0xF0) >> 4) : (*source_ptr & 0xF);
|
u8 i = (morton_offset % 2) ? ((*source_ptr & 0xF0) >> 4) : (*source_ptr & 0xF);
|
||||||
i = Color::Convert4To8(i);
|
i = Common::Color::Convert4To8(i);
|
||||||
|
|
||||||
return {i, i, i, 255};
|
return {i, i, i, 255};
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ Common::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned in
|
||||||
const u8* source_ptr = source + morton_offset / 2;
|
const u8* source_ptr = source + morton_offset / 2;
|
||||||
|
|
||||||
u8 a = (morton_offset % 2) ? ((*source_ptr & 0xF0) >> 4) : (*source_ptr & 0xF);
|
u8 a = (morton_offset % 2) ? ((*source_ptr & 0xF0) >> 4) : (*source_ptr & 0xF);
|
||||||
a = Color::Convert4To8(a);
|
a = Common::Color::Convert4To8(a);
|
||||||
|
|
||||||
if (disable_alpha) {
|
if (disable_alpha) {
|
||||||
return {a, a, a, 255};
|
return {a, a, a, 255};
|
||||||
|
@ -194,7 +194,8 @@ Common::Vec4<u8> LookupTexelInTile(const u8* source, unsigned int x, unsigned in
|
||||||
memcpy(&packed_alpha, subtile_ptr, sizeof(u64));
|
memcpy(&packed_alpha, subtile_ptr, sizeof(u64));
|
||||||
subtile_ptr += sizeof(u64);
|
subtile_ptr += sizeof(u64);
|
||||||
|
|
||||||
alpha = Color::Convert4To8((packed_alpha >> (4 * (x * subtile_width + y))) & 0xF);
|
alpha =
|
||||||
|
Common::Color::Convert4To8((packed_alpha >> (4 * (x * subtile_width + y))) & 0xF);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64_le subtile_data;
|
u64_le subtile_data;
|
||||||
|
|
Loading…
Reference in a new issue