<div dir="ltr">Comments have been addressed: <a href="http://cgit.freedesktop.org/~ldeks/mesa/commit/?h=adsa-textures&id=9c55b528e24650753049a11b05f754ab02a0eba4">http://cgit.freedesktop.org/~ldeks/mesa/commit/?h=adsa-textures&id=9c55b528e24650753049a11b05f754ab02a0eba4</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 31, 2014 at 11:27 AM, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Dec 15, 2014 at 5:22 PM, Laura Ekstrand <<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>> wrote:<br>
> ---<br>
> src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +<br>
> src/mesa/main/texgetimage.c | 169 ++++++++++++++++++-------<br>
> src/mesa/main/texgetimage.h | 12 ++<br>
> 3 files changed, 143 insertions(+), 45 deletions(-)<br>
><br>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> index 605c614..df335eb 100644<br>
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> @@ -157,6 +157,13 @@<br>
> <param name="pixels" type="GLvoid *" /><br>
> </function><br>
><br>
> + <function name="GetCompressedTextureImage" offset="assign"><br>
> + <param name="texture" type="GLuint" /><br>
> + <param name="level" type="GLint" /><br>
> + <param name="bufSize" type="GLsizei" /><br>
> + <param name="pixels" type="GLvoid *" /><br>
> + </function><br>
> +<br>
> <function name="GetTextureLevelParameterfv" offset="assign"><br>
> <param name="texture" type="GLuint" /><br>
> <param name="level" type="GLint" /><br>
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c<br>
> index 32b5ace..3cc3df6 100644<br>
> --- a/src/mesa/main/texgetimage.c<br>
> +++ b/src/mesa/main/texgetimage.c<br>
> @@ -1148,45 +1148,37 @@ _mesa_GetTextureImage( GLuint texture, GLint level, GLenum format,<br>
> * \return GL_TRUE if any error, GL_FALSE if no errors.<br>
> */<br>
> static GLboolean<br>
> -getcompressedteximage_error_check(struct gl_context *ctx, GLenum target,<br>
> - GLint level, GLsizei clientMemSize, GLvoid *img)<br>
> +getcompressedteximage_error_check(struct gl_context *ctx,<br>
> + struct gl_texture_object *texObj,<br>
> + struct gl_texture_image *texImage,<br>
> + GLenum target,<br>
> + GLint level, GLsizei clientMemSize,<br>
> + GLvoid *img, bool dsa)<br>
> {<br>
> - struct gl_texture_object *texObj;<br>
> - struct gl_texture_image *texImage;<br>
> + assert(texObj);<br>
> + assert(texImage);<br>
> const GLint maxLevels = _mesa_max_texture_levels(ctx, target);<br>
> GLuint compressedSize, dimensions;<br>
><br>
> - if (!legal_getteximage_target(ctx, target, false)) {<br>
> - _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)",<br>
> - target);<br>
> + if (!legal_getteximage_target(ctx, target, dsa)) {<br>
> + _mesa_error(ctx, GL_INVALID_ENUM,<br>
> + "glGetCompressedTex%sImage(target=0x%x)",<br>
> + dsa ? "ture" : "", target);<br>
> return GL_TRUE;<br>
> }<br>
><br>
> assert(maxLevels != 0);<br>
> if (level < 0 || level >= maxLevels) {<br>
> _mesa_error(ctx, GL_INVALID_VALUE,<br>
> - "glGetCompressedTexImageARB(bad level = %d)", level);<br>
> - return GL_TRUE;<br>
> - }<br>
> -<br>
> - texObj = _mesa_get_current_tex_object(ctx, target);<br>
> - if (!texObj) {<br>
> - _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)");<br>
> - return GL_TRUE;<br>
> - }<br>
> -<br>
> - texImage = _mesa_select_tex_image(ctx, texObj, target, level);<br>
> -<br>
> - if (!texImage) {<br>
> - /* probably invalid mipmap level */<br>
> - _mesa_error(ctx, GL_INVALID_VALUE,<br>
> - "glGetCompressedTexImageARB(level)");<br>
> + "glGetCompressedTex%sImage(bad level = %d)",<br>
> + dsa ? "ture" : "", level);<br>
> return GL_TRUE;<br>
> }<br>
><br>
> if (!_mesa_is_format_compressed(texImage->TexFormat)) {<br>
> _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> - "glGetCompressedTexImageARB(texture is not compressed)");<br>
> + "glGetCompressedTex%sImage(texture is not compressed)",<br>
> + dsa ? "ture" : "");<br>
> return GL_TRUE;<br>
> }<br>
><br>
> @@ -1198,8 +1190,9 @@ getcompressedteximage_error_check(struct gl_context *ctx, GLenum target,<br>
> /* Check for invalid pixel storage modes */<br>
> dimensions = _mesa_get_texture_dimensions(texImage->TexObject->Target);<br>
> if (!_mesa_compressed_pixel_storage_error_check(ctx, dimensions,<br>
> - &ctx->Pack,<br>
> - "glGetCompressedTexImageARB")) {<br>
> + &ctx->Pack, dsa ?<br>
> + "glGetCompressedTextureImage":<br>
> + "glGetCompressedTexImage")) {<br>
> return GL_TRUE;<br>
> }<br>
><br>
> @@ -1207,8 +1200,9 @@ getcompressedteximage_error_check(struct gl_context *ctx, GLenum target,<br>
> /* do bounds checking on writing to client memory */<br>
> if (clientMemSize < (GLsizei) compressedSize) {<br>
> _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> - "glGetnCompressedTexImageARB(out of bounds access:"<br>
> - " bufSize (%d) is too small)", clientMemSize);<br>
> + "%s(out of bounds access: bufSize (%d) is too small)",<br>
> + dsa ? "glGetCompressedTextureImage" :<br>
> + "glGetnCompressedTexImageARB", clientMemSize);<br>
> return GL_TRUE;<br>
> }<br>
> } else {<br>
> @@ -1216,14 +1210,16 @@ getcompressedteximage_error_check(struct gl_context *ctx, GLenum target,<br>
> if ((const GLubyte *) img + compressedSize ><br>
> (const GLubyte *) ctx->Pack.BufferObj->Size) {<br>
> _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> - "glGetCompressedTexImage(out of bounds PBO access)");<br>
> + "glGetCompressedTex%sImage(out of bounds PBO access)",<br>
> + dsa ? "ture" : "");<br>
> return GL_TRUE;<br>
> }<br>
><br>
> /* make sure PBO is not mapped */<br>
> if (_mesa_check_disallowed_mapping(ctx->Pack.BufferObj)) {<br>
> _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> - "glGetCompressedTexImage(PBO is mapped)");<br>
> + "glGetCompressedTex%sImage(PBO is mapped)",<br>
> + dsa ? "ture" : "");<br>
> return GL_TRUE;<br>
> }<br>
> }<br>
> @@ -1231,49 +1227,132 @@ getcompressedteximage_error_check(struct gl_context *ctx, GLenum target,<br>
> return GL_FALSE;<br>
> }<br>
><br>
> -<br>
> -void GLAPIENTRY<br>
> -_mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize,<br>
> - GLvoid *img)<br>
> +/** Implements glGetnCompressedTexImageARB, glGetCompressedTexImage, and<br>
> + * glGetCompressedTextureImage.<br>
> + *<br>
> + * texImage must be passed in because glGetCompressedTexImage must handle the<br>
> + * target GL_TEXTURE_CUBE_MAP.<br>
> + */<br>
> +void<br>
> +_mesa_get_compressed_texture_image( struct gl_context *ctx,<br>
> + struct gl_texture_object *texObj,<br>
> + struct gl_texture_image *texImage,<br>
> + GLenum target, GLint level,<br>
> + GLsizei bufSize, GLvoid *pixels,<br>
> + bool dsa )<br>
> {<br>
> - struct gl_texture_object *texObj;<br>
> - struct gl_texture_image *texImage;<br>
> - GET_CURRENT_CONTEXT(ctx);<br>
> + assert(texObj);<br>
> + assert(texImage);<br>
><br>
> FLUSH_VERTICES(ctx, 0);<br>
><br>
> - if (getcompressedteximage_error_check(ctx, target, level, bufSize, img)) {<br>
> + if (getcompressedteximage_error_check(ctx, texObj, texImage, target, level,<br>
> + bufSize, pixels, dsa)) {<br>
> return;<br>
> }<br>
><br>
> - if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) {<br>
> + if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) {<br>
> /* not an error, do nothing */<br>
> return;<br>
> }<br>
><br>
> - texObj = _mesa_get_current_tex_object(ctx, target);<br>
> - texImage = _mesa_select_tex_image(ctx, texObj, target, level);<br>
> -<br>
> if (_mesa_is_zero_size_texture(texImage))<br>
> return;<br>
><br>
> if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) {<br>
> _mesa_debug(ctx,<br>
> - "glGetCompressedTexImage(tex %u) format = %s, w=%d, h=%d\n",<br>
> - texObj->Name,<br>
> + "glGetCompressedTex%sImage(tex %u) format = %s, w=%d, h=%d\n",<br>
> + dsa ? "ture" : "", texObj->Name,<br>
> _mesa_get_format_name(texImage->TexFormat),<br>
> texImage->Width, texImage->Height);<br>
> }<br>
><br>
> _mesa_lock_texture(ctx, texObj);<br>
> {<br>
> - ctx->Driver.GetCompressedTexImage(ctx, texImage, img);<br>
> + ctx->Driver.GetCompressedTexImage(ctx, texImage, pixels);<br>
> }<br>
> _mesa_unlock_texture(ctx, texObj);<br>
> }<br>
><br>
> void GLAPIENTRY<br>
> +_mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize,<br>
> + GLvoid *img)<br>
> +{<br>
> + struct gl_texture_object *texObj;<br>
> + struct gl_texture_image *texImage;<br>
> + GET_CURRENT_CONTEXT(ctx);<br>
> +<br>
> + texObj = _mesa_get_current_tex_object(ctx, target);<br>
> + if (!texObj)<br>
> + return;<br>
> +<br>
> + texImage = _mesa_select_tex_image(ctx, texObj, target, level);<br>
> + if (!texImage)<br>
> + return;<br>
> +<br>
> + _mesa_get_compressed_texture_image(ctx, texObj, texImage, target, level,<br>
> + bufSize, img, false);<br>
> +}<br>
> +<br>
> +void GLAPIENTRY<br>
> _mesa_GetCompressedTexImage(GLenum target, GLint level, GLvoid *img)<br>
> {<br>
> _mesa_GetnCompressedTexImageARB(target, level, INT_MAX, img);<br>
> }<br>
> +<br>
> +/**<br>
> + * Get compressed texture image.<br>
> + *<br>
> + * \param texture texture name.<br>
> + * \param level image level.<br>
> + * \param bufSize size of the pixels data buffer.<br>
> + * \param pixels returned pixel data.<br>
> + */<br>
> +void GLAPIENTRY<br>
> +_mesa_GetCompressedTextureImage( GLuint texture, GLint level,<br>
> + GLsizei bufSize, GLvoid *pixels )<br>
> +{<br>
> + struct gl_texture_object *texObj;<br>
> + struct gl_texture_image *texImage;<br>
> + int i;<br>
> + GLint image_stride;<br>
> + GET_CURRENT_CONTEXT(ctx);<br>
> +<br>
> + texObj = _mesa_lookup_texture_err(ctx, texture,<br>
> + "glGetCompressedTextureImage");<br>
> + if (!texObj)<br>
> + return;<br>
> +<br>
> + /* Must special case GL_TEXTURE_CUBE_MAP. */<br>
</div></div>Must handle<br>
<span class="">> + if (texObj->Target == GL_TEXTURE_CUBE_MAP) {<br>
> + assert(texObj->NumLayers >= 6);<br>
> +<br>
> + /* Copy each face. */<br>
> + for (i = 0; i < 6; ++i) { /* For each face. */<br>
</span>duplicate comment.<br>
<div><div class="h5">> + texImage = texObj->Image[i][level];<br>
> + if (!texImage)<br>
> + return;<br>
> +<br>
> + _mesa_get_compressed_texture_image(ctx, texObj, texImage,<br>
> + texObj->Target, level,<br>
> + bufSize, pixels, true);<br>
> +<br>
> + /* Compressed images don't have a client format */<br>
> + image_stride = _mesa_format_image_size(texImage->TexFormat,<br>
> + texImage->Width,<br>
> + texImage->Height, 1);<br>
> +<br>
> + pixels += image_stride;<br>
> + bufSize -= image_stride;<br>
> + }<br>
> + }<br>
> + else {<br>
> + texImage = _mesa_select_tex_image(ctx, texObj, texObj->Target, level);<br>
> + if (!texImage)<br>
> + return;<br>
> +<br>
> + _mesa_get_compressed_texture_image(ctx, texObj, texImage,<br>
> + texObj->Target, level, bufSize,<br>
> + pixels, true);<br>
> + }<br>
> +}<br>
> diff --git a/src/mesa/main/texgetimage.h b/src/mesa/main/texgetimage.h<br>
> index 085f580..1413923 100644<br>
> --- a/src/mesa/main/texgetimage.h<br>
> +++ b/src/mesa/main/texgetimage.h<br>
> @@ -54,6 +54,14 @@ _mesa_get_texture_image( struct gl_context *ctx,<br>
> GLint level, GLenum format, GLenum type,<br>
> GLsizei bufSize, GLvoid *pixels, bool dsa );<br>
><br>
> +extern void<br>
> +_mesa_get_compressed_texture_image( struct gl_context *ctx,<br>
> + struct gl_texture_object *texObj,<br>
> + struct gl_texture_image *texImage,<br>
> + GLenum target, GLint level,<br>
> + GLsizei bufSize, GLvoid *pixels,<br>
> + bool dsa );<br>
> +<br>
><br>
> extern void GLAPIENTRY<br>
> _mesa_GetTexImage( GLenum target, GLint level,<br>
> @@ -72,4 +80,8 @@ extern void GLAPIENTRY<br>
> _mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize,<br>
> GLvoid *img);<br>
><br>
> +extern void GLAPIENTRY<br>
> +_mesa_GetCompressedTextureImage(GLuint texture, GLint level, GLsizei bufSize,<br>
> + GLvoid *pixels);<br>
> +<br>
> #endif /* TEXGETIMAGE_H */<br>
> --<br>
> 2.1.0<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div>