Merge pull request #21999 from hrydgard/vr-shader-fix

VR fixes
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-07-29 15:47:13 +02:00
commit 35355d90e2
7 files changed
+47 -25

No files matched your search

+1 -1
View File
@@ -54,7 +54,7 @@ void GLRenderManager::ThreadStart(Draw::DrawContext *draw) {
renderThreadId = std::this_thread::get_id();
if (newInflightFrames_ != -1) {
INFO_LOG(Log::G3D, "Updating inflight frames to %d", newInflightFrames_);
INFO_LOG(Log::G3D, "OpenGL: Updating inflight frames to %d", newInflightFrames_);
inflightFrames_ = newInflightFrames_;
newInflightFrames_ = -1;
}
+4 -1
View File
@@ -8,16 +8,19 @@
OpenGLGraphicsContext::OpenGLGraphicsContext() {
SetGPUBackend(GPUBackend::OPENGL);
CheckGLExtensions();
// NOTE: On some Android devices, OpenGL is not yet available here so calling CheckGLExtension here
// doesn't work.
// OpenGL handles rotated rendering in the driver.
g_display.rotation = DisplayRotation::ROTATE_0;
g_display.rot_matrix.setIdentity();
}
bool OpenGLGraphicsContext::InitSurface(WindowSystem winsys, void *data1, void *data2, std::string *errorMessage) {
CheckGLExtensions();
INFO_LOG(Log::G3D, "OpenGLGraphicsContext::InitSurface");
draw_ = Draw::T3DCreateGLContext(false); // Can't fail
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
// TODO: In VR mode, we don't want a lot of inflight frames.
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
const bool result = draw_->CreatePresets();
_dbg_assert_(result);
+1 -1
View File
@@ -333,7 +333,7 @@ bool VulkanRenderManager::CreateBackbuffers() {
curHeightRaw_ = -1;
if (newInflightFrames_ != -1) {
INFO_LOG(Log::G3D, "Updating inflight frames to %d", newInflightFrames_);
INFO_LOG(Log::G3D, "Vulkan: Updating inflight frames to %d", newInflightFrames_);
vulkan_->UpdateInflightFrames(newInflightFrames_);
newInflightFrames_ = -1;
}
+1
View File
@@ -289,6 +289,7 @@ static ShaderModule *GenerateFShader(DrawContext *draw, FragmentShaderPreset pre
}
bool DrawContext::CreatePresets() {
INFO_LOG(Log::G3D, "Creating thin3d preset shaders...");
bool tintSupported = !bugs_.Has(Bugs::RASPBERRY_SHADER_COMP_HANG);
for (int i = 0; i < VS_MAX_PRESET; i++) {
+9 -9
View File
@@ -58,14 +58,6 @@ void SetupCallbacks(AllowedCallback allowed, MessageCallback message) {
}
void ReportMessage(const char *message, ...) {
if (!allowedCallback || !messageCallback) {
ERROR_LOG(Log::System, "Reporting not initialized, skipping: %s", message);
return;
}
if (!allowedCallback())
return;
const int MESSAGE_BUFFER_SIZE = 65536;
char *temp = new char [MESSAGE_BUFFER_SIZE];
@@ -75,6 +67,14 @@ void ReportMessage(const char *message, ...) {
temp[MESSAGE_BUFFER_SIZE - 1] = '\0';
va_end(args);
if (!allowedCallback || !messageCallback) {
ERROR_LOG(Log::System, "Reporting not initialized, skipping: %s", temp);
return;
}
if (!allowedCallback())
return;
messageCallback(message, temp);
delete[] temp;
@@ -82,7 +82,7 @@ void ReportMessage(const char *message, ...) {
void ReportMessageFormatted(const char *message, const char *formatted) {
if (!allowedCallback || !messageCallback) {
ERROR_LOG(Log::System, "Reporting not initialized, skipping: %s", message);
ERROR_LOG(Log::System, "Reporting not initialized, skipping: %s", formatted);
return;
}
+26 -12
View File
@@ -289,14 +289,14 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
}
}
//enable or disable mouse
//enable or disable mouse for each controller. Only one can be the mouse at a time.
for (int j = 0; j < 2; j++) {
bool pressed = IN_VRGetButtonState(j) & ovrButton_Trigger;
if (pressed) {
int lastController = mouseController;
const int lastController = mouseController;
mouseController = j;
//prevent misclicks when changing the left/right controller
// prevent misclicks when changing the left/right controller
if (lastController != mouseController) {
mousePressed = true;
}
@@ -332,25 +332,39 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
bool pressed = IN_VRGetButtonState(mouseController) & ovrButton_Trigger;
if (mousePressed != pressed) {
if (pressed) {
touch.flags = TouchInputFlags::DOWN;
touch.flags = TouchInputFlags::DOWN | TouchInputFlags::MOUSE;
touch.buttons = 1;
cbNativeTouch(touch);
touch.flags = TouchInputFlags::UP;
} else {
touch.flags = TouchInputFlags::UP | TouchInputFlags::MOUSE;
touch.buttons = 1;
cbNativeTouch(touch);
}
mousePressed = pressed;
} else {
// Simulate mouse move. This allows for dragging stuff in the UI and scrolling without using the mousewheel emulation.
touch.flags = TouchInputFlags::MOVE | TouchInputFlags::MOUSE;
touch.buttons = mousePressed ? 1 : 0;
cbNativeTouch(touch);
}
// mouse wheel emulation
// TODO: Spams key-up events if nothing changed!
// No longer spams events when scrolling isn't happening.
for (int j = 0; j < 2; j++) {
keyInput.deviceId = controllerIds[j];
float scroll = -IN_VRGetJoystickState(j).y;
keyInput.flags = scroll < -0.5f ? KeyInputFlags::DOWN : KeyInputFlags::UP;
keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_UP;
cbNativeKey(keyInput);
keyInput.flags = scroll > 0.5f ? KeyInputFlags::DOWN : KeyInputFlags::UP;
keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_DOWN;
cbNativeKey(keyInput);
int wheelDelta = (int)(std::min(fabsf(scroll) * 30.0f, 500.0f));
if (scroll < -0.5f) {
// Scroll upwards
keyInput.flags = (KeyInputFlags)((int)(KeyInputFlags::DOWN | KeyInputFlags::UP) | (wheelDelta << 16));
keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_UP;
cbNativeKey(keyInput);
} else if (scroll > 0.5f) {
// Scroll downwards
keyInput.flags = (KeyInputFlags)((int)(KeyInputFlags::DOWN | KeyInputFlags::UP) | (wheelDelta << 16));
keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_DOWN;
cbNativeKey(keyInput);
}
}
} else {
VR_SetConfig(VR_CONFIG_MOUSE_SIZE, 0);
@@ -10,12 +10,16 @@ import java.util.Arrays;
import java.util.List;
class InfraredHelper {
private static final String TAG = InfraredHelper.class.getSimpleName();
private static final String TAG = "PPSSPPActivity";
private static final int SIRC_FREQ = 40000;
private final ConsumerIrManager mConsumerIrManager;
InfraredHelper(Context context) throws Exception {
mConsumerIrManager = (ConsumerIrManager) context.getSystemService(Context.CONSUMER_IR_SERVICE);
if (mConsumerIrManager == null) {
Log.i(TAG, "No IR manager detected.");
return;
}
Log.d(TAG, "HasIrEmitter: " + mConsumerIrManager.hasIrEmitter());
if (!mConsumerIrManager.hasIrEmitter()) {
throw new Exception("No Ir Emitter");