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

Rendering optimization notes #428

Open
omni-viral opened this Issue Oct 18, 2017 · 25 comments

Comments

Projects
3 participants
@omni-viral
Member

omni-viral commented Oct 18, 2017

Here we may put our notes and ideas about rendering optimizations.
I'll start with a few.

  • Cache constant buffers. Don't update if not modified.
    With help of slide-rs/specs#291.
  • Use indexed meshes to reuse vertices.
  • Move to gfx_hal
  • Mark static geometry.
    • Batch it. Reuse secondary command buffers. Optimize static lighting.
  • Discard meshes that falls out of cameras frustum. Mesh is required to have known AABB.
    • collision-rs can help to optimize it further.
@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

I would do frustum culling in user space, and make it possible to use a marker component for visibility

Member

Rhuagh commented Oct 18, 2017

I would do frustum culling in user space, and make it possible to use a marker component for visibility

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member
pub struct Visible;

impl Component for Visible {
    type Storage = NullStorage<Visible>;
}

and use that in the join in the passes.

Member

Rhuagh commented Oct 18, 2017

pub struct Visible;

impl Component for Visible {
    type Storage = NullStorage<Visible>;
}

and use that in the join in the passes.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

Or maybe the opposite would be better, NotVisible and !NotVisible in Join, that way those that don't care about frustum culling don't need to do anything.

Member

Rhuagh commented Oct 18, 2017

Or maybe the opposite would be better, NotVisible and !NotVisible in Join, that way those that don't care about frustum culling don't need to do anything.

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

@Rhuagh Wouldn't it be nicer to do visibility query in renderer? Consider multicamera setup

Member

omni-viral commented Oct 18, 2017

@Rhuagh Wouldn't it be nicer to do visibility query in renderer? Consider multicamera setup

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

It's a fairly expensive procedure, and something that I consider optional.

Member

Rhuagh commented Oct 18, 2017

It's a fairly expensive procedure, and something that I consider optional.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

If you have 8 meshes in total, you're gonna lose performance by doing it.

Member

Rhuagh commented Oct 18, 2017

If you have 8 meshes in total, you're gonna lose performance by doing it.

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

I agree on that frustum culling should be optional.
But I'm not agree about using marker components for this purpose.
It's better to query visible meshes from Camera + Transform + SpecialSortedStructure. Probably with some caching.

Member

omni-viral commented Oct 18, 2017

I agree on that frustum culling should be optional.
But I'm not agree about using marker components for this purpose.
It's better to query visible meshes from Camera + Transform + SpecialSortedStructure. Probably with some caching.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

I don't agree.

With user space culling we allow the user to come up with their own culling techniques without having to duplicate our pass code. Some users may need occlusion culling, z-culling, frustum culling, distance culling. I don't think we should add all of those culling techniques to the renderer crate, but provide systems that can do these things externally.

Member

Rhuagh commented Oct 18, 2017

I don't agree.

With user space culling we allow the user to come up with their own culling techniques without having to duplicate our pass code. Some users may need occlusion culling, z-culling, frustum culling, distance culling. I don't think we should add all of those culling techniques to the renderer crate, but provide systems that can do these things externally.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

And by putting it in user space, we also enable the user to use the visibility data for their own systems.

Member

Rhuagh commented Oct 18, 2017

And by putting it in user space, we also enable the user to use the visibility data for their own systems.

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

Good point. But still those culling methods results are local to camera.

Member

omni-viral commented Oct 18, 2017

Good point. But still those culling methods results are local to camera.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

Some are yes, some aren't. Distance culling for instance can be done without the full camera matrix, you only need the position of the camera (or the controller entity, which might be a different entity).

Member

Rhuagh commented Oct 18, 2017

Some are yes, some aren't. Distance culling for instance can be done without the full camera matrix, you only need the position of the camera (or the controller entity, which might be a different entity).

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

I mean that for another camera you have another results

Member

omni-viral commented Oct 18, 2017

I mean that for another camera you have another results

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

Sure. My point is that it should be up to the user to decide what culling to use, and where, so they can reuse the results of the culling themselves if needed.

Member

Rhuagh commented Oct 18, 2017

Sure. My point is that it should be up to the user to decide what culling to use, and where, so they can reuse the results of the culling themselves if needed.

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

Maybe we can have Culled attached to Camera. And in this component will be bitset with bits set to meshes culled by any technique.

Member

omni-viral commented Oct 18, 2017

Maybe we can have Culled attached to Camera. And in this component will be bitset with bits set to meshes culled by any technique.

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

If nobody fills Culled for specific Camera then renderer will render all meshes

Member

omni-viral commented Oct 18, 2017

If nobody fills Culled for specific Camera then renderer will render all meshes

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

Possibly, I'm not sure what the performance/usability difference would be.

Member

Rhuagh commented Oct 18, 2017

Possibly, I'm not sure what the performance/usability difference would be.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

But it's not a bad idea.

Member

Rhuagh commented Oct 18, 2017

But it's not a bad idea.

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

Difference with what approach?

Member

omni-viral commented Oct 18, 2017

Difference with what approach?

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

Using components.

Member

Rhuagh commented Oct 18, 2017

Using components.

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

It should be close to marker component in performance. And allows multiple cameras

Member

omni-viral commented Oct 18, 2017

It should be close to marker component in performance. And allows multiple cameras

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

That's a good point.

Member

Rhuagh commented Oct 18, 2017

That's a good point.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

I reordered the comment above btw, to reflect what I think is a good order to do the improvements in :)

Member

Rhuagh commented Oct 18, 2017

I reordered the comment above btw, to reflect what I think is a good order to do the improvements in :)

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

I agree with this order. I was writing them in the same order they were coming in my mind 😄

Member

omni-viral commented Oct 18, 2017

I agree with this order. I was writing them in the same order they were coming in my mind 😄

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 18, 2017

Member

@Rhuagh There is already an issue about skinning. This one is about optimizations we can add into renderer.

Member

omni-viral commented Oct 18, 2017

@Rhuagh There is already an issue about skinning. This one is about optimizations we can add into renderer.

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Oct 22, 2017

Member

Caching should be easy soon:

slide-rs/specs#291

Look at the tracked example.

Member

torkleyy commented Oct 22, 2017

Caching should be easy soon:

slide-rs/specs#291

Look at the tracked example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment