DescentDevelopers / Descent3

Descent 3 by Outrage Entertainment
GNU General Public License v3.0
2.88k stars 251 forks source link

Modernize Renderer #527

Closed tophyr closed 3 months ago

tophyr commented 3 months ago

Pull Request Type

Description

Modernize the Descent 3 renderer to use OpenGL 3 (GLES 3, eventually) and shaders. A major caveat here is that this is a minimal modernization of just the OpenGL calls. Performance should be at least as good, but I am not by any means promising that the renderer is now "well-designed". It just now works using non-immediate-mode and non-fixed-function concepts.

Rendering behavior should be identical! Any difference should be considered a bug, unless discussed, determined to be acceptable, and specifically called out here.

Known Issues

None

Related Issues

winterheart commented 3 months ago

On Linux I got runtime error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  invalid enum
SIGNAL 6 caught, aborting
tophyr commented 3 months ago

On Linux I got runtime error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  invalid enum
SIGNAL 6 caught, aborting

interesting. run it under a debugger and it should give you a stack trace of the failing call. some GL call is failing with INVALID_ENUM.

winterheart commented 3 months ago
Thread 1 (Thread 0x7ffff7082540 (LWP 11664) "Descent3"):
#0  CheckError () at /home/winterheart/playground/Descent3/renderer/dyna_gl.h:49
        _dglGetError = 0x7ffff19df5a0
        err = 1280
#1  0x000055555587c34c in FnPtr<unsigned char const* (unsigned int)>::operator()(unsigned int) const (this=0x5555565f7658 <dglGetString>, args#0=7939) at /home/winterheart/playground/Descent3/renderer/dyna_gl.h:75
        ret = 0x0
#2  0x0000555555870da2 in opengl_GetInformation () at /home/winterheart/playground/Descent3/renderer/HardwareOpenGL.cpp:242
No locals.
#3  0x0000555555872110 in opengl_Init (app=0x7fffffffd400, pref_state=0x555555a08160 <Render_preferred_state>) at /home/winterheart/playground/Descent3/renderer/HardwareOpenGL.cpp:588
        width = 640
        height = 480
        retval = 1
        i = 0
        windowX = 0
        windowY = 0
        __FUNCTION__ = {111 'o', 112 'p', 101 'e', 110 'n', 103 'g', 108 'l', 95 '_', 73 'I', 110 'n', 105 'i', 116 't', 0 '\000'}
#4  0x0000555555874676 in rend_Init (state=RENDERER_OPENGL, app=0x7fffffffd400, pref_state=0x555555a08160 <Render_preferred_state>) at /home/winterheart/playground/Descent3/renderer/HardwareOpenGL.cpp:1302
        retval = 0
        flags = 15360
#5  0x00005555555f3f16 in SetScreenMode (sm=2, force_res_change=false) at /home/winterheart/playground/Descent3/Descent3/game.cpp:970
        scr_width = 640
        scr_height = 480
        scr_bitdepth = 32
        old_sm = 0
        rend_width = 0
        rend_height = 0
        rs = {initted = 116 't', cur_bilinear_state = 10 '\n', cur_zbuffer_state = -103 '\231', cur_texture_type = 21845, cur_color_model = (unknown: 0xffffd1e0), cur_light_state = 32767, cur_alpha_type = -16 '\360', cur_wrap_type = (WT_CLAMP | WT_WRAP_V | unknown: 0x7ffc), cur_alpha = 1431942794, cur_color = 21845, cur_texture_quality = -16 '\360', clip_x1 = 32767, clip_x2 = 1435216648, clip_y1 = 21845, clip_y2 = -140061248, screen_width = 32767, screen_height = -311065088}
#6  0x00005555555e46e1 in Descent3 () at /home/winterheart/playground/Descent3/Descent3/descent.cpp:483
        proxyarg = 0
        type = 1
#7  0x00005555557842a7 in oeD3LnxApp::run (this=0x7fffffffd400) at /home/winterheart/playground/Descent3/Descent3/sdlmain.cpp:164
No locals.
#8  0x0000555555783720 in main (argc=5, argv=0x7fffffffd5d8) at /home/winterheart/playground/Descent3/Descent3/sdlmain.cpp:365
        d3 = {<oeLnxApplication> = {<oeApplication> = {_vptr.oeApplication = 0x555555958ea0 <vtable for oeD3LnxApp+16>, m_AppActive = true}, m_WasCreated = false, m_DeferFunc = 0x5555555e4e22 <D3DeferHandler(bool)>, static os_initialized = false, static first_time = true, m_Flags = 15360, m_X = 0, m_Y = 0, m_W = 640, m_H = 480}, shutdown = false, final_shutdown = false, old_screen_mode = 0}
        dbase = {<oeLnxAppDatabase> = {<oeAppDatabase> = {_vptr.oeAppDatabase = 0x555555958e40 <vtable for oeD3LnxDatabase+16>}, database = 0x5555567078a0}, <No data fields>}
        flags = 15360
        run_d3 = true
        __PRETTY_FUNCTION__ = {105 'i', 110 'n', 116 't', 32 ' ', 109 'm', 97 'a', 105 'i', 110 'n', 40 '(', 105 'i', 110 'n', 116 't', 44 ',', 32 ' ', 99 'c', 104 'h', 97 'a', 114 'r', 42 '*', 42 '*', 41 ')', 0 '\000'}
        defaultLogger = 0x555556698500
        rc = 0
        winArg = 2
        fsArg = 0
#9  0x00007ffff78ce330 in ?? () from /usr/lib64/libc.so.6
No symbol table info available.
#10 0x00007ffff78ce3e9 in __libc_start_main () from /usr/lib64/libc.so.6
No symbol table info available.
#11 0x0000555555579a65 in _start ()
No symbol table info available.
tophyr commented 3 months ago

Force-push to address @winterheart feedback

tophyr commented 3 months ago

Aha, interesting, the mprintf() call on that line is no-op'ed on my build for some reason. I'll force it to execute that and adjust

edit: ah, i'm not building with LOGGER=ON

tophyr commented 3 months ago

On Linux I got runtime error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  invalid enum
SIGNAL 6 caught, aborting

Fixed

winterheart commented 3 months ago

Please resolve conflicts on files and we ready to set.

tophyr commented 3 months ago

Rebased onto latest main

winterheart commented 3 months ago

Retested on Linux, no visible issues found.