From dd16530a1f55948aa9739291c937427a06532639 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Sat, 18 Sep 2021 14:36:47 +0100 Subject: [PATCH] Fix an assertion in debug, and building on PC --- CMakeLists.txt | 7 ++++++- GL/clip.c | 2 ++ GL/immediate.c | 2 ++ containers/aligned_vector.h | 6 ++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f174f5a..e534520 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,12 @@ include_directories(include) if(NOT PLATFORM_DREAMCAST) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set(FIND_LIBRARY_USE_LIB32_PATHS true) + set(FIND_LIBRARY_USE_LIB64_PATHS false) endif() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 --fast-math -fexpensive-optimizations -funroll-all-loops") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g") set( SOURCES @@ -60,7 +63,9 @@ configure_file(GL/version.c.in ${CMAKE_CURRENT_BINARY_DIR}/version.c) if(PLATFORM_DREAMCAST) set(SOURCES ${SOURCES} GL/platforms/sh4.c) else() - find_package(SDL2 REQUIRED) + find_package(PkgConfig) + pkg_check_modules(SDL2 REQUIRED sdl2) + include_directories(${SDL2_INCLUDE_DIRS}) link_libraries(${SDL2_LIBRARIES}) set( diff --git a/GL/clip.c b/GL/clip.c index 4573afe..57759bc 100644 --- a/GL/clip.c +++ b/GL/clip.c @@ -209,6 +209,8 @@ static inline void markDead(Vertex* vert) { #define MAX_CLIP_TRIANGLES 255 void _glClipTriangleStrip(SubmissionTarget* target, uint8_t fladeShade) { + printf("WHAT"); + static Triangle TO_CLIP[MAX_CLIP_TRIANGLES]; static uint8_t CLIP_COUNT = 0; diff --git a/GL/immediate.c b/GL/immediate.c index 75e1e75..32b0c9e 100644 --- a/GL/immediate.c +++ b/GL/immediate.c @@ -47,6 +47,8 @@ typedef struct { void _glInitImmediateMode(GLuint initial_size) { + printf("WHAT WHAT"); + aligned_vector_init(&VERTICES, sizeof(IMVertex)); aligned_vector_reserve(&VERTICES, initial_size); diff --git a/containers/aligned_vector.h b/containers/aligned_vector.h index 10c67ae..14e6ac8 100644 --- a/containers/aligned_vector.h +++ b/containers/aligned_vector.h @@ -79,15 +79,17 @@ AV_FORCE_INLINE void* aligned_vector_resize(AlignedVector* vector, const unsigne if(vector->capacity < element_count) { /* If we didn't have capacity, increase capacity (slow) */ + vector->size = element_count; ret = aligned_vector_reserve(vector, element_count); } else if(previousCount < element_count) { /* So we grew, but had the capacity, just get a pointer to * where we were */ + vector->size = element_count; ret = aligned_vector_at(vector, previousCount); + } else { + vector->size = element_count; } - vector->size = element_count; - return ret; }