Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/xenia-project/xenia into …
Browse files Browse the repository at this point in the history
…canary_experimental
  • Loading branch information
Gliniak committed Jul 17, 2022
2 parents 23ca372 + 14fdf4b commit 6e1e623
Show file tree
Hide file tree
Showing 169 changed files with 40,167 additions and 37,935 deletions.
15 changes: 7 additions & 8 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,36 @@ def targets_android(platform):
'mspack',
'snappy',
'xxhash',
'xenia-core',
'xenia-app',
# 'xenia-app-discord',
'xenia-apu',
'xenia-apu-nop',
'xenia-base',
'xenia-base-tests',
'xenia-core',
'xenia-cpu',
# 'xenia-cpu-tests',
# 'xenia-cpu-ppc-tests',
'xenia-cpu-tests',
'xenia-cpu-ppc-tests',
# 'xenia-cpu-backend-x64',
# 'xenia-debug-ui',
'xenia-gpu',
'xenia-gpu-shader-compiler',
'xenia-gpu-null',
'xenia-gpu-vulkan',
# 'xenia-gpu-vulkan-trace-viewer',
'xenia-gpu-vulkan-trace-viewer',
'xenia-gpu-vulkan-trace-dump',
'xenia-hid',
# 'xenia-hid-demo',
'xenia-hid-demo',
'xenia-hid-nop',
'xenia-kernel',
'xenia-ui',
'xenia-ui-vulkan',
# 'xenia-ui-window-vulkan-demo',
'xenia-ui-window-vulkan-demo',
'xenia-vfs',
'xenia-vfs-dump',
]
if platform == 'Android-x86_64':
targets.extend([
'xenia-cpu-tests',
'xenia-cpu-ppc-tests',
'xenia-cpu-backend-x64',
'xenia-debug-ui',
])
Expand Down
12 changes: 8 additions & 4 deletions android/android_studio_project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@ plugins {
}

android {
compileSdkVersion 30
ndkVersion '23.0.7599858'
compileSdkVersion 33
ndkVersion '25.0.8775105'

defaultConfig {
applicationId 'jp.xenia.emulator'
// 24 (7.0) - Vulkan.
minSdkVersion 24
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName 'Prototype'
externalNativeBuild {
ndkBuild {
arguments 'NDK_APPLICATION_MK:=../../../build/xenia.Application.mk',
'PREMAKE_ANDROIDNDK_PLATFORMS:=Android-ARM64',
'PREMAKE_ANDROIDNDK_PLATFORMS+=Android-x86_64',
// ndk.jobs doesn't work as of Gradle 7.1.0.
"-j${Runtime.runtime.availableProcessors()}",
// Work around "Bad file descriptor" on Windows on NDK r22+.
'--output-sync=none'
// For the app, don't build the executables designed for running from a terminal.
// To build the executables, run ndk-build manually.
targets 'xenia-app'
}
}
ndk {
abiFilters 'arm64-v8a', 'x86_64'
jobs Runtime.runtime.availableProcessors()
stl 'c++_static'
}
}
Expand Down
23 changes: 15 additions & 8 deletions android/android_studio_project/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
<!-- Granted automatically - guest sockets. -->
<uses-permission android:name="android.permission.INTERNET" />

<!--
Needs to be requested - loading games from outside the app data directory.
WRITE_EXTERNAL_STORAGE is not required to write to the external app data directory since API 19.
-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -30,14 +24,27 @@
android:theme="@android:style/Theme.Material.Light">

<activity
android:name="jp.xenia.emulator.WindowDemoActivity"
android:label="@string/activity_label_window_demo">
android:name="jp.xenia.emulator.LauncherActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="jp.xenia.emulator.GpuTraceViewerActivity"
android:exported="true"
android:label="@string/activity_label_gpu_trace_viewer"
android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.Material.Light.NoActionBar" />

<activity
android:name="jp.xenia.emulator.WindowDemoActivity"
android:exported="true"
android:label="@string/activity_label_window_demo"
android:theme="@android:style/Theme.Material.Light.NoActionBar" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package jp.xenia.emulator;

import android.os.Bundle;

public class GpuTraceViewerActivity extends WindowedAppActivity {
@Override
protected String getWindowedAppIdentifier() {
return "xenia_gpu_vulkan_trace_viewer";
}

@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_gpu_trace_viewer);
setWindowSurfaceView(findViewById(R.id.gpu_trace_viewer_surface_view));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package jp.xenia.emulator;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

public class LauncherActivity extends Activity {
private static final int REQUEST_OPEN_GPU_TRACE_VIEWER = 0;

@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_launcher);
}

@Override
protected void onActivityResult(
final int requestCode, final int resultCode, final Intent data) {
if (requestCode == REQUEST_OPEN_GPU_TRACE_VIEWER && resultCode == RESULT_OK) {
final Uri uri = data.getData();
if (uri != null) {
final Intent gpuTraceViewerIntent = new Intent(this, GpuTraceViewerActivity.class);
final Bundle gpuTraceViewerLaunchArguments = new Bundle();
gpuTraceViewerLaunchArguments.putString("target_trace_file", uri.toString());
gpuTraceViewerIntent.putExtra(
WindowedAppActivity.EXTRA_CVARS, gpuTraceViewerLaunchArguments);
startActivity(gpuTraceViewerIntent);
}
}
}

public void onLaunchGpuTraceViewerClick(final View view) {
final Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/octet-stream");
startActivityForResult(intent, REQUEST_OPEN_GPU_TRACE_VIEWER);
}

public void onLaunchWindowDemoClick(final View view) {
startActivity(new Intent(this, WindowDemoActivity.class));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package jp.xenia.emulator;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.View;
Expand All @@ -12,15 +14,18 @@
import jp.xenia.XeniaRuntimeException;

public abstract class WindowedAppActivity extends Activity {
// The EXTRA_CVARS value literal is also used in the native code.

/**
* Name of the Bundle intent extra containing Xenia config variable launch arguments.
*/
public static final String EXTRA_CVARS = "jp.xenia.emulator.WindowedAppActivity.EXTRA_CVARS";

static {
// TODO(Triang3l): Move all demos to libxenia.so.
System.loadLibrary("xenia-ui-window-vulkan-demo");
System.loadLibrary("xenia-app");
}

private final WindowSurfaceOnLayoutChangeListener mWindowSurfaceOnLayoutChangeListener =
new WindowSurfaceOnLayoutChangeListener();
private final WindowSurfaceHolderCallback mWindowSurfaceHolderCallback =
new WindowSurfaceHolderCallback();
private final WindowSurfaceListener mWindowSurfaceListener = new WindowSurfaceListener();

// May be 0 while destroying (mainly while the superclass is).
private long mAppContext = 0;
Expand All @@ -36,6 +41,8 @@ private native long initializeWindowedAppOnCreate(
private native void onWindowSurfaceLayoutChange(
long appContext, int left, int top, int right, int bottom);

private native boolean onWindowSurfaceMotionEvent(long appContext, MotionEvent event);

private native void onWindowSurfaceChanged(long appContext, Surface windowSurface);

private native void paintWindow(long appContext, boolean forcePaint);
Expand All @@ -49,8 +56,10 @@ protected void setWindowSurfaceView(@Nullable final WindowSurfaceView windowSurf

// Detach from the old surface.
if (mWindowSurfaceView != null) {
mWindowSurfaceView.getHolder().removeCallback(mWindowSurfaceHolderCallback);
mWindowSurfaceView.removeOnLayoutChangeListener(mWindowSurfaceOnLayoutChangeListener);
mWindowSurfaceView.getHolder().removeCallback(mWindowSurfaceListener);
mWindowSurfaceView.setOnTouchListener(null);
mWindowSurfaceView.setOnGenericMotionListener(null);
mWindowSurfaceView.removeOnLayoutChangeListener(mWindowSurfaceListener);
mWindowSurfaceView = null;
if (mAppContext != 0) {
onWindowSurfaceChanged(mAppContext, null);
Expand All @@ -62,12 +71,12 @@ protected void setWindowSurfaceView(@Nullable final WindowSurfaceView windowSurf
}

mWindowSurfaceView = windowSurfaceView;
// The native window code assumes that, when the surface exists, it covers the entire
// window.
// FIXME(Triang3l): This doesn't work if the layout has already been performed.
mWindowSurfaceView.addOnLayoutChangeListener(mWindowSurfaceOnLayoutChangeListener);
mWindowSurfaceView.addOnLayoutChangeListener(mWindowSurfaceListener);
mWindowSurfaceView.setOnGenericMotionListener(mWindowSurfaceListener);
mWindowSurfaceView.setOnTouchListener(mWindowSurfaceListener);
final SurfaceHolder windowSurfaceHolder = mWindowSurfaceView.getHolder();
windowSurfaceHolder.addCallback(mWindowSurfaceHolderCallback);
windowSurfaceHolder.addCallback(mWindowSurfaceListener);
// If setting after the creation of the surface.
if (mAppContext != 0) {
final Surface windowSurface = windowSurfaceHolder.getSurface();
Expand Down Expand Up @@ -116,7 +125,11 @@ protected void onDestroy() {
super.onDestroy();
}

private class WindowSurfaceOnLayoutChangeListener implements View.OnLayoutChangeListener {
private class WindowSurfaceListener implements
View.OnGenericMotionListener,
View.OnLayoutChangeListener,
View.OnTouchListener,
SurfaceHolder.Callback2 {
@Override
public void onLayoutChange(
final View v, final int left, final int top, final int right, final int bottom,
Expand All @@ -125,9 +138,24 @@ public void onLayoutChange(
onWindowSurfaceLayoutChange(mAppContext, left, top, right, bottom);
}
}
}

private class WindowSurfaceHolderCallback implements SurfaceHolder.Callback2 {
@Override
public boolean onGenericMotion(final View view, final MotionEvent event) {
if (mAppContext == 0) {
return false;
}
return onWindowSurfaceMotionEvent(mAppContext, event);
}

@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(final View view, final MotionEvent event) {
if (mAppContext == 0) {
return false;
}
return onWindowSurfaceMotionEvent(mAppContext, event);
}

@Override
public void surfaceCreated(final SurfaceHolder holder) {
if (mAppContext == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<jp.xenia.emulator.WindowSurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gpu_trace_viewer_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jp.xenia.emulator.GpuTraceViewerActivity" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jp.xenia.emulator.LauncherActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onLaunchGpuTraceViewerClick"
android:text="@string/activity_label_gpu_trace_viewer" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onLaunchWindowDemoClick"
android:text="@string/activity_label_window_demo" />

</LinearLayout>

</ScrollView>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string name="app_name">Xenia</string>
<string name="activity_label_window_demo">Xenia Window Demo</string>
<string name="activity_label_gpu_trace_viewer">GPU Trace Viewer</string>
<string name="activity_label_window_demo">Window Demo</string>
</resources>
2 changes: 1 addition & 1 deletion android/android_studio_project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.android.tools.build:gradle:7.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Nov 01 23:19:20 MSK 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
11 changes: 7 additions & 4 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ filter("platforms:Android-*")
systemversion("24")
cppstl("c++")
staticruntime("On")
-- Hidden visibility is needed to prevent dynamic relocations in FFmpeg
-- AArch64 Neon libavcodec assembly with PIC (accesses extern lookup tables
-- using `adrp` and `add`, without the Global Object Table, expecting that all
-- FFmpeg symbols that aren't a part of the FFmpeg API are hidden by FFmpeg's
-- original build system) by resolving those relocations at link time instead.
visibility("Hidden")
links({
"android",
"dl",
Expand Down Expand Up @@ -272,6 +278,7 @@ workspace("xenia")
end

include("src/xenia")
include("src/xenia/app")
include("src/xenia/app/discord")
include("src/xenia/apu")
include("src/xenia/apu/nop")
Expand All @@ -294,10 +301,6 @@ workspace("xenia")
include("src/xenia/apu/sdl")
include("src/xenia/helper/sdl")
include("src/xenia/hid/sdl")

-- TODO(Triang3l): src/xenia/app has a dependency on xenia-helper-sdl, bring
-- it back later.
include("src/xenia/app")
end

if os.istarget("windows") then
Expand Down
Loading

0 comments on commit 6e1e623

Please sign in to comment.