Skip to content

Commit

Permalink
Fast3D: Update to v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Jun 26, 2023
1 parent 90cc473 commit da50140
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ glutin = { version = "0.29.1", optional = true }
wgpu = { version = "0.16", optional = true }
spin_sleep = "1.1.1"
arie = "0.2.0"
fast3d = { version = "0.1.0", default-features = false }
fast3d = { version = "0.2.0", default-features = false }
fast3d-glium-renderer = { git = "https://github.com/retrofoundry/fast3d-rs", optional = true }
fast3d-wgpu-renderer = { version = "0.1.0", optional = true }
fast3d-wgpu-renderer = { version = "0.2.0", optional = true }

[patch.crates-io]
glium = { git = "https://github.com/retrofoundry/glium", branch = "helix" }
Expand Down
19 changes: 7 additions & 12 deletions src/gui/gui_glium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{ffi::CStr, result::Result::Ok, time::Instant};
use winit::platform::run_return::EventLoopExtRunReturn;

use crate::gamepad::manager::GamepadManager;
use fast3d::graphics::GraphicsIntermediateDevice;
use fast3d::output::RCPOutput;
use fast3d::rcp::RCP;
use fast3d::rdp::OutputDimensions;

Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct Gui<'a> {

// game renderer
rcp: RCP,
pub intermediate_graphics_device: GraphicsIntermediateDevice,
pub rcp_output: RCPOutput,
graphics_device: GliumGraphicsDevice<'a>,
}

Expand Down Expand Up @@ -125,7 +125,7 @@ impl<'a> Gui<'a> {
draw_windows_callback: Box::new(draw_windows),
gamepad_manager,
rcp: RCP::default(),
intermediate_graphics_device: GraphicsIntermediateDevice::default(),
rcp_output: RCPOutput::default(),
graphics_device: GliumGraphicsDevice::default(),
})
}
Expand Down Expand Up @@ -248,7 +248,7 @@ impl<'a> Gui<'a> {
}

fn render_game(&mut self, target: &mut Frame) -> Result<()> {
for draw_call in &self.intermediate_graphics_device.draw_calls {
for draw_call in &self.rcp_output.draw_calls {
assert!(!draw_call.vbo.vbo.is_empty());

self.graphics_device.set_cull_mode(draw_call.cull_mode);
Expand All @@ -272,11 +272,7 @@ impl<'a> Gui<'a> {
// loop through textures and bind them
for (index, hash) in draw_call.textures.iter().enumerate() {
if let Some(hash) = hash {
let texture = self
.intermediate_graphics_device
.texture_cache
.get_mut(*hash)
.unwrap();
let texture = self.rcp_output.texture_cache.get_mut(*hash).unwrap();
self.graphics_device
.bind_texture(&self.display, index, texture);
}
Expand Down Expand Up @@ -313,8 +309,7 @@ impl<'a> Gui<'a> {
self.graphics_device.start_frame(&mut frame);

// Run the RCP
self.rcp
.run(&mut self.intermediate_graphics_device, commands);
self.rcp.run(&mut self.rcp_output, commands);
self.render_game(&mut frame)?;

// Finish rendering
Expand All @@ -324,7 +319,7 @@ impl<'a> Gui<'a> {
self.render(&mut frame)?;

// Clear the draw calls
self.intermediate_graphics_device.clear_draw_calls();
self.rcp_output.clear_draw_calls();

// Swap buffers
frame.finish()?;
Expand Down
11 changes: 3 additions & 8 deletions src/gui/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ impl HelixWindows for Ui {
));

let total_tris = gui
.intermediate_graphics_device
.rcp_output
.draw_calls
.iter()
.fold(0, |acc, draw_call| acc + draw_call.vbo.num_tris);

self.text(format!(
"{} draw calls, {} vertices ({} triangles)",
gui.intermediate_graphics_device.draw_calls.len(),
gui.rcp_output.draw_calls.len(),
total_tris * 3,
total_tris,
));
Expand All @@ -43,12 +43,7 @@ impl HelixWindows for Ui {

if CollapsingHeader::new("Draw Calls").build(self) {
self.indent();
for (i, dc) in gui
.intermediate_graphics_device
.draw_calls
.iter()
.enumerate()
{
for (i, dc) in gui.rcp_output.draw_calls.iter().enumerate() {
TreeNode::new(format!("Draw Call: {}", i), self).build(|| {
self.text(format!("Viewport: {}", dc.viewport));
self.text(format!("Scissor: {:?}", dc.scissor));
Expand Down

0 comments on commit da50140

Please sign in to comment.