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

Use pointers to State structures. #135

Closed
azul3d-bot opened this issue Mar 6, 2016 · 1 comment
Closed

Use pointers to State structures. #135

azul3d-bot opened this issue Mar 6, 2016 · 1 comment

Comments

@azul3d-bot
Copy link

Issue by slimsag
Sunday Dec 28, 2014 at 20:58 GMT
Originally opened as azul3d-legacy/gfx#83


As of right now State is a ~140 byte structure. Most gfx.Object will utilize the same state (as it lowers the number of state changes).

If we turn Object.State into a pointer instead of a value -- we get the following benefits:

  • Less memory usage.
  • Faster state guarding (i.e. checking if two objects have the same exact state is a simple pointer comparison).
  • Reuse of gfx.State object's using a sync.Pool

We would turn gfx.State into more traditional objects:

  • gfx.DefaultState would be replaced by gfx.NewState()
  • State.Destroy() would put the object back in the sync.Pool.
  • Methods (State.Compare) would become pointer receivers.
  • A new State.Copy method.

Overall I think this will be a big plus.

@azul3d-bot
Copy link
Author

Fixed/merged as part of #1

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

No branches or pull requests

1 participant