Open hyclear opened 7 years ago
(void)renderAtInternalSize; { [GPUImageContext setActiveShaderProgram:dataProgram];
outputFramebuffer = [[GPUImageContext sharedFramebufferCache] fetchFramebufferForSize:imageSize onlyTexture:NO]; [outputFramebuffer activateFramebuffer];
if(lockNextFramebuffer) { retainedFramebuffer = outputFramebuffer; [retainedFramebuffer lock]; [retainedFramebuffer lockForReading]; lockNextFramebuffer = NO; }
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
static const GLfloat squareVertices[] = { -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, };
static const GLfloat textureCoordinates[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, };
glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D, [firstInputFramebuffer texture]); glUniform1i(dataInputTextureUniform, 4);
glVertexAttribPointer(dataPositionAttribute, 2, GL_FLOAT, 0, 0, squareVertices); glVertexAttribPointer(dataTextureCoordinateAttribute, 2, GL_FLOAT, 0, 0, textureCoordinates);
glEnableVertexAttribArray(dataPositionAttribute); glEnableVertexAttribArray(dataTextureCoordinateAttribute);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); [firstInputFramebuffer unlock]; }
problem is outputFramebuffer never return to cache, will new outputFramebuffer frequent,cause high cpu usage
(void)renderAtInternalSize; { [GPUImageContext setActiveShaderProgram:dataProgram];
outputFramebuffer = [[GPUImageContext sharedFramebufferCache] fetchFramebufferForSize:imageSize onlyTexture:NO]; [outputFramebuffer activateFramebuffer];
if(lockNextFramebuffer) { retainedFramebuffer = outputFramebuffer; [retainedFramebuffer lock]; [retainedFramebuffer lockForReading]; lockNextFramebuffer = NO; }
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
static const GLfloat squareVertices[] = { -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, };
static const GLfloat textureCoordinates[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, };
glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D, [firstInputFramebuffer texture]); glUniform1i(dataInputTextureUniform, 4);
glVertexAttribPointer(dataPositionAttribute, 2, GL_FLOAT, 0, 0, squareVertices); glVertexAttribPointer(dataTextureCoordinateAttribute, 2, GL_FLOAT, 0, 0, textureCoordinates);
glEnableVertexAttribArray(dataPositionAttribute); glEnableVertexAttribArray(dataTextureCoordinateAttribute);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); [firstInputFramebuffer unlock]; }
problem is outputFramebuffer never return to cache, will new outputFramebuffer frequent,cause high cpu usage