Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: FBO texture corruption in compiler-optimized code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FBO texture corruption in compiler-optimized code?



Hi again everyone,

So, our issue persists, and since no one have stepped forward to tell me there's something wrong in our code, I guess I should file a Radar report on this issue, as there may be a driver bug?

Erik

On Dec 7, 2006, at 4:38 PM, Erik Harg wrote:

Thanks for that info, Ken. It's good to know we're not the only ones having some minor problems with those FBOs. But I'm still wondering what might be causing our FBO problem. And now I even got the corrupted FBO depth map while running a non-optimzed .app (i.e. -O0 setting). But that has only happened once, and it happens every time when using a compiler-optimized .app.

Can anyone assure me that this is not a driver bug? :-)

Erik

On Dec 4, 2006, at 7:42 PM, Ken Drycksback wrote:

Hi Erik,

I don't have a solution to your problem but it's quite interesting since I'm getting complete lockups on the Intel iMac when I try to access the depth texture in an FBO. Any other FBO access or operation works fine but not using the depth map. We use the texture in a GLSL shader.

The exact same shader and code is used in another app also but there it works fine so I have no idea if it might be our bug or a driver bug.

Ken



On Dec 3, 2006, at 4:19 PM, Erik Harg wrote:

Hi everyone,

I have a question regarding what seems to be a texture being corrupted after it has been drawn to using FBO. The really interesting part about it, is that this only occurs when the program is compiled with gcc optimization flag of -O1 or larger (incl. -Os); i.e. with -O0 the texture survives fine. It also appears nice and fine on WinXP (although that's with a slightly different general code base).

The FBO is used as a render target for a depth map. When our program starts, we initialize the framebuffer object, and the texture to hold the depth info, like this:

		glGenFramebuffersEXT(1, &mDepthFBO);
		glGenTextures(1, &mDepthTexture);
		glGenRenderbuffersEXT(1, &mDepthRB);

		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mDepthFBO);

// init texture
glBindTexture(GL_TEXTURE_2D, mDepthTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mDepthTextureSize, mDepthTextureSize, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);


glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, mDepthTexture, 0);


// initialize depth renderbuffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepthRB);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, mDepthTextureSize, mDepthTextureSize);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, mDepthRB);


		CheckFramebufferStatus();

		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

Then, each time the depth map is tagged as dirty, it is rendered like this:

	   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pRM->mDepthFBO);
	   [render all objects]
	   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

And then, mDepthTexture is used in the other render passes as a depth map. But, as I said, when running an optimized executable, this texture gets corrupted at semi-rendom intervals. It never happens in none-optimized mode, and it always happens (at approximately the same place each time) in optimized mode. Most of the time, the corruption is evident as a shift/stripe pattern of the original texture, but sometimes it seems to copy in some very incorrect values from varying places of various other textures (that, as far as I can establish, are also on the GPU). And, while this takes place, the texture has not been rendered to again at all. If the depth map is force-flagged as dirty, the texture's content is reset to correct values, but the same corruption pattern usually occurs shortly after.

I've tried to debug this error using the OpenGL Profiler, but it seems that the Resource view is unable to show the mDepthTexture at all. Depending on the blend modes, it shows up as either (semi-)transparent, blank or white. And, enabling OpenGL error breakpoints almost brings our program to a halt (framerate drops from 30-40 down to ~1), but no errors seem to occur when the texture corruption occurs. Another thing that makes debugging a little bit harder, is that the only Mac hardware we have at our disposal that can run the program with the shaders enabled, and with a useable framerate, is my new 15" MacBook Pro (Core 2 Duo 2.33 w/ 2GB RAM and 256MB VRAM on ATI X1600). I tried to run it through the Software Renderer (through the OpenGL Profiler), but it seems that our Cg shader programs exceed the limitations of that renderer's register count, so it fallbacks to the fixed function render pipeline (without both the FBO and depth map). Oh, and our Windows boxen all sport nVidia cards.

So, I'm not sure if this might be caused by: a) our code [likely], b) some other code/library we're using [also rather likely], c) the OpenGL.framework on my MBP or d) the ATI card itself.

So, I was wondering if anyone had any ideas on what might be causing this, or what I (or rather "we", as this part of our program is written by our lead programmer, Cc'd here) could do to find out what's wrong? Any hints or speculations would be welcome, and I'll try to clarify any ambiguities.

Thanks!

Best regards,
--
Erik Harg
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40codeblender.com


This email sent to email@hidden




-- Erik Harg email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40terravision.no


This email sent to email@hidden

-- Erik Harg Daglig leder TerraVision AS

t. +47 4000 3836
m. +47 924 98 541
e. email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Mac-opengl mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >FBO texture corruption in compiler-optimized code? (From: Erik Harg <email@hidden>)
 >Re: FBO texture corruption in compiler-optimized code? (From: Ken Drycksback <email@hidden>)
 >Re: FBO texture corruption in compiler-optimized code? (From: Erik Harg <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.