From 62b058c9fbfde2918e8ced85297ec680ab7c24ee Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 19 Mar 2024 22:32:20 +0100 Subject: [PATCH] squashed stuff faster palette stuff for ogl. no number for samplerate. smaller possible sdl mixer buffer size. some inline warning fixes. also some camera interp fix on level load. bigger console buffer for very high resolutons etc. --- src/console.c | 2 +- src/dehacked.c | 2 +- src/hardware/r_opengl/ogl_win.c | 18 ++++++------------ src/p_maputl.h | 4 ++-- src/p_setup.c | 11 +++++++++-- src/r_main.h | 3 +-- src/s_sound.c | 2 +- src/sdl/mixer_sound.c | 11 ++++++----- src/sdl/ogl_sdl.c | 13 +++++-------- 9 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/console.c b/src/console.c index 1327e561f..02116b009 100644 --- a/src/console.c +++ b/src/console.c @@ -112,7 +112,7 @@ static void CONS_backcolor_Change(void); #ifdef macintosh #define CON_BUFFERSIZE 4096 // my compiler can't handle local vars >32k #else -#define CON_BUFFERSIZE 16384 +#define CON_BUFFERSIZE 32768 #endif static char con_buffer[CON_BUFFERSIZE]; diff --git a/src/dehacked.c b/src/dehacked.c index c42b191a4..8c1ba8e4d 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8628,7 +8628,7 @@ static int lib_dummysuper(lua_State *L) return luaL_error(L, "Can't call super() outside of hardcode-replacing A_Action functions being called by state changes!"); // convoluted, I know. @_@;; } -static inline int lib_getenum(lua_State *L) +FUNCINLINE static ATTRINLINE int lib_getenum(lua_State *L) { const int UV_MATHLIB = lua_upvalueindex(1); const int GLIB_PROXY = lua_upvalueindex(2); diff --git a/src/hardware/r_opengl/ogl_win.c b/src/hardware/r_opengl/ogl_win.c index 095f2e230..f151d2f78 100644 --- a/src/hardware/r_opengl/ogl_win.c +++ b/src/hardware/r_opengl/ogl_win.c @@ -556,18 +556,12 @@ EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl) // -----------------+ EXPORT void HWRAPI(SetPalette) (RGBA_t *pal) { - INT32 i; - - for (i = 0; i < 256; i++) - { - myPaletteData[i].s.red = pal[i].s.red; - myPaletteData[i].s.green = pal[i].s.green; - myPaletteData[i].s.blue = pal[i].s.blue; - myPaletteData[i].s.alpha = pal[i].s.alpha; - } - + size_t palsize = (sizeof(RGBA_t) * 256); // on a palette change, you have to reload all of the textures - Flush(); + if (memcmp(&myPaletteData, pal, palsize)) + { + memcpy(&myPaletteData, pal, palsize); + Flush(); + } } - #endif diff --git a/src/p_maputl.h b/src/p_maputl.h index ec4a4aa33..d2337d007 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -44,11 +44,11 @@ boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, #define P_AproxDistance(dx, dy) FixedHypot(dx, dy) void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result); -INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); +INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line); void P_MakeDivline(line_t *li, divline_t *dl); void P_CameraLineOpening(line_t *plinedef); fixed_t P_InterceptVector(divline_t *v2, divline_t *v1); -INT32 P_BoxOnLineSide(fixed_t *tmbox, line_t *ld); +INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld); void P_UnsetPrecipThingPosition(precipmobj_t *thing); void P_SetPrecipitationThingPosition(precipmobj_t *thing); void P_CreatePrecipSecNodeList(precipmobj_t *thing, fixed_t x,fixed_t y); diff --git a/src/p_setup.c b/src/p_setup.c index cd5e68472..fa6bcc0a7 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -382,7 +382,7 @@ UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) * \sa ML_VERTEXES */ -static inline void P_LoadRawVertexes(UINT8 *data, size_t i) +FUNCINLINE static ATTRINLINE void P_LoadRawVertexes(UINT8 *data, size_t i) { mapvertex_t *ml; vertex_t *li; @@ -506,7 +506,7 @@ static void P_LoadSegs(lumpnum_t lumpnum) * \param lump Lump number of the SSECTORS resource. * \sa ::ML_SSECTORS */ -static inline void P_LoadRawSubsectors(void *data, size_t i) +FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data, size_t i) { mapsubsector_t *ms; subsector_t *ss; @@ -3308,6 +3308,13 @@ boolean P_SetupLevel(boolean skipprecip) LUAh_MapLoad(); } + if (rendermode != render_none) + { + R_ResetViewInterpolation(0); + R_ResetViewInterpolation(0); + R_UpdateMobjInterpolators(); + } + G_AddMapToBuffer(gamemap-1); return true; diff --git a/src/r_main.h b/src/r_main.h index c8c3f4e8c..2ac784f87 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -82,7 +82,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph); // Performance stats - extern precise_t ps_prevframetime;// time when previous frame was rendered extern ps_metric_t ps_rendercalltime; extern ps_metric_t ps_otherrendertime; @@ -113,7 +112,7 @@ extern consvar_t cv_flipcam, cv_flipcam2, cv_flipcam3, cv_flipcam4; extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_ffloorclip, cv_spriteclip; extern consvar_t cv_translucency; -extern consvar_t /*cv_precipdensity,*/ cv_drawdist, /*cv_drawdist_nights,*/ cv_drawdist_precip, cv_lessprecip; +extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip; extern consvar_t cv_fov; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; diff --git a/src/s_sound.c b/src/s_sound.c index 06a454bdf..5fec5510d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -65,7 +65,7 @@ static void AmigaType_OnChange(void); consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? -static CV_PossibleValue_t audbuffersize_cons_t[] = {{1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}}; +static CV_PossibleValue_t audbuffersize_cons_t[] = {{512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}}; consvar_t cv_audbuffersize = {"buffersize", "2048", CV_SAVE, audbuffersize_cons_t, BufferSize_OnChange, 0, NULL, NULL, 0, 0, NULL}; // stereo reverse diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index c3b117c91..b231f42ef 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -422,7 +422,7 @@ void *I_GetSfx(sfxinfo_t *sfx) zErr = inflate(&stream, Z_FINISH); if (zErr == Z_STREAM_END) { // Run GME on new data - if (!gme_open_data(inflatedData, inflatedLen, &emu, 44100)) + if (!gme_open_data(inflatedData, inflatedLen, &emu, SAMPLERATE)) { short *mem; UINT32 len; @@ -456,7 +456,7 @@ void *I_GetSfx(sfxinfo_t *sfx) #endif } // Try to read it as a GME sound - else if (!gme_open_data(lump, sfx->length, &emu, 44100)) + else if (!gme_open_data(lump, sfx->length, &emu, SAMPLERATE)) { short *mem; UINT32 len; @@ -1109,9 +1109,10 @@ boolean I_LoadSong(char *data, size_t len) if (zErr == Z_OK) // We're good to go { zErr = inflate(&stream, Z_FINISH); - if (zErr == Z_STREAM_END) { + if (zErr == Z_STREAM_END) + { // Run GME on new data - if (!gme_open_data(inflatedData, inflatedLen, &gme, 44100)) + if (!gme_open_data(inflatedData, inflatedLen, &gme, SAMPLERATE)) { Z_Free(inflatedData); // GME supposedly makes a copy for itself, so we don't need this lying around return true; @@ -1130,7 +1131,7 @@ boolean I_LoadSong(char *data, size_t len) return false; #endif } - else if (!gme_open_data(data, len, &gme, 44100)) + else if (!gme_open_data(data, len, &gme, SAMPLERATE)) return true; #endif diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 251c6ae0c..00e3896ed 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -207,16 +207,13 @@ void OglSdlFinishUpdate(boolean waitvbl) EXPORT void HWRAPI(OglSdlSetPalette) (RGBA_t *palette) { - INT32 i; - - for (i = 0; i < 256; i++) + size_t palsize = (sizeof(RGBA_t) * 256); + // on a palette change, you have to reload all of the textures + if (memcmp(&myPaletteData, palette, palsize)) { - myPaletteData[i].s.red = palette[i].s.red; - myPaletteData[i].s.green = palette[i].s.green; - myPaletteData[i].s.blue = palette[i].s.blue; - myPaletteData[i].s.alpha = palette[i].s.alpha; + memcpy(&myPaletteData, palette, palsize); + Flush(); } - Flush(); } #endif //HWRENDER