2018-01-20 20:47:16 +00:00
|
|
|
#include "AndroidJavaGLContext.h"
|
2020-10-04 08:10:55 +00:00
|
|
|
#include "Common/System/Display.h"
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/GPU/OpenGL/GLFeatures.h"
|
2020-07-28 17:06:29 +00:00
|
|
|
#include "Common/Log.h"
|
2022-01-30 23:49:02 +00:00
|
|
|
#include "Core/Config.h"
|
2018-06-17 01:42:31 +00:00
|
|
|
#include "Core/ConfigValues.h"
|
2018-01-20 20:47:16 +00:00
|
|
|
#include "Core/System.h"
|
|
|
|
|
|
|
|
AndroidJavaEGLGraphicsContext::AndroidJavaEGLGraphicsContext() {
|
2018-01-20 19:29:18 +00:00
|
|
|
SetGPUBackend(GPUBackend::OPENGL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AndroidJavaEGLGraphicsContext::InitFromRenderThread(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) {
|
2024-07-14 12:42:59 +00:00
|
|
|
INFO_LOG(Log::G3D, "AndroidJavaEGLGraphicsContext::InitFromRenderThread");
|
2022-12-22 22:07:30 +00:00
|
|
|
if (!CheckGLExtensions()) {
|
2024-07-14 12:42:59 +00:00
|
|
|
ERROR_LOG(Log::G3D, "CheckGLExtensions failed - not gonna attempt starting up.");
|
2022-12-22 22:07:30 +00:00
|
|
|
state_ = GraphicsContextState::FAILED_INIT;
|
|
|
|
return false;
|
|
|
|
}
|
2022-07-25 10:22:50 +00:00
|
|
|
|
2019-06-24 08:30:32 +00:00
|
|
|
// OpenGL handles rotated rendering in the driver.
|
2023-02-25 12:09:44 +00:00
|
|
|
g_display.rotation = DisplayRotation::ROTATE_0;
|
|
|
|
g_display.rot_matrix.setIdentity();
|
2022-12-22 22:07:30 +00:00
|
|
|
|
2023-08-13 11:33:38 +00:00
|
|
|
draw_ = Draw::T3DCreateGLContext(false); // Can't fail
|
2018-01-20 19:29:18 +00:00
|
|
|
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
2020-03-03 03:21:15 +00:00
|
|
|
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
2022-07-25 10:22:50 +00:00
|
|
|
|
|
|
|
if (!draw_->CreatePresets()) {
|
2022-12-22 22:07:30 +00:00
|
|
|
// This can't really happen now that compilation is async - they're only really queued for compile here.
|
2022-07-25 10:22:50 +00:00
|
|
|
_assert_msg_(false, "Failed to compile preset shaders");
|
2022-12-22 22:07:30 +00:00
|
|
|
state_ = GraphicsContextState::FAILED_INIT;
|
2022-07-25 10:22:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-12-22 22:07:30 +00:00
|
|
|
state_ = GraphicsContextState::INITIALIZED;
|
2020-07-28 17:06:29 +00:00
|
|
|
return true;
|
2018-01-20 20:47:16 +00:00
|
|
|
}
|
|
|
|
|
2018-01-20 19:29:18 +00:00
|
|
|
void AndroidJavaEGLGraphicsContext::ShutdownFromRenderThread() {
|
2024-07-14 12:42:59 +00:00
|
|
|
INFO_LOG(Log::G3D, "AndroidJavaEGLGraphicsContext::Shutdown");
|
2018-01-20 19:29:18 +00:00
|
|
|
renderManager_ = nullptr; // owned by draw_.
|
2018-01-20 20:47:16 +00:00
|
|
|
delete draw_;
|
|
|
|
draw_ = nullptr;
|
2022-12-22 22:07:30 +00:00
|
|
|
state_ = GraphicsContextState::SHUTDOWN;
|
2018-01-20 20:47:16 +00:00
|
|
|
}
|