Choice of code design

Discussion in 'Game Development (Technical)' started by lordmetroid, Aug 25, 2007.

  1. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    I doubt it. John worries about performance all the time, but if he's spending his development hours on getting 600 FPS instead of 500 FPS, I don't see why he should. 60 FPS instead of 50 FPS I can see, as it's within the realm of the visible.

    I'm usually concerned with minimizing the number of billable hours to the client. If I can meet the client's need without writing efficient or reusable code, I do so. If later on they decide they want it efficient and/or reusable, they can pay me more for that. I'm not hoodwinking them, as vetting an actual working design makes it easier to figure out what is actually efficient or reusable. When requirements change, they waste a lot of optimization work.
     
  2. jlv

    jlv New Member

    Joined:
    Feb 8, 2007
    Messages:
    78
    Likes Received:
    0
    Wow that's a lot of polygons. Six per pixel at 1024x768. I assume you're using some sort of varying level of detail to keep the polygon area somewhat constant, so why is the count so high?
     
  3. jlv

    jlv New Member

    Joined:
    Feb 8, 2007
    Messages:
    78
    Likes Received:
    0
    So you aren't so much against having a method called ::draw(), you are against putting that method on a high level class. Spaceship::draw() is bad, but Mesh::draw() is fine provided you sort the meshes beforehand to minimize state changes, correct?

    Otherwise, I'm wondering what the heck you call your mesh drawing function.
     
  4. HairyTroll

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    582
    Likes Received:
    0
    An alternative to baking the ::draw() functionality into each game object class is to use mixins. A Mesh::draw() mixin, Nurbs::draw() mixin and Particles::draw() mixin would encapsulate the various mechanisms for drawing objects. Then just add these to each game object as needed.
     
  5. Huge

    Original Member

    Joined:
    Sep 22, 2005
    Messages:
    142
    Likes Received:
    0
    I must admit, I'm a bit Old Skool. But I have finally got over it. I just have to remember that nowdays, for 2D games, nice code trumps performance, by a HUGE margin. This goes against my upbringing, but when you see 5% cpu usage when running 60fps, you know optimisation is a waste of your lifeforce.
     
  6. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Actually, I meant per second. lol. You can get that sort of throughput out of a 360 per frame, but not with the length of shaders I have on them.

    Just one more go. I'm not talking about optimisation, I'm talking about writing efficient code.

    I'm giving up now as my forehead is starting to hurt. I know when I'm beaten and the bottom line is I don't really care if other people are happy to write sloppy code. This thread was about advising someone how to learn C++ quickly.
     
  7. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    Number of move/draw/collides called per frame: a couple of hundred probably.
    Number of polygons blitted per frame: a rather unrealistic 9GB bandwidth/sec.
    Apart from the fact your figures are imaginary, you've not even noticed that the bottleneck will be at the rendering pipeline not the game logic! To the back of the class, boy!

    Cas :)
     
  8. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Yeah, you're right.

    I'm an abject liar who knows nothing about nothing. Just take whatever I say and invert it if you don't like it. I mean, what do I know....
     
  9. Michael Flad

    Indie Author

    Joined:
    Aug 4, 2004
    Messages:
    190
    Likes Received:
    0
    IMO one has to differentiate between premature optimizations where I guess we all agree that it's usually a potential waste of time and mature optimization where you just use your knowledge/experience.

    Most of us do this all day it's just the level of experience where it differs - I guess f.i. almost all of us won't use a list if random access is what's going to be the bottleneck with whatever problem you're solving ...

    If you know your problemspace and what's an efficient solution (i.e. cachefriendly memory layout, an efficient datastructure regarding the algorithms used ...) - there's no reason to not use mature optimizations wherever your really know what you're doing.
     
  10. MedievalElks

    MedievalElks New Member

    Joined:
    Jul 25, 2006
    Messages:
    82
    Likes Received:
    0
    Who advocated writing sloppy code?
     
  11. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    Where did 5m polygons per frame come from? That's 9GB/sec bandwidth - even if the bus could cope, could the CPU hope to fill it?

    Cas :)
     
  12. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    That would be me. If sloppy / throwaway code solves the problem for the client in the shortest time / at minimum cost, I do it. Also, I would write the list for the supposedly random memory access problem, if that's the fastest way to express the prototype design. I don't anticipate bottlenecks anymore. Generally that has led me to overengineer. I don't think people fully appreciate what the You Ain't Gonna Need It philosophy implies.

    My current GMake --> CMake conversion script is a linear pile of regexes applied over and over again. It's redundant as all sin. But you know what? On a 11K text input you can't tell, it runs in 1 second anyways. On a 64K input I am noticing slowdowns, but you know what? Once it all finally works, the script will be executed once. The translation output is what matters, the translator will be thrown away. So unless it starts taking really long amounts of time to do its thing, I'm not going to even think about making it less sloppy.

    In a previous life I worried about 1.5 million hex maps of Mars. It was an erroneous design. How is a player supposed to visualize or manipulate so many hexes? There is neither screen space nor play time for it.
     
  13. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    You're assuming an awful lot of bytes per polygon. Not valid for shader HW.
     
  14. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    Even at the minimum bytes per polygon, which'd be 12 I'd imagine for 3 floats, that's still 3GB/sec. Either way I think you've just highlighted why "facts and figures" quoted in forum discussions like this are really an exchange of ignorance and not knowledge.

    Cas :)
     
  15. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    Nobody said it's all dynamic content, or unique content.
     
  16. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
  17. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    It has a RISC CPU. load, compute, store is the RISC drill, unlike Intel.
     
  18. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Actually I Said It Was A Mistake And I Meant Per Second. You Can Read It Above For Fucks Sake.

    However, Just To Make Me Look Really Stupid/ignorant/bad, I'll Stand By The Fact That I Could Make An X360 Do 5m Tris Per Frame At 60hz. Because I Do Actually Know What The Fuck I'm Talking About.........

    Edit: Who turned off my caps. That was meant to be all in SHOUTING
     
  19. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    But if you pass vectors around in registers and don't save them to memory you shouldn't get *any*. I think it's a compiler bug tbh (as there should be no 'hit' part), but still something that needs working around.
     
  20. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    One of those days eh?

    I still don't think you've grasped what I'm alluding to here. I think I made a comment back there somewhere about "this sounds like the design of a really cool thing that does a wotsit".

    Cas :)
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer