Skip to content

Commit

Permalink
Merge pull request #13907 from unknownbrackets/headless
Browse files Browse the repository at this point in the history
Fix Headless and UnitTest on Android again
  • Loading branch information
hrydgard authored Jan 10, 2021
2 parents 6d0315e + 3734df3 commit 90a8038
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,22 @@ jobs:
extra: android
cc: clang
cxx: clang++
args: cd android && ./ab.sh -j2 APP_ABI=arm64-v8a
args: cd android && ./ab.sh -j2 APP_ABI=arm64-v8a UNITTEST=1 HEADLESS=1
- os: ubuntu-latest
extra: android
cc: clang
cxx: clang++
args: cd android && ./ab.sh -j2 APP_ABI=armeabi-v7a
args: cd android && ./ab.sh -j2 APP_ABI=armeabi-v7a UNITTEST=1 HEADLESS=1
- os: ubuntu-latest
extra: android
cc: clang
cxx: clang++
args: cd android && ./ab.sh -j2 APP_ABI=x86
args: cd android && ./ab.sh -j2 APP_ABI=x86 UNITTEST=1 HEADLESS=1
- os: ubuntu-latest
extra: android
cc: clang
cxx: clang++
args: cd android && ./ab.sh -j2 APP_ABI=x86_64
args: cd android && ./ab.sh -j2 APP_ABI=x86_64 UNITTEST=1 HEADLESS=1
- os: ubuntu-latest
extra: android
cc: clang
Expand Down
19 changes: 7 additions & 12 deletions android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ARCH_FILES := \
$(SRC)/Common/x64Emitter.cpp \
$(SRC)/Common/x64Analyzer.cpp \
$(SRC)/Common/CPUDetect.cpp \
$(SRC)/Common/Math/fast/fast_matrix_sse.c \
$(SRC)/Common/Thunk.cpp \
$(SRC)/Core/MIPS/x86/CompALU.cpp \
$(SRC)/Core/MIPS/x86/CompBranch.cpp \
Expand All @@ -39,6 +40,7 @@ ARCH_FILES := \
$(SRC)/Common/x64Emitter.cpp \
$(SRC)/Common/x64Analyzer.cpp \
$(SRC)/Common/CPUDetect.cpp \
$(SRC)/Common/Math/fast/fast_matrix_sse.c \
$(SRC)/Common/Thunk.cpp \
$(SRC)/Core/MIPS/x86/CompALU.cpp \
$(SRC)/Core/MIPS/x86/CompBranch.cpp \
Expand All @@ -62,6 +64,7 @@ ARCH_FILES := \
$(SRC)/Common/ArmEmitter.cpp \
$(SRC)/Common/ArmCPUDetect.cpp \
$(SRC)/Common/ColorConvNEON.cpp.neon \
$(SRC)/Common/Math/fast/fast_matrix_neon.S.neon \
$(SRC)/Core/MIPS/ARM/ArmCompALU.cpp \
$(SRC)/Core/MIPS/ARM/ArmCompBranch.cpp \
$(SRC)/Core/MIPS/ARM/ArmCompFPU.cpp \
Expand All @@ -76,6 +79,9 @@ ARCH_FILES := \
$(SRC)/Core/MIPS/ARM/ArmRegCacheFPU.cpp \
$(SRC)/GPU/Common/VertexDecoderArm.cpp \
$(SRC)/ext/disarm.cpp \
$(SRC)/ext/libpng17/arm/arm_init.c \
$(SRC)/ext/libpng17/arm/filter_neon_intrinsics.c \
$(SRC)/ext/libpng17/arm/filter_neon.S.neon \
ArmEmitterTest.cpp
endif

Expand Down Expand Up @@ -620,18 +626,6 @@ LOCAL_SRC_FILES := \

ifeq ($(findstring armeabi-v7a,$(TARGET_ARCH_ABI)),armeabi-v7a)
LOCAL_CFLAGS := $(LOCAL_CFLAGS) -DARM
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
$(SRC)/Common/Math/fast/fast_matrix_neon.S.neon \
$(SRC)/ext/libpng17/arm/arm_init.c \
$(SRC)/ext/libpng17/arm/filter_neon_intrinsics.c \
$(SRC)/ext/libpng17/arm/filter_neon.S.neon

else ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
$(SRC)/Common/Math/fast/fast_matrix_sse.c
else ifeq ($(TARGET_ARCH_ABI),x86_64)
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
$(SRC)/Common/Math/fast/fast_matrix_sse.c
endif

ifneq ($(SKIPAPP),1)
Expand Down Expand Up @@ -684,6 +678,7 @@ ifeq ($(UNITTEST),1)
LOCAL_MODULE := ppsspp_unittest
LOCAL_SRC_FILES := \
$(SRC)/unittest/JitHarness.cpp \
$(SRC)/unittest/TestShaderGenerators.cpp \
$(SRC)/unittest/TestVertexJit.cpp \
$(TESTARMEMITTER_FILE) \
$(SRC)/unittest/UnitTest.cpp
Expand Down
8 changes: 6 additions & 2 deletions headless/Headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// See headless.txt.
// To build on non-windows systems, just run CMake in the SDL directory, it will build both a normal ppsspp and the headless version.

#include "ppsspp_config.h"
#include <cstdio>
#include <cstdlib>
#include <limits>
#if defined(ANDROID)
#if PPSSPP_PLATFORM(ANDROID)
#include <jni.h>
#endif

Expand Down Expand Up @@ -38,14 +39,17 @@
#include "SDLHeadlessHost.h"
#endif

#if defined(ANDROID)
#if PPSSPP_PLATFORM(ANDROID)
JNIEnv *getEnv() {
return nullptr;
}

jclass findClass(const char *name) {
return nullptr;
}

bool audioRecording_Available() { return false; }
bool audioRecording_State() { return false; }
#endif

class PrintfLogger : public LogListener {
Expand Down
9 changes: 9 additions & 0 deletions unittest/TestShaderGenerators.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "ppsspp_config.h"
#include <algorithm>

#include "Common/StringUtils.h"
Expand All @@ -13,11 +14,13 @@
#include "GPU/Common/VertexShaderGenerator.h"
#include "GPU/Common/ReinterpretFramebuffer.h"

#if PPSSPP_PLATFORM(WINDOWS)
#include "GPU/D3D11/D3D11Util.h"
#include "GPU/D3D11/D3D11Loader.h"

#include "GPU/D3D9/D3DCompilerLoader.h"
#include "GPU/D3D9/D3D9ShaderCompiler.h"
#endif

bool GenerateFShader(FShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs bugs, std::string *errorString) {
uint64_t uniformMask;
Expand Down Expand Up @@ -89,6 +92,7 @@ bool GenerateVShader(VShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs
bool TestCompileShader(const char *buffer, ShaderLanguage lang, bool vertex, std::string *errorMessage) {
std::vector<uint32_t> spirv;
switch (lang) {
#if PPSSPP_PLATFORM(WINDOWS)
case ShaderLanguage::HLSL_D3D11:
{
auto output = CompileShaderToBytecodeD3D11(buffer, strlen(buffer), vertex ? "vs_4_0" : "ps_4_0", 0);
Expand All @@ -104,6 +108,7 @@ bool TestCompileShader(const char *buffer, ShaderLanguage lang, bool vertex, std
return false;
}
}
#endif

case ShaderLanguage::GLSL_VULKAN:
return GLSLtoSPV(vertex ? VK_SHADER_STAGE_VERTEX_BIT : VK_SHADER_STAGE_FRAGMENT_BIT, buffer, GLSLVariant::VULKAN, spirv, errorMessage);
Expand Down Expand Up @@ -352,9 +357,13 @@ bool TestFragmentShaders() {
}

bool TestShaderGenerators() {
#if PPSSPP_PLATFORM(WINDOWS)
LoadD3D11();
init_glslang();
LoadD3DCompilerDynamic();
#else
init_glslang();
#endif

if (!TestFragmentShaders()) {
return false;
Expand Down
9 changes: 6 additions & 3 deletions unittest/UnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
// To use, set command line parameter to one or more of the tests below, or "all".
// Search for "availableTests".

#include "ppsspp_config.h"
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <sstream>
#if defined(ANDROID)
#if PPSSPP_PLATFORM(ANDROID)
#include <jni.h>
#endif

#include "ppsspp_config.h"
#include "Common/System/NativeApp.h"
#include "Common/System/System.h"
#include "Common/Input/InputState.h"
Expand Down Expand Up @@ -72,14 +72,17 @@ bool System_GetPropertyBool(SystemProperty prop) {
return false;
}

#if defined(ANDROID)
#if PPSSPP_PLATFORM(ANDROID)
JNIEnv *getEnv() {
return nullptr;
}

jclass findClass(const char *name) {
return nullptr;
}

bool audioRecording_Available() { return false; }
bool audioRecording_State() { return false; }
#endif

#ifndef M_PI_2
Expand Down

0 comments on commit 90a8038

Please sign in to comment.