Tag Info

Hot answers tagged

37

For example having a GameObject base class with a deep inheritance hierarchy could be good for maintenance... Actually, deep hierarchies are generally worse for maintainability than shallow ones, and the modern architectural style for game objects is trending towards shallowing, aggregation-based approaches. However I think this approach can ...


34

To say "Python is slow compared to C++" is a generalization that ignores a lot of real-world practicalities and is usually a poor kind of judgement to rely on. What you really want to do is look at what a particular language or technology can bring to the table in terms of your needs and, similarly, evaluate any potential downfalls of that technology against ...


32

The large penalty from mixing ints (of any kind) and floats is because these are in different register sets. To go from one register set to the other, you have to write the value to memory and read it back, which incurs a a load-hit-store stall. Going between different sizes or signed-ness of ints keeps everything in the same register set, so you avoid the ...


27

The reason that most systems (even many modern graphics cards) demand power-of-2 textures is mipmapping. What is mipmapping? Smaller versions of the image will be created in order to make the thing look correctly at a very small size. The image is divided by 2 over and over to make new images. So, imagine a 256x128 image. This would have smaller versions ...


26

Console: static hardware that never varies across every single iteration. Home PC: hardware that changes from day to day, with a million different chip designs. Console: closed system that lives in its own, secure environment from birth to death. Home PC: wild west, barroom brawls and your OS is the sheriff keeping everyone from getting shot. Carmack: ...


24

This would depend on the game and the indexing structure used for the chunks. Though, at such a high level, it's not too likely it has much to do with memory or a specific performance enhancement. More than likely it's an arbitrary decision for sizing chunks in a predictable way. It allows for some counting and indexing tricks using bit shifting that ...


16

Is there a substantial overhead to allocating / deallocating VBOs (I mean the mere act of setting up a buffer)? Define "substantial." It is generally wise not to create them in the middle of frames; they should be set up during initialization or wherever. But this is true of most OpenGL objects, like textures, renderbuffers, or shaders. If I'm ...


16

C++ does everything C does. You can trivially mix C and C++ in cases where the advantages of C outweigh those of C++. This is a very intentional design decision of C++. C++ does things that C does not. This includes easy polymorphism, but also easy compile time code generation via templates. This is really handy for things like containers, which are ...


15

Direct3D drivers on Windows are ridiculously optimized, sometimes for specific games, and developed by individual hardware vendors. Apple's OpenGL drivers are written and maintained (AFAIK) by Apple, and are intended for "general" OS use, compositing the UI and whatnot. There's no so much optimization for gaming and high-performance throughput. Basically, ...


15

Luckily, as you pointed out, the COMPACT Mono builds use a generational GC (in stark contrast to the Microsoft ones, like WinMo/WinPhone/XBox, who just maintain a flat list). If your game is simple the GC should handle it just fine, but here are some pointers you might want to look into. Premature Optimization First make sure this is actually a problem ...


15

I like to think of performance in terms of "limits". It's a handy way to conceptualise a fairly complicated, interconnected system. When you have a performance problem, you ask the question: "What limits am I hitting?" (Or: "Am I CPU/GPU bound?") You can break it down into multiple levels. At the highest level you have the CPU and the GPU. You might be CPU ...


14

Yes, it is. Allocation time isn't the only factor. Allocation can have side-effects, such as inducing a garbage collection pass, which can not only impact performance negatively it can also impact performance unpredictably. The specifics of this will depend on your language and platform choices. Pooling also generally improves locality of reference for the ...


13

There are no real pros or cons here, at least none that should force a programmer comfortable in one language to have to use the other. Performance shouldn't be an issue. It's unlikely that you'd write any heavy lifting with lots of messaging in the inner loops if you're a good Obj-C programmer, which means you'll really be writing those inner loops in C. ...


13

The way OpenGL works, whenever you use non-VBO data, the driver has to make a copy of it - in practice creating a temporary VBO - since nothing stps you from modifying your user-space naked arrays between calls to OpenGL. There may be some driver-side trickery to make the temp allocation faster, but there's nothing you can do to avoid the copying. So yeah, ...


13

Use one of the common space partitioning algorithms, such as a Quadtree, Octree, BSP tree, or even a simple Grid System. Each has their own pros and cons for each specific scenario. You may read more about them in these books. Generally (or so I've heard, I'm not too familiar with the reasoning behind this) a Quadtree or Octree is better fit for outdoor ...


13

Is there any notable performance between Vector2s and Vector3s, for example when adding or multiplying them, or when calling Normalize, Transform, or Distance? Yes, you have one more coordinate so you will use more CPU cycles. But it is very unlikely that it will ever give you any trouble. XNA 4 is using SIMD extensions for vector math (EDIT: on ...


12

It just means that the game matches the refresh rate of the monitor/screen. So if you have a 60Hz monitor (meaning the monitor image is refreshed 60 times a second), the game won't perform above 60 FPS. If you have vertical synchronisation (vsync) turned off, then if the GPU and monitor go out of sync, then you get an artifact commonly known as "tearing" ...


12

First, multiplying by powers of two is much cheaper than multiplying by an arbitrary number, since you can do it by bit shifting. Most of the time the compiler can do this for you, so whenever you write "* 16" in your code, the compiler actually does a shift by four, and you don't need to worry about it - you just need to give the compiler the opportunity by ...


11

1. There is no general best practice. If you got a lot of (complex shaped) elements, particles etc. in your game, the bitmap buffer approach is going to be much faster. The bitmap buffer will also scale better with increasing complexity of your sprites. The vector renderer will become slower with more complex shapes or tween (shape tween) animations, it ...


11

It may be more useful to create a diagram showing frames per second over a period of time. Ideally this diagram contains annotations about what happened in the world, for example changes of areas, starting and ending of fights. In the sample diagram it is easy to see that the frame rate is a lot better in the home town than in the dungeon. And there seems ...


11

While I won't discount the optimization that Microsoft may have put into Windows and/or DirectX, I strongly believe that most programs perform better on Windows simply because that's what the developers focus on (that's where the money is). They make design decisions with Windows in mind, and then later try to make it work in other OSs (Mac, Linux, etc.). ...


10

You want a better communication protocol then HTTP. You probably want UDP or TCP. Browsers have no way of doing UDP communication so your only choice is TCP. For TCP you would want to use a WebSocket, however browser support is unstable on websockets. This means you would need to use a COMET technique to emulate TCP, one popular emulation would be a ...


9

Generally I've used a separate partition tree for static and dynamic objects, or just disregarded it altogether for dynamic objects. This provides the benefits of both worlds: Static objects require no recalculation of the tree each frame Dynamic objects only require the recalculation of a minimal tree If drawing your dynamic objects all the time doesn't ...


9

Seems almost as useful as a speed limit saying "2400 km/day" or "614400 km/year". Both are the same as "100 km/hour". From the mathematical standpoint it makes no difference, but we humans have a narrow perception and we can deal much better with smaller numbers and time-frames. If you throw 216,000+ FPH at me, I had no idea how long a frame is. If ...


9

What John Carmack really wants is to write his own graphics drivers. He lived and worked in the pre-Direct3D/OpenGL days, when the game was responsible for talking to every little piece of hardware that existed. AMD actually made a similar statement, about how APIs are getting in the way of high-end graphics. I don't know if Carmack's numbers are right, ...


9

You mention doing frustum culling on individual blocks — try throwing that out. Most rendering chunks should be either entirely visible or entirely invisible. Minecraft only rebuilds a display list/vertex buffer (I don't know which it uses) when a block is modified in a given chunk, and so do I. If you're modifying the display list whenever the view ...


9

It depends on the CPU in question, but for a modern CPU the list is something like this: Bitwise, addition, subtraction, comparison, multiplication Division Control flow (see answer 3) Depending on CPU there may be a considerable toll for working with 64 bit data types. Your questions: Not at all or not appreciably on a modern CPU. Depend on CPU. That ...


9

In terms of utility as a measurement for how good hardware is? Absolutely nothing Yes, it means thousands of triangles per second. But it means nothing in terms of how good hardware is. It's about as useful a performance metric as CPU clock-speeds: at best an order-of-magnitude approximation. These metrics are usually taken under ideal, benchmarking ...


9

This seems like a big misunderstanding on your part, and I think the comparison doesn't make much sense because in general they serve different purposes: Vertex shaders are executed once for every vertex in the geometry, and are used to modify or add new information to those vertices. For example, they can be used to slightly modify the position of the ...


8

My suggestion is to have your game communicate to a web service that you created that itself deals with querying the database. At that point, it's very simple to try different kinds of databases by "switching" web service implementations (your web service interface always stays the same so your game doesn't break) and decide which one is right for you. ...



Only top voted, non community-wiki answers of a minimum length are eligible