[Mesa-dev] [PATCH 12/41] main: Added entry points for glTextureSubImage*D.
Laura Ekstrand
laura at jlekstrand.net
Mon Jan 5 14:25:39 PST 2015
I've addressed Brian Paul's comment about dsa ? "ture" : "" in this patch.
On Tue, Dec 30, 2014 at 1:25 PM, Laura Ekstrand <laura at jlekstrand.net>
wrote:
>
>
> On Mon, Dec 29, 2014 at 3:02 PM, Anuj Phogat <anuj.phogat at gmail.com>
> wrote:
>
>> On Tue, Dec 16, 2014 at 6:52 AM, Laura Ekstrand <laura at jlekstrand.net>
>> wrote:
>> > ---
>> > src/mapi/glapi/gen/ARB_direct_state_access.xml | 36 +++
>> > src/mesa/main/teximage.c | 343
>> +++++++++++++++++++------
>> > src/mesa/main/teximage.h | 30 +++
>> > 3 files changed, 333 insertions(+), 76 deletions(-)
>> >
>> > diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml
>> b/src/mapi/glapi/gen/ARB_direct_state_access.xml
>> > index 37aac7e..4c5005f 100644
>> > --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
>> > +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
>> > @@ -39,5 +39,41 @@
>> > <param name="depth" type="GLsizei" />
>> > </function>
>> >
>> > + <function name="TextureSubImage1D" offset="assign">
>> > + <param name="texture" type="GLuint" />
>> > + <param name="level" type="GLint" />
>> > + <param name="xoffset" type="GLint" />
>> > + <param name="width" type="GLsizei" />
>> > + <param name="format" type="GLenum" />
>> > + <param name="type" type="GLenum" />
>> > + <param name="pixels" type="const GLvoid *" />
>> > + </function>
>> > +
>> > + <function name="TextureSubImage2D" offset="assign">
>> > + <param name="texture" type="GLuint" />
>> > + <param name="level" type="GLint" />
>> > + <param name="xoffset" type="GLint" />
>> > + <param name="yoffset" type="GLint" />
>> > + <param name="width" type="GLsizei" />
>> > + <param name="height" type="GLsizei" />
>> > + <param name="format" type="GLenum" />
>> > + <param name="type" type="GLenum" />
>> > + <param name="pixels" type="const GLvoid *" />
>> > + </function>
>> > +
>> > + <function name="TextureSubImage3D" offset="assign">
>> > + <param name="texture" type="GLuint" />
>> > + <param name="level" type="GLint" />
>> > + <param name="xoffset" type="GLint" />
>> > + <param name="yoffset" type="GLint" />
>> > + <param name="zoffset" type="GLint" />
>> > + <param name="width" type="GLsizei" />
>> > + <param name="height" type="GLsizei" />
>> > + <param name="depth" type="GLsizei" />
>> > + <param name="format" type="GLenum" />
>> > + <param name="type" type="GLenum" />
>> > + <param name="pixels" type="const GLvoid *" />
>> > + </function>
>> > +
>> > </category>
>> > </OpenGLAPI>
>> > diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
>> > index 08070cd..cfb6297 100644
>> > --- a/src/mesa/main/teximage.c
>> > +++ b/src/mesa/main/teximage.c
>> > @@ -1523,12 +1523,11 @@ _mesa_legal_texture_dimensions(struct
>> gl_context *ctx, GLenum target,
>> > * \return GL_TRUE if error found, GL_FALSE otherwise.
>> > */
>> > static GLboolean
>> > -error_check_subtexture_dimensions(struct gl_context *ctx,
>> > - const char *function, GLuint dims,
>> > +error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims,
>> > const struct gl_texture_image
>> *destImage,
>> > GLint xoffset, GLint yoffset, GLint
>> zoffset,
>> > GLsizei subWidth, GLsizei subHeight,
>> > - GLsizei subDepth)
>> > + GLsizei subDepth, const char *func)
>> > {
>> > const GLenum target = destImage->TexObject->Target;
>> > GLuint bw, bh;
>> > @@ -1536,32 +1535,32 @@ error_check_subtexture_dimensions(struct
>> gl_context *ctx,
>> > /* Check size */
>> > if (subWidth < 0) {
>> > _mesa_error(ctx, GL_INVALID_VALUE,
>> > - "%s%dD(width=%d)", function, dims, subWidth);
>> > + "%s%dD(width=%d)", func, dims, subWidth);
>> > return GL_TRUE;
>> > }
>> >
>> > if (dims > 1 && subHeight < 0) {
>> > _mesa_error(ctx, GL_INVALID_VALUE,
>> > - "%s%dD(height=%d)", function, dims, subHeight);
>> > + "%s%dD(height=%d)", func, dims, subHeight);
>> > return GL_TRUE;
>> > }
>> >
>> > if (dims > 2 && subDepth < 0) {
>> > _mesa_error(ctx, GL_INVALID_VALUE,
>> > - "%s%dD(depth=%d)", function, dims, subDepth);
>> > + "%s%dD(depth=%d)", func, dims, subDepth);
>> > return GL_TRUE;
>> > }
>> >
>> > /* check xoffset and width */
>> > if (xoffset < - (GLint) destImage->Border) {
>> > _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset)",
>> > - function, dims);
>> > + func, dims);
>> > return GL_TRUE;
>> > }
>> >
>> > if (xoffset + subWidth > (GLint) destImage->Width) {
>> > _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset+width)",
>> > - function, dims);
>> > + func, dims);
>> > return GL_TRUE;
>> > }
>> >
>> > @@ -1570,28 +1569,33 @@ error_check_subtexture_dimensions(struct
>> gl_context *ctx,
>> > GLint yBorder = (target == GL_TEXTURE_1D_ARRAY) ? 0 :
>> destImage->Border;
>> > if (yoffset < -yBorder) {
>> > _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset)",
>> > - function, dims);
>> > + func, dims);
>> > return GL_TRUE;
>> > }
>> > if (yoffset + subHeight > (GLint) destImage->Height) {
>> > _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset+height)",
>> > - function, dims);
>> > + func, dims);
>> > return GL_TRUE;
>> > }
>> > }
>> >
>> > /* check zoffset and depth */
>> > if (dims > 2) {
>> > + GLint depth;
>> > GLint zBorder = (target == GL_TEXTURE_2D_ARRAY ||
>> > target == GL_TEXTURE_CUBE_MAP_ARRAY) ?
>> > 0 : destImage->Border;
>> >
>> > if (zoffset < -zBorder) {
>> > - _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset)", function);
>> > + _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset)", func);
>> > return GL_TRUE;
>> > }
>> > - if (zoffset + subDepth > (GLint) destImage->Depth) {
>> > - _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset+depth)",
>> function);
>> > +
>> > + depth = (GLint) destImage->Depth;
>> > + if (target == GL_TEXTURE_CUBE_MAP)
>> > + depth = 6;
>> > + if (zoffset + subDepth > depth) {
>> > + _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset+depth)",
>> func);
>> > return GL_TRUE;
>> > }
>> > }
>> > @@ -1610,7 +1614,7 @@ error_check_subtexture_dimensions(struct
>> gl_context *ctx,
>> > if ((xoffset % bw != 0) || (yoffset % bh != 0)) {
>> > _mesa_error(ctx, GL_INVALID_OPERATION,
>> > "%s%dD(xoffset = %d, yoffset = %d)",
>> > - function, dims, xoffset, yoffset);
>> > + func, dims, xoffset, yoffset);
>> > return GL_TRUE;
>> > }
>> >
>> > @@ -1622,14 +1626,14 @@ error_check_subtexture_dimensions(struct
>> gl_context *ctx,
>> > if ((subWidth % bw != 0) &&
>> > (xoffset + subWidth != (GLint) destImage->Width)) {
>> > _mesa_error(ctx, GL_INVALID_OPERATION,
>> > - "%s%dD(width = %d)", function, dims, subWidth);
>> > + "%s%dD(width = %d)", func, dims, subWidth);
>> > return GL_TRUE;
>> > }
>> >
>> > if ((subHeight % bh != 0) &&
>> > (yoffset + subHeight != (GLint) destImage->Height)) {
>> > _mesa_error(ctx, GL_INVALID_OPERATION,
>> > - "%s%dD(height = %d)", function, dims, subHeight);
>> > + "%s%dD(height = %d)", func, dims, subHeight);
>> > return GL_TRUE;
>> > }
>> > }
>> > @@ -1808,7 +1812,8 @@ legal_teximage_target(struct gl_context *ctx,
>> GLuint dims, GLenum target)
>> > * proxy targets are not supported.
>> > */
>> > static GLboolean
>> > -legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum
>> target)
>> > +legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum
>> target,
>> > + bool dsa)
>> > {
>> > switch (dims) {
>> > case 1:
>> > @@ -1842,6 +1847,13 @@ legal_texsubimage_target(struct gl_context *ctx,
>> GLuint dims, GLenum target)
>> > case GL_TEXTURE_CUBE_MAP_ARRAY:
>> > case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:
>> > return ctx->Extensions.ARB_texture_cube_map_array;
>> > +
>> > + /* Table 8.15 of the OpenGL 4.5 core profile spec
>> > + * (20141030) says that TEXTURE_CUBE_MAP is valid for
>> TextureSubImage3D
>> > + * and CopyTextureSubImage3D.
>> > + */
>> > + case GL_TEXTURE_CUBE_MAP:
>> > + return dsa;
>> > default:
>> > return GL_FALSE;
>> > }
>> > @@ -2350,25 +2362,34 @@ error:
>> > */
>> > static GLboolean
>> > texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
>> > + struct gl_texture_object *texObj,
>> > GLenum target, GLint level,
>> > GLint xoffset, GLint yoffset, GLint zoffset,
>> > GLint width, GLint height, GLint depth,
>> > - GLenum format, GLenum type)
>> > + GLenum format, GLenum type, bool dsa)
>> > {
>> > - struct gl_texture_object *texObj;
>> > struct gl_texture_image *texImage;
>> > GLenum err;
>> >
>> > + if (!texObj) {
>> > + /* must be out of memory */
>> > + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex%sSubImage%dD()",
>> > + dsa ? "ture" : "", dimensions);
>> > + return GL_TRUE;
>> > + }
>> > +
>> > /* check target (proxies not allowed) */
>> > - if (!legal_texsubimage_target(ctx, dimensions, target)) {
>> > - _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)",
>> > + if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) {
>> > + _mesa_error(ctx, GL_INVALID_ENUM,
>> "glTex%sSubImage%uD(target=%s)",
>> > + dsa ? "ture" : "",
>> > dimensions, _mesa_lookup_enum_by_nr(target));
>> > return GL_TRUE;
>> > }
>> >
>> > /* level check */
>> > if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {
>> > - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%uD(level=%d)",
>> > + _mesa_error(ctx, GL_INVALID_VALUE,
>> "glTex%sSubImage%uD(level=%d)",
>> > + dsa ? "ture" : "",
>> > dimensions, level);
>> > return GL_TRUE;
>> > }
>> > @@ -2382,7 +2403,8 @@ texsubimage_error_check(struct gl_context *ctx,
>> GLuint dimensions,
>> > err = _mesa_es_error_check_format_and_type(format, type,
>> dimensions);
>> > if (err != GL_NO_ERROR) {
>> > _mesa_error(ctx, err,
>> > - "glTexSubImage%dD(format = %s, type = %s)",
>> > + "glTex%sSubImage%dD(format = %s, type = %s)",
>> > + dsa ? "ture" : "",
>> > dimensions,
>> > _mesa_lookup_enum_by_nr(format),
>> > _mesa_lookup_enum_by_nr(type));
>> > @@ -2393,38 +2415,35 @@ texsubimage_error_check(struct gl_context *ctx,
>> GLuint dimensions,
>> > err = _mesa_error_check_format_and_type(ctx, format, type);
>> > if (err != GL_NO_ERROR) {
>> > _mesa_error(ctx, err,
>> > - "glTexSubImage%dD(incompatible format = %s, type =
>> %s)",
>> > + "glTex%sSubImage%dD(incompatible format = %s, type =
>> %s)",
>> > + dsa ? "ture" : "",
>> > dimensions, _mesa_lookup_enum_by_nr(format),
>> > _mesa_lookup_enum_by_nr(type));
>> > return GL_TRUE;
>> > }
>> >
>> > - /* Get dest texture object / image pointers */
>> > - texObj = _mesa_get_current_tex_object(ctx, target);
>> > - if (!texObj) {
>> > - /* must be out of memory */
>> > - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage%dD()",
>> dimensions);
>> > - return GL_TRUE;
>> > - }
>> > -
>> > texImage = _mesa_select_tex_image(ctx, texObj, target, level);
>> > if (!texImage) {
>> > /* non-existant texture level */
>> > _mesa_error(ctx, GL_INVALID_OPERATION,
>> > - "glTexSubImage%dD(invalid texture image)",
>> dimensions);
>> > + "glTex%sSubImage%dD(invalid texture image)",
>> > + dsa ? "ture" : "", dimensions);
>> > return GL_TRUE;
>> > }
>> >
>> > - if (error_check_subtexture_dimensions(ctx, "glTexSubImage",
>> dimensions,
>> > + if (error_check_subtexture_dimensions(ctx, dimensions,
>> > texImage, xoffset, yoffset, 0,
>> > - width, height, 1)) {
>> > + width, height, 1,
>> > + dsa ? "glTextureSubImage" :
>> > + "glTexSubImage")) {
>> > return GL_TRUE;
>> > }
>> >
>> > if (_mesa_is_format_compressed(texImage->TexFormat)) {
>> > if (compressedteximage_only_format(ctx,
>> texImage->InternalFormat)) {
>> > _mesa_error(ctx, GL_INVALID_OPERATION,
>> > - "glTexSubImage%dD(no compression for format)",
>> dimensions);
>> > + "glTex%sSubImage%dD(no compression for format)",
>> > + dsa ? "ture" : "", dimensions);
>> > return GL_TRUE;
>> > }
>> > }
>> > @@ -2434,8 +2453,8 @@ texsubimage_error_check(struct gl_context *ctx,
>> GLuint dimensions,
>> > if (_mesa_is_format_integer_color(texImage->TexFormat) !=
>> > _mesa_is_enum_format_integer(format)) {
>> > _mesa_error(ctx, GL_INVALID_OPERATION,
>> > - "glTexSubImage%dD(integer/non-integer format
>> mismatch)",
>> > - dimensions);
>> > + "glTex%sSubImage%dD(integer/non-integer format
>> mismatch)",
>> > + dsa ? "ture" : "", dimensions);
>> > return GL_TRUE;
>> > }
>> > }
>> > @@ -2473,7 +2492,7 @@ copytexture_error_check( struct gl_context *ctx,
>> GLuint dimensions,
>> > GLenum rb_internal_format;
>> >
>> > /* check target */
>> > - if (!legal_texsubimage_target(ctx, dimensions, target)) {
>> > + if (!legal_texsubimage_target(ctx, dimensions, target, false)) {
>> > _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)",
>> > dimensions, _mesa_lookup_enum_by_nr(target));
>> > return GL_TRUE;
>> > @@ -2717,6 +2736,7 @@ copytexsubimage_error_check(struct gl_context
>> *ctx, GLuint dimensions,
>> > struct gl_texture_object *texObj;
>> > struct gl_texture_image *texImage;
>> >
>> > +
>> > /* Check that the source buffer is complete */
>> > if (_mesa_is_user_fbo(ctx->ReadBuffer)) {
>> > if (ctx->ReadBuffer->_Status == 0) {
>> > @@ -2737,8 +2757,8 @@ copytexsubimage_error_check(struct gl_context
>> *ctx, GLuint dimensions,
>> > }
>> >
>> > /* check target (proxies not allowed) */
>> > - if (!legal_texsubimage_target(ctx, dimensions, target)) {
>> > - _mesa_error(ctx, GL_INVALID_ENUM,
>> "glCopyTexSubImage%uD(target=%s)",
>> > + if (!legal_texsubimage_target(ctx, dimensions, target, false)) {
>> > + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)",
>> > dimensions, _mesa_lookup_enum_by_nr(target));
>> > return GL_TRUE;
>> > }
>> > @@ -2765,10 +2785,10 @@ copytexsubimage_error_check(struct gl_context
>> *ctx, GLuint dimensions,
>> > return GL_TRUE;
>> > }
>> >
>> > - if (error_check_subtexture_dimensions(ctx, "glCopyTexSubImage",
>> > - dimensions, texImage,
>> > + if (error_check_subtexture_dimensions(ctx, dimensions, texImage,
>> > xoffset, yoffset, zoffset,
>> > - width, height, 1)) {
>> > + width, height, 1,
>> > + "glCopyTexSubImage")) {
>> > return GL_TRUE;
>> > }
>> >
>> > @@ -2888,7 +2908,6 @@ static inline void
>> > check_gen_mipmap(struct gl_context *ctx, GLenum target,
>> > struct gl_texture_object *texObj, GLint level)
>> > {
>> > - ASSERT(target != GL_TEXTURE_CUBE_MAP);
>> > if (texObj->GenerateMipmap &&
>> > level == texObj->BaseLevel &&
>> > level < texObj->MaxLevel) {
>> > @@ -3377,32 +3396,26 @@ _mesa_EGLImageTargetTexture2DOES (GLenum
>> target, GLeglImageOES image)
>> > }
>> >
>> >
>> > -
>> > /**
>> > - * Implement all the glTexSubImage1/2/3D() functions.
>> > + * Helper that implements the glTexSubImage1/2/3D()
>> > + * and glTextureSubImage1/2/3D() functions.
>> > */
>> > -static void
>> > -texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint
>> level,
>> > - GLint xoffset, GLint yoffset, GLint zoffset,
>> > - GLsizei width, GLsizei height, GLsizei depth,
>> > - GLenum format, GLenum type, const GLvoid *pixels )
>> > +void
>> > +_mesa_texture_sub_image(struct gl_context *ctx, GLuint dims,
>> > + struct gl_texture_object *texObj,
>> > + struct gl_texture_image *texImage,
>> > + GLenum target, GLint level,
>> > + GLint xoffset, GLint yoffset, GLint zoffset,
>> > + GLsizei width, GLsizei height, GLsizei depth,
>> > + GLenum format, GLenum type, const GLvoid
>> *pixels,
>> > + bool dsa)
>> > {
>> > - struct gl_texture_object *texObj;
>> > - struct gl_texture_image *texImage;
>> > -
>> > FLUSH_VERTICES(ctx, 0);
>> >
>> > - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>> > - _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s
>> %p\n",
>> > - dims,
>> > - _mesa_lookup_enum_by_nr(target), level,
>> > - xoffset, yoffset, zoffset, width, height, depth,
>> > - _mesa_lookup_enum_by_nr(format),
>> > - _mesa_lookup_enum_by_nr(type), pixels);
>> > -
>> > /* check target (proxies not allowed) */
>> > - if (!legal_texsubimage_target(ctx, dims, target)) {
>> > - _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)",
>> > + if (!legal_texsubimage_target(ctx, dims, target, dsa)) {
>> > + _mesa_error(ctx, GL_INVALID_ENUM,
>> "glTex%sSubImage%uD(target=%s)",
>> > + dsa ? "ture" : "",
>> > dims, _mesa_lookup_enum_by_nr(target));
>> > return;
>> > }
>> > @@ -3410,17 +3423,8 @@ texsubimage(struct gl_context *ctx, GLuint dims,
>> GLenum target, GLint level,
>> > if (ctx->NewState & _NEW_PIXEL)
>> > _mesa_update_state(ctx);
>> >
>> > - if (texsubimage_error_check(ctx, dims, target, level,
>> > - xoffset, yoffset, zoffset,
>> > - width, height, depth, format, type)) {
>> > - return; /* error was detected */
>> > - }
>> > -
>> > - texObj = _mesa_get_current_tex_object(ctx, target);
>> > -
>> > _mesa_lock_texture(ctx, texObj);
>> > {
>> > - texImage = _mesa_select_tex_image(ctx, texObj, target, level);
>> >
>> > if (width > 0 && height > 0 && depth > 0) {
>> > /* If we have a border, offset=-1 is legal. Bias by border
>> width. */
>> > @@ -3452,6 +3456,150 @@ texsubimage(struct gl_context *ctx, GLuint
>> dims, GLenum target, GLint level,
>> > _mesa_unlock_texture(ctx, texObj);
>> > }
>> >
>> > +/**
>> > + * Implement all the glTexSubImage1/2/3D() functions.
>> > + * Must split this out this way because of GL_TEXTURE_CUBE_MAP.
>> > + */
>> > +static void
>> > +texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint
>> level,
>> > + GLint xoffset, GLint yoffset, GLint zoffset,
>> > + GLsizei width, GLsizei height, GLsizei depth,
>> > + GLenum format, GLenum type, const GLvoid *pixels )
>> > +{
>> > + struct gl_texture_object *texObj;
>> > + struct gl_texture_image *texImage;
>> > + texObj = _mesa_get_current_tex_object(ctx, target);
>> > + if (texsubimage_error_check(ctx, dims, texObj, target, level,
>> > + xoffset, yoffset, zoffset,
>> > + width, height, depth, format, type,
>> false)) {
>> > + return; /* error was detected */
>> > + }
>> > +
>> > + texImage = _mesa_select_tex_image(ctx, texObj, target, level);
>> > + if (!texImage) {
>> > + /* non-existant texture level
>> > + *
>> > + * Why is this invalid operation and not invalid value?
>> > + * Maybe: Look at errors for CompressedTexSubImage*D.
>> > + * In the gl 4.5 spec section 8.7 Compressed Texture Images
>> > + * (30.10.2014):
>> > + * "An INVALID_OPERATION error is generated if xoffset, yoffset,
>> > + * or zoffset are not equal to zero, or if width, height, and
>> > + * depth do not match the corresponding dimensions of the texture
>> > + * level."
>> > + */
>> Use below format to provide spec reference. This is to keep it uniform
>> across Mesa.
>> From page xxx of OpenGL x.x spec:
>> ".................
>> .........."
>>
> > + _mesa_error(ctx, GL_INVALID_OPERATION,
>> > + "glTexSubImage%uD(level)", dims);
>> > + return;
>> > + }
>> Above error check is not required. Isn't it already done in
>> texsubimage_error_check()?
>>
>
> This was already done in the error check, so this block was replaced with
> "/* texsubimage_error_check ensures that texImage is not NULL */."
>
>>
>> > +
>> > + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>> > + _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s
>> %p\n",
>> > + dims,
>> > + _mesa_lookup_enum_by_nr(target), level,
>> > + xoffset, yoffset, zoffset, width, height, depth,
>> > + _mesa_lookup_enum_by_nr(format),
>> > + _mesa_lookup_enum_by_nr(type), pixels);
>> > +
>> > + _mesa_texture_sub_image(ctx, dims, texObj, texImage, target, level,
>> > + xoffset, yoffset, zoffset, width, height,
>> depth,
>> > + format, type, pixels, false);
>> > +}
>> > +
>> > +
>> > +/**
>> > + * Implement all the glTextureSubImage1/2/3D() functions.
>> > + * Must split this out this way because of GL_TEXTURE_CUBE_MAP.
>> > + */
>> > +static void
>> > +texturesubimage(struct gl_context *ctx, GLuint dims,
>> > + GLuint texture, GLint level,
>> > + GLint xoffset, GLint yoffset, GLint zoffset,
>> > + GLsizei width, GLsizei height, GLsizei depth,
>> > + GLenum format, GLenum type, const GLvoid *pixels )
>> > +{
>> > + struct gl_texture_object *texObj;
>> > + struct gl_texture_image *texImage;
>> > + int i;
>> > +
>> > + /* Get the texture object by Name. */
>> > + texObj = _mesa_lookup_texture(ctx, texture);
>> > + if (!texObj) {
>> > + _mesa_error(ctx, GL_INVALID_OPERATION,
>> "glTextureSubImage%uD(texture)",
>> > + dims);
>> > + return;
>> > + }
>> I think same error check is needed in texsubimage() ?
>>
> It's added in patch 38 in the form "if (!texObj)\n return;" (The invalid
> operation error does not need to be thrown for texsubimage because it does
> not use the user's texture_name to look up the texture object in the hash
> table.)
>
>> > +
>> > + if (texsubimage_error_check(ctx, dims, texObj, texObj->Target,
>> level,
>> > + xoffset, yoffset, zoffset,
>> > + width, height, depth, format, type,
>> true)) {
>> > + return; /* error was detected */
>> > + }
>> > +
>> > + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>> > + _mesa_debug(ctx,
>> > + "glTextureSubImage%uD %s %d %d %d %d %d %d %d %s %s
>> %p\n",
>> > + dims,
>> > + _mesa_lookup_enum_by_nr(texObj->Target), level,
>> > + xoffset, yoffset, zoffset, width, height, depth,
>> > + _mesa_lookup_enum_by_nr(format),
>> > + _mesa_lookup_enum_by_nr(type), pixels);
>> > +
>> > +
>> > + /* Must special case GL_TEXTURE_CUBE_MAP. */
>> Must handle special case ...?
>>
> Fixed
>
>> > + if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
>> > +
>> > + /* Error checking */
>> > + if (texObj->NumLayers < 6) {
>> > + /* Not enough image planes for a cube map. The spec does not
>> say
>> > + * what should happen in this case because the user has always
>> > + * specified each cube face separately (using
>> > + * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL versions.
>> > + * This is addressed in Khronos Bug 13223.
>> > + */
>> > + _mesa_error(ctx, GL_INVALID_OPERATION,
>> > + "glTextureSubImage%uD(insufficient cube map
>> storage)",
>> > + dims);
>> > + return;
>> > + }
>> > + for (i = 0; i < 6; ++i) { /* For each face. */
>> > + if (!texObj->Image[i][level]) {
>> > + /* Not enough image planes for a cube map. The spec does
>> not say
>> > + * what should happen in this case because the user has
>> always
>> > + * specified each cube face separately (using
>> > + * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL
>> versions.
>> > + * This is addressed in Khronos Bug 13223.
>> > + */
>> > + _mesa_error(ctx, GL_INVALID_OPERATION,
>> > + "glTextureSubImage%uD(insufficient cube map
>> storage)",
>> > + dims);
>> > + return;
>> > + }
>> > + }
>> > +
>> > + /* Copy in each face. */
>> > + for (i = 0; i < 6; ++i) { /* For each face. */
>> Get rid of duplicate comment.
>>
> Done.
>
>> > + texImage = texObj->Image[i][level];
>> > + _mesa_texture_sub_image(ctx, 3, texObj, texImage,
>> texObj->Target,
>> > + level, xoffset, yoffset, zoffset,
>> > + width, height, 1, format,
>> > + type, pixels, true);
>> > + pixels += _mesa_image_image_stride(&ctx->Unpack, width,
>> height,
>> > + format, type);
>> > + }
>> > + }
>> > + else {
>> > + texImage = _mesa_select_tex_image(ctx, texObj, texObj->Target,
>> level);
>> > + if (!texImage)
>> > + return;
>> > +
>> > + _mesa_texture_sub_image(ctx, dims, texObj, texImage,
>> texObj->Target,
>> > + level, xoffset, yoffset, zoffset,
>> > + width, height, depth, format,
>> > + type, pixels, true);
>> > + }
>> > +}
>> > +
>> >
>> > void GLAPIENTRY
>> > _mesa_TexSubImage1D( GLenum target, GLint level,
>> > @@ -3497,6 +3645,48 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
>> > format, type, pixels);
>> > }
>> >
>> > +void GLAPIENTRY
>> > +_mesa_TextureSubImage1D( GLuint texture, GLint level,
>> > + GLint xoffset, GLsizei width,
>> > + GLenum format, GLenum type,
>> > + const GLvoid *pixels )
>> > +{
>> > + GET_CURRENT_CONTEXT(ctx);
>> > + texturesubimage(ctx, 1, texture, level,
>> > + xoffset, 0, 0,
>> > + width, 1, 1,
>> > + format, type, pixels);
>> > +}
>> > +
>> > +
>> > +void GLAPIENTRY
>> > +_mesa_TextureSubImage2D( GLuint texture, GLint level,
>> > + GLint xoffset, GLint yoffset,
>> > + GLsizei width, GLsizei height,
>> > + GLenum format, GLenum type,
>> > + const GLvoid *pixels )
>> > +{
>> > + GET_CURRENT_CONTEXT(ctx);
>> > + texturesubimage(ctx, 2, texture, level,
>> > + xoffset, yoffset, 0,
>> > + width, height, 1,
>> > + format, type, pixels);
>> > +}
>> > +
>> > +
>> > +void GLAPIENTRY
>> > +_mesa_TextureSubImage3D( GLuint texture, GLint level,
>> > + GLint xoffset, GLint yoffset, GLint zoffset,
>> > + GLsizei width, GLsizei height, GLsizei depth,
>> > + GLenum format, GLenum type,
>> > + const GLvoid *pixels )
>> > +{
>> > + GET_CURRENT_CONTEXT(ctx);
>> > + texturesubimage(ctx, 3, texture, level,
>> > + xoffset, yoffset, zoffset,
>> > + width, height, depth,
>> > + format, type, pixels);
>> > +}
>> >
>> >
>> > /**
>> > @@ -4202,9 +4392,10 @@ compressed_subtexture_error_check(struct
>> gl_context *ctx, GLint dims,
>> > return GL_TRUE;
>> > }
>> >
>> > - if (error_check_subtexture_dimensions(ctx,
>> "glCompressedTexSubImage", dims,
>> > + if (error_check_subtexture_dimensions(ctx, dims,
>> > texImage, xoffset, yoffset,
>> zoffset,
>> > - width, height, depth)) {
>> > + width, height, depth,
>> > + "glCompressedTexSubImage")) {
>> > return GL_TRUE;
>> > }
>> >
>> > diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
>> > index b9da8ae..705410d 100644
>> > --- a/src/mesa/main/teximage.h
>> > +++ b/src/mesa/main/teximage.h
>> > @@ -156,6 +156,15 @@ _mesa_legal_texture_base_format_for_target(struct
>> gl_context *ctx,
>> > unsigned dimensions,
>> > const char *caller);
>> >
>> > +extern void
>> > +_mesa_texture_sub_image( struct gl_context *ctx, GLuint dims,
>> > + struct gl_texture_object *texObj,
>> > + struct gl_texture_image *texImage,
>> > + GLenum target, GLint level,
>> > + GLint xoffset, GLint yoffset, GLint zoffset,
>> > + GLsizei width, GLsizei height, GLsizei depth,
>> > + GLenum format, GLenum type, const GLvoid
>> *pixels,
>> > + bool dsa );
>> > /*@}*/
>> >
>> >
>> > @@ -211,6 +220,27 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
>> > GLenum format, GLenum type,
>> > const GLvoid *pixels );
>> >
>> > +extern void GLAPIENTRY
>> > +_mesa_TextureSubImage1D( GLuint texture, GLint level, GLint xoffset,
>> > + GLsizei width,
>> > + GLenum format, GLenum type,
>> > + const GLvoid *pixels );
>> > +
>> > +
>> > +extern void GLAPIENTRY
>> > +_mesa_TextureSubImage2D( GLuint texture, GLint level,
>> > + GLint xoffset, GLint yoffset,
>> > + GLsizei width, GLsizei height,
>> > + GLenum format, GLenum type,
>> > + const GLvoid *pixels );
>> > +
>> > +extern void GLAPIENTRY
>> > +_mesa_TextureSubImage3D( GLuint texture, GLint level,
>> > + GLint xoffset, GLint yoffset, GLint zoffset,
>> > + GLsizei width, GLsizei height, GLsizei depth,
>> > + GLenum format, GLenum type,
>> > + const GLvoid *pixels );
>> > +
>> >
>> > extern void GLAPIENTRY
>> > _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum
>> internalformat,
>> > --
>> > 2.1.0
>> >
>> > _______________________________________________
>> > mesa-dev mailing list
>> > mesa-dev at lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150105/205a7eab/attachment-0001.html>
More information about the mesa-dev
mailing list