Skip to content

Commit

Permalink
Merge branch 'hrydgard:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anr2me authored Feb 15, 2024
2 parents 2971a99 + d832f96 commit 2cc933d
Show file tree
Hide file tree
Showing 347 changed files with 7,229 additions and 4,674 deletions.
52 changes: 42 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if(NOT IOS)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl)
endif()

include(ccache)
include(CheckCXXSourceCompiles)
include(GNUInstallDirs)

add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/")
Expand Down Expand Up @@ -173,6 +173,11 @@ option(USE_SYSTEM_ZSTD "Dynamically link against system zstd" ${USE_SYSTEM_ZSTD}
option(USE_SYSTEM_MINIUPNPC "Dynamically link against system miniUPnPc" ${USE_SYSTEM_MINIUPNPC})
option(USE_ASAN "Use address sanitizer" OFF)
option(USE_UBSAN "Use undefined behaviour sanitizer" OFF)
option(USE_CCACHE "Use ccache if detected" ON)

if(USE_CCACHE)
include(ccache)
endif()

if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
if(USING_X11_VULKAN)
Expand Down Expand Up @@ -949,6 +954,23 @@ if(USE_FFMPEG)
endif()

find_package(FFmpeg REQUIRED avcodec avformat avutil swresample swscale)
# Check if we need to use avcodec_(alloc|free)_frame instead of av_frame_(alloc|free)
# Check if we need to use const AVCodec
set(CMAKE_REQUIRED_LIBRARIES avcodec;avformat)
set(CMAKE_REQUIRED_FLAGS "-pedantic -Wall -Werror -Wno-unused-variable")
check_cxx_source_compiles("extern \"C\" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
static AVCodecContext *s_codec_context = NULL;
int main() {
const AVCodec *codec = avcodec_find_encoder(s_codec_context->codec_id);
return 0;
}
" HAVE_LIBAVCODEC_CONST_AVCODEC FAIL_REGEX "invalid conversion")

# Check if we need to use avcodec_alloc_context3 instead of stream->codec
# Check if we need to use av_frame_get_buffer instead of avcodec_default_get_buffer
endif(USE_FFMPEG)

find_package(ZLIB)
Expand Down Expand Up @@ -1373,19 +1395,19 @@ else()
set(nativeExtraLibs ${nativeExtraLibs} PkgConfig::SDL2_ttf_PKGCONFIG)
endif()
if(APPLE)
set(nativeExtra ${nativeExtra}
SDL/SDLMain.h
SDL/SDLMain.mm
SDL/SDLCocoaMetalLayer.h
SDL/SDLCocoaMetalLayer.mm
set(nativeExtra ${nativeExtra}
SDL/SDLMain.h
SDL/SDLMain.mm
SDL/SDLCocoaMetalLayer.h
SDL/SDLCocoaMetalLayer.mm
SDL/CocoaBarItems.mm
SDL/CocoaBarItems.h
SDL/PPSSPPAboutViewController.m
SDL/PPSSPPAboutViewController.h
UI/DarwinFileSystemServices.mm
UI/DarwinFileSystemServices.h
Common/Battery/AppleBatteryClient.m
UI/PSPNSApplicationDelegate.mm
UI/DarwinFileSystemServices.mm
UI/DarwinFileSystemServices.h
Common/Battery/AppleBatteryClient.m
UI/PSPNSApplicationDelegate.mm
UI/PSPNSApplicationDelegate.h)

set_source_files_properties(UI/DarwinFileSystemServices.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
Expand Down Expand Up @@ -1455,6 +1477,8 @@ list(APPEND NativeAppSource
UI/GameScreen.cpp
UI/GameSettingsScreen.h
UI/GameSettingsScreen.cpp
UI/DriverManagerScreen.h
UI/DriverManagerScreen.cpp
UI/GPUDriverTestScreen.h
UI/GPUDriverTestScreen.cpp
UI/TiltAnalogSettingsScreen.h
Expand Down Expand Up @@ -2018,6 +2042,7 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/ELF/PrxDecrypter.h
Core/ELF/ParamSFO.cpp
Core/ELF/ParamSFO.h
Core/FFMPEGCompat.h
Core/FileSystems/tlzrc.cpp
Core/FileSystems/BlobFileSystem.cpp
Core/FileSystems/BlobFileSystem.h
Expand Down Expand Up @@ -2160,6 +2185,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HLE/sceSfmt19937.h
Core/HLE/sceSha256.cpp
Core/HLE/sceSha256.h
Core/HLE/sceSircs.cpp
Core/HLE/sceSircs.h
Core/HLE/sceSsl.cpp
Core/HLE/sceSsl.h
Core/HLE/sceUmd.cpp
Expand Down Expand Up @@ -2272,6 +2299,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Util/AudioFormat.h
Core/Util/GameManager.cpp
Core/Util/GameManager.h
Core/Util/MemStick.cpp
Core/Util/MemStick.h
Core/Util/GameDB.cpp
Core/Util/GameDB.h
Core/Util/PortManager.cpp
Expand Down Expand Up @@ -2348,6 +2377,9 @@ target_compile_features(${CoreLibName} PUBLIC cxx_std_17)

if(FFmpeg_FOUND)
target_compile_definitions(${CoreLibName} PRIVATE USE_FFMPEG=1)
if (HAVE_LIBAVCODEC_CONST_AVCODEC)
target_compile_definitions(${CoreLibName} PRIVATE HAVE_LIBAVCODEC_CONST_AVCODEC=1)
endif()
set_target_properties(${CoreLibName} PROPERTIES NO_SYSTEM_FROM_IMPORTED true)
target_include_directories(${CoreLibName} BEFORE PUBLIC ${FFmpeg_INCLUDE_avcodec})
target_link_libraries(${CoreLibName}
Expand Down
14 changes: 7 additions & 7 deletions Common/ArmCPUDetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const char syscpupresentfile[] = "/sys/devices/system/cpu/present";

std::string GetCPUString() {
std::string procdata;
bool readSuccess = File::ReadFileToString(true, Path(procfile), procdata);
bool readSuccess = File::ReadSysTextFileToString(Path(procfile), &procdata);
std::istringstream file(procdata);
std::string cpu_string;

Expand All @@ -113,7 +113,7 @@ std::string GetCPUString() {

std::string GetCPUBrandString() {
std::string procdata;
bool readSuccess = File::ReadFileToString(true, Path(procfile), procdata);
bool readSuccess = File::ReadSysTextFileToString(Path(procfile), &procdata);
std::istringstream file(procdata);
std::string brand_string;

Expand Down Expand Up @@ -143,7 +143,7 @@ unsigned char GetCPUImplementer()
unsigned char implementer = 0;

std::string procdata;
if (!File::ReadFileToString(true, Path(procfile), procdata))
if (!File::ReadSysTextFileToString(Path(procfile), &procdata))
return 0;
std::istringstream file(procdata);

Expand All @@ -166,7 +166,7 @@ unsigned short GetCPUPart()
unsigned short part = 0;

std::string procdata;
if (!File::ReadFileToString(true, Path(procfile), procdata))
if (!File::ReadSysTextFileToString(Path(procfile), &procdata))
return 0;
std::istringstream file(procdata);

Expand All @@ -188,7 +188,7 @@ bool CheckCPUFeature(const std::string& feature)
std::string line, marker = "Features\t: ";

std::string procdata;
if (!File::ReadFileToString(true, Path(procfile), procdata))
if (!File::ReadSysTextFileToString(Path(procfile), &procdata))
return false;
std::istringstream file(procdata);
while (std::getline(file, line))
Expand All @@ -214,7 +214,7 @@ int GetCoreCount()
int cores = 1;

std::string presentData;
bool presentSuccess = File::ReadFileToString(true, Path(syscpupresentfile), presentData);
bool presentSuccess = File::ReadSysTextFileToString(Path(syscpupresentfile), &presentData);
std::istringstream presentFile(presentData);

if (presentSuccess) {
Expand All @@ -228,7 +228,7 @@ int GetCoreCount()
}

std::string procdata;
if (!File::ReadFileToString(true, Path(procfile), procdata))
if (!File::ReadSysTextFileToString(Path(procfile), &procdata))
return 1;
std::istringstream file(procdata);

Expand Down
2 changes: 1 addition & 1 deletion Common/CPUDetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static std::vector<int> ParseCPUList(const std::string &filename) {
std::string data;
std::vector<int> results;

if (File::ReadFileToString(true, Path(filename), data)) {
if (File::ReadSysTextFileToString(Path(filename), &data)) {
std::vector<std::string> ranges;
SplitString(data, ',', ranges);
for (auto range : ranges) {
Expand Down
7 changes: 7 additions & 0 deletions Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
} \
static inline bool operator &(const T &lhs, const T &rhs) { \
return ((int)lhs & (int)rhs) != 0; \
} \
static inline T &operator &= (T &lhs, const T &rhs) { \
lhs = (T)((int)lhs & (int)rhs); \
return lhs; \
} \
static inline T operator ~(const T &rhs) { \
return (T)(~((int)rhs)); \
}
#endif

Expand Down
6 changes: 4 additions & 2 deletions Common/Data/Collections/FastVec.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <cstdlib>
#include <cstring>

#ifdef _DEBUG
#include "Common/Log.h"
#endif

template<class T>
class FastVec {
Expand All @@ -19,6 +17,7 @@ class FastVec {
FastVec(size_t initialCapacity) {
capacity_ = initialCapacity;
data_ = (T *)malloc(initialCapacity * sizeof(T));
_assert_(data_ != nullptr);
}
~FastVec() { if (data_) free(data_); }

Expand Down Expand Up @@ -157,6 +156,7 @@ class FastVec {
return;
T *oldData = data_;
data_ = (T *)malloc(sizeof(T) * newCapacity);
_assert_msg_(data_ != nullptr, "%d", (int)newCapacity);
if (capacity_ != 0) {
memcpy(data_, oldData, sizeof(T) * size_);
free(oldData);
Expand All @@ -165,6 +165,8 @@ class FastVec {
}

void ExtendByOne() {
// We don't really extend capacity by one though - instead we use
// the usual doubling amortization.
size_t newCapacity = capacity_ * 2;
if (newCapacity < 16) {
newCapacity = 16;
Expand Down
Loading

0 comments on commit 2cc933d

Please sign in to comment.