统一 2D 渲染链路以消除格式分叉和热路径中转

将图片主路径收口为 RGBA5551 输入、RGB565 backbuffer 输出,并删除 USE_RGB565_BACKBUFFER 双路径。sprite/tilemap 主绘制改为直接 RGBA5551 -> RGB565,透明语义固定为 1-bit alpha test。同步收口 SDL/FB present 路径、sprite 资源加载/导出规范,以及相关测试与文档。

Constraint: 运行时图片主路径需统一到 RGBA5551,不能继续保留主要 RGBA8888 分支
Constraint: 透明仅支持 1-bit 语义,不引入 alpha blending
Rejected: 保留 USE_RGB565_BACKBUFFER 宏双路径 | 持续增加维护成本并掩盖真实主链路
Rejected: 主绘制继续走 RGBA5551 -> RGBA8888 -> RGB565 | 热路径存在不必要中转
Confidence: high
Scope-risk: moderate
Directive: 后续图片资源默认按 RGBA5551 接入;不要重新引入通用 RGBA8888 主运行时路径
Directive: 字体 atlas 目前仍属兼容输入;若继续收口,优先改成 1-bit mask 而不是新的图片分支
Tested: render_pipeline_tests;SDL Demo Release 构建;搜索确认无 USE_RGB565_BACKBUFFER 残留
Not-tested: Linux framebuffer 目标实机构建与显示验证
This commit is contained in:
2026-06-08 18:32:04 +08:00
parent 8785368913
commit 5ac61dca0e
19 changed files with 167075 additions and 166993 deletions
+166658 -166658
View File
File diff suppressed because it is too large Load Diff
@@ -271,12 +271,25 @@ namespace
return atlas_pixels;
}
static void WritePixel(std::ofstream& file, uint32_t pixel)
static uint16_t rgba8888_to_rgba5551(uint32_t c)
{
uint32_t r = (c >> 24) & 0xFFu;
uint32_t g = (c >> 16) & 0xFFu;
uint32_t b = (c >> 8) & 0xFFu;
uint32_t a = c & 0xFFu;
return static_cast<uint16_t>(
((r >> 3) << 11) |
((g >> 3) << 6) |
((b >> 3) << 1) |
(a ? 1u : 0u));
}
static void WritePixel5551(std::ofstream& file, uint16_t pixel)
{
file << "0x"
<< std::uppercase
<< std::hex
<< std::setw(8)
<< std::setw(4)
<< std::setfill('0')
<< pixel
<< std::dec
@@ -305,7 +318,7 @@ namespace
file << "{\n";
file << "\tstatic const int32_t tom_atlas_width = " << AtlasWidth << ";\n";
file << "\tstatic const int32_t tom_atlas_height = " << atlas_height << ";\n\n";
file << "\tstatic const uint32_t tom_atlas_pixels[] = {\n";
file << "\tstatic const uint16_t tom_atlas_pixels[] = {\n";
for (size_t i = 0; i < atlas_pixels.size(); i += 12)
{
@@ -313,7 +326,7 @@ namespace
const size_t end = std::min(i + 12, atlas_pixels.size());
for (size_t j = i; j < end; ++j)
{
WritePixel(file, atlas_pixels[j]);
WritePixel5551(file, rgba8888_to_rgba5551(atlas_pixels[j]));
file << ", ";
}
file << "\n";
@@ -321,7 +334,8 @@ namespace
file << "\t};\n\n";
file << "\tstatic const RenderData::Image image("
<< "tom_atlas_pixels, tom_atlas_width, tom_atlas_height, 0x00000000u);\n\n";
<< "tom_atlas_pixels, tom_atlas_width, tom_atlas_height, 0x0000, "
<< "RenderData::PixelFormat::RGBA5551);\n\n";
for (size_t i = 0; i < regions.size(); ++i)
{