Skip to content

Commit

Permalink
chore(fix): render data cache
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Jul 18, 2023
1 parent b8d8e08 commit 0e356de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Add this library to your project and one of the following renderers: `fast3d-wgp
The library consists of three main components:

- `RCP` - This represents the N64 RCP and provides a reset and a `process_dl` method.
- `RenderData` - This is the output returned after processing a display list.
- `RenderData` - This is given to the RCP run command that collects draw data and textures for rendering with different renderers.
- `WgpuRenderer` - This is a renderer that can be used to render data produced
- `GliumRenderer` - This is a renderer that can be used to render data produced

Expand Down
8 changes: 5 additions & 3 deletions examples/triangle/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use f3dwgpu::WgpuRenderer;
use fast3d::rdp::{OutputDimensions, SCREEN_HEIGHT, SCREEN_WIDTH};
use fast3d::RCP;
use fast3d::{RCP, RenderData};
use fast3d_gbi::defines::color_combiner::G_CC_SHADE;
use fast3d_gbi::defines::f3dex2::{GeometryModes, MatrixMode, MatrixOperation};
use fast3d_gbi::defines::{
Expand Down Expand Up @@ -70,6 +70,7 @@ impl<F: Future<Output = Option<wgpu::Error>>> Future for ErrorFuture<F> {

struct Example<'a> {
rcp: RCP,
render_data: RenderData,
renderer: WgpuRenderer<'a>,

depth_texture: wgpu::TextureView,
Expand Down Expand Up @@ -235,6 +236,7 @@ impl fast3d_example::framework::Example for Example<'static> {

Self {
rcp,
render_data: RenderData::default(),
renderer: WgpuRenderer::new(device, [config.width, config.height]),

depth_texture: Self::create_depth_texture(config, device),
Expand Down Expand Up @@ -337,11 +339,11 @@ impl fast3d_example::framework::Example for Example<'static> {
});

// Run the RCP
let mut render_data = self.rcp.process_dl(draw_commands_ptr as usize);
self.rcp.process_dl(draw_commands_ptr as usize, &mut self.render_data);

// Process the RCP output
self.renderer
.process_rcp_output(device, queue, self.surface_format, &mut render_data);
.process_rcp_output(device, queue, self.surface_format, &mut self.render_data);

// Draw the RCP output
self.renderer.draw(&mut rpass);
Expand Down
10 changes: 3 additions & 7 deletions fast3d/src/rcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ impl RCP {
/// render list and process until it hits a final `G_ENDDL`.
/// Returns a `RenderData` struct containing graphics data that
/// can be used to render.
pub fn process_dl(&mut self, commands: usize) -> RenderData {
pub fn process_dl(&mut self, commands: usize, output: &mut RenderData) {
self.reset();

let mut output = RenderData::new();
self.run_dl(&mut output, commands);
self.rdp.flush(&mut output);

output
self.run_dl(output, commands);
self.rdp.flush(output);
}

fn run_dl(&mut self, output: &mut RenderData, commands: usize) {
Expand Down

0 comments on commit 0e356de

Please sign in to comment.