fix: particle color byte masking, add reference version

Color channel packing missing & 0xFF after >> 14 extraction — upper
bits bled into adjacent channels causing broken particle fading.
Same class of bug as the alpha output fix earlier.

Added particle_sse_reference.zig (faithful recreation from commit
574f96f) as a separate compilation unit for correctness comparison.
This commit is contained in:
MarcelineVQ
2026-03-24 01:08:01 -07:00
parent 112246e687
commit 2f0e8a8bc0
4 changed files with 552 additions and 5 deletions
+4 -4
View File
@@ -364,10 +364,10 @@ export fn renderParticleSprites_SSE(emitter: u32, particle_data: u32, vertex_buf
const blue_f = @mulAdd(f32, @as(f32, @floatFromInt(ri32(color_ctx + 0x10))), t,
@as(f32, @floatFromInt(@as(i32, ru8(color_ctx + 0))))) + magic;
var color_value: u32 = @as(u32, @truncate(@as(u32, @bitCast(blue_f)) >> 14)) |
(@as(u32, @truncate(@as(u32, @bitCast(green_f)) >> 14)) << 8) |
(@as(u32, @truncate(@as(u32, @bitCast(red_f)) >> 14)) << 16) |
(@as(u32, @truncate(@as(u32, @bitCast(alpha_f)) >> 14)) << 24);
var color_value: u32 = ((@as(u32, @bitCast(blue_f)) >> 14) & 0xFF) |
(((@as(u32, @bitCast(green_f)) >> 14) & 0xFF) << 8) |
(((@as(u32, @bitCast(red_f)) >> 14) & 0xFF) << 16) |
(((@as(u32, @bitCast(alpha_f)) >> 14) & 0xFF) << 24);
// Sprite scale: t * ctx.scaleDelta + ctx.scaleBase
var sprite_scale: f32 = @mulAdd(f32, t, rf32(color_ctx + 0x28), rf32(color_ctx + 0x24));