Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Jan 2005
Offline Last Active Apr 03 2013 04:30 AM

Topics I've Started

How does clipping fit into the pipeline?

21 September 2012 - 06:07 AM

Hello everybody, I'm trying to figure out how to implement clipping in my code. My understanding is that when a triangle crosses a clipping plane (ie the frustum), new vertices are added to avoid disappearing triangles artifacts. This is done on the CPU (correct?), and any object is eligible for clipping. But my question is: doesn't this make GL_STATIC_DRAW flag utopic? I mean, an object standing on the screen border gets clipped every frame, so its vertex data is far from being static (new vertices added and removed continuously).
Moreover, how does it fit with skinned meshes or any other GPU-generated vertices? Anyone got a good reference on clipping? All I've managed to find is either abstract theory or very basic examples.

Authentication on Facebook

04 September 2012 - 12:23 PM

Hello everybody, I need to write some code to make our game perform some actions on Facebook. The game is multiplatform (iOS, MacOSX, Win32, Linux) and is mainly written in c++. We can do http and https communication, and it's ok to invoke platform-specific functions such as ShellExecute from win32.

I've searched the net fo days now, and it seems to me I need a so called "access token" in order to do anything. The question is: how do I get such token? I've seen thousands of examples in php and .net, but all of them are under the assumption the game is a browser game. Our game is a stand-alone binary. Any help on how to get a signed request, an access token, a code or whatever is needed would be very helpful.

As far as I can tell, we need access to the user's friends list and the ability to post pictures on his behalf.

Bind single-threaded apps to a single core

16 February 2012 - 10:01 AM

Hello guys, I'm working on an old game that needs to be ported to modern windows systems. The game is single-threaded, and one of the bugs they assigned to me is to bind the main thread to a fixed core on multi-core cpus. While this should be easy enough, I was wondering if there would really be a good reason for that, and how it may affect the performance and the os. Should I really do that?

Edit: As I said it's an old game, so extreme performance is not an issue at all. Cache misses due to core swapping are hardly a concern.

Strict aliasing rule and memory allocation

17 December 2011 - 07:08 PM

Hello, today I was writing some container class that pre-allocates uninitialized memory and uses placement new when needed. After a long search, I realized I can't possibly do that due to the strict aliasing rule.

To my understanding, void* can be casted to something else only if the original variable holding the pointer to void has not been casted to something else yet. So:

void* myMem = malloc(sizeof(int) * 5);
int* a = (int*) myMem; // OK
short int* b = (short int*) myMem; //WRONG

Is this correct?

If so, writing a stack-based allocator is impossible, or is there any technique I don't know of to achieve that? I'd like to get the equivalent of the following (incorrect) code:

void* StackAlloc(int size) {
    static char mem[64];
    static int used = 0;
    void* ret = mem + used;
    used += size;
    return ret;

From what I gathered, this is only valid if client code casts the returned pointer back to a char. Note that I'm aware of the alignment issues, but this is just a simplified example.

From this discussion with Linus I take it I should disable the no aliasing optimization for the memory lib, but most of the code is templated so I should disable that optimization for every client of the memory lib. From that same discussion understand that the gain in performance and code size is very small to be generous. Do you think I should go ahead and disable said optimization? If so, will I find a way to do the same on compilers other than gcc (ie: Visual Studio), or will I end up with non-standard unportable code? 

Optimizations in debug

15 December 2011 - 03:22 AM

Recently I rewrote the matrix class we use here at work. The old one was really a collection of classes, like matrix4x4, matrix4x3 etc, a very long copy and paste with little changes here and there. My approach was to go template.

Being this the case, the old multiplication code was a manually unrolled loop, like a00 * b00 + a01 * b10 etc, while the new one is the more classical and generic "3 nested loops". Now, the generated optimized code is many times faster than the old code, which is cool. The problem is that in debug mode all the loops are kept, no inlining is performed and the resulting code is 6-7 times slower than the old one (which was already slow due to the many cache misses).

I know that debug is normally slower than release, but in order to keep the framerate at an acceptable rate for the others I'd like my code to be a bit faster in debug. I thought I could surround my function with a #pragma optimize, but that would be VS-specific and maybe there are other downsides I'm not aware of. Any suggestion?

I'm seeing if I can use SIMD intrinsics instead, but I'm not sure I'll get to do that due to some issues with our allocator and the 16-bytes alignment.