[Mesa-dev] [PATCH] mesa: Add ARB_texture_view to Mesa core

Courtney Goeltzenleuchter courtney at lunarg.com
Mon Nov 4 15:34:02 PST 2013


On Fri, Nov 1, 2013 at 1:42 PM, Ian Romanick <idr at freedesktop.org> wrote:

> On 11/01/2013 09:54 AM, Courtney Goeltzenleuchter wrote:
> > Add necessary driver interface and state to support glTextureView as
> > specified by ARB_texture_view.  Includes updates to configuration
> > files (i.e. Makefile.am, SConscript, etc.), xml definition for
> > glTextureView, header files and the new texture parameters.
>
> This needs to be split into multiple patches.  Please look at Fredrik
> Hoglund's recent ARB_vertex_attrib_binding series for a good example.
>
> - Some early patch should just update src/mapi/glapi,
> src/mesa/main/tests/dispatch_sanity.cpp (missing from this patch), and
> stub versions of the new functions.
>
> - A patch after that should add tracking to src/mesa/main/extensions.c
> and the necessary updates to struct gl_extensions.  Sometimes this is
> squashed in with the glapi changes, sometimes not.
>
> - A patch after that should add new data types, tracking, etc. to mtypes.h.
>
> - Successive patches should implement the new functions added by the
> extension.  These patches will also generally update dd_function_table.
>
> - After the core implementation, patches should add back-end work for
> specific drivers (none in this case).
>
> One other general comment... for types that are not visible to the API
> layer, we generally prefer to *not* use GL types.  It looks like there
> are a few places that use GLboolean, for example, that should just use
> bool (from stdbool.h).
>
> I've made just a couple other comments below...
>
> > ---
> >  src/mapi/glapi/gen/ARB_texture_view.xml |  23 ++
> >  src/mapi/glapi/gen/Makefile.am          |   1 +
> >  src/mapi/glapi/gen/gl_API.xml           |   6 +-
> >  src/mapi/glapi/gen/gl_genexec.py        |   1 +
> >  src/mesa/Makefile.sources               |   1 +
> >  src/mesa/SConscript                     |   1 +
> >  src/mesa/drivers/common/driverfuncs.c   |   3 +
> >  src/mesa/main/dd.h                      |   5 +
> >  src/mesa/main/extensions.c              |   1 +
> >  src/mesa/main/mtypes.h                  |   6 +
> >  src/mesa/main/texparam.c                |  52 ++-
> >  src/mesa/main/texstorage.c              |  33 ++
> >  src/mesa/main/textureview.c             | 622
> ++++++++++++++++++++++++++++++++
> >  src/mesa/main/textureview.h             |  39 ++
> >  14 files changed, 792 insertions(+), 2 deletions(-)
> >  create mode 100644 src/mapi/glapi/gen/ARB_texture_view.xml
> >  create mode 100644 src/mesa/main/textureview.c
> >  create mode 100644 src/mesa/main/textureview.h
> >
> > diff --git a/src/mapi/glapi/gen/ARB_texture_view.xml
> b/src/mapi/glapi/gen/ARB_texture_view.xml
> > new file mode 100644
> > index 0000000..3e6b8c9
> > --- /dev/null
> > +++ b/src/mapi/glapi/gen/ARB_texture_view.xml
> > @@ -0,0 +1,23 @@
> > +<?xml version="1.0"?>
> > +<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
> > +
> > +<!-- Note: no GLX protocol info yet. -->
> > +
> > +<OpenGLAPI>
> > +
> > +<category name="GL_ARB_texture_view" number="124">
> > +
> > +   <function name="TextureView" offset="assign">
> > +      <param name="texture" type="GLuint"/>
> > +      <param name="target" type="GLenum"/>
> > +      <param name="origtexture" type="GLuint"/>
> > +      <param name="internalformat" type="GLenum"/>
> > +      <param name="minlevel" type="GLuint"/>
> > +      <param name="numlevels" type="GLuint"/>
> > +      <param name="minlayer" type="GLuint"/>
> > +      <param name="numlayers" type="GLuint"/>
> > +   </function>
> > +
> > +</category>
> > +
> > +</OpenGLAPI>
> > diff --git a/src/mapi/glapi/gen/Makefile.am
> b/src/mapi/glapi/gen/Makefile.am
> > index 3902452..c35e3c1 100644
> > --- a/src/mapi/glapi/gen/Makefile.am
> > +++ b/src/mapi/glapi/gen/Makefile.am
> > @@ -123,6 +123,7 @@ API_XML = \
> >       ARB_texture_rg.xml \
> >       ARB_texture_storage_multisample.xml \
> >       ARB_texture_storage.xml \
> > +     ARB_texture_view.xml \
> >       ARB_vertex_array_object.xml \
> >       AMD_draw_buffers_blend.xml \
> >       AMD_performance_monitor.xml \
> > diff --git a/src/mapi/glapi/gen/gl_API.xml
> b/src/mapi/glapi/gen/gl_API.xml
> > index 45d69b4..0b0d3b5 100644
> > --- a/src/mapi/glapi/gen/gl_API.xml
> > +++ b/src/mapi/glapi/gen/gl_API.xml
> > @@ -8458,7 +8458,11 @@
> >
> >  </category>
> >
> > -<!-- ARB extensions #120...#126 -->
> > +<!-- ARB extensions #120...#123 -->
> > +
> > +<xi:include href="ARB_texture_view.xml" xmlns:xi="
> http://www.w3.org/2001/XInclude"/>
> > +
> > +<!-- ARB extensions #125...#126 -->
> >
> >  <xi:include href="ARB_ES3_compatibility.xml" xmlns:xi="
> http://www.w3.org/2001/XInclude"/>
> >
> > diff --git a/src/mapi/glapi/gen/gl_genexec.py
> b/src/mapi/glapi/gen/gl_genexec.py
> > index 3ce190f..b557b3b 100644
> > --- a/src/mapi/glapi/gen/gl_genexec.py
> > +++ b/src/mapi/glapi/gen/gl_genexec.py
> > @@ -102,6 +102,7 @@ header = """/**
> >  #include "main/texstate.h"
> >  #include "main/texstorage.h"
> >  #include "main/texturebarrier.h"
> > +#include "main/textureview.h"
> >  #include "main/transformfeedback.h"
> >  #include "main/mtypes.h"
> >  #include "main/varray.h"
> > diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> > index a84f8a7..39525bc 100644
> > --- a/src/mesa/Makefile.sources
> > +++ b/src/mesa/Makefile.sources
> > @@ -103,6 +103,7 @@ MAIN_FILES = \
> >       $(SRCDIR)main/texstate.c \
> >       $(SRCDIR)main/texstorage.c \
> >       $(SRCDIR)main/texstore.c \
> > +        $(SRCDIR)main/textureview.c \
> >       $(SRCDIR)main/texturebarrier.c \
> >       $(SRCDIR)main/transformfeedback.c \
> >       $(SRCDIR)main/uniforms.c \
> > diff --git a/src/mesa/SConscript b/src/mesa/SConscript
> > index 4213498..581bd69 100644
> > --- a/src/mesa/SConscript
> > +++ b/src/mesa/SConscript
> > @@ -136,6 +136,7 @@ main_sources = [
> >      'main/texstorage.c',
> >      'main/texstore.c',
> >      'main/texturebarrier.c',
> > +    'main/textureview.c',
> >      'main/transformfeedback.c',
> >      'main/uniform_query.cpp',
> >      'main/uniforms.c',
> > diff --git a/src/mesa/drivers/common/driverfuncs.c
> b/src/mesa/drivers/common/driverfuncs.c
> > index 5faa98a..f185688 100644
> > --- a/src/mesa/drivers/common/driverfuncs.c
> > +++ b/src/mesa/drivers/common/driverfuncs.c
> > @@ -211,6 +211,9 @@ _mesa_init_driver_functions(struct dd_function_table
> *driver)
> >     /* GL_ARB_texture_storage */
> >     driver->AllocTextureStorage = _mesa_alloc_texture_storage;
> >
> > +   /* GL_ARB_texture_view */
> > +   driver->TextureView = NULL;
> > +
> >     /* GL_ARB_texture_multisample */
> >     driver->GetSamplePosition = NULL;
> >  }
> > diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> > index d7c4327..6690e5a 100644
> > --- a/src/mesa/main/dd.h
> > +++ b/src/mesa/main/dd.h
> > @@ -375,6 +375,11 @@ struct dd_function_table {
> >                                      GLsizei levels, GLsizei width,
> >                                      GLsizei height, GLsizei depth);
> >
> > +   /** Called as part of glTextureView to add views to origTexObj */
> > +   GLboolean (*TextureView)(struct gl_context *ctx,
> > +                            struct gl_texture_object *texObj,
> > +                            struct gl_texture_object *origTexObj);
> > +
> >     /**
> >      * Map a renderbuffer into user space.
> >      * \param mode  bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
> > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
> > index 285ec37..1a532b5 100644
> > --- a/src/mesa/main/extensions.c
> > +++ b/src/mesa/main/extensions.c
> > @@ -155,6 +155,7 @@ static const struct extension extension_table[] = {
> >     { "GL_ARB_texture_rg",                          o(ARB_texture_rg),
>                        GL,             2008 },
> >     { "GL_ARB_texture_storage",                     o(dummy_true),
>                        GL,             2011 },
> >     { "GL_ARB_texture_storage_multisample",
> o(ARB_texture_multisample),                 GL,             2012 },
> > +   { "GL_ARB_texture_view",                        o(ARB_texture_view),
>                        GL,             2012 },
> >     { "GL_ARB_texture_swizzle",
> o(EXT_texture_swizzle),                     GL,             2008 },
> >     { "GL_ARB_timer_query",                         o(ARB_timer_query),
>                         GL,             2010 },
> >     { "GL_ARB_transform_feedback2",
> o(ARB_transform_feedback2),                 GL,             2010 },
> > diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> > index 087bc37..74c5d30 100644
> > --- a/src/mesa/main/mtypes.h
> > +++ b/src/mesa/main/mtypes.h
> > @@ -1184,6 +1184,11 @@ struct gl_texture_object
> >                                      pressure? */
> >     GLboolean Immutable;        /**< GL_ARB_texture_storage */
> >
> > +   GLuint MinLevel;            /**< GL_ARB_texture_view */
> > +   GLuint MinLayer;            /**< GL_ARB_texture_view */
> > +   GLuint NumLevels;           /**< GL_ARB_texture_view */
> > +   GLuint NumLayers;           /**< GL_ARB_texture_view */
> > +
> >     /** Actual texture images, indexed by [cube face] and [mipmap level]
> */
> >     struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
> >
> > @@ -3273,6 +3278,7 @@ struct gl_extensions
> >     GLboolean ARB_texture_query_lod;
> >     GLboolean ARB_texture_rg;
> >     GLboolean ARB_texture_rgb10_a2ui;
> > +   GLboolean ARB_texture_view;
> >     GLboolean ARB_timer_query;
> >     GLboolean ARB_transform_feedback2;
> >     GLboolean ARB_transform_feedback3;
> > diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
> > index d56b7d9..9a5bb61 100644
> > --- a/src/mesa/main/texparam.c
> > +++ b/src/mesa/main/texparam.c
> > @@ -1570,6 +1570,30 @@ _mesa_GetTexParameterfv( GLenum target, GLenum
> pname, GLfloat *params )
> >           *params = (GLfloat) obj->ImmutableLevels;
> >           break;
> >
> > +      case GL_TEXTURE_VIEW_MIN_LEVEL:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLfloat) obj->MinLevel;
> > +         break;
> > +
> > +      case GL_TEXTURE_VIEW_NUM_LEVELS:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLfloat) obj->NumLevels;
> > +         break;
> > +
> > +      case GL_TEXTURE_VIEW_MIN_LAYER:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLfloat) obj->MinLayer;
> > +         break;
> > +
> > +      case GL_TEXTURE_VIEW_NUM_LAYERS:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLfloat) obj->NumLayers;
> > +         break;
> > +
> >        case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
> >           if (!_mesa_is_gles(ctx) ||
> !ctx->Extensions.OES_EGL_image_external)
> >              goto invalid_pname;
> > @@ -1746,11 +1770,37 @@ _mesa_GetTexParameteriv( GLenum target, GLenum
> pname, GLint *params )
> >           break;
> >
> >        case GL_TEXTURE_IMMUTABLE_LEVELS:
> > -         if (!_mesa_is_gles3(ctx))
> > +         if (!_mesa_is_gles3(ctx)
> > +             && !_mesa_is_desktop_gl(ctx)
> > +             && !ctx->Extensions.ARB_texture_view)
>
> This if-statement will never evaluate to true because at least one of
> _mesa_is_gles3 or _mesa_is_desktop_gl will be false.
>

The intent - as I understand it - is to only return
GL_TEXTURE_IMMUTABLE_LEVELS if we are being called using a context that can
support it. How about:
if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_texture_view)
   *params = obj->ImmutableLevels;
else
   goto invalid_pname;

Does that protect GL_TEXTURE_IMMUTABLE_LEVELS properly?


> >              goto invalid_pname;
> >           *params = obj->ImmutableLevels;
> >           break;
> >
> > +      case GL_TEXTURE_VIEW_MIN_LEVEL:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLint) obj->MinLevel;
> > +         break;
> > +
> > +      case GL_TEXTURE_VIEW_NUM_LEVELS:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLint) obj->NumLevels;
> > +         break;
> > +
> > +      case GL_TEXTURE_VIEW_MIN_LAYER:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLint) obj->MinLayer;
> > +         break;
> > +
> > +      case GL_TEXTURE_VIEW_NUM_LAYERS:
> > +         if (!ctx->Extensions.ARB_texture_view)
> > +            goto invalid_pname;
> > +         *params = (GLint) obj->NumLayers;
> > +         break;
> > +
> >        case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
> >           if (!_mesa_is_gles(ctx) ||
> !ctx->Extensions.OES_EGL_image_external)
> >              goto invalid_pname;
> > diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
> > index 7bd8652..e8db4af 100644
> > --- a/src/mesa/main/texstorage.c
> > +++ b/src/mesa/main/texstorage.c
> > @@ -429,8 +429,41 @@ texstorage(GLuint dims, GLenum target, GLsizei
> levels, GLenum internalformat,
> >           return;
> >        }
> >
> > +      /* If the command is successful,
> > +       * TEXTURE_IMMUTABLE_FORMAT becomes TRUE.
> > +       * TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS become
> levels.
> > +       * If the texture target is TEXTURE_1D_ARRAY then
> > +       * TEXTURE_VIEW_NUM_LAYERS becomes height.
> > +       * If the texture target is TEXTURE_2D_ARRAY,
> TEXTURE_CUBE_MAP_ARRAY,
> > +       * or TEXTURE_2D_MULTISAMPLE_ARRAY then TEXTURE_VIEW_NUM_LAYERS
> becomes depth.
> > +       * If the texture target is TEXTURE_CUBE_MAP, then
> > +       * TEXTURE_VIEW_NUM_LAYERS becomes 6.
> > +       * For any other texture target, TEXTURE_VIEW_NUM_LAYERS becomes
> 1.
> > +       */
> > +
> >        texObj->Immutable = GL_TRUE;
> >        texObj->ImmutableLevels = levels;
> > +      texObj->MinLevel = 0;
> > +      texObj->NumLevels = levels;
> > +      texObj->MinLayer = 0;
> > +      texObj->NumLayers = 1;
> > +      switch (target)
> > +      {
>
> { on the same line as the switch.
>
got it.

>
> > +      case GL_TEXTURE_1D_ARRAY:
> > +         texObj->NumLayers = height;
> > +         break;
> > +
> > +      case GL_TEXTURE_2D_ARRAY:
> > +      case GL_TEXTURE_CUBE_MAP_ARRAY:
> > +      case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> > +         texObj->NumLayers = depth;
> > +         break;
> > +
> > +      case GL_TEXTURE_CUBE_MAP:
> > +         texObj->NumLayers = 6;
> > +         break;
> > +      }
> > +
> >     }
> >  }
> >
> > diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
> > new file mode 100644
> > index 0000000..62b295b
> > --- /dev/null
> > +++ b/src/mesa/main/textureview.c
> > @@ -0,0 +1,622 @@
> > +/*
> > + * Mesa 3-D graphics library
> > + *
> > + * Copyright (C) 2013 LunarG, Inc.
> > + *
> > + * 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:
> > + *    Courtney Goeltzenleuchter <courtney at lunarg.com>
> > + */
> > +
> > +
> > +/**
> > + * \file textureview.c
> > + * GL_ARB_texture_view functions
> > + */
> > +
> > +#include "glheader.h"
> > +#include "context.h"
> > +#include "enums.h"
> > +#include "imports.h"
> > +#include "macros.h"
> > +#include "teximage.h"
> > +#include "texobj.h"
> > +#include "texstorage.h"
> > +#include "textureview.h"
> > +#include "mtypes.h"
> > +
> > +/* Table 3.X.2 (Compatible internal formats for TextureView)
> > +
>  ---------------------------------------------------------------------------
> > +    | Class                 | Internal formats
>        |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_128_BITS   | RGBA32F, RGBA32UI, RGBA32I
>        |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_96_BITS    | RGB32F, RGB32UI, RGB32I
>       |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_64_BITS    | RGBA16F, RG32F, RGBA16UI, RG32UI,
> RGBA16I,      |
> > +    |                       | RG32I, RGBA16, RGBA16_SNORM
>       |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_48_BITS    | RGB16, RGB16_SNORM, RGB16F, RGB16UI,
> RGB16I     |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_32_BITS    | RG16F, R11F_G11F_B10F, R32F,
>        |
> > +    |                       | RGB10_A2UI, RGBA8UI, RG16UI, R32UI,
>       |
> > +    |                       | RGBA8I, RG16I, R32I, RGB10_A2, RGBA8,
> RG16,     |
> > +    |                       | RGBA8_SNORM, RG16_SNORM, SRGB8_ALPHA8,
> RGB9_E5  |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_24_BITS    | RGB8, RGB8_SNORM, SRGB8, RGB8UI, RGB8I
>        |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_16_BITS    | R16F, RG8UI, R16UI, RG8I, R16I, RG8, R16,
>       |
> > +    |                       | RG8_SNORM, R16_SNORM
>        |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_8_BITS     | R8UI, R8I, R8, R8_SNORM
>       |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_RGTC1_RED  | COMPRESSED_RED_RGTC1,
>       |
> > +    |                       | COMPRESSED_SIGNED_RED_RGTC1
>       |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_RGTC2_RG   | COMPRESSED_RG_RGTC2,
>        |
> > +    |                       | COMPRESSED_SIGNED_RG_RGTC2
>        |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_BPTC_UNORM | COMPRESSED_RGBA_BPTC_UNORM,
>       |
> > +    |                       | COMPRESSED_SRGB_ALPHA_BPTC_UNORM
>        |
> > +
>  ---------------------------------------------------------------------------
> > +    | VIEW_CLASS_BPTC_FLOAT | COMPRESSED_RGB_BPTC_SIGNED_FLOAT,
>       |
> > +    |                       | COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT
>        |
> > +
>  ---------------------------------------------------------------------------
> > + */
> > +struct internal_format_class_info {
> > +   GLenum view_class;
> > +   GLenum internal_format;
> > +};
> > +#define INFO(c,f) {GL_##c, GL_##f}
> > +static const struct internal_format_class_info
> _compatible_internal_formats[] = {
> > +   INFO(VIEW_CLASS_128_BITS, RGBA32F),
> > +   INFO(VIEW_CLASS_128_BITS, RGBA32UI),
> > +   INFO(VIEW_CLASS_128_BITS, RGBA32I),
> > +   INFO(VIEW_CLASS_96_BITS, RGB32F),
> > +   INFO(VIEW_CLASS_96_BITS, RGB32UI),
> > +   INFO(VIEW_CLASS_96_BITS, RGB32I),
> > +   INFO(VIEW_CLASS_64_BITS, RGBA16F),
> > +   INFO(VIEW_CLASS_64_BITS, RG32F),
> > +   INFO(VIEW_CLASS_64_BITS, RGBA16UI),
> > +   INFO(VIEW_CLASS_64_BITS, RG32UI),
> > +   INFO(VIEW_CLASS_64_BITS, RGBA16I),
> > +   INFO(VIEW_CLASS_64_BITS, RG32I),
> > +   INFO(VIEW_CLASS_64_BITS, RGBA16),
> > +   INFO(VIEW_CLASS_64_BITS, RGBA16_SNORM),
> > +   INFO(VIEW_CLASS_48_BITS, RGB16),
> > +   INFO(VIEW_CLASS_48_BITS, RGB16_SNORM),
> > +   INFO(VIEW_CLASS_48_BITS, RGB16F),
> > +   INFO(VIEW_CLASS_48_BITS, RGB16UI),
> > +   INFO(VIEW_CLASS_48_BITS, RGB16I),
> > +   INFO(VIEW_CLASS_32_BITS, RG16F),
> > +   INFO(VIEW_CLASS_32_BITS, R11F_G11F_B10F),
> > +   INFO(VIEW_CLASS_32_BITS, R32F),
> > +   INFO(VIEW_CLASS_32_BITS, RGB10_A2UI),
> > +   INFO(VIEW_CLASS_32_BITS, RGBA8UI),
> > +   INFO(VIEW_CLASS_32_BITS, RG16UI),
> > +   INFO(VIEW_CLASS_32_BITS, R32UI),
> > +   INFO(VIEW_CLASS_32_BITS, RGBA8I),
> > +   INFO(VIEW_CLASS_32_BITS, RG16I),
> > +   INFO(VIEW_CLASS_32_BITS, R32I),
> > +   INFO(VIEW_CLASS_32_BITS, RGB10_A2),
> > +   INFO(VIEW_CLASS_32_BITS, RGBA8),
> > +   INFO(VIEW_CLASS_32_BITS, RG16),
> > +   INFO(VIEW_CLASS_32_BITS, RGBA8_SNORM),
> > +   INFO(VIEW_CLASS_32_BITS, RG16_SNORM),
> > +   INFO(VIEW_CLASS_32_BITS, SRGB8_ALPHA8),
> > +   INFO(VIEW_CLASS_32_BITS, RGB9_E5),
> > +   INFO(VIEW_CLASS_24_BITS, RGB8),
> > +   INFO(VIEW_CLASS_24_BITS, RGB8_SNORM),
> > +   INFO(VIEW_CLASS_24_BITS, SRGB8),
> > +   INFO(VIEW_CLASS_24_BITS, RGB8UI),
> > +   INFO(VIEW_CLASS_24_BITS, RGB8I),
> > +   INFO(VIEW_CLASS_16_BITS, R16F),
> > +   INFO(VIEW_CLASS_16_BITS, RG8UI),
> > +   INFO(VIEW_CLASS_16_BITS, R16UI),
> > +   INFO(VIEW_CLASS_16_BITS, RG8I),
> > +   INFO(VIEW_CLASS_16_BITS, R16I),
> > +   INFO(VIEW_CLASS_16_BITS, RG8),
> > +   INFO(VIEW_CLASS_16_BITS, R16),
> > +   INFO(VIEW_CLASS_16_BITS, RG8_SNORM),
> > +   INFO(VIEW_CLASS_16_BITS, R16_SNORM),
> > +   INFO(VIEW_CLASS_8_BITS, R8UI),
> > +   INFO(VIEW_CLASS_8_BITS, R8I),
> > +   INFO(VIEW_CLASS_8_BITS, R8),
> > +   INFO(VIEW_CLASS_8_BITS, R8_SNORM),
> > +   INFO(VIEW_CLASS_RGTC1_RED, COMPRESSED_RED_RGTC1),
> > +   INFO(VIEW_CLASS_RGTC1_RED, COMPRESSED_SIGNED_RED_RGTC1),
> > +   INFO(VIEW_CLASS_RGTC2_RG, COMPRESSED_RG_RGTC2),
> > +   INFO(VIEW_CLASS_RGTC2_RG, COMPRESSED_SIGNED_RG_RGTC2),
> > +   INFO(VIEW_CLASS_BPTC_UNORM, COMPRESSED_RGBA_BPTC_UNORM_ARB),
> > +   INFO(VIEW_CLASS_BPTC_UNORM, COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB),
> > +   INFO(VIEW_CLASS_BPTC_FLOAT, COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB),
> > +   INFO(VIEW_CLASS_BPTC_FLOAT, COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB),
> > +   INFO(FALSE, FALSE)
>
> I don't think the sentinel is necessary.
>
> > +};
> > +#undef INFO
> > +
> > +/**
> > + * Lookup format view class based on internalformat
> > + * \return VIEW_CLASS if internalformat found in table, GL_FALSE
> otherwise.
> > + */
> > +static GLenum
> > +lookup_view_class(GLenum internalformat)
> > +{
> > +   GLuint i;
> > +
> > +   for (i = 0; _compatible_internal_formats[i].view_class != GL_FALSE;
> i++) {
>
> With the sentinel removed, use
>
>    for (i = 0; i < ARRAY_SIZE(_compatible_internal_formats); i++) {
>
okay

>
> > +      if (_compatible_internal_formats[i].internal_format ==
> internalformat)
> > +         return _compatible_internal_formats[i].view_class;
> > +   }
> > +   return GL_FALSE;
> > +}
> > +
> > +/**
> > + * Compute the size of the next mipmap level.
> > + */
> > +static void
> > +next_mipmap_level_size(GLenum target,
> > +                       GLint *width, GLint *height, GLint *depth)
> > +{
> > +   if (*width > 1) {
> > +      *width /= 2;
> > +   }
> > +
> > +   if ((*height > 1) && (target != GL_TEXTURE_1D_ARRAY)) {
> > +      *height /= 2;
> > +   }
> > +
> > +   if ((*depth > 1) && (target != GL_TEXTURE_2D_ARRAY)) {
> > +      *depth /= 2;
> > +   }
> > +}
> > +
> > +/** Helper to get a particular texture image in a texture object */
> > +static struct gl_texture_image *
> > +get_tex_image(struct gl_context *ctx,
> > +              struct gl_texture_object *texObj,
> > +              GLuint face, GLuint level)
> > +{
> > +   struct gl_texture_image *texImage;
> > +
> > +   if (!texObj)
> > +      return NULL;
> > +
> > +   texImage = texObj->Image[face][level];
> > +   if (!texImage) {
> > +      texImage = ctx->Driver.NewTextureImage(ctx);
> > +      if (!texImage) {
> > +         _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation");
> > +         return NULL;
> > +      }
> > +
> > +      texObj->Image[face][level] = texImage;
> > +
> > +      /* Set the 'back' pointer */
> > +      texImage->TexObject = texObj;
> > +      texImage->Level = level;
> > +      texImage->Face = face;
> > +   }
> > +
> > +   return texImage;
> > +}
> > +
> > +/**
> > + * Initialize new texture's gl_texture_image structures. Will not call
> driver
> > + * to allocate new space, simply record relevant layer, face, format,
> etc.
> > + * \return GL_FALSE if any error, GL_TRUE otherwise.
> > + */
> > +static GLboolean
> > +initialize_texture_fields(struct gl_context *ctx,
> > +                          GLenum target,
> > +                          struct gl_texture_object *texObj,
> > +                          GLint levels,
> > +                          GLsizei width, GLsizei height, GLsizei depth,
> > +                          GLenum internalFormat, gl_format texFormat)
> > +{
> > +   const GLuint numFaces = _mesa_num_tex_faces(target);
> > +   GLint level, levelWidth = width, levelHeight = height, levelDepth =
> depth;
> > +   GLuint face;
> > +
> > +   /* Pretend we are bound to initialize the gl_texture_image structs */
> > +   texObj->Target = target;
> > +
> > +   /* Set up all the texture object's gl_texture_images */
> > +   for (level = 0; level < levels; level++) {
> > +      for (face = 0; face < numFaces; face++) {
> > +         struct gl_texture_image *texImage =
> > +                 get_tex_image(ctx, texObj, face, level);
> > +
> > +         if (!texImage) {
> > +            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage");
> > +            return GL_FALSE;
> > +         }
> > +
> > +         _mesa_init_teximage_fields(ctx, texImage,
> > +                                    levelWidth, levelHeight, levelDepth,
> > +                                    0, internalFormat, texFormat);
> > +      }
> > +
> > +      next_mipmap_level_size(target, &levelWidth, &levelHeight,
> &levelDepth);
> > +   }
> > +
> > +   /* "unbind" */
> > +   texObj->Target = 0;
> > +
> > +   return GL_TRUE;
> > +}
> > +
> > +#define RETURN_IF_SUPPORTED(t) do {          \
> > +   if (newTarget == GL_ ## t)                   \
> > +      return GL_TRUE;                                \
> > +} while (0)
> > +
> > +/**
> > + * Check for compatible target
> > + * If an error is found, record it with _mesa_error()
> > + * \return GL_FALSE if any error, GL_TRUE otherwise.
> > + */
> > +static GLboolean
> > +target_valid(struct gl_context *ctx, GLenum origTarget, GLenum
> newTarget)
> > +{
> > +   /*
> > +    * From ARB_texture_view spec:
> > +
> ---------------------------------------------------------------------------------------------------------
> > +   | Original target              | Valid new targets |
> > +
> ---------------------------------------------------------------------------------------------------------
> > +   | TEXTURE_1D                   | TEXTURE_1D, TEXTURE_1D_ARRAY |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_2D                   | TEXTURE_2D, TEXTURE_2D_ARRAY |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_3D                   | TEXTURE_3D |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_CUBE_MAP             | TEXTURE_CUBE_MAP, TEXTURE_2D,
> TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_RECTANGLE            | TEXTURE_RECTANGLE |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_BUFFER               | <none> |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_1D_ARRAY             | TEXTURE_1D_ARRAY, TEXTURE_1D |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_2D_ARRAY             | TEXTURE_2D_ARRAY, TEXTURE_2D,
> TEXTURE_CUBE_MAP, TEXTURE_CUBE_MAP_ARRAY |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_CUBE_MAP_ARRAY       | TEXTURE_CUBE_MAP_ARRAY,
> TEXTURE_2D_ARRAY, TEXTURE_2D, TEXTURE_CUBE_MAP |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_2D_MULTISAMPLE       | TEXTURE_2D_MULTISAMPLE,
> TEXTURE_2D_MULTISAMPLE_ARRAY |
> > +   |
> -------------------------------------------------------------------------------------------------------
> |
> > +   | TEXTURE_2D_MULTISAMPLE_ARRAY | TEXTURE_2D_MULTISAMPLE,
> TEXTURE_2D_MULTISAMPLE_ARRAY |
> > +
> ---------------------------------------------------------------------------------------------------------
> > +    */
> > +
> > +   switch (origTarget) {
> > +   case GL_TEXTURE_1D:
> > +   case GL_TEXTURE_1D_ARRAY:
> > +      RETURN_IF_SUPPORTED(TEXTURE_1D);
> > +      RETURN_IF_SUPPORTED(TEXTURE_1D_ARRAY);
> > +      break;
> > +   case GL_TEXTURE_2D:
> > +      RETURN_IF_SUPPORTED(TEXTURE_2D);
> > +      RETURN_IF_SUPPORTED(TEXTURE_2D_ARRAY);
> > +      break;
> > +   case GL_TEXTURE_3D:
> > +      RETURN_IF_SUPPORTED(TEXTURE_3D);
> > +      break;
> > +   case GL_TEXTURE_RECTANGLE:
> > +      RETURN_IF_SUPPORTED(TEXTURE_RECTANGLE);
> > +      break;
> > +   case GL_TEXTURE_CUBE_MAP:
> > +   case GL_TEXTURE_2D_ARRAY:
> > +   case GL_TEXTURE_CUBE_MAP_ARRAY:
> > +      RETURN_IF_SUPPORTED(TEXTURE_2D);
> > +      RETURN_IF_SUPPORTED(TEXTURE_2D_ARRAY);
> > +      RETURN_IF_SUPPORTED(TEXTURE_CUBE_MAP);
> > +      RETURN_IF_SUPPORTED(TEXTURE_CUBE_MAP_ARRAY);
> > +      break;
> > +   case GL_TEXTURE_2D_MULTISAMPLE:
> > +   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> > +      RETURN_IF_SUPPORTED(TEXTURE_2D_MULTISAMPLE);
> > +      RETURN_IF_SUPPORTED(TEXTURE_2D_MULTISAMPLE_ARRAY);
> > +      break;
> > +   }
> > +   _mesa_error(ctx, GL_INVALID_OPERATION,
> > +               "glTextureView(illegal target=%s)",
> > +               _mesa_lookup_enum_by_nr(newTarget));
> > +   return GL_FALSE;
> > +}
> > +#undef RETURN_IF_SUPPORTED
> > +
> > +/**
> > + * Check for compatible format
> > + * If an error is found, record it with _mesa_error()
> > + * \return GL_FALSE if any error, GL_TRUE otherwise.
> > + */
> > +static GLboolean
> > +compatible_format(struct gl_context *ctx, struct gl_texture_object
> *origTexObj,
> > +                  GLenum internalformat)
> > +{
> > +   /* Level 0 of a texture created by glTextureStorage or glTextureView
> > +    * is always defined.
> > +    */
> > +   struct gl_texture_image *texImage = origTexObj->Image[0][0];
> > +   GLenum origInternalFormat = texImage->InternalFormat;
> > +
> > +   /* The two textures' internal formats must be compatible according to
> > +    * Table 3.X.2 (Compatible internal formats for TextureView)
> > +    * if the internal format exists in that table the view class must
> match.
> > +    * The internal formats must be identical if not in that table,
> > +    * or an INVALID_OPERATION error is generated.
> > +    */
> > +   if (origInternalFormat == internalformat)
> > +      return GL_TRUE;
> > +
> > +   if (lookup_view_class(origInternalFormat) ==
> > +       lookup_view_class(internalformat))
> > +      return GL_TRUE;
> > +
> > +   _mesa_error(ctx, GL_INVALID_OPERATION,
> > +               "glTextureView(internalformat  %s not compatible with
> origtexture %s)",
> > +               _mesa_lookup_enum_by_nr(internalformat),
> > +               _mesa_lookup_enum_by_nr(origInternalFormat));
> > +   return GL_FALSE;
> > +}
> > +
> > +/**
> > + * glTextureView (ARB_texture_view)
> > + * If an error is found, record it with _mesa_error()
> > + * \return none.
> > + */
> > +void GLAPIENTRY
> > +_mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
> > +                  GLenum internalformat,
> > +                  GLuint minlevel, GLuint numlevels,
> > +                  GLuint minlayer, GLuint numlayers)
> > +{
> > +   struct gl_texture_object *texObj;
> > +   struct gl_texture_object *origTexObj;
> > +   struct gl_texture_image *origTexImage;
> > +   GLuint newViewMinLevel, newViewMinLayer;
> > +   GLuint newViewNumLevels, newViewNumLayers;
> > +   GLsizei width, height, depth;
> > +   gl_format texFormat;
> > +   GLboolean sizeOK, dimensionsOK;
> > +   GLenum faceTarget;
> > +
> > +   GET_CURRENT_CONTEXT(ctx);
> > +
> > +   if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE))
> > +      _mesa_debug(ctx, "glTextureView %d %s %d %s %d %d %d %d\n",
> > +                  texture, _mesa_lookup_enum_by_nr(target), origtexture,
> > +                  _mesa_lookup_enum_by_nr(internalformat),
> > +                  minlevel, numlevels, minlayer, numlayers);
> > +
> > +   if (origtexture == 0) {
> > +      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture =
> 0x%x)", origtexture);
> > +      return;
> > +   }
> > +
> > +   /* Need original texture information to validate arguments */
> > +   origTexObj = _mesa_lookup_texture(ctx, origtexture);
> > +
> > +   /* If <origtexture> is not the name of a texture, INVALID_VALUE is
> generated. */
> > +   if (!origTexObj) {
> > +      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture =
> 0x%x)", origtexture);
> > +      return;
> > +   }
> > +
> > +   /* If <origtexture>'s TEXTURE_IMMUTABLE_FORMAT value is not TRUE,
> > +    * INVALID_OPERATION is generated.
> > +    */
> > +   if (!origTexObj->Immutable) {
> > +      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(origtexture
> not immutable)");
> > +      return;
> > +   }
> > +
> > +   /* If <texture> is 0, INVALID_VALUE is generated. */
> > +   if (texture == 0) {
> > +      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(texture = 0)");
> > +      return;
> > +   }
> > +
> > +   /* If <texture> is not a valid name returned by GenTextures,
> > +    * the error INVALID_OPERATION is generated.
> > +    */
> > +   texObj = _mesa_lookup_texture(ctx, texture);
> > +   if (texObj == NULL) {
> > +      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(texture
> 0x%x non-gen name)", texture);
> > +      return;
> > +   }
> > +
> > +   /* If <texture> has already been bound and given a target, then
> > +    * the error INVALID_OPERATION is generated.
> > +    */
> > +   if (texObj->Target) {
> > +      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(texture
> 0x%x already bound)", texture);
> > +      return;
> > +   }
> > +
> > +   /* Check for compatible target */
> > +   if (!target_valid(ctx, origTexObj->Target, target)) {
> > +      return; /* error was recorded */
> > +   }
> > +
> > +   /* minlevel and minlayer are relative to the view of origtexture */
> > +   /* If minlevel or minlayer is greater than level or layer,
> respectively,
> > +    * of origtexture return INVALID_VALUE.
> > +    */
> > +   newViewMinLevel = origTexObj->MinLevel + minlevel;
> > +   newViewMinLayer = origTexObj->MinLayer + minlayer;
> > +   if (newViewMinLevel >= (origTexObj->MinLevel +
> origTexObj->NumLevels) ||
> > +       newViewMinLayer >= (origTexObj->MinLayer +
> origTexObj->NumLayers)) {
> > +      _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture =
> 0x%x)", origtexture);
> > +      return;
> > +   }
> > +
> > +   if (!compatible_format(ctx, origTexObj, internalformat)) {
> > +      return; // Error logged
> > +   }
> > +
> > +   texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0,
> > +                                           internalformat, GL_NONE,
> GL_NONE);
> > +   assert(texFormat != MESA_FORMAT_NONE);
> > +
> > +   newViewNumLevels = MIN2(numlevels, origTexObj->NumLevels - minlevel);
> > +   newViewNumLayers = MIN2(numlayers, origTexObj->NumLayers - minlayer);
> > +
> > +   faceTarget = origTexObj->Target;
> > +   if (faceTarget == GL_TEXTURE_CUBE_MAP)
> > +      faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + minlayer;
> > +
> > +   /* Get a reference to what will become this View's base level */
> > +   origTexImage = _mesa_select_tex_image(ctx, origTexObj,
> > +                                         faceTarget, minlevel);
> > +   width = origTexImage->Width;
> > +   height = origTexImage->Height;
> > +   depth = origTexImage->Depth;
> > +
> > +   /* Adjust width, height, depth to be appropriate for new target */
> > +   switch (target) {
> > +   case GL_TEXTURE_1D:
> > +   case GL_TEXTURE_3D:
> > +      break;
> > +
> > +   case GL_TEXTURE_1D_ARRAY:
> > +      height = (GLsizei) newViewNumLevels;
> > +      break;
> > +
> > +   case GL_TEXTURE_2D:
> > +   case GL_TEXTURE_2D_MULTISAMPLE:
> > +   case GL_TEXTURE_RECTANGLE:
> > +      depth = 1;
> > +      break;
> > +
> > +   case GL_TEXTURE_CUBE_MAP:
> > +   case GL_TEXTURE_2D_ARRAY:
> > +   case GL_TEXTURE_CUBE_MAP_ARRAY:
> > +   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> > +      depth = newViewNumLevels;
> > +      break;
> > +   }
> > +
> > +   /* If the dimensions of the original texture are larger than the
> maximum
> > +    * supported dimensions of the new target, the error
> INVALID_OPERATION is
> > +    * generated. For example, if the original texture has a
> TEXTURE_2D_ARRAY
> > +    * target and its width is greater than MAX_CUBE_MAP_TEXTURE_SIZE,
> an error
> > +    * will be generated if TextureView is called to create a
> TEXTURE_CUBE_MAP
> > +    * view.
> > +    */
> > +   dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0,
> > +                                                 width, height, depth,
> 0);
> > +   if (!dimensionsOK) {
> > +      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid
> width or height or depth)");
> > +      return;
> > +   }
> > +
> > +   sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
> > +                                          width, height, depth, 0);
> > +   if (!sizeOK) {
> > +      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid
> texture size)");
> > +      return;
> > +   }
> > +
> > +   /* If <target> is TEXTURE_1D, TEXTURE_2D, TEXTURE_3D,
> TEXTURE_RECTANGLE,
> > +    * or TEXTURE_2D_MULTISAMPLE and <numlayers> does not equal 1, the
> error
> > +    * INVALID_VALUE is generated.
> > +    */
> > +   switch (target) {
> > +   case GL_TEXTURE_1D:
> > +   case GL_TEXTURE_2D:
> > +   case GL_TEXTURE_3D:
> > +   case GL_TEXTURE_RECTANGLE:
> > +   case GL_TEXTURE_2D_MULTISAMPLE:
> > +      if (numlayers != 1) {
> > +         _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(numlayers %d
> != 1)", numlayers);
> > +         return;
> > +      }
> > +      break;
> > +
> > +   case GL_TEXTURE_CUBE_MAP:
> > +      /* If the new texture's target is TEXTURE_CUBE_MAP, the clamped
> <numlayers>
> > +       * must be equal to 6.
> > +       */
> > +      if (newViewNumLayers != 6) {
> > +         _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(clamped
> numlayers %d != 6)",
> > +                     newViewNumLayers);
> > +         return;
> > +      }
> > +      break;
> > +
> > +   case GL_TEXTURE_CUBE_MAP_ARRAY:
> > +      /* If the new texture's target is TEXTURE_CUBE_MAP_ARRAY,
> > +       * then <numlayers> counts layer-faces rather than layers,
> > +       * and the clamped <numlayers> must be a multiple of 6.
> > +       * Otherwise, the error INVALID_VALUE is generated.
> > +       */
> > +      if ((newViewNumLayers % 6) != 0) {
> > +         _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(clamped
> numlayers %d is not a multiple of 6)",
> > +                     newViewNumLayers);
> > +         return;
> > +      }
> > +      break;
> > +   }
> > +
> > +   /* If the new texture's target is TEXTURE_CUBE_MAP or
> > +    * TEXTURE_CUBE_MAP_ARRAY, the width and height of the original
> texture's
> > +    * levels must be equal otherwise the error INVALID_OPERATION is
> generated.
> > +    */
> > +   if ((target == GL_TEXTURE_CUBE_MAP || target ==
> GL_TEXTURE_CUBE_MAP_ARRAY) &&
> > +       (origTexImage->Width != origTexImage->Height)) {
> > +      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(origtexture
> width (%d) != height (%d))",
> > +                  origTexImage->Width, origTexImage->Height);
> > +      return;
> > +   }
> > +
> > +   /* When the original texture's target is TEXTURE_CUBE_MAP, the layer
> > +    * parameters are interpreted in the same order as if it were a
> > +    * TEXTURE_CUBE_MAP_ARRAY with 6 layer-faces.
> > +    */
> > +
> > +   /* If the internal format does not exactly match the internal format
> of the
> > +    * original texture, the contents of the memory are reinterpreted in
> the
> > +    * same manner as for image bindings described in
> > +    * section 3.9.20 (Texture Image Loads and Stores).
> > +    */
> > +
> > +   /* TEXTURE_BASE_LEVEL and TEXTURE_MAX_LEVEL are interpreted
> > +    * relative to the view and not relative to the original data store.
> > +    */
> > +
> > +   if (!initialize_texture_fields(ctx, target, texObj, newViewNumLevels,
> > +                                  width, height, depth,
> > +                                  internalformat, texFormat)) {
> > +      return; /* Already recorded error */
> > +   }
> > +
> > +   texObj->MinLevel = newViewMinLevel;
> > +   texObj->MinLayer = newViewMinLayer;
> > +   texObj->NumLevels = newViewNumLevels;
> > +   texObj->NumLayers = newViewNumLayers;
> > +   texObj->Immutable = GL_TRUE;
> > +   texObj->ImmutableLevels = origTexObj->ImmutableLevels;
> > +   texObj->Target = target;
> > +
> > +   if (!ctx->Driver.TextureView(ctx, texObj, origTexObj)) {
> > +      return; /* driver recorded error */
> > +   }
> > +}
> > diff --git a/src/mesa/main/textureview.h b/src/mesa/main/textureview.h
> > new file mode 100644
> > index 0000000..c2f0f32
> > --- /dev/null
> > +++ b/src/mesa/main/textureview.h
> > @@ -0,0 +1,39 @@
> > +/*
> > + * Mesa 3-D graphics library
> > + *
> > + * Copyright (C) 2012-2013 LunarG, Inc.
> > + *
> > + * 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:
> > + *    Courtney Goeltzenleuchter <courtney at lunarg.com>
> > + */
> > +
> > +
> > +#ifndef TEXTUREVIEW_H
> > +#define TEXTUREVIEW_H
> > +
> > +
> > +extern void GLAPIENTRY
> > +_mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
> > +                  GLenum internalformat,
> > +                  GLuint minlevel, GLuint numlevels,
> > +                  GLuint minlayer, GLuint numlayers);
> > +
> > +#endif /* TEXTUREVIEW_H */
> >
>
>


-- 
Courtney Goeltzenleuchter
LunarG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131104/d2263b5e/attachment-0001.html>


More information about the mesa-dev mailing list