-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implementation of UI wrapper #7
Conversation
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.
Nice job!
Except for ui_capture_{keyboard,mouse}
and the vulkan validation layer errors, all my comments are minor and easily fixable.
Note: either the FPS computation is broken, or vsync doesn't work, got 2000fps on debug builds and over 9000 on release builds 😄
Would explain the GPU usage.
Values in IO structure are updated after the current imgui's frame starts. Therefore our calls to `want_capture_mouse` and `want_capture_keyboard` had outdated values. This also didn't work well with `UI::create` and its callback. So I removed the whole UI wrapper and work directly with barebones calls to all involved libraries. All of this orchestration is present only in `main` and doesn't leak to other modules, so it's a good compromise.
src/imgui_renderer.rs
Outdated
@@ -129,7 +130,8 @@ impl ImguiRenderer { | |||
depth_stencil_state: None, | |||
index_format: wgpu::IndexFormat::Uint16, // FIXME(yanchith): may need 32bit indices! | |||
vertex_buffers: &[wgpu::VertexBufferDescriptor { | |||
stride: u64::try_from(Self::DRAW_VERT_SIZE).unwrap(), | |||
stride: u64::try_from(wgpu_size_of::<imgui::DrawVert>()) |
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.
Redundant try_from
, wgpu_size_of
already returns u64
(type aliased as wgpu::BufferAddress
)
@@ -105,14 +105,41 @@ fn main() { | |||
let duration_running = now.duration_since(time_start); | |||
time = now; | |||
|
|||
let duration_last_frame_s = duration_last_frame.as_secs() as f32 |
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.
Can leave a FIXME here to change to https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f32 when it stabilizes in 1.38.0
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.
Beautiful 👍
This is a convenience wrapper around imgui and all of its orchestration. Its practicality can be questioned, but it's the first iteration and I find it to be friendlier than the barebones alternative. All options are also hardcoded, which I (partly) don't expect to stay that way in the future.