diff --git a/cogl/cogl/cogl-context-private.h b/cogl/cogl/cogl-context-private.h index 8eeb56bc0..fc3b77c3e 100644 --- a/cogl/cogl/cogl-context-private.h +++ b/cogl/cogl/cogl-context-private.h @@ -50,7 +50,6 @@ #include "cogl-texture-driver.h" #include "cogl-pipeline-cache.h" #include "cogl-texture-2d.h" -#include "cogl-texture-3d.h" #include "cogl-texture-rectangle.h" #include "cogl-sampler-cache-private.h" #include "cogl-gpu-info-private.h" @@ -166,7 +165,6 @@ struct _CoglContext /* Textures */ CoglTexture2D *default_gl_texture_2d_tex; - CoglTexture3D *default_gl_texture_3d_tex; CoglTextureRectangle *default_gl_texture_rect_tex; /* Central list of all framebuffers so all journals can be flushed diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index c4ea57146..7dffad2df 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -40,7 +40,6 @@ #include "cogl-journal-private.h" #include "cogl-texture-private.h" #include "cogl-texture-2d-private.h" -#include "cogl-texture-3d-private.h" #include "cogl-texture-rectangle-private.h" #include "cogl-pipeline-private.h" #include "cogl-framebuffer-private.h" @@ -307,7 +306,6 @@ cogl_context_new (CoglDisplay *display, context->legacy_state_set = 0; context->default_gl_texture_2d_tex = NULL; - context->default_gl_texture_3d_tex = NULL; context->default_gl_texture_rect_tex = NULL; context->framebuffers = NULL; @@ -436,20 +434,6 @@ cogl_context_new (CoglDisplay *display, white_pixel, NULL); /* abort on error */ - /* If 3D or rectangle textures aren't supported then these will - * return errors that we can simply ignore. */ - internal_error = NULL; - context->default_gl_texture_3d_tex = - cogl_texture_3d_new_from_data (context, - 1, 1, 1, /* width, height, depth */ - COGL_PIXEL_FORMAT_RGBA_8888_PRE, - 0, /* rowstride */ - 0, /* image stride */ - white_pixel, - &internal_error); - if (internal_error) - cogl_error_free (internal_error); - /* TODO: add cogl_texture_rectangle_new_from_data() */ white_pixel_bitmap = cogl_bitmap_new_for_data (context, @@ -509,8 +493,6 @@ _cogl_context_free (CoglContext *context) if (context->default_gl_texture_2d_tex) cogl_object_unref (context->default_gl_texture_2d_tex); - if (context->default_gl_texture_3d_tex) - cogl_object_unref (context->default_gl_texture_3d_tex); if (context->default_gl_texture_rect_tex) cogl_object_unref (context->default_gl_texture_rect_tex); diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index d4104625e..5016a216b 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -194,7 +194,6 @@ cogl_is_context (void *object); * @COGL_FEATURE_ID_TEXTURE_RG: Support for * %COGL_TEXTURE_COMPONENTS_RG as the internal components of a * texture. - * @COGL_FEATURE_ID_TEXTURE_3D: 3D texture support * @COGL_FEATURE_ID_OFFSCREEN: Offscreen rendering support * @COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE: Multisample support for * offscreen framebuffers @@ -241,7 +240,6 @@ typedef enum _CoglFeatureID COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT, COGL_FEATURE_ID_TEXTURE_NPOT, COGL_FEATURE_ID_TEXTURE_RECTANGLE, - COGL_FEATURE_ID_TEXTURE_3D, COGL_FEATURE_ID_GLSL, COGL_FEATURE_ID_OFFSCREEN, COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE, diff --git a/cogl/cogl/cogl-framebuffer.h b/cogl/cogl/cogl-framebuffer.h index e16cc417b..97273a71b 100644 --- a/cogl/cogl/cogl-framebuffer.h +++ b/cogl/cogl/cogl-framebuffer.h @@ -1129,8 +1129,8 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer, * This drawing api doesn't support high-level meta texture types such * as #CoglTexture2DSliced so it is the user's responsibility to * ensure that only low-level textures that can be directly sampled by - * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D - * are associated with layers of the given @pipeline. + * a GPU such as #CoglTexture2D or #CoglTextureRectangle are associated with + * layers of the given @pipeline. * * This api doesn't support any of the legacy global state options such * as cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or @@ -1171,8 +1171,8 @@ cogl_framebuffer_draw_primitive (CoglFramebuffer *framebuffer, * This drawing api doesn't support high-level meta texture types such * as #CoglTexture2DSliced so it is the user's responsibility to * ensure that only low-level textures that can be directly sampled by - * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D - * are associated with layers of the given @pipeline. + * a GPU such as #CoglTexture2D or #CoglTextureRectangle are associated with + * layers of the given @pipeline. * * Stability: unstable * Since: 1.10 @@ -1214,8 +1214,8 @@ cogl_framebuffer_vdraw_attributes (CoglFramebuffer *framebuffer, * This drawing api doesn't support high-level meta texture types such * as #CoglTexture2DSliced so it is the user's responsibility to * ensure that only low-level textures that can be directly sampled by - * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D - * are associated with layers of the given @pipeline. + * a GPU such as #CoglTexture2D or #CoglTextureRectangle are associated with + * layers of the given @pipeline. * * This api doesn't support any of the legacy global state options such * as cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or @@ -1280,8 +1280,8 @@ cogl_framebuffer_draw_attributes (CoglFramebuffer *framebuffer, * This drawing api doesn't support high-level meta texture types such * as #CoglTexture2DSliced so it is the user's responsibility to * ensure that only low-level textures that can be directly sampled by - * a GPU such as #CoglTexture2D, #CoglTextureRectangle or - * #CoglTexture3D are associated with layers of the given @pipeline. + * a GPU such as #CoglTexture2D or #CoglTextureRectangle are associated with + * layers of the given @pipeline. * * This api doesn't support any of the legacy global state * options such as cogl_set_depth_test_enabled(), @@ -1348,8 +1348,8 @@ cogl_framebuffer_vdraw_indexed_attributes (CoglFramebuffer *framebuffer, * This drawing api doesn't support high-level meta texture types such * as #CoglTexture2DSliced so it is the user's responsibility to * ensure that only low-level textures that can be directly sampled by - * a GPU such as #CoglTexture2D, #CoglTextureRectangle or - * #CoglTexture3D are associated with layers of the given @pipeline. + * a GPU such as #CoglTexture2D or #CoglTextureRectangle are associated with + * layers of the given @pipeline. * * This api doesn't support any of the legacy global state * options such as cogl_set_depth_test_enabled(), diff --git a/cogl/cogl/cogl-gles2.h b/cogl/cogl/cogl-gles2.h index 99bf39459..46daf62ac 100644 --- a/cogl/cogl/cogl-gles2.h +++ b/cogl/cogl/cogl-gles2.h @@ -366,9 +366,8 @@ cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx, * GLES2 context. * * This function will only return %TRUE for low-level - * #CoglTextures such as #CoglTexture2D or #CoglTexture3D but - * not for high level meta textures such as - * #CoglTexture2DSliced + * #CoglTextures such as #CoglTexture2D but not for high level + * meta textures such as #CoglTexture2DSliced * * The handle returned should not be passed directly to a system * OpenGL ES 2.0 library, the handle is only intended to be used via diff --git a/cogl/cogl/cogl-glsl-shader.c b/cogl/cogl/cogl-glsl-shader.c index d30f3de50..6e1deb66c 100644 --- a/cogl/cogl/cogl-glsl-shader.c +++ b/cogl/cogl/cogl-glsl-shader.c @@ -100,15 +100,6 @@ _cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx, strings[count] = version_string; lengths[count++] = -1; - if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_EMBEDDED) && - cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D)) - { - static const char texture_3d_extension[] = - "#extension GL_OES_texture_3D : enable\n"; - strings[count] = texture_3d_extension; - lengths[count++] = sizeof (texture_3d_extension) - 1; - } - if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_EGL_IMAGE_EXTERNAL)) { static const char texture_3d_extension[] = diff --git a/cogl/cogl/cogl-meta-texture.h b/cogl/cogl/cogl-meta-texture.h index f398e7a2a..66d592181 100644 --- a/cogl/cogl/cogl-meta-texture.h +++ b/cogl/cogl/cogl-meta-texture.h @@ -42,8 +42,7 @@ G_BEGIN_DECLS /** * SECTION:cogl-meta-texture * @short_description: Interface for high-level textures built from - * low-level textures like #CoglTexture2D and - * #CoglTexture3D. + * low-level textures like #CoglTexture2D. * * Cogl helps to make it easy to deal with high level textures such * as #CoglAtlasTextures, #CoglSubTextures, @@ -52,12 +51,11 @@ G_BEGIN_DECLS * * A #CoglMetaTexture is a texture that might internally be * represented by one or more low-level #CoglTextures - * such as #CoglTexture2D or #CoglTexture3D. These low-level textures - * are the only ones that a GPU really understands but because - * applications often want more high-level texture abstractions - * (such as storing multiple textures inside one larger "atlas" - * texture) it's desirable to be able to deal with these - * using a common interface. + * such as #CoglTexture2D. These low-level textures are the only ones + * that a GPU really understands but because applications often want + * more high-level texture abstractions (such as storing multiple + * textures inside one larger "atlas" texture) it's desirable to be + * able to deal with these using a common interface. * * For example the GPU is not able to automatically handle repeating a * texture that is part of a larger atlas texture but if you use diff --git a/cogl/cogl/cogl-offscreen.h b/cogl/cogl/cogl-offscreen.h index bc80b3166..5782de594 100644 --- a/cogl/cogl/cogl-offscreen.h +++ b/cogl/cogl/cogl-offscreen.h @@ -75,8 +75,8 @@ GType cogl_offscreen_get_gtype (void); * destroy the offscreen buffer before you can use the @texture again. * * This api only works with low-level #CoglTexture types such as - * #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not - * with meta-texture types such as #CoglTexture2DSliced. + * #CoglTexture2D and #CoglTextureRectangle, and not with meta-texture + * types such as #CoglTexture2DSliced. * * The storage for the framebuffer is actually allocated lazily * so this function will never return %NULL to indicate a runtime @@ -110,8 +110,8 @@ cogl_offscreen_new_with_texture (CoglTexture *texture); * you can use the @texture again. * * This only works with low-level #CoglTexture types such as - * #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not - * with meta-texture types such as #CoglTexture2DSliced. + * #CoglTexture2D and #CoglTextureRectangle, and not with meta-texture + * types such as #CoglTexture2DSliced. * * Return value: (transfer full): a newly instantiated #CoglOffscreen * framebuffer or %NULL if it wasn't possible to create the diff --git a/cogl/cogl/cogl-pipeline-layer-state.c b/cogl/cogl/cogl-pipeline-layer-state.c index ea29982e0..3d10925c4 100644 --- a/cogl/cogl/cogl-pipeline-layer-state.c +++ b/cogl/cogl/cogl-pipeline-layer-state.c @@ -343,16 +343,6 @@ cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline, case COGL_TEXTURE_TYPE_2D: break; - case COGL_TEXTURE_TYPE_3D: - if (ctx->default_gl_texture_3d_tex == NULL) - { - g_warning ("The default 3D texture was set on a pipeline but " - "3D textures are not supported"); - texture_type = COGL_TEXTURE_TYPE_2D; - return; - } - break; - case COGL_TEXTURE_TYPE_RECTANGLE: if (ctx->default_gl_texture_rect_tex == NULL) { diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index d1f66d440..d61ee668d 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -1925,10 +1925,6 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data) texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex); break; - case COGL_TEXTURE_TYPE_3D: - texture = COGL_TEXTURE (ctx->default_gl_texture_3d_tex); - break; - case COGL_TEXTURE_TYPE_RECTANGLE: texture = COGL_TEXTURE (ctx->default_gl_texture_rect_tex); break; diff --git a/cogl/cogl/cogl-primitive-texture.h b/cogl/cogl/cogl-primitive-texture.h index 6fd26a529..837347509 100644 --- a/cogl/cogl/cogl-primitive-texture.h +++ b/cogl/cogl/cogl-primitive-texture.h @@ -42,14 +42,14 @@ G_BEGIN_DECLS /** * SECTION:cogl-primitive-texture * @short_description: Interface for low-level textures like - * #CoglTexture2D and #CoglTexture3D. + * #CoglTexture2D. * * A #CoglPrimitiveTexture is a texture that is directly represented * by a single texture on the GPU. For example these could be a - * #CoglTexture2D, #CoglTexture3D or #CoglTextureRectangle. This is - * opposed to high level meta textures which may be composed of - * multiple primitive textures or a sub-region of another texture such - * as #CoglAtlasTexture and #CoglTexture2DSliced. + * #CoglTexture2D or #CoglTextureRectangle. This is opposed to high level + * meta textures which may be composed of multiple primitive textures or a + * sub-region of another texture such as #CoglAtlasTexture and + * #CoglTexture2DSliced. * * A texture that implements this interface can be directly used with * the low level cogl_primitive_draw() API. Other types of textures diff --git a/cogl/cogl/cogl-primitive.h b/cogl/cogl/cogl-primitive.h index 6503b53a5..b6867bbbe 100644 --- a/cogl/cogl/cogl-primitive.h +++ b/cogl/cogl/cogl-primitive.h @@ -926,8 +926,8 @@ cogl_primitive_foreach_attribute (CoglPrimitive *primitive, * This drawing api doesn't support high-level meta texture types such * as #CoglTexture2DSliced so it is the user's responsibility to * ensure that only low-level textures that can be directly sampled by - * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D - * are associated with layers of the given @pipeline. + * a GPU such as #CoglTexture2D or #CoglTextureRectangle are associated + * with layers of the given @pipeline. * * Stability: unstable * Since: 1.16 diff --git a/cogl/cogl/cogl-primitives.c b/cogl/cogl/cogl-primitives.c index 912ef5475..811dfd8f7 100644 --- a/cogl/cogl/cogl-primitives.c +++ b/cogl/cogl/cogl-primitives.c @@ -427,7 +427,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline, * - CoglTexture2DSliced: if only comprised of a single slice with optional * waste, assuming the users given texture coordinates don't require * repeating. - * - CoglTexture{1D,2D,3D}: always. + * - CoglTexture{1D,2D}: always. * - CoglTexture2DAtlas: assuming the users given texture coordinates don't * require repeating. * - CoglTextureRectangle: assuming the users given texture coordinates don't diff --git a/cogl/cogl/cogl-texture-3d-private.h b/cogl/cogl/cogl-texture-3d-private.h deleted file mode 100644 index 170970e24..000000000 --- a/cogl/cogl/cogl-texture-3d-private.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Neil Roberts - */ - -#ifndef __COGL_TEXTURE_3D_PRIVATE_H -#define __COGL_TEXTURE_3D_PRIVATE_H - -#include "cogl-object-private.h" -#include "cogl-pipeline-private.h" -#include "cogl-texture-private.h" -#include "cogl-texture-3d.h" - -struct _CoglTexture3D -{ - CoglTexture _parent; - - /* The internal format of the texture represented as a - CoglPixelFormat */ - CoglPixelFormat internal_format; - int depth; - gboolean auto_mipmap; - gboolean mipmaps_dirty; - - /* TODO: factor out these OpenGL specific members into some form - * of driver private state. */ - - /* The internal format of the GL texture represented as a GL enum */ - GLenum gl_format; - /* The texture object number */ - GLuint gl_texture; - GLenum gl_legacy_texobj_min_filter; - GLenum gl_legacy_texobj_mag_filter; - GLint gl_legacy_texobj_wrap_mode_s; - GLint gl_legacy_texobj_wrap_mode_t; - GLint gl_legacy_texobj_wrap_mode_p; - CoglTexturePixel first_pixel; -}; - -#endif /* __COGL_TEXTURE_3D_PRIVATE_H */ diff --git a/cogl/cogl/cogl-texture-3d.c b/cogl/cogl/cogl-texture-3d.c deleted file mode 100644 index b23bc3761..000000000 --- a/cogl/cogl/cogl-texture-3d.c +++ /dev/null @@ -1,758 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Neil Roberts - */ - -#include "cogl-config.h" - -#include "cogl-private.h" -#include "cogl-util.h" -#include "cogl-texture-private.h" -#include "cogl-texture-3d-private.h" -#include "cogl-texture-3d.h" -#include "cogl-texture-driver.h" -#include "cogl-context-private.h" -#include "cogl-object-private.h" -#include "cogl-journal-private.h" -#include "cogl-pipeline-private.h" -#include "cogl-error-private.h" -#include "cogl-gtype-private.h" -#include "driver/gl/cogl-texture-gl-private.h" -#include "driver/gl/cogl-pipeline-opengl-private.h" -#include "driver/gl/cogl-util-gl-private.h" - -#include -#include - -/* These might not be defined on GLES */ -#ifndef GL_TEXTURE_3D -#define GL_TEXTURE_3D 0x806F -#endif -#ifndef GL_TEXTURE_WRAP_R -#define GL_TEXTURE_WRAP_R 0x8072 -#endif - -static void _cogl_texture_3d_free (CoglTexture3D *tex_3d); - -COGL_TEXTURE_DEFINE (Texture3D, texture_3d); -COGL_GTYPE_DEFINE_CLASS (Texture3D, texture_3d, - COGL_GTYPE_IMPLEMENT_INTERFACE (texture)); - -static const CoglTextureVtable cogl_texture_3d_vtable; - -static void -_cogl_texture_3d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex, - GLenum wrap_mode_s, - GLenum wrap_mode_t, - GLenum wrap_mode_p) -{ - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex); - CoglContext *ctx = tex->context; - - /* Only set the wrap mode if it's different from the current value - to avoid too many GL calls. */ - if (tex_3d->gl_legacy_texobj_wrap_mode_s != wrap_mode_s || - tex_3d->gl_legacy_texobj_wrap_mode_t != wrap_mode_t || - tex_3d->gl_legacy_texobj_wrap_mode_p != wrap_mode_p) - { - _cogl_bind_gl_texture_transient (GL_TEXTURE_3D, - tex_3d->gl_texture, - FALSE); - GE( ctx, glTexParameteri (GL_TEXTURE_3D, - GL_TEXTURE_WRAP_S, - wrap_mode_s) ); - GE( ctx, glTexParameteri (GL_TEXTURE_3D, - GL_TEXTURE_WRAP_T, - wrap_mode_t) ); - GE( ctx, glTexParameteri (GL_TEXTURE_3D, - GL_TEXTURE_WRAP_R, - wrap_mode_p) ); - - tex_3d->gl_legacy_texobj_wrap_mode_s = wrap_mode_s; - tex_3d->gl_legacy_texobj_wrap_mode_t = wrap_mode_t; - tex_3d->gl_legacy_texobj_wrap_mode_p = wrap_mode_p; - } -} - -static void -_cogl_texture_3d_free (CoglTexture3D *tex_3d) -{ - if (tex_3d->gl_texture) - _cogl_delete_gl_texture (tex_3d->gl_texture); - - /* Chain up */ - _cogl_texture_free (COGL_TEXTURE (tex_3d)); -} - -static void -_cogl_texture_3d_set_auto_mipmap (CoglTexture *tex, - gboolean value) -{ - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex); - - tex_3d->auto_mipmap = value; -} - -static CoglTexture3D * -_cogl_texture_3d_create_base (CoglContext *ctx, - int width, - int height, - int depth, - CoglPixelFormat internal_format, - CoglTextureLoader *loader) -{ - CoglTexture3D *tex_3d = g_new (CoglTexture3D, 1); - CoglTexture *tex = COGL_TEXTURE (tex_3d); - - _cogl_texture_init (tex, ctx, width, height, - internal_format, loader, &cogl_texture_3d_vtable); - - tex_3d->gl_texture = 0; - - tex_3d->depth = depth; - tex_3d->mipmaps_dirty = TRUE; - tex_3d->auto_mipmap = TRUE; - - /* We default to GL_LINEAR for both filters */ - tex_3d->gl_legacy_texobj_min_filter = GL_LINEAR; - tex_3d->gl_legacy_texobj_mag_filter = GL_LINEAR; - - /* Wrap mode not yet set */ - tex_3d->gl_legacy_texobj_wrap_mode_s = GL_FALSE; - tex_3d->gl_legacy_texobj_wrap_mode_t = GL_FALSE; - tex_3d->gl_legacy_texobj_wrap_mode_p = GL_FALSE; - - return _cogl_texture_3d_object_new (tex_3d); -} - -CoglTexture3D * -cogl_texture_3d_new_with_size (CoglContext *ctx, - int width, - int height, - int depth) -{ - CoglTextureLoader *loader = _cogl_texture_create_loader (); - loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED; - loader->src.sized.width = width; - loader->src.sized.height = height; - loader->src.sized.depth = depth; - - return _cogl_texture_3d_create_base (ctx, width, height, depth, - COGL_PIXEL_FORMAT_RGBA_8888_PRE, - loader); -} - -CoglTexture3D * -cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp, - int height, - int depth) -{ - CoglTextureLoader *loader; - - _COGL_RETURN_VAL_IF_FAIL (bmp, NULL); - - loader = _cogl_texture_create_loader (); - loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP; - loader->src.bitmap.bitmap = cogl_object_ref (bmp); - loader->src.bitmap.height = height; - loader->src.bitmap.depth = depth; - loader->src.bitmap.can_convert_in_place = FALSE; /* TODO add api for this */ - - return _cogl_texture_3d_create_base (_cogl_bitmap_get_context (bmp), - cogl_bitmap_get_width (bmp), - height, - depth, - cogl_bitmap_get_format (bmp), - loader); -} - -CoglTexture3D * -cogl_texture_3d_new_from_data (CoglContext *context, - int width, - int height, - int depth, - CoglPixelFormat format, - int rowstride, - int image_stride, - const uint8_t *data, - CoglError **error) -{ - CoglBitmap *bitmap; - CoglTexture3D *ret; - - _COGL_RETURN_VAL_IF_FAIL (data, NULL); - _COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL); - - /* Rowstride from width if not given */ - if (rowstride == 0) - rowstride = width * _cogl_pixel_format_get_bytes_per_pixel (format); - /* Image stride from height and rowstride if not given */ - if (image_stride == 0) - image_stride = height * rowstride; - - if (image_stride < rowstride * height) - return NULL; - - /* GL doesn't support uploading when the image_stride isn't a - multiple of the rowstride. If this happens we'll just pack the - image into a new bitmap. The documentation for this function - recommends avoiding this situation. */ - if (image_stride % rowstride != 0) - { - uint8_t *bmp_data; - int bmp_rowstride; - int z, y; - - bitmap = _cogl_bitmap_new_with_malloc_buffer (context, - width, - depth * height, - format, - error); - if (!bitmap) - return NULL; - - bmp_data = _cogl_bitmap_map (bitmap, - COGL_BUFFER_ACCESS_WRITE, - COGL_BUFFER_MAP_HINT_DISCARD, - error); - - if (bmp_data == NULL) - { - cogl_object_unref (bitmap); - return NULL; - } - - bmp_rowstride = cogl_bitmap_get_rowstride (bitmap); - - /* Copy all of the images in */ - for (z = 0; z < depth; z++) - for (y = 0; y < height; y++) - memcpy (bmp_data + (z * bmp_rowstride * height + - bmp_rowstride * y), - data + z * image_stride + rowstride * y, - bmp_rowstride); - - _cogl_bitmap_unmap (bitmap); - } - else - bitmap = cogl_bitmap_new_for_data (context, - width, - image_stride / rowstride * depth, - format, - rowstride, - (uint8_t *) data); - - ret = cogl_texture_3d_new_from_bitmap (bitmap, - height, - depth); - - cogl_object_unref (bitmap); - - if (ret && - !cogl_texture_allocate (COGL_TEXTURE (ret), error)) - { - cogl_object_unref (ret); - return NULL; - } - - return ret; -} - -static gboolean -_cogl_texture_3d_can_create (CoglContext *ctx, - int width, - int height, - int depth, - CoglPixelFormat internal_format, - CoglError **error) -{ - GLenum gl_intformat; - GLenum gl_type; - - /* This should only happen on GLES */ - if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D)) - { - _cogl_set_error (error, - COGL_SYSTEM_ERROR, - COGL_SYSTEM_ERROR_UNSUPPORTED, - "3D textures are not supported by the GPU"); - return FALSE; - } - - /* If NPOT textures aren't supported then the size must be a power - of two */ - if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT) && - (!_cogl_util_is_pot (width) || - !_cogl_util_is_pot (height) || - !_cogl_util_is_pot (depth))) - { - _cogl_set_error (error, - COGL_SYSTEM_ERROR, - COGL_SYSTEM_ERROR_UNSUPPORTED, - "A non-power-of-two size was requested but this is not " - "supported by the GPU"); - return FALSE; - } - - ctx->driver_vtable->pixel_format_to_gl (ctx, - internal_format, - &gl_intformat, - NULL, - &gl_type); - - /* Check that the driver can create a texture with that size */ - if (!ctx->texture_driver->size_supported_3d (ctx, - GL_TEXTURE_3D, - gl_intformat, - gl_type, - width, - height, - depth)) - { - _cogl_set_error (error, - COGL_SYSTEM_ERROR, - COGL_SYSTEM_ERROR_UNSUPPORTED, - "The requested dimensions are not supported by the GPU"); - return FALSE; - } - - return TRUE; -} - -static gboolean -allocate_with_size (CoglTexture3D *tex_3d, - CoglTextureLoader *loader, - CoglError **error) -{ - CoglTexture *tex = COGL_TEXTURE (tex_3d); - CoglContext *ctx = tex->context; - CoglPixelFormat internal_format; - int width = loader->src.sized.width; - int height = loader->src.sized.height; - int depth = loader->src.sized.depth; - GLenum gl_intformat; - GLenum gl_format; - GLenum gl_type; - GLenum gl_texture; - - internal_format = - _cogl_texture_determine_internal_format (tex, COGL_PIXEL_FORMAT_ANY); - - if (!_cogl_texture_3d_can_create (ctx, - width, - height, - depth, - internal_format, - error)) - return FALSE; - - ctx->driver_vtable->pixel_format_to_gl (ctx, - internal_format, - &gl_intformat, - &gl_format, - &gl_type); - - gl_texture = - ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, internal_format); - _cogl_bind_gl_texture_transient (GL_TEXTURE_3D, - gl_texture, - FALSE); - /* Clear any GL errors */ - _cogl_gl_util_clear_gl_errors (ctx); - - ctx->glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat, - width, height, depth, - 0, gl_format, gl_type, NULL); - - if (_cogl_gl_util_catch_out_of_memory (ctx, error)) - { - GE( ctx, glDeleteTextures (1, &gl_texture) ); - return FALSE; - } - - tex_3d->gl_texture = gl_texture; - tex_3d->gl_format = gl_intformat; - - tex_3d->depth = depth; - - tex_3d->internal_format = internal_format; - - _cogl_texture_set_allocated (tex, internal_format, width, height); - - return TRUE; -} - -static gboolean -allocate_from_bitmap (CoglTexture3D *tex_3d, - CoglTextureLoader *loader, - CoglError **error) -{ - CoglTexture *tex = COGL_TEXTURE (tex_3d); - CoglContext *ctx = tex->context; - CoglPixelFormat internal_format; - CoglBitmap *bmp = loader->src.bitmap.bitmap; - int bmp_width = cogl_bitmap_get_width (bmp); - int height = loader->src.bitmap.height; - int depth = loader->src.bitmap.depth; - CoglPixelFormat bmp_format = cogl_bitmap_get_format (bmp); - gboolean can_convert_in_place = loader->src.bitmap.can_convert_in_place; - CoglBitmap *upload_bmp; - CoglPixelFormat upload_format; - GLenum gl_intformat; - GLenum gl_format; - GLenum gl_type; - - internal_format = _cogl_texture_determine_internal_format (tex, bmp_format); - - if (!_cogl_texture_3d_can_create (ctx, - bmp_width, height, depth, - internal_format, - error)) - return FALSE; - - upload_bmp = _cogl_bitmap_convert_for_upload (bmp, - internal_format, - can_convert_in_place, - error); - if (upload_bmp == NULL) - return FALSE; - - upload_format = cogl_bitmap_get_format (upload_bmp); - - ctx->driver_vtable->pixel_format_to_gl (ctx, - upload_format, - NULL, /* internal format */ - &gl_format, - &gl_type); - ctx->driver_vtable->pixel_format_to_gl (ctx, - internal_format, - &gl_intformat, - NULL, - NULL); - - /* Keep a copy of the first pixel so that if glGenerateMipmap isn't - supported we can fallback to using GL_GENERATE_MIPMAP */ - if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN)) - { - CoglError *ignore = NULL; - uint8_t *data = _cogl_bitmap_map (upload_bmp, - COGL_BUFFER_ACCESS_READ, 0, - &ignore); - - tex_3d->first_pixel.gl_format = gl_format; - tex_3d->first_pixel.gl_type = gl_type; - - if (data) - { - memcpy (tex_3d->first_pixel.data, data, - _cogl_pixel_format_get_bytes_per_pixel (upload_format)); - _cogl_bitmap_unmap (upload_bmp); - } - else - { - g_warning ("Failed to read first pixel of bitmap for " - "glGenerateMipmap fallback"); - cogl_error_free (ignore); - memset (tex_3d->first_pixel.data, 0, - _cogl_pixel_format_get_bytes_per_pixel (upload_format)); - } - } - - tex_3d->gl_texture = - ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, internal_format); - - if (!ctx->texture_driver->upload_to_gl_3d (ctx, - GL_TEXTURE_3D, - tex_3d->gl_texture, - FALSE, /* is_foreign */ - height, - depth, - upload_bmp, - gl_intformat, - gl_format, - gl_type, - error)) - { - cogl_object_unref (upload_bmp); - return FALSE; - } - - tex_3d->gl_format = gl_intformat; - - cogl_object_unref (upload_bmp); - - tex_3d->depth = loader->src.bitmap.depth; - - tex_3d->internal_format = internal_format; - - _cogl_texture_set_allocated (tex, internal_format, - bmp_width, loader->src.bitmap.height); - - return TRUE; -} - -static gboolean -_cogl_texture_3d_allocate (CoglTexture *tex, - CoglError **error) -{ - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex); - CoglTextureLoader *loader = tex->loader; - - _COGL_RETURN_VAL_IF_FAIL (loader, FALSE); - - switch (loader->src_type) - { - case COGL_TEXTURE_SOURCE_TYPE_SIZED: - return allocate_with_size (tex_3d, loader, error); - case COGL_TEXTURE_SOURCE_TYPE_BITMAP: - return allocate_from_bitmap (tex_3d, loader, error); - default: - break; - } - - g_return_val_if_reached (FALSE); -} - -static int -_cogl_texture_3d_get_max_waste (CoglTexture *tex) -{ - return -1; -} - -static gboolean -_cogl_texture_3d_is_sliced (CoglTexture *tex) -{ - return FALSE; -} - -static gboolean -_cogl_texture_3d_can_hardware_repeat (CoglTexture *tex) -{ - return TRUE; -} - -static void -_cogl_texture_3d_transform_coords_to_gl (CoglTexture *tex, - float *s, - float *t) -{ - /* The texture coordinates map directly so we don't need to do - anything */ -} - -static CoglTransformResult -_cogl_texture_3d_transform_quad_coords_to_gl (CoglTexture *tex, - float *coords) -{ - /* The texture coordinates map directly so we don't need to do - anything other than check for repeats */ - - gboolean need_repeat = FALSE; - int i; - - for (i = 0; i < 4; i++) - if (coords[i] < 0.0f || coords[i] > 1.0f) - need_repeat = TRUE; - - return (need_repeat ? COGL_TRANSFORM_HARDWARE_REPEAT - : COGL_TRANSFORM_NO_REPEAT); -} - -static gboolean -_cogl_texture_3d_get_gl_texture (CoglTexture *tex, - GLuint *out_gl_handle, - GLenum *out_gl_target) -{ - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex); - - if (out_gl_handle) - *out_gl_handle = tex_3d->gl_texture; - - if (out_gl_target) - *out_gl_target = GL_TEXTURE_3D; - - return TRUE; -} - -static void -_cogl_texture_3d_gl_flush_legacy_texobj_filters (CoglTexture *tex, - GLenum min_filter, - GLenum mag_filter) -{ - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex); - CoglContext *ctx = tex->context; - - if (min_filter == tex_3d->gl_legacy_texobj_min_filter - && mag_filter == tex_3d->gl_legacy_texobj_mag_filter) - return; - - /* Store new values */ - tex_3d->gl_legacy_texobj_min_filter = min_filter; - tex_3d->gl_legacy_texobj_mag_filter = mag_filter; - - /* Apply new filters to the texture */ - _cogl_bind_gl_texture_transient (GL_TEXTURE_3D, - tex_3d->gl_texture, - FALSE); - GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, mag_filter) ); - GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, min_filter) ); -} - -static void -_cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags) -{ - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex); - CoglContext *ctx = tex->context; - - /* Only update if the mipmaps are dirty */ - if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) && - tex_3d->auto_mipmap && tex_3d->mipmaps_dirty) - { - /* glGenerateMipmap is defined in the FBO extension. If it's not - available we'll fallback to temporarily enabling - GL_GENERATE_MIPMAP and reuploading the first pixel */ - if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN)) - _cogl_texture_gl_generate_mipmaps (tex); -#ifdef HAVE_COGL_GL - else if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED)) - { - _cogl_bind_gl_texture_transient (GL_TEXTURE_3D, - tex_3d->gl_texture, - FALSE); - - GE( ctx, glTexParameteri (GL_TEXTURE_3D, - GL_GENERATE_MIPMAP, - GL_TRUE) ); - GE( ctx, glTexSubImage3D (GL_TEXTURE_3D, - 0, /* level */ - 0, /* xoffset */ - 0, /* yoffset */ - 0, /* zoffset */ - 1, /* width */ - 1, /* height */ - 1, /* depth */ - tex_3d->first_pixel.gl_format, - tex_3d->first_pixel.gl_type, - tex_3d->first_pixel.data) ); - GE( ctx, glTexParameteri (GL_TEXTURE_3D, - GL_GENERATE_MIPMAP, - GL_FALSE) ); - } -#endif - - tex_3d->mipmaps_dirty = FALSE; - } -} - -static void -_cogl_texture_3d_ensure_non_quad_rendering (CoglTexture *tex) -{ - /* Nothing needs to be done */ -} - -static gboolean -_cogl_texture_3d_set_region (CoglTexture *tex, - int src_x, - int src_y, - int dst_x, - int dst_y, - int dst_width, - int dst_height, - int level, - CoglBitmap *bmp, - CoglError **error) -{ - /* This function doesn't really make sense for 3D textures because - it can't specify which image to upload to */ - _cogl_set_error (error, - COGL_SYSTEM_ERROR, - COGL_SYSTEM_ERROR_UNSUPPORTED, - "Setting a 2D region on a 3D texture isn't " - "currently supported"); - - return FALSE; -} - -static int -_cogl_texture_3d_get_data (CoglTexture *tex, - CoglPixelFormat format, - int rowstride, - uint8_t *data) -{ - /* FIXME: we could probably implement this by assuming the data is - big enough to hold all of the images and that there is no stride - between the images. However it would be better to have an API - that can provide an image stride and this function probably isn't - particularly useful anyway so for now it just reports failure */ - return 0; -} - -static CoglPixelFormat -_cogl_texture_3d_get_format (CoglTexture *tex) -{ - return COGL_TEXTURE_3D (tex)->internal_format; -} - -static GLenum -_cogl_texture_3d_get_gl_format (CoglTexture *tex) -{ - return COGL_TEXTURE_3D (tex)->gl_format; -} - -static CoglTextureType -_cogl_texture_3d_get_type (CoglTexture *tex) -{ - return COGL_TEXTURE_TYPE_3D; -} - -static const CoglTextureVtable -cogl_texture_3d_vtable = - { - TRUE, /* primitive */ - _cogl_texture_3d_allocate, - _cogl_texture_3d_set_region, - NULL, /* is_get_data_supported */ - _cogl_texture_3d_get_data, - NULL, /* foreach_sub_texture_in_region */ - _cogl_texture_3d_get_max_waste, - _cogl_texture_3d_is_sliced, - _cogl_texture_3d_can_hardware_repeat, - _cogl_texture_3d_transform_coords_to_gl, - _cogl_texture_3d_transform_quad_coords_to_gl, - _cogl_texture_3d_get_gl_texture, - _cogl_texture_3d_gl_flush_legacy_texobj_filters, - _cogl_texture_3d_pre_paint, - _cogl_texture_3d_ensure_non_quad_rendering, - _cogl_texture_3d_gl_flush_legacy_texobj_wrap_modes, - _cogl_texture_3d_get_format, - _cogl_texture_3d_get_gl_format, - _cogl_texture_3d_get_type, - NULL, /* is_foreign */ - _cogl_texture_3d_set_auto_mipmap - }; diff --git a/cogl/cogl/cogl-texture-3d.h b/cogl/cogl/cogl-texture-3d.h deleted file mode 100644 index d1ab623eb..000000000 --- a/cogl/cogl/cogl-texture-3d.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Neil Roberts - */ - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __COGL_TEXTURE_3D_H -#define __COGL_TEXTURE_3D_H - -G_BEGIN_DECLS - -/** - * SECTION:cogl-texture-3d - * @short_description: Functions for creating and manipulating 3D textures - * - * These functions allow 3D textures to be used. 3D textures can be - * thought of as layers of 2D images arranged into a cuboid - * shape. When choosing a texel from the texture, Cogl will take into - * account the 'r' texture coordinate to select one of the images. - */ - -typedef struct _CoglTexture3D CoglTexture3D; - -#define COGL_TEXTURE_3D(X) ((CoglTexture3D *)X) - -/** - * cogl_texture_3d_get_gtype: - * - * Returns: a #GType that can be used with the GLib type system. - */ -GType cogl_texture_3d_get_gtype (void); - -/** - * cogl_texture_3d_new_with_size: - * @context: a #CoglContext - * @width: width of the texture in pixels. - * @height: height of the texture in pixels. - * @depth: depth of the texture in pixels. - * - * Creates a low-level #CoglTexture3D texture with the specified - * dimensions and pixel format. - * - * The storage for the texture is not allocated before this function - * returns. You can call cogl_texture_allocate() to explicitly - * allocate the underlying storage or preferably let Cogl - * automatically allocate storage lazily when it may know more about - * how the texture is going to be used and can optimize how it is - * allocated. - * - * The texture is still configurable until it has been allocated so - * for example you can influence the internal format of the texture - * using cogl_texture_set_components() and - * cogl_texture_set_premultiplied(). - * - * This texture will fail to allocate later if - * %COGL_FEATURE_ID_TEXTURE_3D is not advertised. Allocation can also - * fail if the requested dimensions are not supported by the - * GPU. - * - * Returns: (transfer full): A new #CoglTexture3D object with no storage yet allocated. - * Since: 1.10 - * Stability: Unstable - */ -CoglTexture3D * -cogl_texture_3d_new_with_size (CoglContext *context, - int width, - int height, - int depth); - -/** - * cogl_texture_3d_new_from_data: - * @context: a #CoglContext - * @width: width of the texture in pixels. - * @height: height of the texture in pixels. - * @depth: depth of the texture in pixels. - * @format: the #CoglPixelFormat the buffer is stored in in RAM - * @rowstride: the memory offset in bytes between the starts of - * scanlines in @data or 0 to infer it from the width and format - * @image_stride: the number of bytes from one image to the next. This - * can be used to add padding between the images in a similar way - * that the rowstride can be used to add padding between - * rows. Alternatively 0 can be passed to infer the @image_stride - * from the @height. - * @data: pointer the memory region where the source buffer resides - * @error: A CoglError return location. - * - * Creates a low-level 3D texture and initializes it with @data. The - * data is assumed to be packed array of @depth images. There can be - * padding between the images using @image_stride. - * - * This api will always immediately allocate GPU memory for the - * texture and upload the given data so that the @data pointer does - * not need to remain valid once this function returns. This means it - * is not possible to configure the texture before it is allocated. If - * you do need to configure the texture before allocation (to specify - * constraints on the internal format for example) then you can - * instead create a #CoglBitmap for your data and use - * cogl_texture_3d_new_from_bitmap(). - * - * Return value: (transfer full): the newly created #CoglTexture3D or - * %NULL if there was an error and an exception will be - * returned through @error. - * Since: 1.10 - * Stability: Unstable - */ -CoglTexture3D * -cogl_texture_3d_new_from_data (CoglContext *context, - int width, - int height, - int depth, - CoglPixelFormat format, - int rowstride, - int image_stride, - const uint8_t *data, - CoglError **error); - -/** - * cogl_texture_3d_new_from_bitmap: - * @bitmap: A #CoglBitmap object. - * @height: height of the texture in pixels. - * @depth: depth of the texture in pixels. - * - * Creates a low-level 3D texture and initializes it with the images - * in @bitmap. The images are assumed to be packed together after one - * another in the increasing y axis. The height of individual image is - * given as @height and the number of images is given in @depth. The - * actual height of the bitmap can be larger than @height × @depth. In - * this case it assumes there is padding between the images. - * - * The storage for the texture is not allocated before this function - * returns. You can call cogl_texture_allocate() to explicitly - * allocate the underlying storage or preferably let Cogl - * automatically allocate storage lazily when it may know more about - * how the texture is going to be used and can optimize how it is - * allocated. - * - * The texture is still configurable until it has been allocated so - * for example you can influence the internal format of the texture - * using cogl_texture_set_components() and - * cogl_texture_set_premultiplied(). - * - * This texture will fail to allocate later if - * %COGL_FEATURE_ID_TEXTURE_3D is not advertised. Allocation can also - * fail if the requested dimensions are not supported by the - * GPU. - * - * Return value: (transfer full): a newly created #CoglTexture3D - * Since: 2.0 - * Stability: unstable - */ -CoglTexture3D * -cogl_texture_3d_new_from_bitmap (CoglBitmap *bitmap, - int height, - int depth); - -/** - * cogl_is_texture_3d: - * @object: a #CoglObject - * - * Checks whether the given object references a #CoglTexture3D - * - * Return value: %TRUE if the passed object represents a 3D texture - * and %FALSE otherwise - * - * Since: 1.4 - * Stability: Unstable - */ -gboolean -cogl_is_texture_3d (void *object); - -G_END_DECLS - -#endif /* __COGL_TEXTURE_3D_H */ diff --git a/cogl/cogl/cogl-texture-driver.h b/cogl/cogl/cogl-texture-driver.h index a6e7d4f1a..e5932a98f 100644 --- a/cogl/cogl/cogl-texture-driver.h +++ b/cogl/cogl/cogl-texture-driver.h @@ -103,26 +103,6 @@ struct _CoglTextureDriver GLuint source_gl_type, CoglError **error); - /* - * Replaces the contents of the GL texture with the entire bitmap. The - * width of the texture is inferred from the bitmap. The height and - * depth of the texture is given directly. The 'image_height' (which - * is the number of rows between images) is inferred by dividing the - * height of the bitmap by the depth. - */ - gboolean - (* upload_to_gl_3d) (CoglContext *ctx, - GLenum gl_target, - GLuint gl_handle, - gboolean is_foreign, - GLint height, - GLint depth, - CoglBitmap *source_bmp, - GLint internal_gl_format, - GLuint source_gl_format, - GLuint source_gl_type, - CoglError **error); - /* * This sets up the glPixelStore state for an download to a destination with * the same size, and with no offset. @@ -162,15 +142,6 @@ struct _CoglTextureDriver int width, int height); - gboolean - (* size_supported_3d) (CoglContext *ctx, - GLenum gl_target, - GLenum gl_format, - GLenum gl_type, - int width, - int height, - int depth); - /* * It may depend on the driver as to what texture targets may be used when * creating a foreign texture. E.g. OpenGL supports ARB_texture_rectangle diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index 695b9bea4..dd4c37e9a 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -47,7 +47,6 @@ #include "cogl-texture-2d-sliced-private.h" #include "cogl-texture-2d-private.h" #include "cogl-texture-2d-gl.h" -#include "cogl-texture-3d-private.h" #include "cogl-texture-rectangle-private.h" #include "cogl-sub-texture-private.h" #include "cogl-atlas-texture-private.h" @@ -245,12 +244,6 @@ _cogl_texture_get_n_levels (CoglTexture *texture) int height = cogl_texture_get_height (texture); int max_dimension = MAX (width, height); - if (cogl_is_texture_3d (texture)) - { - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (texture); - max_dimension = MAX (max_dimension, tex_3d->depth); - } - return _cogl_util_fls (max_dimension); } @@ -263,17 +256,9 @@ _cogl_texture_get_level_size (CoglTexture *texture, { int current_width = cogl_texture_get_width (texture); int current_height = cogl_texture_get_height (texture); - int current_depth; + int current_depth = 0; int i; - if (cogl_is_texture_3d (texture)) - { - CoglTexture3D *tex_3d = COGL_TEXTURE_3D (texture); - current_depth = tex_3d->depth; - } - else - current_depth = 0; - /* NB: The OpenGL spec (like D3D) uses a floor() convention to * round down the size of a mipmap level when dividing the size * of the previous level results in a fraction... diff --git a/cogl/cogl/cogl-texture.h b/cogl/cogl/cogl-texture.h index a19b6c2e0..0c428b5ee 100644 --- a/cogl/cogl/cogl-texture.h +++ b/cogl/cogl/cogl-texture.h @@ -110,7 +110,6 @@ typedef enum /** * CoglTextureType: * @COGL_TEXTURE_TYPE_2D: A #CoglTexture2D - * @COGL_TEXTURE_TYPE_3D: A #CoglTexture3D * @COGL_TEXTURE_TYPE_RECTANGLE: A #CoglTextureRectangle * * Constants representing the underlying hardware texture type of a @@ -122,7 +121,6 @@ typedef enum typedef enum { COGL_TEXTURE_TYPE_2D, - COGL_TEXTURE_TYPE_3D, COGL_TEXTURE_TYPE_RECTANGLE } CoglTextureType; diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h index dc0de87c4..981b74fff 100644 --- a/cogl/cogl/cogl-types.h +++ b/cogl/cogl/cogl-types.h @@ -347,7 +347,6 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/ * hardware. * @COGL_FEATURE_POINT_SPRITE: Whether * cogl_material_set_layer_point_sprite_coords_enabled() is supported. - * @COGL_FEATURE_TEXTURE_3D: 3D texture support * @COGL_FEATURE_MAP_BUFFER_FOR_READ: Whether cogl_buffer_map() is * supported with CoglBufferAccess including read support. * @COGL_FEATURE_MAP_BUFFER_FOR_WRITE: Whether cogl_buffer_map() is @@ -379,7 +378,6 @@ typedef enum COGL_FEATURE_TEXTURE_NPOT_MIPMAP = (1 << 16), COGL_FEATURE_TEXTURE_NPOT_REPEAT = (1 << 17), COGL_FEATURE_POINT_SPRITE = (1 << 18), - COGL_FEATURE_TEXTURE_3D = (1 << 19), COGL_FEATURE_MAP_BUFFER_FOR_READ = (1 << 21), COGL_FEATURE_MAP_BUFFER_FOR_WRITE = (1 << 22), COGL_FEATURE_ONSCREEN_MULTIPLE = (1 << 23), diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index 565ea289a..8663d251e 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -106,7 +106,6 @@ #include #include #include -#include #include #include #include diff --git a/cogl/cogl/cogl.symbols b/cogl/cogl/cogl.symbols index f26e43d35..4fbf2246b 100644 --- a/cogl/cogl/cogl.symbols +++ b/cogl/cogl/cogl.symbols @@ -410,7 +410,6 @@ cogl_is_texture_pixmap_x11 #endif cogl_is_texture_rectangle cogl_is_texture_2d -cogl_is_texture_3d cogl_material_alpha_func_get_type cogl_material_copy @@ -954,12 +953,6 @@ cogl_texture_2d_sliced_new_from_bitmap cogl_texture_2d_sliced_new_from_data cogl_texture_2d_sliced_new_from_file cogl_texture_2d_sliced_new_with_size -#ifdef COGL_HAS_GTYPE_SUPPORT -cogl_texture_3d_get_gtype -#endif -cogl_texture_3d_new_from_bitmap -cogl_texture_3d_new_from_data -cogl_texture_3d_new_with_size cogl_transform cogl_translate diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index 9e00b1049..cadb2d2ef 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -778,9 +778,6 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data) case COGL_TEXTURE_TYPE_2D: texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex); break; - case COGL_TEXTURE_TYPE_3D: - texture = COGL_TEXTURE (ctx->default_gl_texture_3d_tex); - break; case COGL_TEXTURE_TYPE_RECTANGLE: texture = COGL_TEXTURE (ctx->default_gl_texture_rect_tex); break; diff --git a/cogl/cogl/driver/gl/cogl-texture-gl.c b/cogl/cogl/driver/gl/cogl-texture-gl.c index 89308adaa..17b5662fd 100644 --- a/cogl/cogl/driver/gl/cogl-texture-gl.c +++ b/cogl/cogl/driver/gl/cogl-texture-gl.c @@ -32,7 +32,6 @@ #include #include "cogl-context-private.h" -#include "cogl-texture-3d-private.h" #include "cogl-util.h" #include "driver/gl/cogl-util-gl-private.h" #include "driver/gl/cogl-texture-gl-private.h" diff --git a/cogl/cogl/driver/gl/cogl-util-gl.c b/cogl/cogl/driver/gl/cogl-util-gl.c index 45f5130db..022516c79 100644 --- a/cogl/cogl/driver/gl/cogl-util-gl.c +++ b/cogl/cogl/driver/gl/cogl-util-gl.c @@ -148,11 +148,6 @@ _cogl_gl_util_get_texture_target_string (CoglTextureType texture_type, tex_coord_swizzle = "st"; break; - case COGL_TEXTURE_TYPE_3D: - target_string = "3D"; - tex_coord_swizzle = "stp"; - break; - case COGL_TEXTURE_TYPE_RECTANGLE: target_string = "2DRect"; tex_coord_swizzle = "st"; diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index d7ba9280e..ab92b0e08 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -475,12 +475,6 @@ _cogl_driver_update_features (CoglContext *ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE, TRUE); } - if (ctx->glTexImage3D) - { - flags |= COGL_FEATURE_TEXTURE_3D; - COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_3D, TRUE); - } - if (ctx->glEGLImageTargetTexture2D) COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE, TRUE); diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c index 35b87f7a7..c2270124f 100644 --- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c @@ -71,7 +71,6 @@ _cogl_texture_driver_gen (CoglContext *ctx, switch (gl_target) { case GL_TEXTURE_2D: - case GL_TEXTURE_3D: /* In case automatic mipmap generation gets disabled for this * texture but a minification filter depending on mipmap * interpolation is selected then we initialize the max mipmap @@ -131,9 +130,6 @@ prep_gl_for_pixels_upload_full (CoglContext *ctx, GE( ctx, glPixelStorei (GL_UNPACK_SKIP_PIXELS, pixels_src_x) ); GE( ctx, glPixelStorei (GL_UNPACK_SKIP_ROWS, pixels_src_y) ); - if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D)) - GE( ctx, glPixelStorei (GL_UNPACK_IMAGE_HEIGHT, image_height) ); - _cogl_texture_gl_prep_alignment_for_pixels_upload (ctx, pixels_rowstride); } @@ -161,9 +157,6 @@ prep_gl_for_pixels_download_full (CoglContext *ctx, GE( ctx, glPixelStorei (GL_PACK_SKIP_PIXELS, pixels_src_x) ); GE( ctx, glPixelStorei (GL_PACK_SKIP_ROWS, pixels_src_y) ); - if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D)) - GE( ctx, glPixelStorei (GL_PACK_IMAGE_HEIGHT, image_height) ); - _cogl_texture_gl_prep_alignment_for_pixels_download (ctx, pixels_bpp, image_width, @@ -355,59 +348,6 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx, return status; } -static gboolean -_cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx, - GLenum gl_target, - GLuint gl_handle, - gboolean is_foreign, - GLint height, - GLint depth, - CoglBitmap *source_bmp, - GLint internal_gl_format, - GLuint source_gl_format, - GLuint source_gl_type, - CoglError **error) -{ - uint8_t *data; - CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp); - int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format); - gboolean status = TRUE; - - data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0, error); - if (!data) - return FALSE; - - /* Setup gl alignment to match rowstride and top-left corner */ - prep_gl_for_pixels_upload_full (ctx, - cogl_bitmap_get_rowstride (source_bmp), - (cogl_bitmap_get_height (source_bmp) / - depth), - 0, 0, bpp); - - _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign); - - /* Clear any GL errors */ - _cogl_gl_util_clear_gl_errors (ctx); - - ctx->glTexImage3D (gl_target, - 0, /* level */ - internal_gl_format, - cogl_bitmap_get_width (source_bmp), - height, - depth, - 0, - source_gl_format, - source_gl_type, - data); - - if (_cogl_gl_util_catch_out_of_memory (ctx, error)) - status = FALSE; - - _cogl_bitmap_gl_unbind (source_bmp); - - return status; -} - static gboolean _cogl_texture_driver_gl_get_tex_image (CoglContext *ctx, GLenum gl_target, @@ -423,35 +363,6 @@ _cogl_texture_driver_gl_get_tex_image (CoglContext *ctx, return TRUE; } -static gboolean -_cogl_texture_driver_size_supported_3d (CoglContext *ctx, - GLenum gl_target, - GLenum gl_format, - GLenum gl_type, - int width, - int height, - int depth) -{ - GLenum proxy_target; - GLint new_width = 0; - - if (gl_target == GL_TEXTURE_3D) - proxy_target = GL_PROXY_TEXTURE_3D; - else - /* Unknown target, assume it's not supported */ - return FALSE; - - /* Proxy texture allows for a quick check for supported size */ - GE( ctx, glTexImage3D (proxy_target, 0, GL_RGBA, - width, height, depth, 0 /* border */, - gl_format, gl_type, NULL) ); - - GE( ctx, glGetTexLevelParameteriv (proxy_target, 0, - GL_TEXTURE_WIDTH, &new_width) ); - - return new_width != 0; -} - static gboolean _cogl_texture_driver_size_supported (CoglContext *ctx, GLenum gl_target, @@ -523,11 +434,9 @@ _cogl_texture_driver_gl = _cogl_texture_driver_prep_gl_for_pixels_upload, _cogl_texture_driver_upload_subregion_to_gl, _cogl_texture_driver_upload_to_gl, - _cogl_texture_driver_upload_to_gl_3d, _cogl_texture_driver_prep_gl_for_pixels_download, _cogl_texture_driver_gl_get_tex_image, _cogl_texture_driver_size_supported, - _cogl_texture_driver_size_supported_3d, _cogl_texture_driver_allows_foreign_gl_target, _cogl_texture_driver_find_best_gl_get_data_format }; diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index df9e8674f..49a81ba0d 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -362,12 +362,6 @@ _cogl_driver_update_features (CoglContext *context, COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT, TRUE); - if (context->glTexImage3D) - { - flags |= COGL_FEATURE_TEXTURE_3D; - COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TEXTURE_3D, TRUE); - } - if (context->glMapBuffer) { /* The GL_OES_mapbuffer extension doesn't support mapping for diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c index f773f93b8..db0135dcc 100644 --- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c @@ -394,152 +394,6 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx, return status; } -static gboolean -_cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx, - GLenum gl_target, - GLuint gl_handle, - gboolean is_foreign, - GLint height, - GLint depth, - CoglBitmap *source_bmp, - GLint internal_gl_format, - GLuint source_gl_format, - GLuint source_gl_type, - CoglError **error) -{ - CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp); - int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format); - int rowstride = cogl_bitmap_get_rowstride (source_bmp); - int bmp_width = cogl_bitmap_get_width (source_bmp); - int bmp_height = cogl_bitmap_get_height (source_bmp); - uint8_t *data; - - _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign); - - /* If the rowstride or image height can't be specified with just - GL_ALIGNMENT alone then we need to copy the bitmap because there - is no GL_ROW_LENGTH */ - if (rowstride / bpp != bmp_width || - height != bmp_height / depth) - { - CoglBitmap *bmp; - int image_height = bmp_height / depth; - CoglPixelFormat source_bmp_format = cogl_bitmap_get_format (source_bmp); - int i; - - _cogl_texture_driver_prep_gl_for_pixels_upload (ctx, bmp_width * bpp, bpp); - - /* Initialize the texture with empty data and then upload each - image with a sub-region update */ - - /* Clear any GL errors */ - _cogl_gl_util_clear_gl_errors (ctx); - - ctx->glTexImage3D (gl_target, - 0, /* level */ - internal_gl_format, - bmp_width, - height, - depth, - 0, - source_gl_format, - source_gl_type, - NULL); - - if (_cogl_gl_util_catch_out_of_memory (ctx, error)) - return FALSE; - - bmp = _cogl_bitmap_new_with_malloc_buffer (ctx, - bmp_width, - height, - source_bmp_format, - error); - if (!bmp) - return FALSE; - - for (i = 0; i < depth; i++) - { - if (!_cogl_bitmap_copy_subregion (source_bmp, - bmp, - 0, image_height * i, - 0, 0, - bmp_width, - height, - error)) - { - cogl_object_unref (bmp); - return FALSE; - } - - data = _cogl_bitmap_gl_bind (bmp, - COGL_BUFFER_ACCESS_READ, 0, error); - if (!data) - { - cogl_object_unref (bmp); - return FALSE; - } - - /* Clear any GL errors */ - _cogl_gl_util_clear_gl_errors (ctx); - - ctx->glTexSubImage3D (gl_target, - 0, /* level */ - 0, /* xoffset */ - 0, /* yoffset */ - i, /* zoffset */ - bmp_width, /* width */ - height, /* height */ - 1, /* depth */ - source_gl_format, - source_gl_type, - data); - - if (_cogl_gl_util_catch_out_of_memory (ctx, error)) - { - cogl_object_unref (bmp); - _cogl_bitmap_gl_unbind (bmp); - return FALSE; - } - - _cogl_bitmap_gl_unbind (bmp); - } - - cogl_object_unref (bmp); - } - else - { - data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0, error); - if (!data) - return FALSE; - - _cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp); - - /* Clear any GL errors */ - _cogl_gl_util_clear_gl_errors (ctx); - - ctx->glTexImage3D (gl_target, - 0, /* level */ - internal_gl_format, - bmp_width, - height, - depth, - 0, - source_gl_format, - source_gl_type, - data); - - if (_cogl_gl_util_catch_out_of_memory (ctx, error)) - { - _cogl_bitmap_gl_unbind (source_bmp); - return FALSE; - } - - _cogl_bitmap_gl_unbind (source_bmp); - } - - return TRUE; -} - /* NB: GLES doesn't support glGetTexImage2D, so cogl-texture will instead * fallback to a generic render + readpixels approach to downloading * texture data. (See _cogl_texture_draw_and_read() ) */ @@ -553,25 +407,6 @@ _cogl_texture_driver_gl_get_tex_image (CoglContext *ctx, return FALSE; } -static gboolean -_cogl_texture_driver_size_supported_3d (CoglContext *ctx, - GLenum gl_target, - GLenum gl_format, - GLenum gl_type, - int width, - int height, - int depth) -{ - GLint max_size; - - /* GLES doesn't support a proxy texture target so let's at least - check whether the size is greater than - GL_MAX_3D_TEXTURE_SIZE_OES */ - GE( ctx, glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE_OES, &max_size) ); - - return width <= max_size && height <= max_size && depth <= max_size; -} - static gboolean _cogl_texture_driver_size_supported (CoglContext *ctx, GLenum gl_target, @@ -622,11 +457,9 @@ _cogl_texture_driver_gles = _cogl_texture_driver_prep_gl_for_pixels_upload, _cogl_texture_driver_upload_subregion_to_gl, _cogl_texture_driver_upload_to_gl, - _cogl_texture_driver_upload_to_gl_3d, _cogl_texture_driver_prep_gl_for_pixels_download, _cogl_texture_driver_gl_get_tex_image, _cogl_texture_driver_size_supported, - _cogl_texture_driver_size_supported_3d, _cogl_texture_driver_allows_foreign_gl_target, _cogl_texture_driver_find_best_gl_get_data_format }; diff --git a/cogl/cogl/gl-prototypes/cogl-all-functions.h b/cogl/cogl/gl-prototypes/cogl-all-functions.h index 924ee349d..8c92bdb05 100644 --- a/cogl/cogl/gl-prototypes/cogl-all-functions.h +++ b/cogl/cogl/gl-prototypes/cogl-all-functions.h @@ -109,27 +109,6 @@ COGL_EXT_FUNCTION (GLboolean, glUnmapBuffer, (GLenum target)) COGL_EXT_END () -COGL_EXT_BEGIN (texture_3d, 1, 2, - 0, /* not in either GLES */ - "OES\0", - "texture_3D\0") -COGL_EXT_FUNCTION (void, glTexImage3D, - (GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLsizei height, - GLsizei depth, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels)) -COGL_EXT_FUNCTION (void, glTexSubImage3D, - (GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, - GLenum format, - GLenum type, const GLvoid *pixels)) -COGL_EXT_END () - - COGL_EXT_BEGIN (offscreen_blit, 3, 0, 0, /* not in either GLES */ diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index cb940420a..2e8e5af31 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -119,7 +119,6 @@ cogl_nonintrospected_headers = [ 'cogl-quaternion.h', 'cogl-matrix-stack.h', 'cogl-poll.h', - 'cogl-texture-3d.h', 'cogl-texture-2d-gl.h', 'cogl-texture-rectangle.h', 'cogl-sub-texture.h', @@ -307,13 +306,11 @@ cogl_sources = [ 'cogl-texture-private.h', 'cogl-texture-2d-private.h', 'cogl-texture-2d-sliced-private.h', - 'cogl-texture-3d-private.h', 'cogl-texture-driver.h', 'cogl-sub-texture.c', 'cogl-texture.c', 'cogl-texture-2d.c', 'cogl-texture-2d-sliced.c', - 'cogl-texture-3d.c', 'cogl-texture-rectangle-private.h', 'cogl-texture-rectangle.c', 'cogl-rectangle-map.h', diff --git a/cogl/test-fixtures/test-utils.c b/cogl/test-fixtures/test-utils.c index c1dd44f54..1bf2acd26 100644 --- a/cogl/test-fixtures/test-utils.c +++ b/cogl/test-fixtures/test-utils.c @@ -30,12 +30,6 @@ check_flags (TestFlags flags, return FALSE; } - if (flags & TEST_REQUIREMENT_TEXTURE_3D && - !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_3D)) - { - return FALSE; - } - if (flags & TEST_REQUIREMENT_TEXTURE_RECTANGLE && !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE)) { diff --git a/cogl/test-fixtures/test-utils.h b/cogl/test-fixtures/test-utils.h index e4929e57f..3ce68895b 100644 --- a/cogl/test-fixtures/test-utils.h +++ b/cogl/test-fixtures/test-utils.h @@ -33,7 +33,6 @@ typedef enum _TestFlags TEST_KNOWN_FAILURE = 1<<0, TEST_REQUIREMENT_GL = 1<<1, TEST_REQUIREMENT_NPOT = 1<<2, - TEST_REQUIREMENT_TEXTURE_3D = 1<<3, TEST_REQUIREMENT_TEXTURE_RECTANGLE = 1<<4, TEST_REQUIREMENT_TEXTURE_RG = 1<<5, TEST_REQUIREMENT_POINT_SPRITE = 1<<6, diff --git a/cogl/tests/conform/meson.build b/cogl/tests/conform/meson.build index e4d516947..beb9a084d 100644 --- a/cogl/tests/conform/meson.build +++ b/cogl/tests/conform/meson.build @@ -17,7 +17,6 @@ cogl_test_conformance_sources = [ 'test-custom-attributes.c', 'test-offscreen.c', 'test-primitive.c', - 'test-texture-3d.c', 'test-sparse-pipeline.c', 'test-read-texture-formats.c', 'test-write-texture-formats.c', diff --git a/cogl/tests/conform/test-conform-main.c b/cogl/tests/conform/test-conform-main.c index 000b37d27..087faab2f 100644 --- a/cogl/tests/conform/test-conform-main.c +++ b/cogl/tests/conform/test-conform-main.c @@ -73,8 +73,6 @@ main (int argc, char **argv) ADD_TEST (test_pixel_buffer_set_data, 0, 0); ADD_TEST (test_pixel_buffer_sub_region, 0, 0); UNPORTED_TEST (test_texture_rectangle); - ADD_TEST (test_texture_3d, TEST_REQUIREMENT_TEXTURE_3D, - TEST_REQUIREMENT_GL | TEST_KNOWN_FAILURE); ADD_TEST (test_wrap_modes, 0, 0); UNPORTED_TEST (test_texture_pixmap_x11); ADD_TEST (test_texture_get_set_data, 0, 0); diff --git a/cogl/tests/conform/test-declarations.h b/cogl/tests/conform/test-declarations.h index c41b3e31b..f64d4feb6 100644 --- a/cogl/tests/conform/test-declarations.h +++ b/cogl/tests/conform/test-declarations.h @@ -16,7 +16,6 @@ void test_sub_texture (void); void test_pixel_buffer_map (void); void test_pixel_buffer_set_data (void); void test_pixel_buffer_sub_region (void); -void test_texture_3d (void); void test_wrap_modes (void); void test_texture_get_set_data (void); void test_atlas_migration (void); diff --git a/cogl/tests/conform/test-texture-3d.c b/cogl/tests/conform/test-texture-3d.c deleted file mode 100644 index 880503976..000000000 --- a/cogl/tests/conform/test-texture-3d.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include - -#include "test-declarations.h" -#include "test-utils.h" - -#define TEX_WIDTH 4 -#define TEX_HEIGHT 8 -#define TEX_DEPTH 16 -/* Leave four bytes of padding between each row */ -#define TEX_ROWSTRIDE (TEX_WIDTH * 4 + 4) -/* Leave four rows of padding between each image */ -#define TEX_IMAGE_STRIDE ((TEX_HEIGHT + 4) * TEX_ROWSTRIDE) - -typedef struct _TestState -{ - int fb_width; - int fb_height; -} TestState; - -static CoglTexture3D * -create_texture_3d (CoglContext *context) -{ - int x, y, z; - uint8_t *data = g_malloc (TEX_IMAGE_STRIDE * TEX_DEPTH); - uint8_t *p = data; - CoglTexture3D *tex; - CoglError *error = NULL; - - for (z = 0; z < TEX_DEPTH; z++) - { - for (y = 0; y < TEX_HEIGHT; y++) - { - for (x = 0; x < TEX_WIDTH; x++) - { - /* Set red, green, blue to values based on x, y, z */ - *(p++) = 255 - x * 8; - *(p++) = y * 8; - *(p++) = 255 - z * 8; - /* Fully opaque */ - *(p++) = 0xff; - } - - /* Set the padding between rows to 0xde */ - memset (p, 0xde, TEX_ROWSTRIDE - (TEX_WIDTH * 4)); - p += TEX_ROWSTRIDE - (TEX_WIDTH * 4); - } - /* Set the padding between images to 0xad */ - memset (p, 0xba, TEX_IMAGE_STRIDE - (TEX_HEIGHT * TEX_ROWSTRIDE)); - p += TEX_IMAGE_STRIDE - (TEX_HEIGHT * TEX_ROWSTRIDE); - } - - tex = cogl_texture_3d_new_from_data (context, - TEX_WIDTH, TEX_HEIGHT, TEX_DEPTH, - COGL_PIXEL_FORMAT_RGBA_8888, - TEX_ROWSTRIDE, - TEX_IMAGE_STRIDE, - data, - &error); - - if (tex == NULL) - { - g_assert (error != NULL); - g_warning ("Failed to create 3D texture: %s", error->message); - g_assert_not_reached (); - } - - g_free (data); - - return tex; -} - -static void -draw_frame (TestState *state) -{ - CoglTexture *tex = create_texture_3d (test_ctx); - CoglPipeline *pipeline = cogl_pipeline_new (test_ctx); - typedef struct { float x, y, s, t, r; } Vert; - CoglPrimitive *primitive; - CoglAttributeBuffer *attribute_buffer; - CoglAttribute *attributes[2]; - Vert *verts, *v; - int i; - - cogl_pipeline_set_layer_texture (pipeline, 0, tex); - cogl_object_unref (tex); - cogl_pipeline_set_layer_filters (pipeline, 0, - COGL_PIPELINE_FILTER_NEAREST, - COGL_PIPELINE_FILTER_NEAREST); - - /* Render the texture repeated horizontally twice using a regular - cogl rectangle. This should end up with the r texture coordinates - as zero */ - cogl_framebuffer_draw_textured_rectangle (test_fb, pipeline, - 0.0f, 0.0f, TEX_WIDTH * 2, TEX_HEIGHT, - 0.0f, 0.0f, 2.0f, 1.0f); - - /* Render all of the images in the texture using coordinates from a - CoglPrimitive */ - v = verts = g_new (Vert, 4 * TEX_DEPTH); - for (i = 0; i < TEX_DEPTH; i++) - { - float r = (i + 0.5f) / TEX_DEPTH; - - v->x = i * TEX_WIDTH; - v->y = TEX_HEIGHT; - v->s = 0; - v->t = 0; - v->r = r; - v++; - - v->x = i * TEX_WIDTH; - v->y = TEX_HEIGHT * 2; - v->s = 0; - v->t = 1; - v->r = r; - v++; - - v->x = i * TEX_WIDTH + TEX_WIDTH; - v->y = TEX_HEIGHT * 2; - v->s = 1; - v->t = 1; - v->r = r; - v++; - - v->x = i * TEX_WIDTH + TEX_WIDTH; - v->y = TEX_HEIGHT; - v->s = 1; - v->t = 0; - v->r = r; - v++; - } - - attribute_buffer = cogl_attribute_buffer_new (test_ctx, - 4 * TEX_DEPTH * sizeof (Vert), - verts); - attributes[0] = cogl_attribute_new (attribute_buffer, - "cogl_position_in", - sizeof (Vert), - G_STRUCT_OFFSET (Vert, x), - 2, /* n_components */ - COGL_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = cogl_attribute_new (attribute_buffer, - "cogl_tex_coord_in", - sizeof (Vert), - G_STRUCT_OFFSET (Vert, s), - 3, /* n_components */ - COGL_ATTRIBUTE_TYPE_FLOAT); - primitive = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES, - 6 * TEX_DEPTH, - attributes, - 2 /* n_attributes */); - - cogl_primitive_set_indices (primitive, - cogl_get_rectangle_indices (test_ctx, - TEX_DEPTH), - 6 * TEX_DEPTH); - - cogl_primitive_draw (primitive, test_fb, pipeline); - - g_free (verts); - - cogl_object_unref (primitive); - cogl_object_unref (attributes[0]); - cogl_object_unref (attributes[1]); - cogl_object_unref (attribute_buffer); - cogl_object_unref (pipeline); -} - -static void -validate_block (int block_x, int block_y, int z) -{ - int x, y; - - for (y = 0; y < TEX_HEIGHT; y++) - for (x = 0; x < TEX_WIDTH; x++) - test_utils_check_pixel_rgb (test_fb, - block_x * TEX_WIDTH + x, - block_y * TEX_HEIGHT + y, - 255 - x * 8, - y * 8, - 255 - z * 8); -} - -static void -validate_result (void) -{ - int i; - - validate_block (0, 0, 0); - - for (i = 0; i < TEX_DEPTH; i++) - validate_block (i, 1, i); -} - -static void -test_multi_texture (TestState *state) -{ - CoglPipeline *pipeline; - CoglTexture3D *tex_3d; - CoglTexture2D *tex_2d; - uint8_t tex_data[4]; - - cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1); - - /* Tests a pipeline that is using multi-texturing to combine a 3D - texture with a 2D texture. The texture from another layer is - sampled with TEXTURE_? just to pick up a specific bug that was - happening with the ARBfp fragend */ - - pipeline = cogl_pipeline_new (test_ctx); - - tex_data[0] = 0xff; - tex_data[1] = 0x00; - tex_data[2] = 0x00; - tex_data[3] = 0xff; - tex_2d = cogl_texture_2d_new_from_data (test_ctx, - 1, 1, /* width/height */ - COGL_PIXEL_FORMAT_RGBA_8888_PRE, - 4, /* rowstride */ - tex_data, - NULL); - cogl_pipeline_set_layer_texture (pipeline, 0, tex_2d); - - tex_data[0] = 0x00; - tex_data[1] = 0xff; - tex_data[2] = 0x00; - tex_data[3] = 0xff; - tex_3d = cogl_texture_3d_new_from_data (test_ctx, - 1, 1, 1, /* width/height/depth */ - COGL_PIXEL_FORMAT_RGBA_8888_PRE, - 4, /* rowstride */ - 4, /* image_stride */ - tex_data, - NULL); - cogl_pipeline_set_layer_texture (pipeline, 1, tex_3d); - - cogl_pipeline_set_layer_combine (pipeline, 0, - "RGBA = REPLACE(PREVIOUS)", - NULL); - cogl_pipeline_set_layer_combine (pipeline, 1, - "RGBA = ADD(TEXTURE_0, TEXTURE_1)", - NULL); - - cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10); - - test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff); - - cogl_object_unref (tex_2d); - cogl_object_unref (tex_3d); - cogl_object_unref (pipeline); -} - -void -test_texture_3d (void) -{ - TestState state; - - state.fb_width = cogl_framebuffer_get_width (test_fb); - state.fb_height = cogl_framebuffer_get_height (test_fb); - - cogl_framebuffer_orthographic (test_fb, - 0, 0, /* x_1, y_1 */ - state.fb_width, /* x_2 */ - state.fb_height /* y_2 */, - -1, 100 /* near/far */); - - draw_frame (&state); - validate_result (); - - test_multi_texture (&state); - - if (cogl_test_verbose ()) - g_print ("OK\n"); -} diff --git a/cogl/tests/conform/test-texture-no-allocate.c b/cogl/tests/conform/test-texture-no-allocate.c index 74726d627..0c1c14fa4 100644 --- a/cogl/tests/conform/test-texture-no-allocate.c +++ b/cogl/tests/conform/test-texture-no-allocate.c @@ -61,15 +61,6 @@ test_texture_no_allocate (void) 64, 64); cogl_object_unref (texture_2d); - /* 3D texture */ - if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_3D)) - { - CoglTexture3D *texture_3d = - cogl_texture_3d_new_with_size (test_ctx, - 64, 64, 64); - cogl_object_unref (texture_3d); - } - /* Rectangle texture */ if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE)) {