Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous optimizations #1468

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- fixed `/give` console command confusing logging around mismatched items (#1463, regression from 3.0)
- fixed `/flip` console command misreporting an already enabled flipmap as off (regression from 4.0)
- fixed console commands causing improper ring shutdown with selected inventory item (#1460, regression from 3.0)
- improved level load times
- improved logs module names readability
- improved crash debug information on Windows

Expand Down
12 changes: 12 additions & 0 deletions src/game/gamebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ void GameBuf_Init(void)
m_GameAllocMemFree = MALLOC_SIZE;
}

void GameBuf_Reset(void)
{
if (m_GameMemoryPointer == NULL) {
m_GameAllocMemPointer = NULL;
m_GameAllocMemFree = 0;
return;
}

m_GameAllocMemPointer = m_GameMemoryPointer;
m_GameAllocMemFree = MALLOC_SIZE;
}

void GameBuf_Shutdown(void)
{
Memory_FreePointer(&m_GameMemoryPointer);
Expand Down
1 change: 1 addition & 0 deletions src/game/gamebuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ typedef enum GAME_BUFFER {
} GAME_BUFFER;

void GameBuf_Init(void);
void GameBuf_Reset(void);
void *GameBuf_Alloc(int32_t alloc_size, GAME_BUFFER buffer);
void GameBuf_Shutdown(void);
3 changes: 1 addition & 2 deletions src/game/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ static size_t Level_CalculateMaxVertices(void);
static void Level_LoadFromFile(
const char *filename, int32_t level_num, bool is_demo)
{
GameBuf_Shutdown();
GameBuf_Init();
GameBuf_Reset();

MYFILE *fp = File_Open(filename, FILE_OPEN_READ);
if (!fp) {
Expand Down
1 change: 1 addition & 0 deletions src/game/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ void Shell_Init(const char *gameflow_path)
return;
}

GameBuf_Init();
Text_Init();
Clock_Init();
Sound_Init();
Expand Down
12 changes: 6 additions & 6 deletions src/specific/s_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,6 @@ void S_Output_DrawShadow(PHD_VBUF *vbufs, int clip, int vertex_count)

void S_Output_ApplyRenderSettings(void)
{
S_Output_ReleaseSurfaces();

m_SurfaceWidth = Screen_GetResWidth();
m_SurfaceHeight = Screen_GetResHeight();
m_SurfaceMinX = 0.0f;
Expand All @@ -876,19 +874,21 @@ void S_Output_ApplyRenderSettings(void)
GFX_Context_SetDisplaySize(m_SurfaceWidth, m_SurfaceHeight);
GFX_Context_SetRenderingMode(g_Config.rendering.render_mode);

{
if (m_PrimarySurface == NULL) {
GFX_2D_SurfaceDesc surface_desc = { 0 };
m_PrimarySurface = GFX_2D_Surface_Create(&surface_desc);

S_Output_ClearSurface(m_PrimarySurface);
}

S_Output_ClearSurface(m_PrimarySurface);

for (int i = 0; i < GFX_MAX_TEXTURES; i++) {
GFX_2D_SurfaceDesc surface_desc = {
.width = 256,
.height = 256,
};
m_TextureSurfaces[i] = GFX_2D_Surface_Create(&surface_desc);
if (m_TextureSurfaces[i] == NULL) {
m_TextureSurfaces[i] = GFX_2D_Surface_Create(&surface_desc);
}
}
}

Expand Down
Loading