Skip to content
This repository has been archived by the owner on Jul 5, 2019. It is now read-only.

Mupen updates #69

Merged
merged 5 commits into from
Oct 7, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions GLideN64/src/GLideNHQ/Ext_TxFilter.h
Expand Up @@ -34,7 +34,9 @@
#define CHDIR(a) SetCurrentDirectoryW(a)
#else
#include <iostream>
#ifndef __LIBRETRO__
#include <dlfcn.h>
#endif
#include <unistd.h>
#define MAX_PATH 4095
#define TXHMODULE void*
Expand Down
8 changes: 7 additions & 1 deletion GLideN64/src/GLideNHQ/TxFilter.cpp
Expand Up @@ -299,23 +299,28 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
numcore--;
}
if (blkrow > 0 && numcore > 1) {
#ifndef HAVE_LIBNX
std::thread *thrd[MAX_NUMCORE];
#endif
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (srcwidth * blkheight) << 2;
unsigned int destStride = srcStride * scale * scale;
for (i = 0; i < numcore - 1; i++) {
#ifndef HAVE_LIBNX
thrd[i] = new std::thread(std::bind(filter_8888,
(uint32*)_texture,
srcwidth,
blkheight,
(uint32*)_tmptex,
filter,
i));
#endif
_texture += srcStride;
_tmptex += destStride;
}
thrd[i] = new std::thread(std::bind(filter_8888,
#ifndef HAVE_LIBNX
thrd[i] = new std::thread(std::bind(filter_8888,
(uint32*)_texture,
srcwidth,
srcheight - blkheight * i,
Expand All @@ -326,6 +331,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
filter_8888((uint32*)_texture, srcwidth, srcheight, (uint32*)_tmptex, filter, 0);
}
Expand Down
14 changes: 13 additions & 1 deletion GLideN64/src/GLideNHQ/TxQuantize.cpp
Expand Up @@ -843,21 +843,26 @@ TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcf
numcore--;
}
if (blkrow > 0 && numcore > 1) {
#ifndef HAVE_LIBNX
std::thread *thrd[MAX_NUMCORE];
#endif
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (width * blkheight) << (2 - bpp_shift);
unsigned int destStride = srcStride << bpp_shift;
for (i = 0; i < numcore - 1; i++) {
#ifndef HAVE_LIBNX
thrd[i] = new std::thread(std::bind(quantizer,
this,
(uint32*)src,
(uint32*)dest,
width,
blkheight));
#endif
src += srcStride;
dest += destStride;
}
#ifndef HAVE_LIBNX
thrd[i] = new std::thread(std::bind(quantizer,
this,
(uint32*)src,
Expand All @@ -868,6 +873,7 @@ TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcf
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
(*this.*quantizer)((uint32*)src, (uint32*)dest, width, height);
}
Expand Down Expand Up @@ -897,22 +903,27 @@ TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcf
numcore--;
}
if (blkrow > 0 && numcore > 1) {
#ifndef HAVE_LIBNX
std::thread *thrd[MAX_NUMCORE];
#endif
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (width * blkheight) << 2;
unsigned int destStride = srcStride >> bpp_shift;
for (i = 0; i < numcore - 1; i++) {
#ifndef HAVE_LIBNX
thrd[i] = new std::thread(std::bind(quantizer,
this,
(uint32*)src,
(uint32*)dest,
width,
blkheight));
#endif
src += srcStride;
dest += destStride;
}
thrd[i] = new std::thread(std::bind(quantizer,
#ifndef HAVE_LIBNX
thrd[i] = new std::thread(std::bind(quantizer,
this,
(uint32*)src,
(uint32*)dest,
Expand All @@ -922,6 +933,7 @@ TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcf
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
(*this.*quantizer)((uint32*)src, (uint32*)dest, width, height);
}
Expand Down
4 changes: 4 additions & 0 deletions GLideN64/src/GLideNHQ/TxUtil.cpp
Expand Up @@ -491,6 +491,10 @@ int
TxUtil::getNumberofProcessors()
{
int numcore = 1;
#ifdef SWITCH
return 1;
#endif

#ifndef ANDROID
try {
#if defined (OS_WINDOWS)
Expand Down
12 changes: 12 additions & 0 deletions GLideN64/src/Textures.cpp
Expand Up @@ -18,6 +18,10 @@
#include "GLideNHQ/Ext_TxFilter.h"
#include "TextureFilterHandler.h"

#ifdef HAVE_LIBNX
#include <switch.h>
#endif

using namespace std;

const GLuint g_noiseTexIndex = 2;
Expand Down Expand Up @@ -1408,11 +1412,19 @@ void TextureCache::update(u32 _t)
if (m_toggleDumpTex) {
displayLoadProgress(L"Texture dump - ON\n");
_clear();
#ifdef SWITCH
svcSleepThread(1000000000);
#else
std::this_thread::sleep_for(std::chrono::seconds(1));
#endif
}
else {
displayLoadProgress(L"Texture dump - OFF\n");
#ifdef SWITCH
svcSleepThread(1000000000);
#else
std::this_thread::sleep_for(std::chrono::seconds(1));
#endif
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions GLideN64/src/Types.h
@@ -1,26 +1,36 @@
#ifndef TYPES_H
#define TYPES_H

#ifdef HAVE_LIBNX
#include <switch.h>
#endif

typedef unsigned char u8; /* unsigned 8-bit */
typedef unsigned short u16; /* unsigned 16-bit */
typedef unsigned int u32; /* unsigned 32-bit */
#ifndef HAVE_LIBNX
typedef unsigned long long u64; /* unsigned 64-bit */

#endif
typedef signed char s8; /* signed 8-bit */
typedef short s16; /* signed 16-bit */
typedef int s32; /* signed 32-bit */
#ifndef HAVE_LIBNX
typedef long long s64; /* signed 64-bit */
#endif

typedef volatile unsigned char vu8; /* unsigned 8-bit */
typedef volatile unsigned short vu16; /* unsigned 16-bit */
typedef volatile unsigned int vu32; /* unsigned 32-bit */
#ifndef HAVE_LIBNX
typedef volatile unsigned long long vu64; /* unsigned 64-bit */
#endif

typedef volatile signed char vs8; /* signed 8-bit */
typedef volatile short vs16; /* signed 16-bit */
typedef volatile int vs32; /* signed 32-bit */
#ifndef HAVE_LIBNX
typedef volatile long long vs64; /* signed 64-bit */

#endif
typedef float f32; /* single prec floating point */
typedef double f64; /* double prec floating point */

Expand Down
8 changes: 7 additions & 1 deletion GLideN64/src/winlnxdefs.h
Expand Up @@ -30,7 +30,10 @@
#ifndef WINLNXDEFS_H
#define WINLNXDEFS_H

#ifndef __LIBRETRO__
#include <dlfcn.h>
#endif

#include <errno.h>
#include <limits.h> // PATH_MAX
#include <stdlib.h> // malloc(), srand()
Expand Down Expand Up @@ -95,7 +98,9 @@ typedef const char *LPCSTR;
static inline const char *GetPluginDir()
{
static char path[PATH_MAX];

#ifdef SWITCH
return "/";
#else
#ifdef __USE_GNU
Dl_info info;
void *addr = (void *)GetPluginDir;
Expand All @@ -122,6 +127,7 @@ static inline const char *GetPluginDir()
#endif

return path;
#endif // SWITCH
}

#endif
27 changes: 24 additions & 3 deletions Makefile
Expand Up @@ -118,9 +118,25 @@ else ifneq (,$(findstring rpi,$(platform)))
CPUFLAGS += -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
HAVE_NEON = 1
endif

COREFLAGS += -DOS_LINUX
ASFLAGS = -f elf -d ELF_TYPE

# Nintendo Switch
else ifeq ($(platform), libnx)
include $(DEVKITPRO)/libnx/switch_rules
PIC = 1
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CPUOPTS := -g -march=armv8-a -mtune=cortex-a57 -mtp=soft -mcpu=cortex-a57+crc+fp+simd
PLATCFLAGS = -O3 -ffast-math -funsafe-math-optimizations -fPIE -I$(PORTLIBS)/include/ -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -specs=$(LIBNX)/switch.specs
PLATCFLAGS += $(INCLUDE) -D__SWITCH__=1 -DSWITCH -DHAVE_LIBNX -D_GLIBCXX_USE_C99_MATH_TR1 -D_LDBL_EQ_DBL -funroll-loops
SOURCES_C += $(CORE_DIR)/src/r4300/empty_dynarec.c
CXXFLAGS += -fno-rtti -std=gnu++11
COREFLAGS += -DOS_LINUX
GLES = 0
WITH_DYNAREC =
DYNAREC_USED = 0
STATIC_LINKING = 1

# ODROIDs
else ifneq (,$(findstring odroid,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
Expand Down Expand Up @@ -304,17 +320,22 @@ ifeq ($(HAVE_NEON), 1)
COREFLAGS += -DHAVE_NEON -D__ARM_NEON__ -D__NEON_OPT -ftree-vectorize -mvectorize-with-neon-quad -ftree-vectorizer-verbose=2 -funsafe-math-optimizations -fno-finite-math-only
endif

COREFLAGS += -D__LIBRETRO__ -DUSE_FILE32API -DM64P_PLUGIN_API -DM64P_CORE_PROTOTYPES -D_ENDUSER_RELEASE -DSINC_LOWER_QUALITY -DMUPENPLUSAPI -DTXFILTER_LIB -D__VEC4_OPT
COREFLAGS += -D__LIBRETRO__ -DUSE_FILE32API -DM64P_PLUGIN_API -DM64P_CORE_PROTOTYPES -D_ENDUSER_RELEASE -DSINC_LOWER_QUALITY -DTXFILTER_LIB -D__VEC4_OPT -DMUPENPLUSAPI

ifeq ($(DEBUG), 1)
CPUOPTS += -O0 -g
CPUOPTS += -DOPENGL_DEBUG
else
CPUOPTS += -O2 -DNDEBUG -fsigned-char -ffast-math -fno-strict-aliasing -fomit-frame-pointer -fvisibility=hidden
CPUOPTS += -DNDEBUG -fsigned-char -ffast-math -fno-strict-aliasing -fomit-frame-pointer -fvisibility=hidden
ifneq ($(platform), libnx)
CPUOPTS := -O2 $(CPUOPTS)
endif
CXXFLAGS += -fvisibility-inlines-hidden
endif

ifneq ($(platform), libnx)
CXXFLAGS += -std=c++11
endif

ifeq ($(PIC), 1)
fpic = -fPIC
Expand Down
3 changes: 2 additions & 1 deletion Makefile.common
Expand Up @@ -41,7 +41,8 @@ SOURCES_C += \
$(RSPDIR)/src/memory.c \
$(RSPDIR)/src/mp3.c \
$(RSPDIR)/src/musyx.c \
$(ROOT_DIR)/custom/mupen64plus-rsp-hle/plugin.c
$(RSPDIR)/src/re2.c \
$(RSPDIR)/src/plugin.c

ifeq ($(LLE), 1)
SOURCES_C += \
Expand Down
26 changes: 0 additions & 26 deletions custom/GLideN64/MupenPlusPluginAPI.cpp
Expand Up @@ -10,32 +10,6 @@ EXPORT int CALL RomOpen(void)
return 1;
}

EXPORT m64p_error CALL PluginGetVersion(
m64p_plugin_type * _PluginType,
int * _PluginVersion,
int * _APIVersion,
const char ** _PluginNamePtr,
int * _Capabilities
)
{
return M64ERR_SUCCESS;
}

EXPORT m64p_error CALL PluginStartup(
m64p_dynlib_handle CoreLibHandle,
void *Context,
void (*DebugCallback)(void *, int, const char *)
)
{
return M64ERR_SUCCESS;
}

EXPORT m64p_error CALL PluginShutdown(void)
{
video().stop();
return M64ERR_SUCCESS;
}

EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front)
{
}
Expand Down
2 changes: 1 addition & 1 deletion custom/mupen64plus-core/main/main.c
Expand Up @@ -306,7 +306,7 @@ m64p_error main_run(void)
open_sra_file(&sra);

/* setup backends */
aout = (struct audio_out_backend){ &g_dev.ai, set_audio_format_via_audio_plugin, push_audio_samples_via_audio_plugin };
aout = (struct audio_out_backend){ &g_dev.ai, set_audio_format_via_libretro, push_audio_samples_via_libretro };
rtc = (struct clock_backend){ NULL, get_time_using_C_localtime };
fla_storage = (struct storage_backend){ &fla, save_storage_file_libretro };
sra_storage = (struct storage_backend){ &sra, save_storage_file_libretro };
Expand Down