Hello.

My plugin implements both a QCPluginInputImage and Output image, and renders to an FBO, and outputs that via a custom QCPlugInOutputImageProvider, which implements the copyRenderedTextureForCGLContext method.

My simple QC test patch is video input -> my plugin input - plugin output -> billboard.

Now, I am leaking some textures within my custom QC plugin, and it seems that the following code (below) is the culprit. But first some info: Using GL profiler, I can watch the textures be created, vram drop down to nearly nothing, and have my whole system swapping like mad. Since GL profiler allows me to set breakpoints and view resources (btw, how insanely cool is that?), I can see which textures are leaking... (or, at least not being cleaned up/deleted), and it is the input image, not the output image (for reference).


my copyRenderedTextureForCGLContext method on my QCPluginOutputImageProvider looks like : - (GLuint) copyRenderedTextureForCGLContext:(CGLContextObj)cgl_ctx pixelFormat:(NSString*)format bounds:(NSRect)bounds isFlipped: (BOOL*)flipped
{
return _CreateTexture(cgl_ctx, width, height, bounds, (GLuint) 40, image);
}


and _CreateTexture() borrows heavily from GLImage, creates a texture and an FBO, draws to the FBO, and outputs the GLuint texture name. The culprit seems to be the code at the bottom, which is is within the texture creation function: Note I am passing in a QCPlugInInputImageSource...

static GLuint _CreateTexture(CGLContextObj cgl_ctx, NSUInteger pixelsWide, NSUInteger pixelsHigh, NSRect bounds, GLuint flybackSize, id<QCPlugInInputImageSource> texture)
{

// fbo and texture creation stuff here // borrowed from GLImage

// draw our video
if(texture && [texture lockTextureRepresentationWithColorSpace: [texture imageColorSpace] forBounds:[texture imageBounds]])
                        {       
[texture bindTextureRepresentationToCGLContext:cgl_ctx textureUnit:GL_TEXTURE0 normalizeCoordinates:YES];
                                
                                glColor4f(1.0, 1.0, 1.0, 1.0);
                                
                                glBegin(GL_QUADS);
                                        glTexCoord2f(1.0,1.0);
                                        glVertex2f(pixelsWide, pixelsHigh - 
flybackSize);
                                        glTexCoord2f(0.0, 1.0);
                                        glVertex2f(flybackSize, pixelsHigh - 
flybackSize);
                                        glTexCoord2f(0.0, 0.0);
                                        glVertex2f(flybackSize, 0);
                                        glTexCoord2f(1.0, 0.0);
                                        glVertex2f(pixelsWide, 0);
                                glEnd();
                        
[texture unbindTextureRepresentationFromCGLContext:cgl_ctx textureUnit:GL_TEXTURE0];
                                [texture unlockTextureRepresentation];
                        }

// draw some additional GL primities here

return texture
}

If I remove or commented out any calls to the QCPlugInInputImageSource, I do not leak textures.

Is it not allowed to call QCPlugInInputImageSource from a static function, within either a QCPlugInOutputImageProvider ? If I am allowed, is there anything I have to do to force texture cleanup for a QCPluginInputImageSource? Using GLProfiler and viewing resources, I can confirm the only textures leaking are the 'input' image textures, not the FBO or its textures (my output), and ive also manually confirmed for that my texture release callback is being properly called, with the correct texture name. So, im curious about why the above would leak, as the same code is within the GLHeighfield and other plugins, with the only difference being they are within the execute: atTime: method of the plugin, not the QCPlugInOutputImageProvider or a static function.

I suppose, somehow, that must make a difference?

Thank you for any advice.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to