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