<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>性能优化 on MrOptimist</title><link>https://mr0ptimist.github.io/tags/%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/</link><description>Recent content in 性能优化 on MrOptimist</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Wed, 22 Apr 2026 10:00:00 +0800</lastBuildDate><atom:link href="https://mr0ptimist.github.io/tags/%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/index.xml" rel="self" type="application/rss+xml"/><item><title>纹理压缩格式详解：ASTC、BC、ETC 与 PVRTC</title><link>https://mr0ptimist.github.io/posts/%E7%BA%B9%E7%90%86%E5%8E%8B%E7%BC%A9%E6%A0%BC%E5%BC%8F%E8%AF%A6%E8%A7%A3_astc_bc_etc_pvrtc/</link><pubDate>Wed, 22 Apr 2026 10:00:00 +0800</pubDate><guid>https://mr0ptimist.github.io/posts/%E7%BA%B9%E7%90%86%E5%8E%8B%E7%BC%A9%E6%A0%BC%E5%BC%8F%E8%AF%A6%E8%A7%A3_astc_bc_etc_pvrtc/</guid><description>&lt;h2 id="概述"&gt;概述&lt;/h2&gt;
&lt;p&gt;纹理压缩（Texture Compression）是实时渲染中降低显存占用和带宽消耗的核心技术。与通用图像压缩（如 PNG、JPEG）不同，硬件纹理压缩格式支持&lt;strong&gt;随机访问&lt;/strong&gt;——GPU 无需解压整幅图像即可直接读取单个 texel，这对纹理缓存和着色器采样至关重要。&lt;/p&gt;
&lt;p&gt;本文系统梳理主流硬件纹理压缩格式的技术细节、适用场景及硬件支持情况，所有关键数据均来自官方文档与公开规范。&lt;/p&gt;
&lt;h2 id="bc-系列block-compression"&gt;BC 系列（Block Compression）&lt;/h2&gt;
&lt;p&gt;BC 系列是 DirectX 生态中最主流的压缩格式，由 S3TC（DXT）发展而来，后续经 RGTC、BPTC 扩展为今日形态。所有 BC 格式均以固定 &lt;strong&gt;4×4 texel 块&lt;/strong&gt;为单位进行编码。&lt;/p&gt;
&lt;h3 id="bc1原-dxt1--s3tc"&gt;BC1（原 DXT1 / S3TC）&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;数据量&lt;/strong&gt;：64 bits / 4×4 block（&lt;strong&gt;4 bpp&lt;/strong&gt;）&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;结构&lt;/strong&gt;：两个 16-bit RGB565 端点色 + 16 个 2-bit 索引&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;色板&lt;/strong&gt;：4 色（两个端点 + 两个插值色）&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alpha&lt;/strong&gt;：无独立 alpha，仅支持 1-bit &amp;ldquo;镂空&amp;rdquo;（punch-through）透明&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;支持通道&lt;/strong&gt;：RGB（无独立 Alpha）&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;典型用途&lt;/strong&gt;：不透明漫反射贴图、简单遮罩&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;据 &lt;a href="https://registry.khronos.org/DataFormat/specs/1.3/dataformat.1.3.html"&gt;Khronos Data Format Specification&lt;/a&gt; 描述，BC1 的 1-bit alpha 行为由两个端点值的相对大小决定：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;color0 &amp;gt; color1&lt;/code&gt;（按无符号整数比较）&lt;/strong&gt;：4 色不透明模式，&lt;code&gt;00/01/10/11&lt;/code&gt; 均为插值颜色，无透明&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;color0 &amp;lt;= color1&lt;/code&gt;&lt;/strong&gt;：&lt;strong&gt;3 色 + 透明模式&lt;/strong&gt;，&lt;code&gt;11&lt;/code&gt; 表示完全透明像素（alpha = 0）&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="实际使用方式"&gt;实际使用方式&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;编码端&lt;/strong&gt;：向压缩器提供带 Alpha 的源图（如 PNG with 1-bit alpha），大多数 BC1 编码器（如 DirectXTex、&lt;code&gt;nvcompress&lt;/code&gt;、Compressonator）会自动判断 block 是否需要透明模式。若源图 alpha 为纯 0/255，编码器会尽量使用 &lt;code&gt;color0 &amp;lt;= color1&lt;/code&gt; 模式将 &lt;code&gt;11&lt;/code&gt; 映射为透明。&lt;/p&gt;</description></item></channel></rss>