dethrace-labs / dethrace

Reverse engineering the 1997 game "Carmageddon"
https://twitter.com/dethrace_labs
GNU General Public License v3.0
859 stars 44 forks source link

glGetUniformLocation(program, "u_material_index_range") fails #304

Closed madebr closed 1 year ago

madebr commented 1 year ago

dethrace of current master fails with the following message:

[PANIC] GetValidatedUniformLocation glGetUniformLocation(4, u_material_index_range) failed. Check the shader uniform names.

I think what's happening is that the opengl shader compiler optimizes away unused uniforms. Looking at the fragment shader, u_material_index_range is practically unused. https://github.com/dethrace-labs/dethrace/blob/6c0b26cc8d72c21d4152adee3328aa88a3c95363/src/harness/resources/3d_frag.glsl#L46

Reading this StackOverflow answer, it looks like this optimization is spec compliant.

Because it's unused anyway, I locally commented out https://github.com/dethrace-labs/dethrace/blob/6c0b26cc8d72c21d4152adee3328aa88a3c95363/src/harness/renderers/gl/gl_renderer.c#L162 and https://github.com/dethrace-labs/dethrace/blob/6c0b26cc8d72c21d4152adee3328aa88a3c95363/src/harness/renderers/gl/gl_renderer.c#L549

Gerwin2k commented 1 year ago

I have the same fatal error. Since smudge commit #1a0301b of april 14 2023. Hardware of 2013, Radeon 7xxx. Windows 7 x64 or Windows XP x86 same thing.