mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 20:32:16 +00:00
1c449c67f6
This removes the need to maintain an array of tex_coord varyings and instead we now just emit a varying per-layer uniquely named using a layer_number infix like cogl_tex_coord0_out and cogl_tex_coord0_in. Notable this patch also had to change the journal flushing code to use pipeline layer numbers to determine the name of texture coordinate attributes. We now also break batches by using a deeper comparison of layers so such that two pipelines with the same number of layers can now cause a batch break if they use different layer numbers. This adds an internal _cogl_pipeline_layer_numbers_equal() function that takes two pipelines and returns TRUE if they have the same number of layers and all the layer numbers are the same too, otherwise it returns FALSE. Where we used to break batches based on changes to the number of layers we now break according to the status of _cogl_pipeline_layer_numbers_equal Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit e55b64a9cdc93285049d9b969bef67484c2d9fb3) Note: this will cause a temporary regression for the Cogl 1.x CoglShader api since it will break compatibility with existing shaders that reference the texture varyings from the fragment shader. The intention is to follow up with another patch to add back CoglShader compatibility.
115 lines
3.5 KiB
C
115 lines
3.5 KiB
C
/*
|
|
* Cogl
|
|
*
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
*
|
|
* Copyright (C) 2008,2009,2010 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/>.
|
|
*
|
|
*
|
|
*
|
|
* Authors:
|
|
* Neil Roberts <neil@linux.intel.com>
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "cogl-context-private.h"
|
|
#include "cogl-pipeline-private.h"
|
|
#include "cogl-pipeline-state-private.h"
|
|
#include "cogl-pipeline-opengl-private.h"
|
|
#include "cogl-framebuffer-private.h"
|
|
|
|
#ifdef COGL_PIPELINE_VERTEND_FIXED
|
|
|
|
#include "cogl-internal.h"
|
|
#include "cogl-context-private.h"
|
|
#include "cogl-object-private.h"
|
|
#include "cogl-program-private.h"
|
|
|
|
const CoglPipelineVertend _cogl_pipeline_fixed_vertend;
|
|
|
|
static void
|
|
_cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline,
|
|
int n_layers,
|
|
unsigned long pipelines_difference)
|
|
{
|
|
_cogl_use_vertex_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED);
|
|
}
|
|
|
|
static CoglBool
|
|
_cogl_pipeline_vertend_fixed_add_layer (CoglPipeline *pipeline,
|
|
CoglPipelineLayer *layer,
|
|
unsigned long layers_difference,
|
|
CoglFramebuffer *framebuffer)
|
|
{
|
|
CoglContext *ctx = framebuffer->context;
|
|
int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
|
|
CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index);
|
|
|
|
if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX)
|
|
{
|
|
CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
|
|
CoglPipelineLayer *authority =
|
|
_cogl_pipeline_layer_get_authority (layer, state);
|
|
CoglMatrixEntry *matrix_entry;
|
|
|
|
_cogl_matrix_stack_set (unit->matrix_stack,
|
|
&authority->big_state->matrix);
|
|
|
|
_cogl_set_active_texture_unit (unit_index);
|
|
|
|
matrix_entry = unit->matrix_stack->last_entry;
|
|
_cogl_matrix_entry_flush_to_gl_builtins (ctx, matrix_entry,
|
|
COGL_MATRIX_TEXTURE,
|
|
framebuffer,
|
|
FALSE /* enable flip */);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static CoglBool
|
|
_cogl_pipeline_vertend_fixed_end (CoglPipeline *pipeline,
|
|
unsigned long pipelines_difference)
|
|
{
|
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
|
|
if (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE)
|
|
{
|
|
CoglPipeline *authority =
|
|
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE);
|
|
|
|
GE( ctx, glPointSize (authority->big_state->point_size) );
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
const CoglPipelineVertend _cogl_pipeline_fixed_vertend =
|
|
{
|
|
_cogl_pipeline_vertend_fixed_start,
|
|
_cogl_pipeline_vertend_fixed_add_layer,
|
|
_cogl_pipeline_vertend_fixed_end,
|
|
NULL, /* pipeline_change_notify */
|
|
NULL /* layer_change_notify */
|
|
};
|
|
|
|
#endif /* COGL_PIPELINE_VERTEND_FIXED */
|
|
|