commit 40d907db11f502912f9d42c2b25233019d8a9168
parent cfee95ade0a1df3440b1f51b6e36248a22c8210a
Author: anon <anon@example.com>
Date: Thu, 15 Oct 2026 14:59:20 +0000
Support source-color native framebuffer blending
Diffstat:
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/decompiled/runtime/gl_renderer.c b/decompiled/runtime/gl_renderer.c
@@ -426,6 +426,7 @@ static GLenum blend_factor(uint32_t factor)
switch (factor) {
case 1: return GL_ZERO;
case 2: return GL_ONE;
+ case 3: return GL_SRC_COLOR;
case 5: return GL_SRC_ALPHA;
case 6: return GL_ONE_MINUS_SRC_ALPHA;
default: abort();
diff --git a/decompiled/runtime/linux_graphics.c b/decompiled/runtime/linux_graphics.c
@@ -401,7 +401,7 @@ static void describe_device(uint32_t record)
MEM32(record + 64) = 0x10; /* Triangle culling: NONE */
MEM32(record + 68) = 0x10; /* Triangle rasterization: ZTEST */
MEM32(record + 72) = 8; /* Depth comparison: LESSEQUAL */
- MEM32(record + 76) = MEM32(record + 80) = 0x33; /* ZERO, ONE, SRCALPHA, INVSRCALPHA. */
+ MEM32(record + 76) = MEM32(record + 80) = 0x37; /* ZERO, ONE, SRCCOLOR, SRCALPHA, INVSRCALPHA. */
MEM32(record + 88) = 8; /* Gouraud RGB interpolation */
MEM32(record + 92) = 0x45; /* Perspective, alpha, normalized repeat range. */
MEM32(record + 96) = 0x03010317; /* Point/linear filtering with nearest mip selection. */
@@ -1648,8 +1648,8 @@ static void device_set_state(void)
else if (state == 139) device->ambient = value;
else if (state == 140 && (value == 0 || value == 3)) device->fog_vertex_mode = value;
else if (state == 143 && value <= 1) device->normalize_normals = value;
- else if (state == 19 && (value == 1 || value == 2 || value == 5 || value == 6)) device->source_blend = value;
- else if (state == 20 && (value == 1 || value == 2 || value == 5 || value == 6)) device->destination_blend = value;
+ else if (state == 19 && (value == 1 || value == 2 || value == 3 || value == 5 || value == 6)) device->source_blend = value;
+ else if (state == 20 && (value == 1 || value == 2 || value == 3 || value == 5 || value == 6)) device->destination_blend = value;
else if (value != device_state(device, state)) {
fprintf(stderr, "Unsupported Direct3D render state %u value=%08x\n", state, value); exit(3);
}
diff --git a/decompiled/tests/devices.c b/decompiled/tests/devices.c
@@ -159,9 +159,9 @@ static void textured_triangles(uint32_t draw, uint32_t device, uint32_t target,
assert(invoke(texture, 2, 1) == 2);
assert(invoke(texture, 2, 1) == 1);
- const uint32_t blends[][3] = {{0, 2, 1}, {1, 5, 6}, {1, 6, 5}, {1, 1, 2}, {1, 2, 1}};
+ const uint32_t blends[][3] = {{0, 2, 1}, {1, 5, 6}, {1, 6, 5}, {1, 1, 2}, {1, 2, 1}, {1, 2, 3}, {1, 3, 1}};
for (unsigned legacy = 0; legacy <= 5; ++legacy)
- for (unsigned scenario = 0; scenario < (legacy < 2 ? 40 : 4); ++scenario) {
+ for (unsigned scenario = 0; scenario < (legacy < 2 ? 56 : 4); ++scenario) {
uint32_t filter = scenario & 1 ? 2 : 1, address = scenario & 2 ? 3 : 1;
float span = scenario & 4 ? 16.25f : 1.75f;
struct vertex { float x, y, z, rhw; uint32_t color; float u, v; } vertices[] = {
diff --git a/tools/reconstruction/test_portable_devices.py b/tools/reconstruction/test_portable_devices.py
@@ -25,8 +25,8 @@ actual = subprocess.check_output(wsl + ["env", "GALLIUM_DRIVER=d3d12", linux_wor
assert actual == expected, (expected, actual)
windows_pixels = (work / "reference.rgb").read_bytes()
linux_pixels = (work / "native.rgb").read_bytes()
-assert len(windows_pixels) == len(linux_pixels) == 2316288
+assert len(windows_pixels) == len(linux_pixels) == 2709504
error = max(abs(a - b) for a, b in zip(windows_pixels, linux_pixels))
assert error <= 1, error
print("Windows == Linux: " + actual.strip())
-print("All 772096 pixels agree within one 8-bit channel step; maximum error:", error)
+print("All 903168 pixels agree within one 8-bit channel step; maximum error:", error)