Optimize PSP slightly
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
set(CMAKE_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
||||||
set(CMAKE_RANLIB "$ENV{PSPDEV}/bin/psp-ranlib" CACHE FILEPATH "" FORCE)
|
set(CMAKE_RANLIB "$ENV{PSPDEV}/bin/psp-ranlib" CACHE FILEPATH "" FORCE)
|
||||||
set(CMAKE_C_COMPILER_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
set(CMAKE_C_COMPILER_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
||||||
@@ -58,12 +62,6 @@ target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
|||||||
DUSK_DISPLAY_OVERSCAN=6
|
DUSK_DISPLAY_OVERSCAN=6
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_ASSERTIONS_FAKED
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Postbuild, create .pbp file for PSP.
|
# Postbuild, create .pbp file for PSP.
|
||||||
create_pbp_file(
|
create_pbp_file(
|
||||||
TARGET "${DUSK_BINARY_TARGET_NAME}"
|
TARGET "${DUSK_BINARY_TARGET_NAME}"
|
||||||
|
|||||||
@@ -8,6 +8,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "dusk.h"
|
#include "dusk.h"
|
||||||
|
|
||||||
|
// Release-style CMake configs (Release, RelWithDebInfo, MinSizeRel) define
|
||||||
|
// NDEBUG automatically; fake assertions there rather than requiring every
|
||||||
|
// platform's CMakeLists to set DUSK_ASSERTIONS_FAKED itself.
|
||||||
|
#if defined(NDEBUG) && !defined(DUSK_ASSERTIONS_FAKED)
|
||||||
|
#define DUSK_ASSERTIONS_FAKED
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DUSK_TEST_ASSERT
|
#ifdef DUSK_TEST_ASSERT
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
#include "util/math.h"
|
|
||||||
|
|
||||||
size_t memoryGetAllocatedCount(void) {
|
size_t memoryGetAllocatedCount(void) {
|
||||||
return MEMORY_POINTERS_IN_USE;
|
return MEMORY_POINTERS_IN_USE;
|
||||||
@@ -106,9 +105,8 @@ int_t memoryCompare(
|
|||||||
void memoryReallocate(void **ptr, const size_t size) {
|
void memoryReallocate(void **ptr, const size_t size) {
|
||||||
assertNotNull(ptr, "Cannot reallocate NULL pointer.");
|
assertNotNull(ptr, "Cannot reallocate NULL pointer.");
|
||||||
assertTrue(size > 0, "Cannot reallocate to 0 bytes of memory.");
|
assertTrue(size > 0, "Cannot reallocate to 0 bytes of memory.");
|
||||||
void *newPointer = memoryAllocate(size);
|
void *newPointer = realloc(*ptr, size);
|
||||||
assertNotNull(newPointer, "Memory reallocation failed.");
|
assertNotNull(newPointer, "Memory reallocation failed.");
|
||||||
memoryFree(*ptr);
|
|
||||||
*ptr = newPointer;
|
*ptr = newPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,9 +139,7 @@ void memoryResize(void **ptr, const size_t oldSize, const size_t newSize) {
|
|||||||
assertTrue(oldSize > 0, "Old size cannot be 0 bytes.");
|
assertTrue(oldSize > 0, "Old size cannot be 0 bytes.");
|
||||||
if(newSize == oldSize) return;
|
if(newSize == oldSize) return;
|
||||||
|
|
||||||
void *newPointer = memoryAllocate(newSize);
|
void *newPointer = realloc(*ptr, newSize);
|
||||||
assertNotNull(newPointer, "Memory resizing failed.");
|
assertNotNull(newPointer, "Memory resizing failed.");
|
||||||
memoryCopy(newPointer, *ptr, mathMin(oldSize, newSize));
|
|
||||||
memoryFree(*ptr);
|
|
||||||
*ptr = newPointer;
|
*ptr = newPointer;
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,12 @@
|
|||||||
#include "display/displaygl.h"
|
#include "display/displaygl.h"
|
||||||
#include "error/errorgl.h"
|
#include "error/errorgl.h"
|
||||||
|
|
||||||
|
static bool_t DISPLAY_SDL2_STATE_VALID = false;
|
||||||
|
static uint8_t DISPLAY_SDL2_STATE_FLAGS = 0;
|
||||||
|
|
||||||
errorret_t displaySDL2Init(void) {
|
errorret_t displaySDL2Init(void) {
|
||||||
|
DISPLAY_SDL2_STATE_VALID = false;
|
||||||
|
|
||||||
uint32_t flags = SDL_INIT_VIDEO;
|
uint32_t flags = SDL_INIT_VIDEO;
|
||||||
#ifdef DUSK_INPUT_GAMEPAD
|
#ifdef DUSK_INPUT_GAMEPAD
|
||||||
flags |= SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK;
|
flags |= SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK;
|
||||||
@@ -103,38 +108,53 @@ errorret_t displaySDL2Swap(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
errorret_t displaySDL2SetState(displaystate_t state) {
|
errorret_t displaySDL2SetState(displaystate_t state) {
|
||||||
if(state.flags & DISPLAY_STATE_FLAG_CULL) {
|
// Only touch GL state that actually differs from what's already bound --
|
||||||
glEnable(GL_CULL_FACE);
|
// avoids a redundant glEnable/glDisable/glBlendFunc/glDepthFunc round
|
||||||
errorChain(errorGLCheck());
|
// trip per draw when consecutive entities share the same display state.
|
||||||
glCullFace(GL_BACK);
|
const uint8_t changed = DISPLAY_SDL2_STATE_VALID ?
|
||||||
errorChain(errorGLCheck());
|
(state.flags ^ DISPLAY_SDL2_STATE_FLAGS) : 0xFF;
|
||||||
} else {
|
|
||||||
glDisable(GL_CULL_FACE);
|
if(changed & DISPLAY_STATE_FLAG_CULL) {
|
||||||
errorChain(errorGLCheck());
|
if(state.flags & DISPLAY_STATE_FLAG_CULL) {
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
glCullFace(GL_BACK);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
} else {
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.flags & DISPLAY_STATE_FLAG_DEPTH_TEST) {
|
if(changed & DISPLAY_STATE_FLAG_DEPTH_TEST) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
if(state.flags & DISPLAY_STATE_FLAG_DEPTH_TEST) {
|
||||||
errorChain(errorGLCheck());
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(GL_LEQUAL);
|
errorChain(errorGLCheck());
|
||||||
errorChain(errorGLCheck());
|
glDepthFunc(GL_LEQUAL);
|
||||||
glClearDepth(1.0f);
|
errorChain(errorGLCheck());
|
||||||
errorChain(errorGLCheck());
|
glClearDepth(1.0f);
|
||||||
} else {
|
errorChain(errorGLCheck());
|
||||||
glDisable(GL_DEPTH_TEST);
|
} else {
|
||||||
errorChain(errorGLCheck());
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.flags & DISPLAY_STATE_FLAG_BLEND) {
|
if(changed & DISPLAY_STATE_FLAG_BLEND) {
|
||||||
glEnable(GL_BLEND);
|
if(state.flags & DISPLAY_STATE_FLAG_BLEND) {
|
||||||
errorChain(errorGLCheck());
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
errorChain(errorGLCheck());
|
||||||
errorChain(errorGLCheck());
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
} else {
|
errorChain(errorGLCheck());
|
||||||
glDisable(GL_BLEND);
|
} else {
|
||||||
errorChain(errorGLCheck());
|
glDisable(GL_BLEND);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DISPLAY_SDL2_STATE_FLAGS = state.flags;
|
||||||
|
DISPLAY_SDL2_STATE_VALID = true;
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user