Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1784 from reicast/skmp/adreno-3xx-fixes
Browse files Browse the repository at this point in the history
Adreno 3xx fixes
  • Loading branch information
skmp committed Feb 2, 2020
2 parents 133017c + 5aac6b7 commit 333b7c5
Show file tree
Hide file tree
Showing 12 changed files with 568 additions and 523 deletions.
27 changes: 15 additions & 12 deletions libswirl/android/Android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,19 +394,15 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitNative(JNIEnv
{
if (surface == NULL) {


g_GUI->OpenSettings([] {
g_GUIRenderer->Stop();
verify(render_thread.hThread != NULL);
render_thread.WaitToEnd();

render_thread.hThread = NULL;
g_GUIRenderer->Stop();
verify(render_thread.hThread != NULL);
render_thread.WaitToEnd();

render_thread.hThread = NULL;

ANativeWindow_release(g_window);
verify(g_window != NULL);
g_window = NULL;
});
ANativeWindow_release(g_window);
verify(g_window != NULL);
g_window = NULL;

do {} while (g_window != NULL);
}
Expand Down Expand Up @@ -717,4 +713,11 @@ int msgboxf(const wchar* text, unsigned int type, ...) {

return rv;
}
#endif
#endif

void android_RecreateView()
{
JNIEnv *env = jvm_attacher.getEnv();
jmethodID RecreateViewMID = env->GetMethodID(env->GetObjectClass(g_activity), "RecreateView", "()V");
env->CallVoidMethod(g_activity, RecreateViewMID);
}
3 changes: 3 additions & 0 deletions libswirl/android/Android.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void android_RecreateView();
4 changes: 3 additions & 1 deletion libswirl/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ struct ReicastUI_impl : GUI {
ImGui::GetStyle().ScaleAllSizes(scaling);

font17 = io.Fonts->AddFontFromMemoryCompressedTTF(roboto_medium_compressed_data, roboto_medium_compressed_size, 17 * scaling);
font64 = io.Fonts->AddFontFromMemoryCompressedTTF(roboto_medium_compressed_data, roboto_medium_compressed_size, 128 * scaling);
// don't use scaling for this one to avoid too big textures

font64 = io.Fonts->AddFontFromMemoryCompressedTTF(roboto_medium_compressed_data, roboto_medium_compressed_size, 96);
printf("Screen DPI is %d, size %d x %d. Scaling by %.2f\n", screen_dpi, screen_width, screen_height, scaling);
}

Expand Down
24 changes: 19 additions & 5 deletions libswirl/gui/gui_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ std::unique_ptr<GUIRenderer> g_GUIRenderer;

#include "rend/gles/gles.h"
#include "rend/gles/glcache.h"
#include "android/Android.h"

#if defined(TARGET_EMSCRIPTEN)
#include <emscripten.h>
Expand All @@ -34,6 +35,9 @@ static void findGLVersion()
if (!strncmp(version, "OpenGL ES", 9))
{
gl.is_gles = true;
if (settings.pvr.ForceGLES2)
gl.gl_major = 2;

if (gl.gl_major >= 3)
{
gl.gl_version = "GLES3";
Expand Down Expand Up @@ -449,8 +453,7 @@ struct GUIRenderer_impl : GUIRenderer {
}
callback_mutex.Unlock();


if (cb) {
if (cb) {
if (cb()) {
DrawOSD(false);
g_GUI->RenderOSD();
Expand Down Expand Up @@ -484,10 +487,21 @@ struct GUIRenderer_impl : GUIRenderer {

virtual void UIFrame() {
if (!tryUIFrame()) {
printf("UIFRAME: Re-creating context...\n");
SleepMs(10);
DestroyContext();

if (!CreateContext()) {
return;
if (!CreateContext())
{
#if !defined(_ANDROID)
die("UIFrame: Failed to recover gl context")
#else
msgboxf("Your graphics driver has crashed. Will try to recover.\n You can force a GLES2 context from the settings to avoid this message.\n\n Please upgrade your OS.", MBX_ICONEXCLAMATION);
printf("UIFRAME: Failed to create context - recreating view\n");
Stop();
android_RecreateView();
settings.pvr.ForceGLES2 = true;
SaveSettings();
#endif
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion libswirl/gui/gui_settings_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ void gui_settings_video()
}
if (ImGui::CollapsingHeader("Rendering Options", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::Checkbox("Force GLESv2 Context", &settings.pvr.ForceGLES2);
ImGui::SameLine();
gui_ShowHelpMarker("Avoid using GLESv3. Works around old Adreno driver bugs");
ImGui::Checkbox("Synchronous Rendering", &settings.pvr.SynchronousRender);
ImGui::SameLine();
gui_ShowHelpMarker("Reduce frame skipping by pausing the CPU when possible. Recommended for most platforms");
gui_ShowHelpMarker("Reduce frame skipping by pausing the CPU when possible. Recommended for powerful devices");
ImGui::Checkbox("Clipping", &settings.rend.Clipping);
ImGui::SameLine();
gui_ShowHelpMarker("Enable clipping. May produce graphical errors when disabled");
Expand Down
Loading

0 comments on commit 333b7c5

Please sign in to comment.