aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 073220cd7e2b75e1cf3123d5dea196caa1bf9937
parent eb7e1265ed6ea1c052c138cc10e84614ebc80c0c
Author: anon <anon@example.com>
Date:   Thu, 15 Oct 2026 15:26:31 +0000

Combine native texture color with inverse argument alpha

Diffstat:
Mdecompiled/runtime/gl_renderer.c | 1+
Mdecompiled/runtime/linux_graphics.c | 4++--
Mdecompiled/tests/devices.c | 11++++++-----
Mdecompiled/tests/graphics.c | 2+-
Mtools/reconstruction/test_portable_devices.py | 4++--
5 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/decompiled/runtime/gl_renderer.c b/decompiled/runtime/gl_renderer.c @@ -76,6 +76,7 @@ int gl_renderer_initialize(void) "vec3 c1=argument(color_arg1[s],t).rgb, c2=argument(color_arg2[s],t).rgb;" "float a1=argument(alpha_arg1[s],t).a, a2=argument(alpha_arg2[s],t).a;" "pixel.rgb=color_op[s]==4 ? c1*c2 : color_op[s]==7 ? min(vec3(1.0),c1+c2) : c1;" + "if(color_op[s]==20) pixel.rgb=min(vec3(1.0),c1+(1.0-argument(color_arg1[s],t).a)*c2);" "if(alpha_op[s]!=1) pixel.a=alpha_op[s]==3 ? a2 : alpha_op[s]==4 ? a1*a2 : a1; }\n" "void main() { pixel=color; if(textured[0]) { combine(0,texture(image0,uv));" "if(textured[1]) combine(1,texture(image1,uv_second)); }" diff --git a/decompiled/runtime/linux_graphics.c b/decompiled/runtime/linux_graphics.c @@ -418,7 +418,7 @@ static void describe_device(uint32_t record) MEM32(record + 144) = maximum; /* A 1-by-maximum texture is supported. */ MEM32(record + 148) = 1; /* No anisotropic filtering. */ MEM32(record + 176) = 2; /* Two texture-coordinate sets. */ - MEM32(record + 180) = 0x4b; /* Disable, select argument 1, modulate and add. */ + MEM32(record + 180) = 0x8004b; /* Disable, select argument 1, modulate, add, inverse-alpha add. */ MEM16(record + 184) = MEM16(record + 186) = 2; /* HAL denotes rasterization without hardware transform-and-lighting. * Lighting, W buffering and other unimplemented features stay zero. */ @@ -1973,7 +1973,7 @@ static void device_set_texture_state(void) if (device->stages[stage].address_v != value) device->stages[stage].sampler_v = value; device->stages[stage].address_v = value; } - else if (state == 1 && (value == 1 || value == 2 || value == 4 || value == 7)) device->stages[stage].color_op = value; + else if (state == 1 && (value == 1 || value == 2 || value == 4 || value == 7 || value == 20)) device->stages[stage].color_op = value; else if (state == 4 && (value >= 1 && value <= 4)) device->stages[stage].alpha_op = value; /* CURRENT selects the preceding stage; DIFFUSE selects vertex color. */ else if (state == 2 && value <= 3) device->stages[stage].color_arg1 = value; diff --git a/decompiled/tests/devices.c b/decompiled/tests/devices.c @@ -1077,7 +1077,7 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32 assert(!invoke(device, 20, 3, 27u, 1u)); assert(!invoke(device, 20, 3, 19u, 5u)); assert(!invoke(device, 20, 3, 20u, 6u)); - for (unsigned sample = 0; sample < 448; ++sample) { + for (unsigned sample = 0; sample < 512; ++sample) { struct vertex { float x, y, z, rhw; uint32_t color; float u, v, u1, v1; } vertices[] = { {0,0,.25f,1,0x4080c0a0, -.25f,.125f, .875f,-.375f}, {32,0,.25f,.5f,0x8080c0a0, 1.75f,.125f, -.125f,-.375f}, @@ -1101,6 +1101,7 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32 memcpy(memory(input + i * 32 + 12), &vertices[i].color, 20); } const uint32_t arguments[] = {0, 1, 2, 0, 3, 2, 2}; + unsigned first_argument = sample >= 448 ? (sample >> 2) & 3 : arguments[sample / 64]; for (unsigned stage = 0; stage < 2; ++stage) { uint32_t texture = sample >= 192 && sample < 256 ? 0 : textures[sample & 16 ? 0 : stage]; assert(!invoke(device, 35, 3, stage, texture)); @@ -1117,11 +1118,11 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32 assert(!invoke(device, 37, 4, stage, 12u, stage ? 3u : 1u)); assert(!invoke(device, 37, 4, stage, 13u, stage ? 3u : 1u)); assert(!invoke(device, 37, 4, stage, 14u, stage ? 3u : 1u)); - assert(!invoke(device, 37, 4, stage, 2u, arguments[sample / 64])); - assert(!invoke(device, 37, 4, stage, 5u, sample & 16 ? (arguments[sample / 64] + 1) % 4 : arguments[sample / 64])); - assert(!invoke(device, 36, 4, stage, 2u, workspace()) && *memory(workspace()) == arguments[sample / 64]); + assert(!invoke(device, 37, 4, stage, 2u, first_argument)); + assert(!invoke(device, 37, 4, stage, 5u, sample & 16 ? (first_argument + 1) % 4 : first_argument)); + assert(!invoke(device, 36, 4, stage, 2u, workspace()) && *memory(workspace()) == first_argument); const uint32_t operations[] = {4, 7, 2, 1}; - assert(!invoke(device, 37, 4, stage, 1u, stage ? operations[(sample >> 2) & 3] : 4u)); + assert(!invoke(device, 37, 4, stage, 1u, sample >= 448 && (stage || (sample & 16)) ? 20u : stage ? operations[(sample >> 2) & 3] : 4u)); assert(!invoke(device, 37, 4, stage, 4u, stage ? (sample & 3) + 1 : 4u)); assert(!invoke(device, 37, 4, stage, 3u, sample >= 256 ? sample & 3 : sample & 16 ? 0u : 1u)); assert(!invoke(device, 37, 4, stage, 6u, sample >= 256 ? 3u : sample & 16 ? 0u : 1u)); diff --git a/decompiled/tests/graphics.c b/decompiled/tests/graphics.c @@ -537,7 +537,7 @@ static int inspect_device(uint32_t description, uint32_t name, uint32_t caps, ui assert(*memory(caps + 72) == 8 && *memory(caps + 88) == 8); assert(*memory(caps + 184) == 0x00020002); /* Two textures and two blend stages. */ assert(*memory(caps + 92) == 0x45 && *memory(caps + 96) == 0x03010317); - assert(*memory(caps + 104) == 0x15 && *memory(caps + 180) == 0x4b); + assert(*memory(caps + 104) == 0x15 && *memory(caps + 180) == 0x8004b); const uint32_t hal[] = {0x84e63de0, 0x11cf46aa, 0x00006f81, 0x6e1520c0}; assert(!memcmp(memory(caps + 196), hal, 16)); #endif 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) == 5363712 +assert len(windows_pixels) == len(linux_pixels) == 5560320 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 1787904 pixels agree within one 8-bit channel step; maximum error:", error) +print("All 1853440 pixels agree within one 8-bit channel step; maximum error:", error)