Move from dependency on JNI and Implement AtomicMutex

This commit is the start of moving towards a lockless and faster kernel which can run multiple independent threads with fast userspace synchronization.
This commit is contained in:
◱ PixelyIon
2019-12-26 23:40:29 +05:30
committed by ◱ PixelyIon
parent 3e9bfaec0e
commit 48d47a2b25
9 changed files with 128 additions and 35 deletions

View File

@ -8,9 +8,10 @@
#include <android/native_window_jni.h>
extern bool Halt;
extern jobject Surface;
namespace skyline::gpu {
GPU::GPU(const DeviceState &state) : state(state), window(ANativeWindow_fromSurface(state.jvmManager->env, state.jvmManager->GetField("surface", "Landroid/view/Surface;"))), bufferQueue(state), vsyncEvent(std::make_shared<kernel::type::KEvent>(state)), bufferEvent(std::make_shared<kernel::type::KEvent>(state)) {
GPU::GPU(const DeviceState &state) : state(state), window(ANativeWindow_fromSurface(state.jvmManager->GetEnv(), Surface)), bufferQueue(state), vsyncEvent(std::make_shared<kernel::type::KEvent>(state)), bufferEvent(std::make_shared<kernel::type::KEvent>(state)) {
ANativeWindow_acquire(window);
resolution.width = static_cast<u32>(ANativeWindow_getWidth(window));
resolution.height = static_cast<u32>(ANativeWindow_getHeight(window));
@ -23,16 +24,16 @@ namespace skyline::gpu {
void GPU::Loop() {
if (surfaceUpdate) {
if (!state.jvmManager->CheckNull("surface", "Landroid/view/Surface;")) {
window = ANativeWindow_fromSurface(state.jvmManager->env, state.jvmManager->GetField("surface", "Landroid/view/Surface;"));
ANativeWindow_acquire(window);
resolution.width = static_cast<u32>(ANativeWindow_getWidth(window));
resolution.height = static_cast<u32>(ANativeWindow_getHeight(window));
format = ANativeWindow_getFormat(window);
} else
if (state.jvmManager->CheckNull(Surface))
return;
window = ANativeWindow_fromSurface(state.jvmManager->GetEnv(), Surface);
ANativeWindow_acquire(window);
resolution.width = static_cast<u32>(ANativeWindow_getWidth(window));
resolution.height = static_cast<u32>(ANativeWindow_getHeight(window));
format = ANativeWindow_getFormat(window);
surfaceUpdate = true;
} else
surfaceUpdate = state.jvmManager->CheckNull("surface", "Landroid/view/Surface;");
surfaceUpdate = state.jvmManager->CheckNull(Surface);
if (!bufferQueue.displayQueue.empty()) {
auto &buffer = bufferQueue.displayQueue.front();
bufferQueue.displayQueue.pop();