Skip to content

Commit

Permalink
Small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Jul 10, 2023
1 parent d590cb9 commit d8fd3d3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env_logger = "0.10.0"
gilrs = { version = "0.10.2", features = ["serde", "serde-serialize"] }
glium = { version = "0.32.1", optional = true }
imgui = { version = "0.11.0", features = ["docking"] }
imgui-wgpu = { git = "https://github.com/retrofoundry/imgui-wgpu-rs.git", branch = "helix", optional = true }
imgui-wgpu = { git = "https://github.com/Yatekii/imgui-wgpu-rs.git", optional = true }
imgui-winit-support = "0.11.0"
imgui-glium-renderer = { version = "0.11.0", optional = true }
winit = { version = "0.27.5", features = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"] }
Expand Down
6 changes: 1 addition & 5 deletions src/gui/glium_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ impl<'a> Renderer<'a> {

// MARK: - Helpers

fn render_game(
&mut self,
frame: &mut Frame,
rcp_output: &mut RCPOutput,
) -> anyhow::Result<()> {
fn render_game(&mut self, frame: &mut Frame, rcp_output: &mut RCPOutput) -> anyhow::Result<()> {
// omit the last draw call, because we know we that's an extra from the last flush
// for draw_call in &self.rcp_output.draw_calls[..self.rcp_output.draw_calls.len() - 1] {
for draw_call in rcp_output
Expand Down
96 changes: 47 additions & 49 deletions src/gui/wgpu_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,32 +204,6 @@ impl<'a> Renderer<'a> {
.texture
.create_view(&wgpu::TextureViewDescriptor::default());

let mut encoder: wgpu::CommandEncoder =
self.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor {
label: Some("Game Render Pass Command Encoder"),
});

let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("Game Render Pass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &frame_texture,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &self.depth_texture,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: true,
}),
stencil_ops: None,
}),
});

// Prepare the context device
self.graphics_device.update_frame_count();

Expand All @@ -241,11 +215,36 @@ impl<'a> Renderer<'a> {
rcp_output,
);

// Draw the RCP output
self.graphics_device.draw(&mut rpass);
let mut encoder: wgpu::CommandEncoder =
self.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor {
label: Some("Game Render Pass Command Encoder"),
});

{
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("Game Render Pass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &frame_texture,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &self.depth_texture,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: true,
}),
stencil_ops: None,
}),
});

// Drop the render pass
drop(rpass);
// Draw the RCP output
self.graphics_device.draw(&mut rpass);
}

// Finish encoding and submit
self.queue.submit(Some(encoder.finish()));
Expand All @@ -263,25 +262,24 @@ impl<'a> Renderer<'a> {
label: Some("ImGui Render Pass Command Encoder"),
});

let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("ImGui Render Pass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &frame_texture,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Load,
store: true,
},
})],
depth_stencil_attachment: None,
});

// Render the ImGui content
self.renderer
.render(imgui_draw_data, &self.queue, &self.device, &mut rpass)?;

// Drop the render pass
drop(rpass);
{
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("ImGui Render Pass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &frame_texture,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Load,
store: true,
},
})],
depth_stencil_attachment: None,
});

// Render the ImGui content
self.renderer
.render(imgui_draw_data, &self.queue, &self.device, &mut rpass)?;
}

// Finish encoding and submit
self.queue.submit(Some(encoder.finish()));
Expand Down
2 changes: 1 addition & 1 deletion src/gui/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,5 @@ pub extern "C" fn GUIShowProfilerWindow(ui: &Ui, gui: Option<&mut Gui>, opened:
return;
}

ui.show_profiler_window(opened as &mut bool, gui);
ui.show_profiler_window(opened, gui);
}

0 comments on commit d8fd3d3

Please sign in to comment.