Deferred renderer issue on AMD only

Based on this tutorial,
I had allot of problems getting AMD based GPU's to work.

I will post snippets of code bellow to detail the issue, but a simplistic explanation of the issue is that there is an issue with the depth test. I can see background objects tear infront of closer objects etc.

I contacted the original author regarding the issue, he does not seem to have access to AMD hardware so the question is open to be resolved, and I hope someone here have had similar issues.

The tutorial are covered in 3 stages, basic deferred shading to the final example using stencil buffer to draw a sphere (for point lights) to make GLSL only process the light volume.

Code can be downloaded from the tutorial, but to make it convenient I will post the important areas (and order of execution) here.

Edit:
There are a few additions in the code samples bellow, as compared to the original tutorial, but the same issues are confirmed on AMD gpu's in its original state by multiple systems (6k/7k series).

Solved

I solved this issue, not sure how to edit the original title (seems to be locked for edit after some period)

Will incorporate the fix in original tutorial, if the fix is working well for everyone. Will need some time to determine the exact issue as I had to rewrite how I set up the color attachments to the FBO, partially based on "OpenGL 4.0 Shading Language" book.