cogl-pipeline-layer: Use CoglTextureType instead of GL target enum

Instead of storing the GLenum for the target of the last used texture
for a layer it now stores the CoglTextureType instead. The state name
has been renamed to 'texture type' instead of 'texture target'.
Previously the default pipeline layer would store 0 here to represent
that there is no texture. This has been changed to store
COGL_TEXTURE_TYPE_2D instead which means that all pipeline layers
always have a valid value for the texture type. Any places that were
previously fetching the texture from a layer to determine the target
(for example when generating shaders or when enabling a particular
texture target) now use the texture type instead. This means they will
work even for layers that don't have a texture.

This also changes it so that when binding a fallback texture instead
of always using a 2D texture it will now use the default texture
corresponding to the texture type of the layer. That way when the
generated shader tries to do a texture lookup for that type of texture
it will get a valid texture object. To make this work the patch adds a
default texture for 3D textures to the context and also makes the
default rectangle texture actually be a rectangle texture instead of
using a 2D texture.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts
2012-02-09 12:52:45 +00:00
parent 8012eee31f
commit b96e6900f5
11 changed files with 205 additions and 173 deletions

View File

@ -71,7 +71,7 @@ typedef enum
{
/* sparse state */
COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_TARGET_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
COGL_PIPELINE_LAYER_STATE_FILTERS_INDEX,
COGL_PIPELINE_LAYER_STATE_WRAP_MODES_INDEX,
@ -99,8 +99,8 @@ typedef enum
{
COGL_PIPELINE_LAYER_STATE_UNIT =
1L<<COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_TARGET =
1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_TARGET_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE =
1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA =
1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
COGL_PIPELINE_LAYER_STATE_FILTERS =
@ -259,7 +259,11 @@ struct _CoglPipelineLayer
/* The texture for this layer, or NULL for an empty
* layer */
CoglTexture *texture;
GLenum target;
/* The type of the texture. This is always set even if the texture
is NULL and it will be used to determine what type of texture
lookups to use in any shaders generated by the pipeline
backends. */
CoglTextureType texture_type;
CoglPipelineFilter mag_filter;
CoglPipelineFilter min_filter;
@ -363,6 +367,9 @@ _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
CoglTexture *
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
CoglTextureType
_cogl_pipeline_layer_get_texture_type (CoglPipelineLayer *layer);
CoglPipelineFilter
_cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer);