commit 65c60893100cdb3212a5f96f000b2f942034bbff
parent 4bd578d402a78c3a5e22f91e5f438b4ab3065f90
Author: anon <anon@example.com>
Date: Thu, 15 Oct 2026 14:23:50 +0000
Render scene vertices without normals
Diffstat:
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/decompiled/runtime/linux_graphics.c b/decompiled/runtime/linux_graphics.c
@@ -1708,7 +1708,7 @@ static void draw_primitive(struct device_object *device, uint32_t primitive, uin
uint32_t input, uint32_t count, uint32_t flags,
uint32_t input_indices, uint32_t element_count)
{
- int untransformed = (fvf & ~0x40u) == 0x112;
+ int untransformed = (fvf & ~0x40u) == 0x112 || fvf == 0x142;
if ((primitive != 4 && primitive != 5) ||
((fvf & ~0x80u) != 0x44 && (fvf & ~0x80u) != 0x144 && !untransformed) || flags) {
fprintf(stderr, "Unsupported Direct3D draw primitive=%u fvf=%08x flags=%08x cull=%u\n", primitive, fvf, flags, device->cull); exit(3);
@@ -1740,7 +1740,7 @@ static void draw_primitive(struct device_object *device, uint32_t primitive, uin
}
/* Specular input is inactive while D3DRENDERSTATE_SPECULARENABLE is false. */
uint32_t uv_offset = 20 + (fvf & 0x80 ? 4 : 0), stride = uv_offset + (fvf & 0x100 ? 8 : 0);
- if (untransformed) stride = fvf & 0x40 ? 36 : 32;
+ if (untransformed) stride = 12 + (fvf & 0x10 ? 12 : 0) + (fvf & 0x40 ? 4 : 0) + 8;
for (uint32_t i = 0; i < count; ++i) {
if (untransformed) {
float input_vertex[9], position[4], camera[4], projected[4], normal[3], diffuse[4];
@@ -1755,10 +1755,10 @@ static void draw_primitive(struct device_object *device, uint32_t primitive, uin
w * (1 - (2.0f * device->viewport[1] + device->viewport[3] + 1) / height);
vertices[i].position[2] = projected[2]; vertices[i].position[3] = w;
for (unsigned j = 0; j < 3; ++j)
- normal[j] = input_vertex[3] * normal_matrix[j] + input_vertex[4] * normal_matrix[3+j] + input_vertex[5] * normal_matrix[6+j];
+ normal[j] = fvf & 0x10 ? input_vertex[3] * normal_matrix[j] + input_vertex[4] * normal_matrix[3+j] + input_vertex[5] * normal_matrix[6+j] : 0;
if (device->normalize_normals) normalize_vector(normal);
if (fvf & 0x40) {
- uint32_t color = MEM32(input + i * stride + 24);
+ uint32_t color = MEM32(input + i * stride + (fvf & 0x10 ? 24 : 12));
diffuse[0] = ((color >> 16) & 255) / 255.0f;
diffuse[1] = ((color >> 8) & 255) / 255.0f;
diffuse[2] = (color & 255) / 255.0f;
@@ -1773,7 +1773,7 @@ static void draw_primitive(struct device_object *device, uint32_t primitive, uin
memcpy(&start, &device->fog_start, 4); memcpy(&end, &device->fog_end, 4);
vertices[i].fog = fminf(1, fmaxf(0, (end - fabsf(camera[2])) / (end - start)));
}
- memcpy(vertices[i].uv, input_vertex + (fvf & 0x40 ? 7 : 6), 8);
+ memcpy(vertices[i].uv, (const unsigned char *)input_vertex + stride - 8, 8);
continue;
}
float position[4];
diff --git a/decompiled/tests/devices.c b/decompiled/tests/devices.c
@@ -486,7 +486,7 @@ static void indexed_vertex_buffers_use_relative_indices(uint32_t draw, uint32_t
static void untransformed_vertices_apply_camera_and_lighting(uint32_t device, uint32_t target, FILE *file)
{
- for (unsigned colored = 0; colored <= 1; ++colored) for (unsigned sample = 0; sample < 17; ++sample) {
+ for (unsigned colored = 0; colored <= 2; ++colored) for (unsigned sample = 0; sample < 17; ++sample) {
uint32_t input = workspace() + 512, data = workspace() + 256, desc = workspace() + 128;
float vertices[3][8] = {{-.75f,.75f,.5f,0,0,-1,0,0}, {.75f,.75f,.5f,0,0,-1,1,0}, {-.75f,-.75f,.5f,0,0,-1,0,1}};
float world[] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
@@ -525,14 +525,15 @@ static void untransformed_vertices_apply_camera_and_lighting(uint32_t device, ui
assert(!invoke(device, 20, 3, 19u, 5u));
assert(!invoke(device, 20, 3, 20u, 6u));
if (colored) for (unsigned i = 0; i < 3; ++i) {
- memcpy(memory(input + i * 36), vertices[i], 24);
- *memory(input + i * 36 + 24) = sample == 6 ? (0xff204060u + i * 0x203020u) : 0x804060a0u;
- memcpy(memory(input + i * 36 + 28), vertices[i] + 6, 8);
+ unsigned stride = colored == 1 ? 36 : 24, color_offset = colored == 1 ? 24 : 12;
+ memcpy(memory(input + i * stride), vertices[i], color_offset);
+ *memory(input + i * stride + color_offset) = sample == 6 ? (0xff204060u + i * 0x203020u) : 0x804060a0u;
+ memcpy(memory(input + i * stride + color_offset + 4), vertices[i] + 6, 8);
} else memcpy(memory(input), vertices, sizeof(vertices));
assert(!invoke(device, 10, 7, 0u, 0u, 3u, 0xff102030u, 0x3f800000u, 0u));
assert(!invoke(device, 5, 1));
- assert(!invoke(device, 25, 6, 4u, colored ? 0x152u : 0x112u, input, 3u, 0u));
+ assert(!invoke(device, 25, 6, 4u, colored == 2 ? 0x142u : colored ? 0x152u : 0x112u, input, 3u, 0u));
assert(!invoke(device, 6, 1));
*memory(desc) = 124;
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) == 1723392
+assert len(windows_pixels) == len(linux_pixels) == 1775616
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 574464 pixels agree within one 8-bit channel step; maximum error:", error)
+print("All 591872 pixels agree within one 8-bit channel step; maximum error:", error)