-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Editor windows playback performance #1613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e23dfb6
4ded373
47e0026
2883cca
c5f3982
0281ad4
62381d0
e53808a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,7 +81,9 @@ export async function isWebGPUSupported(): Promise<boolean> { | |||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| const adapter = await navigator.gpu.requestAdapter(); | ||||||||||||||||||||||||||||||||
| const adapter = await navigator.gpu.requestAdapter({ | ||||||||||||||||||||||||||||||||
| powerPreference: "high-performance", | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| return adapter !== null; | ||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||
|
|
@@ -91,7 +93,9 @@ export async function isWebGPUSupported(): Promise<boolean> { | |||||||||||||||||||||||||||||||
| export async function initWebGPU( | ||||||||||||||||||||||||||||||||
| canvas: OffscreenCanvas, | ||||||||||||||||||||||||||||||||
| ): Promise<WebGPURenderer> { | ||||||||||||||||||||||||||||||||
| const adapter = await navigator.gpu.requestAdapter(); | ||||||||||||||||||||||||||||||||
| const adapter = await navigator.gpu.requestAdapter({ | ||||||||||||||||||||||||||||||||
| powerPreference: "high-performance", | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| if (!adapter) { | ||||||||||||||||||||||||||||||||
| throw new Error("No WebGPU adapter available"); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+96
to
101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same idea here: try high-performance, but fall back to default adapter request so initialization still works if the preference is unsupported.
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,20 +147,48 @@ impl Renderer { | |
| break; | ||
| } | ||
| } | ||
| match frame_renderer | ||
| .render_immediate( | ||
| current.segment_frames, | ||
| current.uniforms, | ||
| let nv12_result = frame_renderer | ||
| .render_nv12( | ||
| current.segment_frames.clone(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis is a comment left during a code review.
Path: crates/editor/src/editor.rs
Line: 152:152
Comment:
`.clone()` on `segment_frames` may be expensive if `DecodedFrame` contains large buffers. Verify whether this clone is necessary or if the data can be moved/borrowed instead.
How can I resolve this? If you propose a fix, please make it concise. |
||
| current.uniforms.clone(), | ||
| ¤t.cursor, | ||
| &mut layers, | ||
| ) | ||
| .await | ||
| { | ||
| Ok(frame) => { | ||
| (self.frame_cb)(EditorFrameOutput::Rgba(frame)); | ||
| .await; | ||
|
|
||
| match nv12_result { | ||
| Ok(pipeline_frame) => { | ||
| if let Some(prev) = pipeline_frame { | ||
| (self.frame_cb)(EditorFrameOutput::Nv12(prev)); | ||
| } | ||
| match frame_renderer.flush_pipeline_nv12().await { | ||
| Some(Ok(current_frame)) => { | ||
| (self.frame_cb)(EditorFrameOutput::Nv12(current_frame)); | ||
| } | ||
| Some(Err(e)) => { | ||
| tracing::warn!(error = %e, "Failed to flush NV12 pipeline frame"); | ||
| } | ||
| None => {} | ||
| } | ||
| } | ||
| Err(e) => { | ||
| tracing::error!(error = %e, "Failed to render frame in editor"); | ||
| tracing::warn!(error = %e, "NV12 render failed, falling back to RGBA"); | ||
| match frame_renderer | ||
| .render_immediate( | ||
| current.segment_frames, | ||
| current.uniforms, | ||
| ¤t.cursor, | ||
| &mut layers, | ||
| ) | ||
| .await | ||
| { | ||
| Ok(frame) => { | ||
| (self.frame_cb)(EditorFrameOutput::Rgba(frame)); | ||
| } | ||
| Err(e) => { | ||
| tracing::error!(error = %e, "Failed to render frame in editor"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option can throw or be ignored on some WebGPU implementations; falling back to a plain
requestAdapter()keeps the capability check from returningfalsefor supported devices.