diff --git a/GL/flush.c b/GL/flush.c index e07c3a1..b6393a2 100644 --- a/GL/flush.c +++ b/GL/flush.c @@ -103,6 +103,9 @@ void APIENTRY glKosShutdown() { aligned_vector_clear(&OP_LIST.vector); aligned_vector_clear(&PT_LIST.vector); aligned_vector_clear(&TR_LIST.vector); + + ShutdownGPU(); + _initialized = false; } void APIENTRY glKosInit() { diff --git a/GL/platforms/sh4.c b/GL/platforms/sh4.c index 179f22d..21f5bde 100644 --- a/GL/platforms/sh4.c +++ b/GL/platforms/sh4.c @@ -53,6 +53,10 @@ void InitGPU(_Bool autosort, _Bool fsaa) { #endif } +void ShutdownGPU() { + pvr_shutdown(); +} + GL_FORCE_INLINE float _glFastInvert(float x) { return (1.0f / __builtin_sqrtf(x * x)); } diff --git a/GL/platforms/sh4.h b/GL/platforms/sh4.h index c91b34c..306db8a 100644 --- a/GL/platforms/sh4.h +++ b/GL/platforms/sh4.h @@ -160,6 +160,8 @@ GL_FORCE_INLINE void TransformVertex(float x, float y, float z, float w, float* void InitGPU(_Bool autosort, _Bool fsaa); +void ShutdownGPU(); + static inline size_t GPUMemoryAvailable() { return pvr_mem_available(); } diff --git a/GL/platforms/software.c b/GL/platforms/software.c index 57940b6..99943cb 100644 --- a/GL/platforms/software.c +++ b/GL/platforms/software.c @@ -54,6 +54,22 @@ void InitGPU(_Bool autosort, _Bool fsaa) { aligned_vector_init(&vbuffer, sizeof(SDL_Vertex)); } +void ShutdownGPU() { + aligned_vector_clear(&vbuffer); + + if (RENDERER) { + SDL_DestroyRenderer(RENDERER); + RENDERER = NULL; + } + + if (WINDOW) { + SDL_DestroyWindow(WINDOW); + WINDOW = NULL; + } + + SDL_Quit(); +} + void SceneBegin() { SDL_SetRenderDrawColor(RENDERER, BACKGROUND_COLOR[0], BACKGROUND_COLOR[1], BACKGROUND_COLOR[2], 0); SDL_RenderClear(RENDERER); diff --git a/GL/platforms/software.h b/GL/platforms/software.h index 08cf4ed..e407e9d 100644 --- a/GL/platforms/software.h +++ b/GL/platforms/software.h @@ -54,6 +54,7 @@ static inline void TransformNormalNoMod(const float* xIn, float* xOut) { void TransformVertex(float x, float y, float z, float w, float* oxyz, float* ow); void InitGPU(_Bool autosort, _Bool fsaa); +void ShutdownGPU(); enum GPUPaletteFormat;