fragend-arbfp: Move the pipeline cache to a separate file

The pipeline cache is now handled in CoglPipelineCache instead of
directly in the ARBfp fragend. The flags needed to hash a pipeline
should be exactly the same for the ARBfp and GLSL fragends so it's
convenient to share the code. The hash table now stores the actual
pipeline as the value instead of the private data so that the two
fragends can attach their data to it. That way it's possible to use
the same pipeline key with ancestors that are using different
fragends.

The hash table is created with g_hash_table_new_full to set a
destructor for the key and value and there is a destructor for
CoglPipelineCache that gets called when the CoglContext is
destroyed. That way we no longer leak the pipelines and shader state
when the context is desroyed.
This commit is contained in:
Neil Roberts
2011-06-30 15:55:56 +01:00
parent d69d49fada
commit 461bff1867
7 changed files with 249 additions and 152 deletions

View File

@ -0,0 +1,50 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#ifndef __COGL_PIPELINE_CACHE_H__
#define __COGL_PIPELINE_CACHE_H__
#include "cogl-pipeline.h"
typedef struct _CoglPipelineCache CoglPipelineCache;
CoglPipelineCache *
cogl_pipeline_cache_new (void);
void
cogl_pipeline_cache_free (CoglPipelineCache *cache);
/*
* Gets a pipeline from the cache that has the same state as
* @key_pipeline for the state in
* COGL_PIPELINE_STATE_AFFECTS_FRAGMENT_CODEGEN. If there is no
* matching pipline already then a copy of key_pipeline is stored in
* the cache so that it will be used next time the function is called
* with a similar pipeline. In that case the copy itself will be
* returned
*/
CoglPipeline *
_cogl_pipeline_cache_get_fragment_template (CoglPipelineCache *cache,
CoglPipeline *key_pipeline);
#endif /* __COGL_PIPELINE_CACHE_H__ */