Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

Pink Horror

Member Since 02 Jul 2013
Offline Last Active Mar 27 2015 02:20 PM

Posts I've Made

In Topic: Global Consts

27 March 2015 - 08:22 AM


The number of vertices per quad? That constant has a standard name, which is `4'. smile.png

Unfortunately "4" can also be misread as the number of wheels on a shopping cart, so that's no good.

Better to just go with the unique name "NumVertsInQuad" and avoid readability issues tongue.png

(in other words "magic numbers" are the enemy of good code, avoid them)



Now I wouldn't be surprised to see someone make the variable NumVertsInQuadOrWheelsOnShoppingCart.

In Topic: SSE2 code slower than scalar

25 March 2015 - 12:23 PM

#define isAligned(p) (((unsigned long)(p)) & 15 == 0)


I think == has precedence over &.

In Topic: SSE2 code slower than scalar

25 March 2015 - 11:00 AM

It doesn't seem necessary to test for triangle visibility while rendering an octree or anything else. You could just rasterize those triangles and let the z-buffer take care of occlusion.


As for performance issues, you still have depth buffer comparison in non-SIMD code. Seems like you could use _mm_cmplt_ps / _mm_and_si128 / _mm_test_all_zeros to test 4 pixels at a time.


P.S. No need to do the 1/x division manually. There's _mm_rcp_ps.


It looks like he's doing some division (a / b), and then doing the reciprocal of that. I don't see why it cannot be (b / a). Maybe I'm missing something, but I think the reciprocal can be removed.


Also, I haven't worked with SSE in awhile, but I think that inner for loop should be able to be turned into SIMD logic. The comparison and mask test could be converted to work on all four pixels at once. Casting the address of an __m128 to something else to read it as an array sounds like a bad idea to me. Maybe the compiler could do something better, but I believe the simple approach to compiling that is to save the register out to memory to treat it like an array. So, I would be conerned about a load-hit-store.


Once I'm throwing intrinsics around and trying to hand-optimize things my own way, I don't trust the compiler to optimize things nearly as well as when I'm using conventional C++.

In Topic: c++ count lines in txt file and then read these lines without reopening a file

23 March 2015 - 01:19 PM

and to people that said use vector no i wont because i dont want to recreate the array almost every line.


I understand you don't want to dynamically resize the array, but why do you think it'll happen "almost every line"?

In Topic: Review of class rendering code using marmalade c++

18 March 2015 - 02:32 PM

Thanks so much for your suggestion and your help. But would you tell me what's the problem with the above code?  At least explaining to me the problem above would give me hints to work on simpler game. Because for example in a pong game, I will still have to use bounding boxes,..etc 


You didn't say where the BoundingRect variable comes from or what it's used for.


You didn't say where the Position variable comes from.


Your missing curly brace makes it unclear whether the Transform variable in the second part is the same as the one in the first part, because I'm not sure they're supposed to be the same scope.


You didn't even say what's wrong with the bounding box. It's just not "correctly bounded".


What do you expect anyone to do?