mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
Don't create a dummy texture for the texture pipeline template
The meta_create_texture_pipeline function used to create a dummy 1x1
texture so that it could make sure that the all of the state that
affects the shader generation would be set on the template pipeline so
that Cogl could share the pipeline's shader with any other pipelines
that are just rendering a texture. This is no longer necessary because
the only thing that affects the shader generation is the texture type,
not the actual texture data and Cogl now has a function to explicitly
set the texture type which we can use instead. Additionally even if
the template mechanism is not used at all Cogl will still end up
reusing the same shader because it now has a shader cache which is
indexed by the pipeline state so pipeline's don't strictly need to
share ancestry in order to take advantage of it. However we still
might as well use the function because if there is a common ancestry
it is faster to look up the shader because Cogl doesn't need to hash
the pipeline state.
https://bugzilla.gnome.org/show_bug.cgi?id=707458
(cherry picked from commit c5bf60eab4
)
This commit is contained in:
parent
bf78f067a2
commit
6014d31dea
@ -50,7 +50,7 @@ meta_create_color_texture_4ub (guint8 red,
|
||||
CoglColor color;
|
||||
guint8 pixel[4];
|
||||
|
||||
cogl_color_set_from_4ub (&color, red, green, blue, alpha);
|
||||
cogl_color_init_from_4ub (&color, red, green, blue, alpha);
|
||||
cogl_color_premultiply (&color);
|
||||
|
||||
pixel[0] = cogl_color_get_red_byte (&color);
|
||||
@ -73,10 +73,8 @@ meta_create_color_texture_4ub (guint8 red,
|
||||
* @src_texture: (allow-none): texture to use initially for the layer
|
||||
*
|
||||
* Creates a pipeline with a single layer. Using a common template
|
||||
* allows sharing a shader for different uses in Mutter. To share the same
|
||||
* shader with all other pipelines that are just texture plus opacity
|
||||
* would require Cogl fixes.
|
||||
* (See http://bugzilla.clutter-project.org/show_bug.cgi?id=2425)
|
||||
* makes it easier for Cogl to share a shader for different uses in
|
||||
* Mutter.
|
||||
*
|
||||
* Return value: (transfer full): a newly created #CoglPipeline
|
||||
*/
|
||||
@ -86,22 +84,21 @@ meta_create_texture_pipeline (CoglTexture *src_texture)
|
||||
static CoglPipeline *texture_pipeline_template = NULL;
|
||||
CoglPipeline *pipeline;
|
||||
|
||||
/* We use a pipeline that has a dummy texture as a base for all
|
||||
texture pipelines. The idea is that only the Cogl texture object
|
||||
would be different in the children so it is likely that Cogl will
|
||||
be able to share GL programs between all the textures. */
|
||||
/* The only state used in the pipeline that would affect the shader
|
||||
generation is the texture type on the layer. Therefore we create
|
||||
a template pipeline which sets this state and all texture
|
||||
pipelines are created as a copy of this. That way Cogl can find
|
||||
the shader state for the pipeline more quickly by looking at the
|
||||
pipeline ancestry instead of resorting to the shader cache. */
|
||||
if (G_UNLIKELY (texture_pipeline_template == NULL))
|
||||
{
|
||||
CoglTexture *dummy_texture;
|
||||
CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||
|
||||
dummy_texture = meta_create_color_texture_4ub (0xff, 0xff, 0xff, 0xff,
|
||||
COGL_TEXTURE_NONE);
|
||||
|
||||
CoglContext *ctx =
|
||||
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||
|
||||
texture_pipeline_template = cogl_pipeline_new (ctx);
|
||||
cogl_pipeline_set_layer_texture (texture_pipeline_template, 0, dummy_texture);
|
||||
cogl_object_unref (dummy_texture);
|
||||
cogl_pipeline_set_layer_null_texture (texture_pipeline_template,
|
||||
0, /* layer */
|
||||
COGL_TEXTURE_TYPE_2D);
|
||||
}
|
||||
|
||||
pipeline = cogl_pipeline_copy (texture_pipeline_template);
|
||||
|
Loading…
Reference in New Issue
Block a user