Quote:Original post by deathkrushQuote:Original post by Seroja
glCopy could indeed be implemented badly, but:
1) It's 1 copy of 512*512 depth texture per frame, why would it decrease preformance x3 or even x4?
If the OpenGL driver is doing something silly like using the CPU to copy data, that would kill performance because accessing VRAM from CPU is very slow on many graphic cards. Think 10MB/s instead of 10GB/s !!!Quote:Original post by Seroja
2) I use same glCopy for cube mapping, which is 6 256*256 RGB(A) textures, and even increasing that to 6 512*512 textures didn't hurt performance as much.
Maybe the OpenGL driver supports copying an RGBA texture using the GPU, but it falls back to 10MB/s for depth textures? In that case you can lie to the driver and say it's an RGBA texture so it does a fast copy and then change it back to DEPTH texture. You can use PBO (pixel buffer object) for that.
OK, now that makes sense. But I don't think I can fool the driver that easily. FBOs are out of my reach, so PBOs definitely are (not that I know how to use them anyway). Or is it possible with something more simple like pbuffers?
Otherwise, I don't know how to do it. If I tell it's RGBA, it will copy black (since I disable color writes during depth map creation pass). If I glRead the depth, I'll get same performance drop.
Maybe there is a way to convert depth (Z-buffer value) to color... Actually why not... It would be quite cumbersome with the way my code is set up, but the depth pass could have color writes enabled, everything disabled, except for eye-linear texture giving value according to distance from eye (which is the Z value). Will glCopy be able to copy RGBA into depth texture? e.g. what would the following call result with:
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, DepthSize, DepthSize, 0);
If a depth texture is bound?
OK, I actually tried that while writing the post :-)
I didn't do the eye-linear thing, but I bound the scene rendered from light view as a texture. Shadow became colorized :D
Actually, I think it ended up with some interesting projective texture. Unfortunately the R-coordinate comparison won't work this way (RGBA doesn't have R-coordinate). Speed did get up to the reasonable level, but this isn't shadow mapping (at least not without a shader). Unless I can convince OpenGL to use s or t as if they were the r coordinate - which I have no idea of how to do.
I still have doubts about this being a driver bug. Somehow, almost everything that didn't work for me in OpenGL ended up being my own bug.