commit b9a3171ba16670455695307be01179bce91f619f
parent ec64577b6247a42bf96d2d38d64bf7bddeead72e
Author: anon <anon@example.com>
Date: Fri, 16 Oct 2026 07:03:42 +0000
Render native Linux Bronto Burger with normal texture coordinates
Diffstat:
4 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/decompiled/runtime/linux_graphics.c b/decompiled/runtime/linux_graphics.c
@@ -1828,6 +1828,7 @@ static void draw_primitive(struct device_object *device, uint32_t primitive, uin
unsigned coordinate = device->stages[stage].texture_coordinate;
float input_uv[] = {0, 0, 1, 0}, transformed[4];
if (coordinate == 0x20000) memcpy(input_uv, camera, 16);
+ else if (coordinate == 0x10000) { memcpy(input_uv, normal, 12); input_uv[3] = 1; }
else if (coordinate < texture_count)
memcpy(input_uv, (const unsigned char *)input_vertex + stride - texture_count * 8 + coordinate * 8, 8);
memcpy(uv, input_uv, 8);
@@ -1860,7 +1861,7 @@ static void draw_primitive(struct device_object *device, uint32_t primitive, uin
float *uv = stage ? vertices[i].uv_second : vertices[i].uv;
unsigned coordinate = device->stages[stage].texture_coordinate;
/* Pretransformed vertices use the stage's own UV set for generation modes. */
- if (coordinate == 0x20000) coordinate = stage;
+ if (coordinate == 0x10000 || coordinate == 0x20000) coordinate = stage;
uv[0] = uv[1] = 0;
if (coordinate < texture_count)
memcpy(uv, (void *)ADDR(input + i * stride + uv_offset + coordinate * 8), 8);
@@ -1998,7 +1999,7 @@ static void device_set_texture_state(void)
struct device_object *device = find_device(MEM32(g_esp + 4));
uint32_t stage = MEM32(g_esp + 8), state = MEM32(g_esp + 12), value = MEM32(g_esp + 16);
if (stage >= 2) { fprintf(stderr, "Unsupported texture stage %u\n", stage); exit(3); }
- if (state == 11 && (value <= 1 || value == 0x20000)) device->stages[stage].texture_coordinate = value;
+ if (state == 11 && (value <= 1 || value == 0x10000 || value == 0x20000)) device->stages[stage].texture_coordinate = value;
else if (state == 16 && (value == 1 || value == 2)) device->stages[stage].mag_filter = value;
else if (state == 17 && (value == 1 || value == 2)) device->stages[stage].min_filter = value;
else if (state == 18 && (value == 1 || value == 2)) device->stages[stage].mip_filter = value;
diff --git a/decompiled/tests/devices.c b/decompiled/tests/devices.c
@@ -1101,7 +1101,7 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32
assert(!invoke(device, 20, 3, 19u, 5u));
assert(!invoke(device, 20, 3, 20u, 6u));
for (unsigned replicate = 0; replicate < 4; ++replicate)
- for (unsigned sample = 0; sample < 576; ++sample) {
+ for (unsigned sample = 0; sample < 640; ++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},
@@ -1124,7 +1124,7 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32
memcpy(memory(input + i * 32), xyz, 12);
memcpy(memory(input + i * 32 + 12), &vertices[i].color, 20);
}
- assert(!invoke(device, 20, 3, 29u, sample >= 512 ? 1u : 0u));
+ assert(!invoke(device, 20, 3, 29u, sample >= 512 && sample < 576 ? 1u : 0u));
if (sample >= 512) {
const uint32_t specular[] = {0x00102040, 0x80307050, 0xff602030};
for (unsigned i = 0; i < 3; ++i) {
@@ -1136,6 +1136,14 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32
assert(!invoke(device, 20, 3, 34u, 0x00406080u));
}
const uint32_t arguments[] = {0, 1, 2, 0, 3, 2, 2};
+ assert(!invoke(device, 20, 3, 143u, sample >= 576 && (sample & 8) ? 1u : 0u));
+ if (sample >= 576) for (unsigned i = 0; i < 3; ++i) {
+ const float normals[][3] = {{.25f,.5f,-1}, {.75f,.25f,-.5f}, {-.5f,.75f,.25f}};
+ float xyz[] = {vertices[i].x / 16 - 1, 1 - vertices[i].y / 16, .25f};
+ memcpy(memory(input + i * 40), xyz, 12);
+ memcpy(memory(input + i * 40 + 12), normals[i], 12);
+ memcpy(memory(input + i * 40 + 24), &vertices[i].u, 16);
+ }
unsigned first_argument = sample >= 448 ? (sample >> 2) & 3 : arguments[sample / 64];
if (replicate & 1) first_argument |= 0x20;
unsigned second_argument = sample >= 256 ? sample & 3 : sample & 16 ? 0 : 1;
@@ -1145,7 +1153,9 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32
assert(!invoke(device, 35, 3, stage, texture));
assert(!invoke(device, 34, 3, stage, workspace()) && *memory(workspace()) == texture);
if (texture) assert(invoke(texture, 2, 1) > 0);
- assert(!invoke(device, 37, 4, stage, 11u, sample >= 320 && (stage || (sample & 16)) ? 0x20000u : stage));
+ unsigned coordinate = sample >= 320 && (stage || (sample & 16)) ? (sample >= 576 ? 0x10000 : 0x20000) : stage;
+ assert(!invoke(device, 37, 4, stage, 11u, coordinate));
+ assert(!invoke(device, 36, 4, stage, 11u, workspace()) && *memory(workspace()) == coordinate);
assert(!invoke(device, 37, 4, stage, 24u, sample >= 384 ? 3u : sample >= 320 ? (sample & 4 ? 2u : 0u) : sample & 32 ? 2u : 0u));
const float matrix[] = {2,0,0,0, 0,1,0,0, .125f,.375f,1,0, 0,0,0,1};
memcpy(memory(workspace() + 1024), matrix, 64);
@@ -1173,7 +1183,7 @@ static void two_texture_stages_combine_independent_samples(uint32_t draw, uint32
*memory(workspace() + 4) = 0xcccccccc;
assert(!invoke(device, 38, 2, workspace()));
assert(*memory(workspace()) == 1 && *memory(workspace() + 4) == 0xcccccccc);
- assert(!invoke(device, 25, 6, 4u, sample >= 512 ? 0x2c4u : sample & 32 ? 0x242u : 0x244u, input, 3u, 0u));
+ assert(!invoke(device, 25, 6, 4u, sample >= 576 ? 0x212u : sample >= 512 ? 0x2c4u : sample & 32 ? 0x242u : 0x244u, input, 3u, 0u));
assert(!invoke(device, 6, 1));
*memory(desc) = 124;
diff --git a/docs/images/linux-bronto-burger-14.9.1.png b/docs/images/linux-bronto-burger-14.9.1.png
Binary files differ.
diff --git a/tools/reconstruction/test_portable_devices.py b/tools/reconstruction/test_portable_devices.py
@@ -25,9 +25,9 @@ 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) == 18634752
+assert len(windows_pixels) == len(linux_pixels) == 19421184
error = max(abs(a - b) for a, b in zip(windows_pixels, linux_pixels))
assert error <= 1, error
print("Windows == Linux: " + actual.strip())
-print("6210432 pixels agree within one 8-bit channel step; maximum error:", error)
+print("6472576 pixels agree within one 8-bit channel step; maximum error:", error)
print("1152 filtered half-byte alpha cutoffs allow either visibility result; all other pixels are compared.")