Trouble with glCopyTexSubImage2D when using multisampled rendering

Sage
Posts: 1,199
Joined: 2004.10
Post: #1
Well, the subject says it all. I use glCopyTexSubImage2D as part of a "full screen effect" stack, allowing me to add filters which run GLSL against the grabbed value from the frame buffer. This is for stuff like tinting, bloom, etc.

The filter stack works by using glCopyTexSubImage2D to grab what was rendered in the scene to a texture, then each filter, in turn, does whatever it wants, resulting in the final value rendered back to the screen.

Trouble is, when multisample rendering is enabled, it no longer seems to grab the rendered scene. Rather, the last frame rendered before turning on multisampling is used over and over. I can't really be certain what's going on, so I was thinking maybe it's just my 5200 being wonky. I'm linking to an app which demonstrates this. When you run the app ( "WorldHud.app" ), click the "multisample" checkbox along the bottom. On my machine, the scene freezes, though the user interface keeps working. The filter keeps running on the last frame rendered, so you see the scene fade to white.

(Universal, but untested except on PPC )
http://zakariya.net/shamyl/etc/WorldHud.app.zip

I'm hoping somebody may have an inkling as to what's going on. Obviously, I'll post any code anybody asks for, but since I'm not certain what's going on, I don't know yet what code is relevant.

On a side note, I've got a new macbook pro coming on thursday! This has me excited, if only because I'm compiling a release build of the app above as I'm typing. It's already taken my 12" powerbook 15 minutes to make it to halfway. I'm looking forward to a faster machine.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Hmmm. Different weird response on my G5/9600XT. When in windowed mode you can see weird artifacts sometimes (see picture below). When antialiasing is enabled, the screen goes black. Fullscreen seems to work fine.

[Image: artifacts.png]
See the weird diagonal lines? They change randomly (sometimes disappearing) as the screen is resized.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #3
I'm guessing that the artifacts are a result of the effect I'm running being untested ( by me, my fault ) on ATI graphics.

That being said, the fact that multisample fails there, too, is interesting.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
I wouldn't really expect this to work. You might have to wait for EXT_framebuffer_multisample/EXT_framebuffer_blit...
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #5
Works 100% fine on my MacBook Pro. I'll try it on my PowerMac when I get home.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
Yeah -- actually I just received my spanking new Core 2 Duo MBP this morning at work. The toggle works on the ATI card.

Also, get this: on my 12" powerbook, my core framework compiles as an optimized universal binary in about 30 to 45 minutes, depending on what I'm doing while it builds. On my new MBP, it compiles in about 3 or 4 minutes. I'm astonished. I mean, I can't describe how astonished I am.

Plus, my reflective water demo, which got about 5 fps in fullscreen 1024x768 on my 12" powerbook get 40 fps in full-res fullscreen on my MBP.

I'm going to pass out.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #7
Works fine in fullscreen on my 15" Powerbook, but I only see black when windowed. Also, the diagonal lines as described by Skorche appeared.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #8
I just tried it on my PowerMac, and it's black with anti aliasing enabled both in windowed and full screen on a Radeon X800. No weird diagonal lines, though.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #9
So, here's what I'm gathering from the responses:
1) Antialiasing only works on the ATI x1600 or whatever it is these MBPs use.
2) On older ATI cards, the 9600 and or 9700, my filter effect causes strange artifacts.

So, regarding #2, does anybody know if the 9600 and or 9700 do ( or do not ) support sampler2DRect and texture2DRect?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
9600 and 9700 do support those, just fine in my experience. The obvious difference between 9500-9800 and X800 is the shader instruction limit.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
OneSadCookie Wrote:9600 and 9700 do support those, just fine in my experience. The obvious difference between 9500-9800 and X800 is the shader instruction limit.

OSC, perhaps you can help. Could you open up WorldHud.app and look in Frameworks/SGF.framework/Contents/Resources/Filters and look at the three GLSL programs:

gaussian_h.fp
gaussian_v.fp
gloom_mix.fp

The filter effect running in WorldHud is my "Gloom" filter, which performs a gaussian blur on the captured framebuffer texture in two passes into a quarter-resolution texture, which is then passed in to gloom_mix.fp ( along with the original unmodified texture ) and mixed by converting the blurred texture to luminance, ramping it a bit, and performing an add-signed addition to the original color texture. Can you tell me if any of those three would be unsupported on those ATI cards?

( in the gaussian blurs, __SIZE__ is a macro which is substituted for a constant by my GLSL program loader )

Thanks,
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
There's no difference in capability between the X800 and 9500 other than the precise shader limits, AFAIK. That means that just looking at the shader source wouldn't be enough to say whether it'd work or not.

Of course, even if the shader can't fit within the native limits, it should fall back to software rather than drawing crap -- unless your context has the "no recovery" attribute set...

It's not a simple topic Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  glCopyTexSubImage2D vs antialiasing on iPhone? Mark Levin 4 4,903 Jul 16, 2010 01:46 AM
Last Post: Bersaelor
  Understanding multisampled FBOs Coyote 12 9,110 Nov 27, 2009 01:01 AM
Last Post: arekkusu
  Quick question, will glCopyTexSubImage2D with with RECT textures? TomorrowPlusX 28 9,206 Jun 8, 2006 07:04 PM
Last Post: akb825
  glCopyTexSubImage2D pkraft 3 3,938 Mar 8, 2005 01:59 PM
Last Post: pkraft
  2D games and glCopyTexSubImage2D() Skorche 7 6,516 Feb 19, 2005 11:25 PM
Last Post: Skorche