Skip to content
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

Pipelined-rendering performance #3052

Open
molikto opened this issue Oct 30, 2021 · 9 comments
Open

Pipelined-rendering performance #3052

molikto opened this issue Oct 30, 2021 · 9 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times O-MacOS Specific to the MacOS (Apple) desktop operating system P-Regression Functionality that used to work but no longer does. Add a test for this!

Comments

@molikto
Copy link
Contributor

molikto commented Oct 30, 2021

Bevy version

c5af133

Operating system & version

macOS Catalina, 10.15.7
AdapterInfo { name: "AMD Radeon RX 5700 XT", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Metal }

What you did

test file for old renderer:

use bevy::{
    DefaultPlugins,
    diagnostic::*,
    app::prelude::*,
    asset::prelude::*,
    ecs::prelude::*,
    math::prelude::*,
    pbr::{*, prelude::*},
    render::prelude::*,
    transform::prelude::*};



pub fn setup(
  mut commands: Commands,
  mut meshes: ResMut<Assets<Mesh>>,
  mut materials: ResMut<Assets<StandardMaterial>>,
) {
  let size = UVec3::new(20, 20, 20);
  for x in 1..size[0] - 1 {
      for y in 1..size[1] - 1 {
          for z in 1..size[2] - 1 {
              for p in 0..3 {
                  let material = materials.add(StandardMaterial {
                      unlit: true,
                      ..Default::default()
                  });
                  commands
                      .spawn_bundle(PbrBundle {
                          mesh: meshes.add(Mesh::from(shape::Cube {
                              size: 1.0,
                          })),
                          material: material.clone(),
                          transform: Transform {
                              translation: Vec3::new(
                                  x as f32 + 0.5,
                                  y as f32 + 0.5,
                                  z as f32 + 0.5,
                              ),
                              ..Default::default()
                          },
                          ..Default::default()
                      });
              }
          }
      }
  }
  commands
    .spawn_bundle(PerspectiveCameraBundle {
        transform: Transform::from_translation(size.as_f32() * 1.1).looking_at(Vec3::ZERO, Vec3::Y),
        ..Default::default()
    });
  commands.insert_resource(AmbientLight {
      color: Color::ORANGE_RED,
      brightness: 0.02,
  });
}


pub fn main() {
  App::new()
      .add_plugins(DefaultPlugins)
       .add_plugin(LogDiagnosticsPlugin::default())
       .add_plugin(FrameTimeDiagnosticsPlugin::default())
      .add_startup_system(setup)
      .run();
}

test file for new renderer:

use bevy::{
    PipelinedDefaultPlugins,
     app::prelude::*,
      asset::prelude::*,
       diagnostic::*,
        ecs::prelude::*,
         math::prelude::*,
          pbr2::*,
           render2::{camera::PerspectiveCameraBundle, color::Color, mesh::{Mesh, shape}},
            transform::prelude::*
        };



pub fn setup(
  mut commands: Commands,
  mut meshes: ResMut<Assets<Mesh>>,
  mut materials: ResMut<Assets<StandardMaterial>>,
) {
  let size = UVec3::new(20, 20, 20);
  for x in 1..size[0] - 1 {
      for y in 1..size[1] - 1 {
          for z in 1..size[2] - 1 {
              for p in 0..3 {
                  let material = materials.add(StandardMaterial {
                      unlit: true,
                      ..Default::default()
                  });
                  commands
                      .spawn_bundle(PbrBundle {
                          mesh: meshes.add(Mesh::from(shape::Cube {
                              size: 1.0,
                          })),
                          material: material.clone(),
                          transform: Transform {
                              translation: Vec3::new(
                                  x as f32 + 0.5,
                                  y as f32 + 0.5,
                                  z as f32 + 0.5,
                              ),
                              ..Default::default()
                          },
                          ..Default::default()
                      });
              }
          }
      }
  }
  commands
    .spawn_bundle(PerspectiveCameraBundle {
        transform: Transform::from_translation(size.as_f32() * 1.1).looking_at(Vec3::ZERO, Vec3::Y),
        ..Default::default()
    });
  commands.insert_resource(AmbientLight {
      color: Color::ORANGE_RED,
      brightness: 0.02,
  });
}


pub fn main() {
  App::new()
      .add_plugins(PipelinedDefaultPlugins)
       .add_plugin(LogDiagnosticsPlugin::default())
       .add_plugin(FrameTimeDiagnosticsPlugin::default())
      .add_startup_system(setup)
      .run();
}

my results:

    // 3*20^3
    // Oct 30 13:52:58.313  INFO bevy diagnostic: fps                             :    7.408413  (avg 7.417044)
    // 3*10^3
    // Oct 30 13:53:54.464  INFO bevy diagnostic: fps                             :   60.049122  (avg 59.930744)
    // rendering_test::main();

    // 3*20^3
    // Oct 30 13:52:14.582  INFO bevy diagnostic: fps                             :    4.563918  (avg 4.635602)
    // 3*10^3
    // Oct 30 13:54:40.295  INFO bevy diagnostic: fps                             :    5.064065  (avg 5.013634)

What you expected to happen

new renderer to be faster

What actually happened

new renderer is slower

@molikto molikto added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 30, 2021
@TheRawMeatball
Copy link
Member

Is size being 10^3 for the old renderer a typo?

@molikto
Copy link
Contributor Author

molikto commented Oct 30, 2021

Is size being 10^3 for the old renderer a typo?

I changed it manually to test different sizes.

@rparrett
Copy link
Contributor

I am seeing very similar results with

MacOS 11.2.3
AdapterInfo { name: "AMD Radeon Pro 560X", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Metal }

@rparrett
Copy link
Contributor

rparrett commented Oct 30, 2021

Is this metal-specific? On my other machine I see

Oct 30 08:35:10.667  INFO bevy_render2::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 1660", vendor: 4318, device: 8580, device_type: DiscreteGpu, backend: Vulkan }

old
Oct 30 08:31:20.348  INFO bevy diagnostic: frame_time                      :    0.078404s (avg 0.078207s)
Oct 30 08:31:20.349  INFO bevy diagnostic: fps                             :   12.172581  (avg 12.418601)
Oct 30 08:31:20.350  INFO bevy diagnostic: frame_count                     :  187.000000  (avg 187.000000)

new
Oct 30 08:35:38.768  INFO bevy diagnostic: frame_time                      :    0.066500s (avg 0.067083s)
Oct 30 08:35:38.844  INFO bevy diagnostic: fps                             :   14.853039  (avg 14.893850)
Oct 30 08:35:38.847  INFO bevy diagnostic: frame_count                     :  402.000000  (avg 402.000000)

And also these lines, which didn't show up on the macbook.

Oct 30 08:35:11.111  INFO naga::back::spv::writer: Skip function Some("fetch_point_shadow")
Oct 30 08:35:11.111  INFO naga::back::spv::writer: Skip function Some("fetch_directional_shadow")

@mockersf
Copy link
Member

mockersf commented Oct 30, 2021

On my Mac, disabling vsync, example pbr runs at 58fps in release mode, and pbr_pipelined runs at 32fps (with vsync enabled, everything tops at 30fps)

Oct 30 19:13:22.023  INFO bevy_render2::renderer: AdapterInfo { name: "Intel(R) Iris(TM) Plus Graphics 655", vendor: 0, device: 0, device_type: IntegratedGpu, backend: Metal }

@cart
Copy link
Member

cart commented Nov 1, 2021

Yeah so far we're only seeing repros from metal users. This is definitely worth investigating prior to the 0.6 release. Given that our sprite rendering pipeline (which performs pretty well) uses pretty much the same renderer abstractions as our pbr pipeline, I have a feeling that this is something specific to how the pbr pipeline is implemented, but I guess we'll find out! I'll start poking around. I have mac/linux/windows machines to test on.

@mockersf
Copy link
Member

mockersf commented Nov 2, 2021

I now have access to a m1 Mac, both pbr and pbr_pipelined run around 170 fps on it. The example from this issue runs at 22fps (old) / 18fps (pipelined)

Nov 02 12:25:26.041  INFO bevy_render2::renderer: AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Metal }

@TheRawMeatball TheRawMeatball added A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times P-Regression Functionality that used to work but no longer does. Add a test for this! O-MacOS Specific to the MacOS (Apple) desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Nov 2, 2021
@drhaynes
Copy link

drhaynes commented Nov 16, 2021

Just to add my experience; possibly related - I'm seeing poor performance on an M1 Mac on Big Sur, running @cart 's bevymark_pipelined example:

bevy_render2::renderer: AdapterInfo { name: "Apple M1", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Metal }

Screenshot 2021-11-16 at 14 15 14

@james7132
Copy link
Member

james7132 commented Feb 19, 2024

Is this still an issue? We've moved significantly in terms of the end-to-end engine performance and specifically the renderer in the releases since 0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times O-MacOS Specific to the MacOS (Apple) desktop operating system P-Regression Functionality that used to work but no longer does. Add a test for this!
Projects
None yet
Development

No branches or pull requests

7 participants