This repository was archived by the owner on Oct 31, 2025. It is now read-only.
example-runner-wgpu: bump android_logger to unbreak Android logging.#1033
Merged
Conversation
Contributor
Author
|
EDIT: most of the comment hidden because I opened a separate PR: With a few more hacks, I was able to get the "mouse" example to kinda work too: (click to reveal hacky patch and video)diff --git a/Cargo.toml b/Cargo.toml
index 2035cee7e7..35e8298359 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -52,3 +52,11 @@ codegen-units = 256
opt-level = 3
incremental = true
codegen-units = 256
+
+# HACK(eddyb) we override the `wgpu`->`naga` git dependency, with our own, so
+# that we can upgrade to newer `naga` than `wgpu` (and/or use our own patches).
+[patch."https://github.com/gfx-rs/naga".naga]
+git = "https://github.com/EmbarkStudios/naga"
+# rev = "53d62b9ede64898681c0dbc70d04296caf90ed16"
+# HACK(eddyb) using https://github.com/gfx-rs/naga/pull/2290 before it's merged.
+branch = "spv-in-break-if"
diff --git a/examples/runners/wgpu/src/graphics.rs b/examples/runners/wgpu/src/graphics.rs
index 9a5bd43263..c857de5bc8 100644
--- a/examples/runners/wgpu/src/graphics.rs
+++ b/examples/runners/wgpu/src/graphics.rs
@@ -3,7 +3,10 @@ use crate::maybe_watch;
use super::Options;
use shared::ShaderConstants;
use winit::{
- event::{ElementState, Event, KeyboardInput, MouseButton, VirtualKeyCode, WindowEvent},
+ event::{
+ ElementState, Event, KeyboardInput, MouseButton, Touch, TouchPhase, VirtualKeyCode,
+ WindowEvent,
+ },
event_loop::{ControlFlow, EventLoop, EventLoopBuilder},
window::Window,
};
@@ -297,7 +300,40 @@ async fn run(
}
}
Event::WindowEvent {
- event: WindowEvent::CursorMoved { position, .. },
+ event:
+ WindowEvent::Touch(Touch {
+ phase: phase @ (TouchPhase::Started | TouchPhase::Ended | TouchPhase::Cancelled),
+ ..
+ }),
+ ..
+ } => {
+ // FIXME(eddyb) deduplicate!
+ let button = MouseButton::Left;
+ let mask = 1 << mouse_button_index(button);
+ match phase {
+ TouchPhase::Started => {
+ mouse_button_pressed |= mask;
+ mouse_button_press_since_last_frame |= mask;
+
+ if button == MouseButton::Left {
+ drag_start_x = cursor_x;
+ drag_start_y = cursor_y;
+ drag_end_x = cursor_x;
+ drag_end_y = cursor_y;
+ }
+ }
+ TouchPhase::Moved => unreachable!(),
+ TouchPhase::Ended | TouchPhase::Cancelled => mouse_button_pressed &= !mask,
+ }
+ }
+ Event::WindowEvent {
+ event:
+ WindowEvent::CursorMoved { position, .. }
+ | WindowEvent::Touch(Touch {
+ phase: TouchPhase::Moved,
+ location: position,
+ ..
+ }),
..
} => {
cursor_x = position.x as f32;
diff --git a/examples/runners/wgpu/src/lib.rs b/examples/runners/wgpu/src/lib.rs
index 4bdb7cd9cc..c19515d61b 100644
--- a/examples/runners/wgpu/src/lib.rs
+++ b/examples/runners/wgpu/src/lib.rs
@@ -153,7 +153,7 @@ fn maybe_watch(
#[derive(StructOpt)]
#[structopt(name = "example-runner-wgpu")]
pub struct Options {
- #[structopt(short, long, default_value = "Sky")]
+ #[structopt(short, long, default_value = "Mouse")]
shader: RustGPUShader,
}
com.oculus.shellenv-20230415-101759.mp4Looking at it, this shader should probably just have an extra bit to control whether to show the "cursor" UI at all (but this isn't something shadertoy ever accounted for, and my data model here mostly matches theirs). |
3 tasks
Contributor
Author
|
Opened a PR to |
fu5ha
approved these changes
Apr 17, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I don't fully understand what was wrong with this before, but it acted like
== Infoinstead of>= Infoor<= Info(neither warn/error nor debug/trace, were present, and this seems impossible given the code ofandroid_logger 0.11.3, but maybe it was doing both<= Infoand>= Info, just in two different places?).With this PR, warn/error logging can also be seen, and I get this on my Android-based VR headset:
There's still a bunch of wonkery here,
Not enough memory leftshould be "device lost" or something instead, orERROR_INITIALIZATION_FAILEDbe used as indication that a fallback should be used, etc.The explanation for why there is even an error is that
VK_KHR_timeline_semaphoreis broken in AdrenoVK on this headset (Oculus Quest 2) with the latest update, because the userspace AdrenoVK component advertises it but it's blocked by SELinux(?) - thepath="/dev/kgsl-3d0" ... ioctlcmd=0x958message, which AFAICT isIOCTL_KGSL_TIMELINE_CREATE.I am also not the first to run into this, e.g.: https://communityforums.atmeta.com/t5/Quest-Development/Issue-with-VK-KHR-timeline-semaphore/td-p/1027690
By locally patching
wgpu(not included in this PR), I was able to get this:com.oculus.shellenv-20230414-150104.mp4