Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4b74f2367 | ||
|
|
f312db60c2 | ||
|
|
00d2230b84 |
No files matched your search
+1
-5
@@ -1,10 +1,6 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use arboard::Clipboard;
|
use arboard::Clipboard;
|
||||||
use std::{
|
use std::{marker::PhantomData, sync::Arc, time::Instant};
|
||||||
marker::{PhantomData, Sized},
|
|
||||||
sync::Arc,
|
|
||||||
time::Instant,
|
|
||||||
};
|
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Ime, WindowEvent},
|
event::{Ime, WindowEvent},
|
||||||
event_loop::{ActiveEventLoop, EventLoopProxy},
|
event_loop::{ActiveEventLoop, EventLoopProxy},
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ impl UiRenderer {
|
|||||||
pub fn draw(&mut self) {
|
pub fn draw(&mut self) {
|
||||||
let output = match self.surface.get_current_texture() {
|
let output = match self.surface.get_current_texture() {
|
||||||
CurrentSurfaceTexture::Success(texture) => texture,
|
CurrentSurfaceTexture::Success(texture) => texture,
|
||||||
// Still drawable; the surface has just changed under us, and
|
|
||||||
// reconfiguring is what the next frame wants rather than this one.
|
|
||||||
CurrentSurfaceTexture::Suboptimal(texture) => {
|
CurrentSurfaceTexture::Suboptimal(texture) => {
|
||||||
self.surface.configure(&self.device, &self.config);
|
self.surface.configure(&self.device, &self.config);
|
||||||
texture
|
texture
|
||||||
@@ -34,7 +32,6 @@ impl UiRenderer {
|
|||||||
self.surface.configure(&self.device, &self.config);
|
self.surface.configure(&self.device, &self.config);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Nothing to draw into this frame.
|
|
||||||
CurrentSurfaceTexture::Timeout
|
CurrentSurfaceTexture::Timeout
|
||||||
| CurrentSurfaceTexture::Occluded
|
| CurrentSurfaceTexture::Occluded
|
||||||
| CurrentSurfaceTexture::Validation => return,
|
| CurrentSurfaceTexture::Validation => return,
|
||||||
@@ -81,8 +78,6 @@ impl UiRenderer {
|
|||||||
pub fn new(window: Arc<Window>) -> Self {
|
pub fn new(window: Arc<Window>) -> Self {
|
||||||
let size = window.inner_size();
|
let size = window.inner_size();
|
||||||
|
|
||||||
// The display handle is what GLES needs to present on Wayland, and it
|
|
||||||
// has to be the one the surface is made from.
|
|
||||||
let instance = Instance::new(InstanceDescriptor {
|
let instance = Instance::new(InstanceDescriptor {
|
||||||
backends: Backends::PRIMARY,
|
backends: Backends::PRIMARY,
|
||||||
display: Some(Box::new(window.clone())),
|
display: Some(Box::new(window.clone())),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ mod max_size;
|
|||||||
mod offset;
|
mod offset;
|
||||||
mod pad;
|
mod pad;
|
||||||
mod scroll;
|
mod scroll;
|
||||||
mod sized;
|
mod set_size;
|
||||||
mod span;
|
mod span;
|
||||||
mod stack;
|
mod stack;
|
||||||
|
|
||||||
@@ -14,6 +14,6 @@ pub use max_size::*;
|
|||||||
pub use offset::*;
|
pub use offset::*;
|
||||||
pub use pad::*;
|
pub use pad::*;
|
||||||
pub use scroll::*;
|
pub use scroll::*;
|
||||||
pub use sized::*;
|
pub use set_size::*;
|
||||||
pub use span::*;
|
pub use span::*;
|
||||||
pub use stack::*;
|
pub use stack::*;
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub struct Sized {
|
pub struct SetSize {
|
||||||
pub inner: StrongWidget,
|
pub inner: StrongWidget,
|
||||||
pub x: Option<Len>,
|
pub x: Option<Len>,
|
||||||
pub y: Option<Len>,
|
pub y: Option<Len>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sized {
|
impl SetSize {
|
||||||
fn apply_to_outer(&self, ctx: &mut SizeCtx) {
|
fn apply_to_outer(&self, ctx: &mut SizeCtx) {
|
||||||
if let Some(x) = self.x {
|
if let Some(x) = self.x {
|
||||||
ctx.outer.x.select_len(x.apply_rest());
|
ctx.outer.x.select_len(x.apply_rest());
|
||||||
@@ -17,7 +17,7 @@ impl Sized {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for Sized {
|
impl Widget for SetSize {
|
||||||
fn draw(&mut self, painter: &mut Painter) {
|
fn draw(&mut self, painter: &mut Painter) {
|
||||||
painter.widget(&self.inner);
|
painter.widget(&self.inner);
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use std::marker::{Sized, Unsize};
|
use std::marker::Unsize;
|
||||||
|
|
||||||
pub struct WidgetPtr {
|
pub struct WidgetPtr {
|
||||||
pub inner: Option<StrongWidget>,
|
pub inner: Option<StrongWidget>,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use std::marker::{PhantomData, Sized};
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
pub struct TextBuilder<State, O = TextOutput, H: WidgetOption<State> = ()> {
|
pub struct TextBuilder<State, O = TextOutput, H: WidgetOption<State> = ()> {
|
||||||
pub content: String,
|
pub content: String,
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ widget_trait! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sized(self, size: impl Into<Size>) -> impl WidgetFn<Rsc, Sized> {
|
fn sized(self, size: impl Into<Size>) -> impl WidgetFn<Rsc, SetSize> {
|
||||||
let size = size.into();
|
let size = size.into();
|
||||||
move |state| Sized {
|
move |state| SetSize {
|
||||||
inner: self.add_strong(state),
|
inner: self.add_strong(state),
|
||||||
x: Some(size.x),
|
x: Some(size.x),
|
||||||
y: Some(size.y),
|
y: Some(size.y),
|
||||||
@@ -58,18 +58,18 @@ widget_trait! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn width(self, len: impl Into<Len>) -> impl WidgetFn<Rsc, Sized> {
|
fn width(self, len: impl Into<Len>) -> impl WidgetFn<Rsc, SetSize> {
|
||||||
let len = len.into();
|
let len = len.into();
|
||||||
move |state| Sized {
|
move |state| SetSize {
|
||||||
inner: self.add_strong(state),
|
inner: self.add_strong(state),
|
||||||
x: Some(len),
|
x: Some(len),
|
||||||
y: None,
|
y: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn height(self, len: impl Into<Len>) -> impl WidgetFn<Rsc, Sized> {
|
fn height(self, len: impl Into<Len>) -> impl WidgetFn<Rsc, SetSize> {
|
||||||
let len = len.into();
|
let len = len.into();
|
||||||
move |state| Sized {
|
move |state| SetSize {
|
||||||
inner: self.add_strong(state),
|
inner: self.add_strong(state),
|
||||||
x: None,
|
x: None,
|
||||||
y: Some(len),
|
y: Some(len),
|
||||||
|
|||||||
+13
-14
@@ -4,20 +4,19 @@
|
|||||||
//!
|
//!
|
||||||
//! cargo test --release --test draw_cost -- --ignored --nocapture
|
//! cargo test --release --test draw_cost -- --ignored --nocapture
|
||||||
//!
|
//!
|
||||||
//! **Read the instruction count, not the clock.** Wall time here swings by 2x
|
//! Wall time is the wrong number to read for anything under a few percent --
|
||||||
//! between runs of one binary on this machine -- more under `cargo test` than
|
//! it varied by 2x between runs of one unchanged binary where instructions
|
||||||
//! run directly -- while instructions retired are stable to 0.1%:
|
//! retired varied by 0.1%. Count those instead:
|
||||||
//!
|
//!
|
||||||
//! perf stat -e instructions:u target/release/.../draw_cost-* --ignored
|
//! perf stat -e instructions:u target/release/.../draw_cost-* --ignored
|
||||||
//!
|
//!
|
||||||
//! Measured that way on 2026-09-13, drawing each primitive through its own
|
//! That is how `PrimitiveRender` was measured against a match in the renderer:
|
||||||
//! `PrimitiveRender` rather than a match in the renderer costs **6
|
//! 6 instructions per list drawn, against the ~5,400 wgpu spends recording
|
||||||
//! instructions per list drawn**, which is 0.1% of a frame at both 256 and
|
//! one.
|
||||||
//! 1024 layers. Recording one list into the pass costs wgpu ~5,400.
|
|
||||||
//!
|
//!
|
||||||
//! The instance is leaked on purpose. Dropping the last one makes the Vulkan
|
//! The instance is leaked deliberately. A Vulkan loader may unload the driver
|
||||||
//! loader unload Mesa's ICD, which faults when a thread that touched Vulkan
|
//! when the last one drops, which can fault as a thread that used it exits --
|
||||||
//! exits -- and libtest runs every test on a spawned thread.
|
//! and every test runs on a spawned thread.
|
||||||
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
@@ -30,13 +29,13 @@ use wgpu::{Color as GpuColor, *};
|
|||||||
|
|
||||||
const SIZE: u32 = 1024;
|
const SIZE: u32 = 1024;
|
||||||
const FRAMES: u32 = 200;
|
const FRAMES: u32 = 200;
|
||||||
/// Reported as the best of this many batches. The mean moves by 15% between
|
/// Reported as the best of this many batches, since the mean moves by more
|
||||||
/// runs on this machine, which is more than the thing being measured.
|
/// than the thing being measured.
|
||||||
const BATCHES: u32 = 8;
|
const BATCHES: u32 = 8;
|
||||||
|
|
||||||
fn gpu() -> Option<(Device, Queue)> {
|
fn gpu() -> Option<(Device, Queue)> {
|
||||||
// Probed rather than assumed: this machine's Vulkan device comes and goes,
|
// Probed rather than assumed: there may be no Vulkan adapter, and GL is
|
||||||
// and GL is what is left when it is gone.
|
// what is left when there is not.
|
||||||
let all = Instance::new(InstanceDescriptor::new_without_display_handle());
|
let all = Instance::new(InstanceDescriptor::new_without_display_handle());
|
||||||
let instance = match pollster::block_on(all.request_adapter(&RequestAdapterOptions::default()))
|
let instance = match pollster::block_on(all.request_adapter(&RequestAdapterOptions::default()))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user