• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
590
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Data-Oriented Design
    @Neku42
    max.klyga@gmail.com
  • 2.
  • 3. Unreasoned
    OOD
  • 4.
  • 5. PROGRAM
    DATA
    DATA
  • 6. Good code follows good data, not the other way around.
  • 7. class Bot
    {
    Vector3 position;

    float mod;

    float aimDirection;

    voidUpdateAim(Vector3 target)
    {
    aimDirection = Vector3.DotProduct(position, target) * mod;
    }
    }
  • 8. class Bot
    {
    Vector3 position;

    float mod;

    float aimDirection;

    voidUpdateAim(Vector3 target)
    {
    aimDirection = Vector3.DotProduct(position, target) * mod;
    }
    }
    Icache-miss
  • 9. class Bot
    {
    Vector3 position;

    float mod;

    float aimDirection;

    voidUpdateAim(Vector3 target)
    {
    aimDirection = Vector3.DotProduct(position, target) * mod;
    }
    }
    Icache-miss
    data-miss
  • 10. class Bot
    {
    Vector3 position;

    float mod;

    float aimDirection;

    voidUpdateAim(Vector3 target)
    {
    aimDirection = Vector3.DotProduct(position, target) * mod;
    }
    }
    U
    N
    U
    S
    E
    D
    Icache-miss
    data-miss
  • 11.





  • 12. Array of Structures
    Structure of Arrays
    class Bot
    {
    Vector3 position;

    float mod;

    float aimDirection;

    }
    List<Bot> bots;
    class Bots
    {
    List<Vector3> positions;

    List<float> mods;

    List<float> aimDirections;

    }
  • 13. class Bot
    {

    voidUpdateAim(Vector3 target)
    {
    aimDirection = Vector3.DotProduct(position, target) * mod;
    }
    }
    class Bots
    {

    staticvoidUpdateAims(List<float> aimDirections,
    List<Vector3> positions, List<float> mods, List<Vector3> targets)
    {
    for (uint i = 0; i < aimDirections.Count; ++i)
    aimDirections[i] = Vector3.DotProduct(positions[i], targets[i]) * mods[i];
    }
    }
  • 14. Know the data!Think! Think! Think!
  • 15. It’s all about memory
    Optimize for data not code
  • 16. It’s all about memory
    Optimize for data not code
    Most code is mostly bound to memory access
  • 17. It’s all about memory
    Optimize for data not code
    Most code is mostly bound to memory access
    Not everything needs to be an object
  • 18. Data-Oriented Design:
    Better performance
  • 19. Data-Oriented Design:
    Better performance
    Often simpler code
  • 20. Data-Oriented Design:
    Better performance
    Often simpler code
    More parallelizable code
  • 21. Questions?
  • 22. http://slidesha.re/hKF9er