diff options
author | marha <marha@users.sourceforge.net> | 2012-01-06 19:47:46 +0100 |
---|---|---|
committer | Marc Haesen <marc@hc-consult.be> | 2012-01-06 19:47:46 +0100 |
commit | 2d52fd67e716caae85bce150b01bc5c284b12de7 (patch) | |
tree | 2a641392a6affe99603cbaf169c1ab5173879d27 /mesalib/src/mesa | |
parent | d515b895dc5151d102f33b577cafbf63473bbafa (diff) | |
parent | 7e9f4ea970e8f7008c212d7d3918a974eb0066da (diff) | |
download | vcxsrv-2d52fd67e716caae85bce150b01bc5c284b12de7.tar.gz vcxsrv-2d52fd67e716caae85bce150b01bc5c284b12de7.tar.bz2 vcxsrv-2d52fd67e716caae85bce150b01bc5c284b12de7.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
mesalib/src/glsl/link_uniforms.cpp
mesalib/src/mesa/drivers/dri/common/drisw_util.c
Diffstat (limited to 'mesalib/src/mesa')
48 files changed, 1170 insertions, 1644 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 5098680b6..785a59531 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -3157,19 +3157,19 @@ copy_tex_sub_image(struct gl_context *ctx, */ _mesa_meta_begin(ctx, MESA_META_PIXEL_STORE); if (target == GL_TEXTURE_1D) { - ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, - width, format, type, buf, - &ctx->Unpack, texObj, texImage); + ctx->Driver.TexSubImage1D(ctx, texImage, + xoffset, width, + format, type, buf, &ctx->Unpack); } else if (target == GL_TEXTURE_3D) { - ctx->Driver.TexSubImage3D(ctx, target, level, xoffset, yoffset, zoffset, - width, height, 1, format, type, buf, - &ctx->Unpack, texObj, texImage); + ctx->Driver.TexSubImage3D(ctx, texImage, + xoffset, yoffset, zoffset, width, height, 1, + format, type, buf, &ctx->Unpack); } else { - ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset, - width, height, format, type, buf, - &ctx->Unpack, texObj, texImage); + ctx->Driver.TexSubImage2D(ctx, texImage, + xoffset, yoffset, width, height, + format, type, buf, &ctx->Unpack); } _mesa_meta_end(ctx); diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index a153d525d..db7322ec4 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -134,35 +134,98 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp) /*@{*/ static __DRIcontext * -dri2CreateNewContextForAPI(__DRIscreen *screen, int api, - const __DRIconfig *config, - __DRIcontext *shared, void *data) +dri2CreateContextAttribs(__DRIscreen *screen, int api, + const __DRIconfig *config, + __DRIcontext *shared, + unsigned num_attribs, + const uint32_t *attribs, + unsigned *error, + void *data) { __DRIcontext *context; const struct gl_config *modes = (config != NULL) ? &config->modes : NULL; void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; gl_api mesa_api; + unsigned major_version = 1; + unsigned minor_version = 0; + uint32_t flags = 0; - if (!(screen->api_mask & (1 << api))) + assert((num_attribs == 0) || (attribs != NULL)); + + if (!(screen->api_mask & (1 << api))) { + *error = __DRI_CTX_ERROR_BAD_API; return NULL; + } switch (api) { case __DRI_API_OPENGL: - mesa_api = API_OPENGL; - break; + mesa_api = API_OPENGL; + break; case __DRI_API_GLES: - mesa_api = API_OPENGLES; - break; + mesa_api = API_OPENGLES; + break; case __DRI_API_GLES2: - mesa_api = API_OPENGLES2; - break; + mesa_api = API_OPENGLES2; + break; + case __DRI_API_OPENGL_CORE: default: + *error = __DRI_CTX_ERROR_BAD_API; + return NULL; + } + + if (mesa_api != API_OPENGL && num_attribs != 0) { + *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; + assert(!"Should not get here."); + return NULL; + } + + for (unsigned i = 0; i < num_attribs; i++) { + switch (attribs[i * 2]) { + case __DRI_CTX_ATTRIB_MAJOR_VERSION: + major_version = attribs[i * 2 + 1]; + break; + case __DRI_CTX_ATTRIB_MINOR_VERSION: + minor_version = attribs[i * 2 + 1]; + break; + case __DRI_CTX_ATTRIB_FLAGS: + flags = attribs[i * 2 + 1]; + break; + default: + /* We can't create a context that satisfies the requirements of an + * attribute that we don't understand. Return failure. + */ + assert(!"Should not get here."); + *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; return NULL; + } + } + + /* There are no forward-compatible contexts before OpenGL 3.0. The + * GLX_ARB_create_context spec says: + * + * "Forward-compatible contexts are defined only for OpenGL versions + * 3.0 and later." + * + * Moreover, Mesa can't fulfill the requirements of a forward-looking + * context. Return failure if a forward-looking context is requested. + * + * In Mesa, a debug context is the same as a regular context. + */ + if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) { + *error = __DRI_CTX_ERROR_BAD_FLAG; + return NULL; + } + + if ((flags & ~__DRI_CTX_FLAG_DEBUG) != 0) { + *error = __DRI_CTX_ERROR_UNKNOWN_FLAG; + return NULL; } context = malloc(sizeof *context); - if (!context) + if (!context) { + *error = __DRI_CTX_ERROR_NO_MEMORY; return NULL; + } context->loaderPrivate = data; @@ -170,14 +233,27 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api, context->driDrawablePriv = NULL; context->driReadablePriv = NULL; - if (!driDriverAPI.CreateContext(mesa_api, modes, context, shareCtx) ) { + if (!driDriverAPI.CreateContext(mesa_api, modes, context, + major_version, minor_version, + flags, error, shareCtx) ) { free(context); return NULL; } + *error = __DRI_CTX_ERROR_SUCCESS; return context; } +static __DRIcontext * +dri2CreateNewContextForAPI(__DRIscreen *screen, int api, + const __DRIconfig *config, + __DRIcontext *shared, void *data) +{ + unsigned error; + + return dri2CreateContextAttribs(screen, api, config, shared, 0, NULL, + &error, data); +} static __DRIcontext * dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config, @@ -454,10 +530,7 @@ const __DRIcoreExtension driCoreExtension = { /** DRI2 interface */ const __DRIdri2Extension driDRI2Extension = { - /* Force the version to 2 because the underlying drivers don't (can't!) - * support the extra requirements of CreateContextAttribs. - */ - { __DRI_DRI2, 2 }, + { __DRI_DRI2, __DRI_DRI2_VERSION }, dri2CreateNewScreen, dri2CreateNewDrawable, dri2CreateNewContext, @@ -465,7 +538,7 @@ const __DRIdri2Extension driDRI2Extension = { dri2CreateNewContextForAPI, dri2AllocateBuffer, dri2ReleaseBuffer, - NULL + dri2CreateContextAttribs }; const __DRI2configQueryExtension dri2ConfigQueryExtension = { diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.h b/mesalib/src/mesa/drivers/dri/common/dri_util.h index bebb021f6..900f04853 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.h +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.h @@ -84,6 +84,10 @@ struct __DriverAPIRec { GLboolean (*CreateContext)(gl_api api, const struct gl_config *glVis, __DRIcontext *driContextPriv, + unsigned major_version, + unsigned minor_version, + uint32_t flags, + unsigned *error, void *sharedContextPrivate); void (*DestroyContext)(__DRIcontext *driContextPriv); diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c index 76b41231a..0ec124ae5 100644 --- a/mesalib/src/mesa/drivers/dri/common/drisw_util.c +++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.c @@ -94,14 +94,26 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp) */ static __DRIcontext * -driCreateNewContextForAPI(__DRIscreen *psp, int api, - const __DRIconfig *config, - __DRIcontext *shared, void *data) +driCreateContextAttribs(__DRIscreen *screen, int api, + const __DRIconfig *config, + __DRIcontext *shared, + unsigned num_attribs, + const uint32_t *attribs, + unsigned *error, + void *data) { __DRIcontext *pcp; const struct gl_config *modes = (config != NULL) ? &config->modes : NULL; void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; gl_api mesa_api; + unsigned major_version = 1; + unsigned minor_version = 0; + uint32_t flags = 0; + + /* Either num_attribs is zero and attribs is NULL, or num_attribs is not + * zero and attribs is not NULL. + */ + assert((num_attribs == 0) == (attribs == NULL)); switch (api) { case __DRI_API_OPENGL: @@ -113,21 +125,59 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api, case __DRI_API_GLES2: mesa_api = API_OPENGLES2; break; + case __DRI_API_OPENGL_CORE: default: return NULL; } + for (unsigned i = 0; i < num_attribs; i++) { + switch (attribs[i * 2]) { + case __DRI_CTX_ATTRIB_MAJOR_VERSION: + major_version = attribs[i * 2 + 1]; + break; + case __DRI_CTX_ATTRIB_MINOR_VERSION: + minor_version = attribs[i * 2 + 1]; + break; + case __DRI_CTX_ATTRIB_FLAGS: + flags = attribs[i * 2 + 1]; + break; + default: + /* We can't create a context that satisfies the requirements of an + * attribute that we don't understand. Return failure. + */ + return NULL; + } + } + + /* There are no forward-compatible contexts before OpenGL 3.0. The + * GLX_ARB_create_context spec says: + * + * "Forward-compatible contexts are defined only for OpenGL versions + * 3.0 and later." + * + * Moreover, Mesa can't fulfill the requirements of a forward-looking + * context. Return failure if a forward-looking context is requested. + * + * In Mesa, a debug context is the same as a regular context. + */ + if (major_version >= 3) { + if ((flags & ~__DRI_CTX_FLAG_DEBUG) != 0) + return NULL; + } + pcp = CALLOC_STRUCT(__DRIcontextRec); if (!pcp) return NULL; pcp->loaderPrivate = data; - pcp->driScreenPriv = psp; + pcp->driScreenPriv = screen; pcp->driDrawablePriv = NULL; pcp->driReadablePriv = NULL; - if (!driDriverAPI.CreateContext(mesa_api, modes, pcp, shareCtx)) { + if (!driDriverAPI.CreateContext(mesa_api, modes, pcp, + major_version, minor_version, + flags, error, shareCtx)) { FREE(pcp); return NULL; } @@ -136,6 +186,17 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api, } static __DRIcontext * +driCreateNewContextForAPI(__DRIscreen *psp, int api, + const __DRIconfig *config, + __DRIcontext *shared, void *data) +{ + unsigned error; + + return driCreateContextAttribs(psp, api, config, shared, 0, NULL, + &error, data); +} + +static __DRIcontext * driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, __DRIcontext *shared, void *data) { @@ -288,12 +349,9 @@ const __DRIcoreExtension driCoreExtension = { }; const __DRIswrastExtension driSWRastExtension = { - /* Force the version to 2 because the underlying driver don't (can't!) - * support the extra requirements of CreateContextAttribs. - */ { __DRI_SWRAST, __DRI_SWRAST_VERSION }, driCreateNewScreen, driCreateNewDrawable, driCreateNewContextForAPI, - NULL + driCreateContextAttribs }; diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index b31700d10..f8d749453 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -96,7 +96,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, else texFormat = MESA_FORMAT_ARGB8888; - _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage, + _mesa_init_teximage_fields(&dri_ctx->Base, texImage, w, h, 1, 0, internalFormat, texFormat); sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Data, @@ -707,7 +707,12 @@ InitExtensionsES2(struct gl_context *ctx) static GLboolean dri_create_context(gl_api api, const struct gl_config * visual, - __DRIcontext * cPriv, void *sharedContextPrivate) + __DRIcontext * cPriv, + unsigned major_version, + unsigned minor_version, + uint32_t flags, + unsigned *error, + void *sharedContextPrivate) { struct dri_context *ctx = NULL; struct dri_context *share = (struct dri_context *)sharedContextPrivate; @@ -717,9 +722,22 @@ dri_create_context(gl_api api, TRACE; + /* Flag filtering is handled in dri2CreateContextAttribs. + */ + (void) flags; + + if (api == API_OPENGL + && (major_version > 2 + || (major_version == 2 && minor_version > 1))) { + *error = __DRI_CTX_ERROR_BAD_VERSION; + goto context_fail; + } + ctx = CALLOC_STRUCT(dri_context); - if (ctx == NULL) + if (ctx == NULL) { + *error = __DRI_CTX_ERROR_NO_MEMORY; goto context_fail; + } cPriv->driverPrivate = ctx; ctx->cPriv = cPriv; @@ -736,6 +754,7 @@ dri_create_context(gl_api api, /* basic context setup */ if (!_mesa_initialize_context(mesaCtx, api, visual, sharedCtx, &functions, (void *) cPriv)) { + *error = __DRI_CTX_ERROR_NO_MEMORY; goto context_fail; } @@ -777,6 +796,7 @@ dri_create_context(gl_api api, break; } + *error = __DRI_CTX_ERROR_SUCCESS; return GL_TRUE; context_fail: diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index 9e6f56b14..63eb6faaa 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -184,7 +184,10 @@ buffer_object_subdata_range_good( struct gl_context * ctx, GLenum target, } if (offset + size > bufObj->Size) { _mesa_error(ctx, GL_INVALID_VALUE, - "%s(size + offset > buffer size)", caller); + "%s(offset %lu + size %lu > buffer size %lu)", caller, + (unsigned long) offset, + (unsigned long) size, + (unsigned long) bufObj->Size); return NULL; } if (_mesa_bufferobj_mapped(bufObj)) { @@ -499,19 +502,20 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - GLubyte *srcPtr, *dstPtr; + void *srcPtr, *dstPtr; /* buffer should not already be mapped */ assert(!_mesa_bufferobj_mapped(src)); assert(!_mesa_bufferobj_mapped(dst)); - srcPtr = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, src->Size, - GL_MAP_READ_BIT, src); - dstPtr = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, dst->Size, - GL_MAP_WRITE_BIT, dst); + srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size, + GL_MAP_READ_BIT, src); + dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size, + (GL_MAP_WRITE_BIT | + GL_MAP_INVALIDATE_RANGE_BIT), dst); if (srcPtr && dstPtr) - memcpy(dstPtr + writeOffset, srcPtr + readOffset, size); + memcpy(dstPtr, srcPtr, size); ctx->Driver.UnmapBuffer(ctx, src); ctx->Driver.UnmapBuffer(ctx, dst); diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index 5816faa78..6707e785d 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -203,83 +203,77 @@ struct dd_function_table { * fully initialized. * The parameters are the same as glTexImage1D(), plus: * \param packing describes how to unpack the source data. - * \param texObj is the target texture object. - * \param texImage is the target texture image. + * \param texImage is the destination texture image. */ - void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*TexImage1D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing); /** * Called by glTexImage2D(). * * \sa dd_function_table::TexImage1D. */ - void (*TexImage2D)( struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*TexImage2D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing); /** * Called by glTexImage3D(). * * \sa dd_function_table::TexImage1D. */ - void (*TexImage3D)( struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*TexImage3D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing); /** * Called by glTexSubImage1D(). Replace a subset of the target texture * with new texel data. * \sa dd_function_table::TexImage1D. */ - void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*TexSubImage1D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing); /** * Called by glTexSubImage2D(). * * \sa dd_function_table::TexSubImage1D. */ - void (*TexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*TexSubImage2D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing); /** * Called by glTexSubImage3D(). * * \sa dd_function_table::TexSubImage1D. */ - void (*TexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLint depth, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*TexSubImage3D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLint depth, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing); + /** * Called by glGetTexImage(). @@ -342,105 +336,73 @@ struct dd_function_table { /** * Called by glCompressedTexImage1D(). - * - * \param target user specified. - * \param format user specified. - * \param type user specified. - * \param pixels user specified. - * \param packing indicates the image packing of pixels. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p depth, \p border and \p internalFormat information. - * - * \a retainInternalCopy is returned by this function and indicates whether - * core Mesa should keep an internal copy of the texture image. - */ - void (*CompressedTexImage1D)( struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + * The parameters are the same as for glCompressedTexImage1D(), plus a + * pointer to the destination texure image. + */ + void (*CompressedTexImage1D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint internalFormat, + GLsizei width, GLint border, + GLsizei imageSize, const GLvoid *data); /** * Called by glCompressedTexImage2D(). * * \sa dd_function_table::CompressedTexImage1D. */ - void (*CompressedTexImage2D)( struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*CompressedTexImage2D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid *data); + /** * Called by glCompressedTexImage3D(). * * \sa dd_function_table::CompressedTexImage3D. */ - void (*CompressedTexImage3D)( struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); + void (*CompressedTexImage3D)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLsizei imageSize, const GLvoid *data); /** * Called by glCompressedTexSubImage1D(). - * - * \param target user specified. - * \param level user specified. - * \param xoffset user specified. - * \param yoffset user specified. - * \param zoffset user specified. - * \param width user specified. - * \param height user specified. - * \param depth user specified. - * \param imageSize user specified. - * \param data user specified. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p depth, \p border and \p internalFormat information. - */ - void (*CompressedTexSubImage1D)(struct gl_context *ctx, GLenum target, GLint level, + */ + void (*CompressedTexSubImage1D)(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); + /** * Called by glCompressedTexSubImage2D(). - * - * \sa dd_function_table::CompressedTexImage3D. */ - void (*CompressedTexSubImage2D)(struct gl_context *ctx, GLenum target, GLint level, + void (*CompressedTexSubImage2D)(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLsizei width, GLint height, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); + /** * Called by glCompressedTexSubImage3D(). - * - * \sa dd_function_table::CompressedTexImage3D. */ - void (*CompressedTexSubImage3D)(struct gl_context *ctx, GLenum target, GLint level, + void (*CompressedTexSubImage3D)(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLint height, GLint depth, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); /** * Called by glGetCompressedTexImage. */ - void (*GetCompressedTexImage)(struct gl_context *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + void (*GetCompressedTexImage)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLvoid *data); /*@}*/ diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index 008da0d0e..3e736fa15 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -632,15 +632,19 @@ emit_combine_source(struct texenv_fragment_program *p, new(p->mem_ctx) ir_constant(1.0f), src); - case OPR_SRC_ALPHA: - return new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1); + case OPR_SRC_ALPHA: + return src->type->is_scalar() + ? src : (ir_rvalue *) new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1); + + case OPR_ONE_MINUS_SRC_ALPHA: { + ir_rvalue *const scalar = (src->type->is_scalar()) + ? src : (ir_rvalue *) new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1); - case OPR_ONE_MINUS_SRC_ALPHA: return new(p->mem_ctx) ir_expression(ir_binop_sub, new(p->mem_ctx) ir_constant(1.0f), - new(p->mem_ctx) ir_swizzle(src, - 3, 3, - 3, 3, 1)); + scalar); + } + case OPR_ZERO: return new(p->mem_ctx) ir_constant(0.0f); case OPR_ONE: diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c index 840559bac..43677117e 100644 --- a/mesalib/src/mesa/main/format_pack.c +++ b/mesalib/src/mesa/main/format_pack.c @@ -2453,7 +2453,7 @@ _mesa_pack_ubyte_stencil_row(gl_format format, GLuint n, break; case MESA_FORMAT_Z32_FLOAT_X24S8: { - GLfloat *d = ((GLfloat *) dst); + GLuint *d = dst; GLuint i; for (i = 0; i < n; i++) { d[i * 2 + 1] = src[i]; diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 0c9d6b391..5ad601242 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -2498,7 +2498,7 @@ find_value_indexed(const char *func, GLenum pname, int index, union value *v) goto invalid_value; if (!ctx->Extensions.EXT_transform_feedback) goto invalid_enum; - v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name; + v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index]; return TYPE_INT; } diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h index d5e3859f8..b7e87439f 100644 --- a/mesalib/src/mesa/main/imports.h +++ b/mesalib/src/mesa/main/imports.h @@ -568,7 +568,7 @@ _mesa_init_sqrt_table(void); #ifdef __GNUC__ -#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID) +#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID) || defined(__APPLE__) #define ffs __builtin_ffs #define ffsll __builtin_ffsll #endif diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c index 867cb22e2..867506c9f 100644 --- a/mesalib/src/mesa/main/mipmap.c +++ b/mesalib/src/mesa/main/mipmap.c @@ -1860,7 +1860,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx, /* need to (re)allocate image */ ctx->Driver.FreeTextureImageBuffer(ctx, dstImage); - _mesa_init_teximage_fields(ctx, target, dstImage, + _mesa_init_teximage_fields(ctx, dstImage, width, height, depth, border, intFormat, format); @@ -2132,11 +2132,10 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, } /* The image space was allocated above so use glTexSubImage now */ - ctx->Driver.TexSubImage2D(ctx, target, level + 1, + ctx->Driver.TexSubImage2D(ctx, dstImage, 0, 0, dstWidth, dstHeight, temp_base_format, temp_datatype, - temp_dst, &ctx->DefaultPacking, - texObj, dstImage); + temp_dst, &ctx->DefaultPacking); /* swap src and dest pointers */ { diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 107371e52..dcb987116 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1817,10 +1817,21 @@ struct prog_instruction; struct gl_program_parameter_list; struct gl_uniform_list; +struct gl_transform_feedback_varying_info { + char *Name; + GLenum Type; + GLint Size; +}; + /** Post-link transform feedback info. */ struct gl_transform_feedback_info { unsigned NumOutputs; + /** + * Number of transform feedback buffers in use by this program. + */ + unsigned NumBuffers; + struct { unsigned OutputRegister; unsigned OutputBuffer; @@ -1828,8 +1839,22 @@ struct gl_transform_feedback_info { /** offset (in DWORDs) of this output within the interleaved structure */ unsigned DstOffset; + + /** + * Offset into the output register of the data to output. For example, + * if NumComponents is 2 and ComponentOffset is 1, then the data to + * offset is in the y and z components of the output register. + */ + unsigned ComponentOffset; } Outputs[MAX_PROGRAM_OUTPUTS]; + /** Transform feedback varyings used for the linking of this shader program. + * + * Use for glGetTransformFeedbackVarying(). + */ + struct gl_transform_feedback_varying_info *Varyings; + GLint NumVarying; + /** * Total number of components stored in each buffer. This may be used by * hardware back-ends to determine the correct stride when interleaving @@ -2222,7 +2247,13 @@ struct gl_shader_program */ struct string_to_uint_map *FragDataBindings; - /** Transform feedback varyings */ + /** + * Transform feedback varyings last specified by + * glTransformFeedbackVaryings(). + * + * For the current set of transform feeedback varyings used for transform + * feedback output, see LinkedTransformFeedback. + */ struct { GLenum BufferMode; GLuint NumVarying; @@ -2273,7 +2304,6 @@ struct gl_shader_program /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ gl_texture_index SamplerTargets[MAX_SAMPLERS]; - struct gl_program_parameter_list *Varying; GLboolean LinkStatus; /**< GL_LINK_STATUS */ GLboolean Validated; GLboolean _Used; /**< Ever used for drawing? */ diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index 2933ff638..8f2c8fd97 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -692,6 +692,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], dst[i] = (GLubyte) rgba[i][ACOMP]; } break; + case GL_RG_INTEGER: + for (i=0;i<n;i++) { + dst[i*2+0] = (GLubyte) rgba[i][RCOMP]; + dst[i*2+1] = (GLubyte) rgba[i][GCOMP]; + } + break; case GL_RGB_INTEGER_EXT: for (i=0;i<n;i++) { dst[i*3+0] = (GLubyte) rgba[i][RCOMP]; @@ -843,6 +849,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], dst[i] = (GLbyte) rgba[i][ACOMP]; } break; + case GL_RG_INTEGER: + for (i=0;i<n;i++) { + dst[i*2+0] = (GLbyte) rgba[i][RCOMP]; + dst[i*2+1] = (GLbyte) rgba[i][GCOMP]; + } + break; case GL_RGB_INTEGER_EXT: for (i=0;i<n;i++) { dst[i*3+0] = (GLbyte) rgba[i][RCOMP]; @@ -994,6 +1006,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], dst[i] = (GLushort) rgba[i][ACOMP]; } break; + case GL_RG_INTEGER: + for (i=0;i<n;i++) { + dst[i*2+0] = (GLushort) rgba[i][RCOMP]; + dst[i*2+1] = (GLushort) rgba[i][GCOMP]; + } + break; case GL_RGB_INTEGER_EXT: for (i=0;i<n;i++) { dst[i*3+0] = (GLushort) rgba[i][RCOMP]; @@ -1145,6 +1163,13 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], dst[i] = (GLshort) rgba[i][ACOMP]; } break; + case GL_RG_INTEGER: + for (i=0;i<n;i++) { + dst[i*3+0] = (GLshort) rgba[i][RCOMP]; + dst[i*3+1] = (GLshort) rgba[i][GCOMP]; + dst[i*3+2] = (GLshort) rgba[i][BCOMP]; + } + break; case GL_RGB_INTEGER_EXT: for (i=0;i<n;i++) { dst[i*3+0] = (GLshort) rgba[i][RCOMP]; @@ -1296,6 +1321,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], dst[i] = (GLuint) rgba[i][ACOMP]; } break; + case GL_RG_INTEGER: + for (i=0;i<n;i++) { + dst[i*2+0] = (GLuint) rgba[i][RCOMP]; + dst[i*2+1] = (GLuint) rgba[i][GCOMP]; + } + break; case GL_RGB_INTEGER_EXT: for (i=0;i<n;i++) { dst[i*3+0] = (GLuint) rgba[i][RCOMP]; @@ -1454,6 +1485,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], dst[i] = (GLint) rgba[i][ACOMP]; } break; + case GL_RG_INTEGER: + for (i=0;i<n;i++) { + dst[i*2+0] = (GLint) rgba[i][RCOMP]; + dst[i*2+1] = (GLint) rgba[i][GCOMP]; + } + break; case GL_RGB_INTEGER_EXT: for (i=0;i<n;i++) { dst[i*3+0] = (GLint) rgba[i][RCOMP]; @@ -2397,6 +2434,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], srcFormat == GL_GREEN_INTEGER_EXT || srcFormat == GL_BLUE_INTEGER_EXT || srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RG_INTEGER || srcFormat == GL_RGB_INTEGER_EXT || srcFormat == GL_RGBA_INTEGER_EXT || srcFormat == GL_BGR_INTEGER_EXT || @@ -3778,6 +3816,7 @@ _mesa_unpack_color_span_float( struct gl_context *ctx, srcFormat == GL_GREEN_INTEGER_EXT || srcFormat == GL_BLUE_INTEGER_EXT || srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RG_INTEGER || srcFormat == GL_RGB_INTEGER_EXT || srcFormat == GL_RGBA_INTEGER_EXT || srcFormat == GL_BGR_INTEGER_EXT || diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index b71b44b70..52a9bd452 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -751,7 +751,7 @@ link_program(struct gl_context *ctx, GLuint program) || shProg == ctx->Shader.CurrentGeometryProgram || shProg == ctx->Shader.CurrentFragmentProgram)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glLinkProgram(transform feedback active"); + "glLinkProgram(transform feedback active)"); return; } diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c index 454007f83..de66851e9 100644 --- a/mesalib/src/mesa/main/shaderobj.c +++ b/mesalib/src/mesa/main/shaderobj.c @@ -286,11 +286,6 @@ _mesa_clear_shader_program_data(struct gl_context *ctx, shProg->UniformHash = NULL; } - if (shProg->Varying) { - _mesa_free_parameter_list(shProg->Varying); - shProg->Varying = NULL; - } - assert(shProg->InfoLog != NULL); ralloc_free(shProg->InfoLog); shProg->InfoLog = ralloc_strdup(shProg, ""); diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c index d5c73e3b4..2480ffb38 100644 --- a/mesalib/src/mesa/main/texcompress_fxt1.c +++ b/mesalib/src/mesa/main/texcompress_fxt1.c @@ -64,14 +64,9 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) const GLubyte *pixels; GLint srcRowStride; GLubyte *dst; - const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ const GLubyte *tempImage = NULL; ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1); - ASSERT(dstXoffset % 8 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset == 0); - (void) dstZoffset; if (srcFormat != GL_RGB || srcType != GL_UNSIGNED_BYTE || @@ -99,9 +94,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) srcType) / sizeof(GLubyte); } - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride, dst, dstRowStride); @@ -122,14 +115,9 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) const GLubyte *pixels; GLint srcRowStride; GLubyte *dst; - GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ const GLubyte *tempImage = NULL; ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1); - ASSERT(dstXoffset % 8 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset == 0); - (void) dstZoffset; if (srcFormat != GL_RGBA || srcType != GL_UNSIGNED_BYTE || @@ -156,9 +144,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) srcType) / sizeof(GLubyte); } - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride, dst, dstRowStride); diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c index 3586fc39d..b8e334b45 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc.c +++ b/mesalib/src/mesa/main/texcompress_rgtc.c @@ -92,7 +92,6 @@ GLboolean _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS) { GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ const GLubyte *tempImage = NULL; int i, j; int numxpixels, numypixels; @@ -102,11 +101,6 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS) GLint dstRowDiff; ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1 || dstFormat == MESA_FORMAT_L_LATC1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - tempImage = _mesa_make_temp_ubyte_image(ctx, dims, baseInternalFormat, @@ -117,9 +111,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; /* out of memory */ - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; blkaddr = dst; dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0; @@ -147,7 +139,6 @@ GLboolean _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) { GLbyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ const GLfloat *tempImage = NULL; int i, j; int numxpixels, numypixels; @@ -157,10 +148,6 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) GLint dstRowDiff; ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1 || dstFormat == MESA_FORMAT_SIGNED_L_LATC1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; tempImage = _mesa_make_temp_float_image(ctx, dims, baseInternalFormat, @@ -171,9 +158,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; /* out of memory */ - dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = (GLbyte *) dstSlices[0]; blkaddr = dst; dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0; @@ -201,7 +186,6 @@ GLboolean _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) { GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ const GLubyte *tempImage = NULL; int i, j; int numxpixels, numypixels; @@ -212,10 +196,6 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2 || dstFormat == MESA_FORMAT_LA_LATC2); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; tempImage = _mesa_make_temp_ubyte_image(ctx, dims, baseInternalFormat, @@ -226,9 +206,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; /* out of memory */ - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; blkaddr = dst; dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0; @@ -262,7 +240,6 @@ GLboolean _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) { GLbyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ const GLfloat *tempImage = NULL; int i, j; int numxpixels, numypixels; @@ -273,10 +250,6 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2 || dstFormat == MESA_FORMAT_SIGNED_LA_LATC2); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; tempImage = _mesa_make_temp_float_image(ctx, dims, baseInternalFormat, @@ -287,9 +260,7 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; /* out of memory */ - dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = (GLbyte *) dstSlices[0]; blkaddr = dst; dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0; diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c index 11c7db4ef..2b796dac0 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.c +++ b/mesalib/src/mesa/main/texcompress_s3tc.c @@ -169,15 +169,10 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) { const GLubyte *pixels; GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ const GLubyte *tempImage = NULL; ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 || dstFormat == MESA_FORMAT_SRGB_DXT1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; if (srcFormat != GL_RGB || srcType != GL_UNSIGNED_BYTE || @@ -201,9 +196,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) srcFormat, srcType, 0, 0); } - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; if (ext_tx_compress_dxtn) { (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, @@ -229,15 +222,10 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) { const GLubyte *pixels; GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ const GLubyte *tempImage = NULL; ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 || dstFormat == MESA_FORMAT_SRGBA_DXT1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; if (srcFormat != GL_RGBA || srcType != GL_UNSIGNED_BYTE || @@ -261,9 +249,8 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) srcFormat, srcType, 0, 0); } - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; + if (ext_tx_compress_dxtn) { (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, @@ -288,15 +275,10 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) { const GLubyte *pixels; GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ const GLubyte *tempImage = NULL; ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 || dstFormat == MESA_FORMAT_SRGBA_DXT3); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; if (srcFormat != GL_RGBA || srcType != GL_UNSIGNED_BYTE || @@ -319,9 +301,8 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) srcFormat, srcType, 0, 0); } - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; + if (ext_tx_compress_dxtn) { (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, @@ -346,15 +327,10 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) { const GLubyte *pixels; GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ const GLubyte *tempImage = NULL; ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 || dstFormat == MESA_FORMAT_SRGBA_DXT5); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; if (srcFormat != GL_RGBA || srcType != GL_UNSIGNED_BYTE || @@ -377,9 +353,8 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) srcFormat, srcType, 0, 0); } - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, dstSlices[0]); + dst = dstSlices[0]; + if (ext_tx_compress_dxtn) { (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 738c18112..f848aa89d 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -603,10 +603,9 @@ _mesa_get_teximage(struct gl_context *ctx, * All error checking will have been done before this routine is called. */ void -_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +_mesa_get_compressed_teximage(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLvoid *img) { const GLuint row_stride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width); @@ -981,8 +980,7 @@ _mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize, _mesa_lock_texture(ctx, texObj); { - ctx->Driver.GetCompressedTexImage(ctx, target, level, img, - texObj, texImage); + ctx->Driver.GetCompressedTexImage(ctx, texImage, img); } _mesa_unlock_texture(ctx, texObj); } diff --git a/mesalib/src/mesa/main/texgetimage.h b/mesalib/src/mesa/main/texgetimage.h index 02b1cf459..cd8e76e7a 100644 --- a/mesalib/src/mesa/main/texgetimage.h +++ b/mesalib/src/mesa/main/texgetimage.h @@ -40,10 +40,9 @@ _mesa_get_teximage(struct gl_context *ctx, extern void -_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +_mesa_get_compressed_teximage(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLvoid *data); diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 18a7b87c0..6dd70b96c 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1059,7 +1059,6 @@ clear_teximage_fields(struct gl_texture_image *img) * Initialize basic fields of the gl_texture_image struct. * * \param ctx GL context. - * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc). * \param img texture image structure to be initialized. * \param width image width. * \param height image height. @@ -1072,7 +1071,7 @@ clear_teximage_fields(struct gl_texture_image *img) * Note: width, height and depth include the border. */ void -_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, +_mesa_init_teximage_fields(struct gl_context *ctx, struct gl_texture_image *img, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum internalFormat, @@ -2422,7 +2421,7 @@ teximage(struct gl_context *ctx, GLuint dims, format, type); if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, target, texImage, width, height, + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, border, internalFormat, texFormat); } @@ -2473,7 +2472,7 @@ teximage(struct gl_context *ctx, GLuint dims, type); if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, border, internalFormat, texFormat); @@ -2481,22 +2480,19 @@ teximage(struct gl_context *ctx, GLuint dims, ASSERT(ctx->Driver.TexImage3D); switch (dims) { case 1: - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, + ctx->Driver.TexImage1D(ctx, texImage, internalFormat, width, border, format, - type, pixels, unpack, texObj, - texImage); + type, pixels, unpack); break; case 2: - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + ctx->Driver.TexImage2D(ctx, texImage, internalFormat, width, height, border, format, - type, pixels, unpack, texObj, - texImage); + type, pixels, unpack); break; case 3: - ctx->Driver.TexImage3D(ctx, target, level, internalFormat, + ctx->Driver.TexImage3D(ctx, texImage, internalFormat, width, height, depth, border, format, - type, pixels, unpack, texObj, - texImage); + type, pixels, unpack); break; default: _mesa_problem(ctx, "invalid dims=%u in teximage()", dims); @@ -2681,23 +2677,20 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, switch (dims) { case 1: - ctx->Driver.TexSubImage1D(ctx, target, level, + ctx->Driver.TexSubImage1D(ctx, texImage, xoffset, width, - format, type, pixels, - &ctx->Unpack, texObj, texImage ); + format, type, pixels, &ctx->Unpack); break; case 2: - ctx->Driver.TexSubImage2D(ctx, target, level, + ctx->Driver.TexSubImage2D(ctx, texImage, xoffset, yoffset, width, height, - format, type, pixels, - &ctx->Unpack, texObj, texImage ); + format, type, pixels, &ctx->Unpack); break; case 3: - ctx->Driver.TexSubImage3D(ctx, target, level, + ctx->Driver.TexSubImage3D(ctx, texImage, xoffset, yoffset, zoffset, width, height, depth, - format, type, pixels, - &ctx->Unpack, texObj, texImage ); + format, type, pixels, &ctx->Unpack); break; default: _mesa_problem(ctx, "unexpected dims in subteximage()"); @@ -2818,19 +2811,19 @@ copyteximage(struct gl_context *ctx, GLuint dims, /* Free old texture image */ ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, + _mesa_init_teximage_fields(ctx, texImage, width, height, 1, border, internalFormat, texFormat); /* Allocate texture memory (no pixel data yet) */ if (dims == 1) { - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, + ctx->Driver.TexImage1D(ctx, texImage, internalFormat, width, border, GL_NONE, GL_NONE, NULL, - &ctx->Unpack, texObj, texImage); + &ctx->Unpack); } else { - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + ctx->Driver.TexImage2D(ctx, texImage, internalFormat, width, height, border, GL_NONE, GL_NONE, - NULL, &ctx->Unpack, texObj, texImage); + NULL, &ctx->Unpack); } if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, @@ -3410,7 +3403,7 @@ compressedteximage(struct gl_context *ctx, GLuint dims, } else { /* no error: store the teximage parameters */ - _mesa_init_teximage_fields(ctx, target, texImage, width, height, + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, border, internalFormat, MESA_FORMAT_NONE); } @@ -3445,34 +3438,31 @@ compressedteximage(struct gl_context *ctx, GLuint dims, GL_NONE); if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, border, internalFormat, texFormat); switch (dims) { case 1: ASSERT(ctx->Driver.CompressedTexImage1D); - ctx->Driver.CompressedTexImage1D(ctx, target, level, + ctx->Driver.CompressedTexImage1D(ctx, texImage, internalFormat, width, - border, imageSize, data, - texObj, texImage); + border, imageSize, data); break; case 2: ASSERT(ctx->Driver.CompressedTexImage2D); - ctx->Driver.CompressedTexImage2D(ctx, target, level, + ctx->Driver.CompressedTexImage2D(ctx, texImage, internalFormat, width, height, - border, imageSize, data, - texObj, texImage); + border, imageSize, data); break; case 3: ASSERT(ctx->Driver.CompressedTexImage3D); - ctx->Driver.CompressedTexImage3D(ctx, target, level, + ctx->Driver.CompressedTexImage3D(ctx, texImage, internalFormat, width, height, depth, - border, imageSize, data, - texObj, texImage); + border, imageSize, data); break; default: _mesa_problem(ctx, "bad dims in compressedteximage"); @@ -3570,28 +3560,25 @@ compressed_tex_sub_image(GLuint dims, GLenum target, GLint level, switch (dims) { case 1: if (ctx->Driver.CompressedTexSubImage1D) { - ctx->Driver.CompressedTexSubImage1D(ctx, target, level, + ctx->Driver.CompressedTexSubImage1D(ctx, texImage, xoffset, width, - format, imageSize, data, - texObj, texImage); + format, imageSize, data); } break; case 2: if (ctx->Driver.CompressedTexSubImage2D) { - ctx->Driver.CompressedTexSubImage2D(ctx, target, level, + ctx->Driver.CompressedTexSubImage2D(ctx, texImage, xoffset, yoffset, width, height, - format, imageSize, data, - texObj, texImage); + format, imageSize, data); } break; case 3: if (ctx->Driver.CompressedTexSubImage3D) { - ctx->Driver.CompressedTexSubImage3D(ctx, target, level, + ctx->Driver.CompressedTexSubImage3D(ctx, texImage, xoffset, yoffset, zoffset, width, height, depth, - format, imageSize, data, - texObj, texImage); + format, imageSize, data); } break; default: diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h index 0354c9ac5..12af0e6d6 100644 --- a/mesalib/src/mesa/main/teximage.h +++ b/mesalib/src/mesa/main/teximage.h @@ -67,7 +67,7 @@ _mesa_delete_texture_image( struct gl_context *ctx, extern void -_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, +_mesa_init_teximage_fields(struct gl_context *ctx, struct gl_texture_image *img, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum internalFormat, diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 8e447cabd..7ee200585 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -793,16 +793,16 @@ _mesa_get_fallback_texture(struct gl_context *ctx) GL_UNSIGNED_BYTE); /* init the image fields */ - _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, + _mesa_init_teximage_fields(ctx, texImage, 8, 8, 1, 0, GL_RGBA, texFormat); ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); /* set image data */ - ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA, + ctx->Driver.TexImage2D(ctx, texImage, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, texels, - &ctx->DefaultPacking, texObj, texImage); + &ctx->DefaultPacking); _mesa_test_texobj_completeness(ctx, texObj); assert(texObj->_Complete); diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c index 241a940cc..5e1f31a93 100644 --- a/mesalib/src/mesa/main/texstorage.c +++ b/mesalib/src/mesa/main/texstorage.c @@ -155,7 +155,7 @@ setup_texstorage(struct gl_context *ctx, return; } - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, levelWidth, levelHeight, levelDepth, 0, internalFormat, texFormat); } @@ -180,7 +180,7 @@ setup_texstorage(struct gl_context *ctx, for (face = 0; face < numFaces; face++) { struct gl_texture_image *texImage = texObj->Image[face][level]; if (texImage) { - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, 0, 0, 0, 0, GL_NONE, MESA_FORMAT_NONE); } @@ -223,7 +223,7 @@ clear_image_fields(struct gl_context *ctx, return; } - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, 0, 0, 0, 0, GL_NONE, MESA_FORMAT_NONE); } } diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 86c35d38f..512965fc3 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -851,7 +851,6 @@ _mesa_swizzle_ubyte_image(struct gl_context *ctx, const GLubyte *rgba2dst, GLuint dstComponents, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, GLint dstRowStride, GLubyte **dstSlices, @@ -896,9 +895,7 @@ _mesa_swizzle_ubyte_image(struct gl_context *ctx, srcRowStride == srcWidth * srcComponents && dimensions < 3) { /* 1 and 2D images only */ - GLubyte *dstImage = dstSlices[0] - + dstYoffset * dstRowStride - + dstXoffset * dstComponents; + GLubyte *dstImage = dstSlices[0]; swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map, srcWidth * srcHeight); } @@ -906,9 +903,7 @@ _mesa_swizzle_ubyte_image(struct gl_context *ctx, GLint img, row; for (img = 0; img < srcDepth; img++) { const GLubyte *srcRow = srcImage; - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * dstComponents; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth); dstRow += dstRowStride; @@ -929,7 +924,6 @@ static void memcpy_texture(struct gl_context *ctx, GLuint dimensions, gl_format dstFormat, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, GLint dstRowStride, GLubyte **dstSlices, GLint srcWidth, GLint srcHeight, GLint srcDepth, @@ -951,9 +945,7 @@ memcpy_texture(struct gl_context *ctx, /* memcpy image by image */ GLint img; for (img = 0; img < srcDepth; img++) { - GLubyte *dstImage = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstImage = dstSlices[img]; memcpy(dstImage, srcImage, bytesPerRow * srcHeight); srcImage += srcImageStride; } @@ -963,9 +955,7 @@ memcpy_texture(struct gl_context *ctx, GLint img, row; for (img = 0; img < srcDepth; img++) { const GLubyte *srcRow = srcImage; - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { memcpy(dstRow, srcRow, bytesPerRow); dstRow += dstRowStride; @@ -985,12 +975,11 @@ static GLboolean _mesa_texstore_z32(TEXSTORE_PARAMS) { const GLuint depthScale = 0xffffffff; - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); GLenum dstType; (void) dims; ASSERT(dstFormat == MESA_FORMAT_Z32 || dstFormat == MESA_FORMAT_Z32_FLOAT); - ASSERT(texelBytes == sizeof(GLuint)); + ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint)); if (dstFormat == MESA_FORMAT_Z32) dstType = GL_UNSIGNED_INT; @@ -1005,7 +994,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS) srcType == dstType) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1014,9 +1003,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS) /* general path */ GLint img, row; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); @@ -1038,7 +1025,6 @@ static GLboolean _mesa_texstore_x8_z24(TEXSTORE_PARAMS) { const GLuint depthScale = 0xffffff; - const GLuint texelBytes = 4; (void) dims; ASSERT(dstFormat == MESA_FORMAT_X8_Z24); @@ -1047,9 +1033,7 @@ _mesa_texstore_x8_z24(TEXSTORE_PARAMS) /* general path */ GLint img, row; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); @@ -1071,7 +1055,6 @@ static GLboolean _mesa_texstore_z24_x8(TEXSTORE_PARAMS) { const GLuint depthScale = 0xffffff; - const GLuint texelBytes = 4; (void) dims; ASSERT(dstFormat == MESA_FORMAT_Z24_X8); @@ -1080,9 +1063,7 @@ _mesa_texstore_z24_x8(TEXSTORE_PARAMS) /* general path */ GLint img, row; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); @@ -1108,10 +1089,9 @@ static GLboolean _mesa_texstore_z16(TEXSTORE_PARAMS) { const GLuint depthScale = 0xffff; - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); (void) dims; ASSERT(dstFormat == MESA_FORMAT_Z16); - ASSERT(texelBytes == sizeof(GLushort)); + ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort)); if (ctx->Pixel.DepthScale == 1.0f && ctx->Pixel.DepthBias == 0.0f && @@ -1121,7 +1101,7 @@ _mesa_texstore_z16(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_SHORT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1130,9 +1110,7 @@ _mesa_texstore_z16(TEXSTORE_PARAMS) /* general path */ GLint img, row; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); @@ -1154,12 +1132,11 @@ _mesa_texstore_z16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgb565(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_RGB565 || dstFormat == MESA_FORMAT_RGB565_REV); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1169,7 +1146,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_SHORT_5_6_5) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1186,9 +1163,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS) const GLubyte *src = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); - GLubyte *dst = dstSlices[0] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dst = dstSlices[0]; GLint row, col; for (row = 0; row < srcHeight; row++) { const GLubyte *srcUB = (const GLubyte *) src; @@ -1223,9 +1198,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstUS = (GLushort *) dstRow; /* check for byteswapped format */ @@ -1261,14 +1234,13 @@ static GLboolean _mesa_texstore_rgba8888(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_RGBA8888 || dstFormat == MESA_FORMAT_RGBA8888_REV || dstFormat == MESA_FORMAT_RGBX8888 || dstFormat == MESA_FORMAT_RGBX8888_REV); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1281,7 +1253,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS) (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1297,7 +1269,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS) (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1334,7 +1306,6 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS) srcType, baseInternalFormat, dstmap, 4, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcAddr, srcPacking); @@ -1352,9 +1323,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint *) dstRow; if (dstFormat == MESA_FORMAT_RGBA8888 || @@ -1389,14 +1358,13 @@ static GLboolean _mesa_texstore_argb8888(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = GL_RGBA; ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || dstFormat == MESA_FORMAT_ARGB8888_REV || dstFormat == MESA_FORMAT_XRGB8888 || dstFormat == MESA_FORMAT_XRGB8888_REV ); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1408,7 +1376,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { /* simple memcpy path (little endian) */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1423,7 +1391,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_INT_8_8_8_8)) { /* simple memcpy path (big endian) */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1442,9 +1410,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *d4 = (GLuint *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -1477,9 +1443,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *d4 = (GLuint *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -1529,7 +1493,6 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) srcType, baseInternalFormat, dstmap, 4, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcAddr, @@ -1548,9 +1511,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint *) dstRow; if (dstFormat == MESA_FORMAT_ARGB8888) { @@ -1593,11 +1554,10 @@ static GLboolean _mesa_texstore_rgb888(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_RGB888); - ASSERT(texelBytes == 3); + ASSERT(_mesa_get_format_bytes(dstFormat) == 3); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1607,7 +1567,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1623,9 +1583,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP]; @@ -1656,7 +1614,6 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) srcType, baseInternalFormat, dstmap, 3, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcAddr, srcPacking); @@ -1674,9 +1631,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { #if 0 if (littleEndian) { @@ -1716,11 +1671,10 @@ static GLboolean _mesa_texstore_bgr888(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_BGR888); - ASSERT(texelBytes == 3); + ASSERT(_mesa_get_format_bytes(dstFormat) == 3); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1730,7 +1684,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1746,9 +1700,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP]; @@ -1779,7 +1731,6 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) srcType, baseInternalFormat, dstmap, 3, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcAddr, srcPacking); @@ -1797,9 +1748,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { dstRow[col * 3 + 0] = src[RCOMP]; @@ -1819,12 +1768,11 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_argb4444(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_ARGB4444 || dstFormat == MESA_FORMAT_ARGB4444_REV); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1834,7 +1782,7 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1852,9 +1800,7 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstUS = (GLushort *) dstRow; if (dstFormat == MESA_FORMAT_ARGB4444) { @@ -1886,11 +1832,10 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba5551(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_RGBA5551); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1900,7 +1845,7 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_SHORT_5_5_5_1) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1918,9 +1863,7 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstUS = (GLushort *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -1941,12 +1884,11 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_argb1555(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_ARGB1555 || dstFormat == MESA_FORMAT_ARGB1555_REV); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -1956,7 +1898,7 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1974,9 +1916,7 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstUS = (GLushort *) dstRow; if (dstFormat == MESA_FORMAT_ARGB1555) { @@ -2009,11 +1949,10 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_argb2101010(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_ARGB2101010); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2023,7 +1962,7 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) baseInternalFormat == GL_RGBA) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2042,9 +1981,7 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; if (baseInternalFormat == GL_RGBA) { for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint *) dstRow; @@ -2090,11 +2027,10 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_unorm44(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_AL44); - ASSERT(texelBytes == 1); + ASSERT(_mesa_get_format_bytes(dstFormat) == 1); { /* general path */ @@ -2109,9 +2045,7 @@ _mesa_texstore_unorm44(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLubyte *dstUS = (GLubyte *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -2136,14 +2070,13 @@ static GLboolean _mesa_texstore_unorm88(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_AL88_REV || dstFormat == MESA_FORMAT_GR88 || dstFormat == MESA_FORMAT_RG88); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2156,7 +2089,7 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2200,7 +2133,6 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS) srcType, baseInternalFormat, dstmap, 2, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcAddr, srcPacking); @@ -2218,9 +2150,7 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstUS = (GLushort *) dstRow; if (dstFormat == MESA_FORMAT_AL88 || @@ -2256,14 +2186,13 @@ static GLboolean _mesa_texstore_unorm1616(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_AL1616 || dstFormat == MESA_FORMAT_AL1616_REV || dstFormat == MESA_FORMAT_RG1616 || dstFormat == MESA_FORMAT_RG1616_REV); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2276,7 +2205,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2295,9 +2224,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint *) dstRow; if (dstFormat == MESA_FORMAT_AL1616 || @@ -2335,14 +2262,13 @@ static GLboolean _mesa_texstore_unorm16(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_R16 || dstFormat == MESA_FORMAT_A16 || dstFormat == MESA_FORMAT_L16 || dstFormat == MESA_FORMAT_I16); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2351,7 +2277,7 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2370,9 +2296,7 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstUS = (GLushort *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -2394,11 +2318,10 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_16(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_RGBA_16); - ASSERT(texelBytes == 8); + ASSERT(_mesa_get_format_bytes(dstFormat) == 8); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2407,7 +2330,7 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_SHORT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2426,9 +2349,7 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstUS = (GLushort *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -2456,7 +2377,6 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGB_16 || @@ -2470,7 +2390,7 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) srcType == GL_SHORT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2495,9 +2415,7 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) * 3 or 4 components/pixel here. */ for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLshort *dstRowS = (GLshort *) dstRow; if (dstFormat == MESA_FORMAT_SIGNED_RGBA_16) { @@ -2534,11 +2452,10 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgb332(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_RGB332); - ASSERT(texelBytes == 1); + ASSERT(_mesa_get_format_bytes(dstFormat) == 1); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2546,7 +2463,7 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS) srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2564,9 +2481,7 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { dstRow[col] = PACK_COLOR_332( src[RCOMP], @@ -2589,14 +2504,13 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_unorm8(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_A8 || dstFormat == MESA_FORMAT_L8 || dstFormat == MESA_FORMAT_I8 || dstFormat == MESA_FORMAT_R8); - ASSERT(texelBytes == 1); + ASSERT(_mesa_get_format_bytes(dstFormat) == 1); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2604,7 +2518,7 @@ _mesa_texstore_unorm8(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_BYTE) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2632,7 +2546,6 @@ _mesa_texstore_unorm8(TEXSTORE_PARAMS) srcType, baseInternalFormat, dstmap, 1, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcAddr, srcPacking); @@ -2650,9 +2563,7 @@ _mesa_texstore_unorm8(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { dstRow[col] = src[col]; @@ -2675,13 +2586,12 @@ static GLboolean _mesa_texstore_ycbcr(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); (void) ctx; (void) dims; (void) baseInternalFormat; ASSERT((dstFormat == MESA_FORMAT_YCBCR) || (dstFormat == MESA_FORMAT_YCBCR_REV)); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); ASSERT(ctx->Extensions.MESA_ycbcr_texture); ASSERT(srcFormat == GL_YCBCR_MESA); ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || @@ -2690,7 +2600,7 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS) /* always just memcpy since no pixel transfer ops apply */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2703,9 +2613,7 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS) !littleEndian) { GLint img, row; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { _mesa_swap2((GLushort *) dstRow, srcWidth); dstRow += dstRowStride; @@ -2732,7 +2640,7 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2758,7 +2666,6 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS) GL_UNSIGNED_BYTE, /* hack */ GL_LUMINANCE_ALPHA, /* hack */ dstmap, 2, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcAddr, srcPacking); @@ -2791,9 +2698,7 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS) } src = tempImage; - dst = (GLbyte *) dstSlices[0] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + dst = (GLbyte *) dstSlices[0]; for (row = 0; row < srcHeight; row++) { memcpy(dst, src, srcWidth * texelBytes); dst += dstRowStride; @@ -2811,14 +2716,13 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_snorm8(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_A8 || dstFormat == MESA_FORMAT_SIGNED_L8 || dstFormat == MESA_FORMAT_SIGNED_I8 || dstFormat == MESA_FORMAT_SIGNED_R8); - ASSERT(texelBytes == 1); + ASSERT(_mesa_get_format_bytes(dstFormat) == 1); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2826,7 +2730,7 @@ _mesa_texstore_snorm8(TEXSTORE_PARAMS) srcType == GL_BYTE) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2845,9 +2749,7 @@ _mesa_texstore_snorm8(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLbyte *dstRow = (GLbyte *) dstSlices[img]; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { dstRow[col] = FLOAT_TO_BYTE_TEX(src[col]); @@ -2869,12 +2771,11 @@ static GLboolean _mesa_texstore_snorm88(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL88 || dstFormat == MESA_FORMAT_SIGNED_RG88_REV); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2883,7 +2784,7 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2902,9 +2803,7 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLbyte *dstRow = (GLbyte *) dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLbyte *dst = dstRow; for (col = 0; col < srcWidth; col++) { @@ -2926,14 +2825,13 @@ static GLboolean _mesa_texstore_snorm16(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_R16 || dstFormat == MESA_FORMAT_SIGNED_A16 || dstFormat == MESA_FORMAT_SIGNED_L16 || dstFormat == MESA_FORMAT_SIGNED_I16); - ASSERT(texelBytes == 2); + ASSERT(_mesa_get_format_bytes(dstFormat) == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2942,7 +2840,7 @@ _mesa_texstore_snorm16(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -2961,9 +2859,7 @@ _mesa_texstore_snorm16(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLshort *dstUS = (GLshort *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -2988,12 +2884,11 @@ static GLboolean _mesa_texstore_snorm1616(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL1616 || dstFormat == MESA_FORMAT_SIGNED_GR1616); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -3002,7 +2897,7 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS) littleEndian) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3021,9 +2916,7 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLshort *dst = (GLshort *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -3050,11 +2943,10 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); { /* general path */ @@ -3070,9 +2962,7 @@ _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLbyte *dstRow = (GLbyte *) dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLbyte *dst = dstRow; for (col = 0; col < srcWidth; col++) { @@ -3101,12 +2991,11 @@ static GLboolean _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) { const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 || dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -3116,7 +3005,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3129,7 +3018,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3148,9 +3037,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLbyte *dstRow = (GLbyte *) dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLbyte *dst = dstRow; if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) { @@ -3204,7 +3091,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) !srcPacking->SwapBytes) { /* simple path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3213,9 +3100,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) srcFormat == GL_STENCIL_INDEX) { /* In case we only upload depth we need to preserve the stencil */ for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) (dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * 4); + GLuint *dstRow = (GLuint *) dstSlices[img]; const GLubyte *src = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, @@ -3285,9 +3170,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_INT_24_8_EXT); for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) (dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * 4); + GLuint *dstRow = (GLuint *) dstSlices[img]; const GLubyte *src = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, @@ -3353,7 +3236,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_BYTE) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3364,9 +3247,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS) GLint img, row; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; + GLubyte *dstRow = dstSlices[img]; const GLubyte *src = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, @@ -3409,7 +3290,6 @@ _mesa_texstore_s8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3429,7 +3309,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) baseInternalFormat == GL_INTENSITY || baseInternalFormat == GL_RED || baseInternalFormat == GL_RG); - ASSERT(texelBytes == components * sizeof(GLfloat)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLfloat)); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -3438,7 +3318,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) srcType == GL_FLOAT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3459,9 +3339,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) return GL_FALSE; bytesPerRow = srcWidth * components * sizeof(GLfloat); for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { memcpy(dstRow, srcRow, bytesPerRow); dstRow += dstRowStride; @@ -3482,7 +3360,6 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3502,7 +3379,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) baseInternalFormat == GL_INTENSITY || baseInternalFormat == GL_RED || baseInternalFormat == GL_RG); - ASSERT(texelBytes == components * sizeof(GLhalfARB)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLhalfARB)); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -3511,7 +3388,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) srcType == GL_HALF_FLOAT_ARB) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3530,9 +3407,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLhalfARB *dstTexel = (GLhalfARB *) dstRow; GLint i; @@ -3554,7 +3429,6 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3574,7 +3448,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) baseInternalFormat == GL_LUMINANCE || baseInternalFormat == GL_LUMINANCE_ALPHA || baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLbyte)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLbyte)); /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply * to integer formats. @@ -3584,7 +3458,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) srcType == GL_BYTE) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3602,9 +3476,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLbyte *dstTexel = (GLbyte *) dstRow; GLint i; @@ -3626,7 +3498,6 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3646,7 +3517,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) baseInternalFormat == GL_LUMINANCE || baseInternalFormat == GL_LUMINANCE_ALPHA || baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLshort)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLshort)); /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply * to integer formats. @@ -3656,7 +3527,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) srcType == GL_SHORT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3674,9 +3545,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLshort *dstTexel = (GLshort *) dstRow; GLint i; @@ -3698,7 +3567,6 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3718,7 +3586,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) baseInternalFormat == GL_LUMINANCE || baseInternalFormat == GL_LUMINANCE_ALPHA || baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLint)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLint)); /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply * to integer formats. @@ -3728,7 +3596,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) srcType == GL_INT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3746,9 +3614,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLint *dstTexel = (GLint *) dstRow; GLint i; @@ -3770,7 +3636,6 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3790,7 +3655,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) baseInternalFormat == GL_LUMINANCE || baseInternalFormat == GL_LUMINANCE_ALPHA || baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLubyte)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLubyte)); /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply * to integer formats. @@ -3800,7 +3665,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_BYTE) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3816,9 +3681,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLubyte *dstTexel = (GLubyte *) dstRow; GLint i; @@ -3840,7 +3703,6 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3860,7 +3722,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) baseInternalFormat == GL_LUMINANCE || baseInternalFormat == GL_LUMINANCE_ALPHA || baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLushort)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLushort)); /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply * to integer formats. @@ -3870,7 +3732,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_SHORT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3886,9 +3748,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLushort *dstTexel = (GLushort *) dstRow; GLint i; @@ -3910,7 +3770,6 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); const GLint components = _mesa_components_in_format(baseFormat); @@ -3930,7 +3789,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) baseInternalFormat == GL_LUMINANCE || baseInternalFormat == GL_LUMINANCE_ALPHA || baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLuint)); + ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLuint)); /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply * to integer formats. @@ -3940,7 +3799,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_INT) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -3956,9 +3815,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *dstTexel = (GLuint *) dstRow; GLint i; @@ -3992,7 +3849,6 @@ _mesa_texstore_srgb8(TEXSTORE_PARAMS) k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat, newDstFormat, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, @@ -4013,7 +3869,6 @@ _mesa_texstore_srgba8(TEXSTORE_PARAMS) newDstFormat = MESA_FORMAT_RGBA8888; k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, newDstFormat, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, @@ -4035,7 +3890,6 @@ _mesa_texstore_sargb8(TEXSTORE_PARAMS) k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, newDstFormat, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, @@ -4057,7 +3911,6 @@ _mesa_texstore_sl8(TEXSTORE_PARAMS) /* _mesa_textore_a8 handles luminance8 too */ k = _mesa_texstore_unorm8(ctx, dims, baseInternalFormat, newDstFormat, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, @@ -4079,7 +3932,6 @@ _mesa_texstore_sla8(TEXSTORE_PARAMS) k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat, newDstFormat, - dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, @@ -4112,7 +3964,7 @@ _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_INT_5_9_9_9_REV) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -4131,9 +3983,7 @@ _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * 4; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint*)dstRow; for (col = 0; col < srcWidth; col++) { @@ -4163,7 +4013,7 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_INT_10F_11F_11F_REV) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -4182,9 +4032,7 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * 4; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint*)dstRow; for (col = 0; col < srcWidth; col++) { @@ -4217,7 +4065,7 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS) !srcPacking->SwapBytes) { /* simple path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -4231,9 +4079,7 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS) /* In case we only upload depth we need to preserve the stencil */ for (img = 0; img < srcDepth; img++) { - uint64_t *dstRow = (uint64_t *) (dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * 8); + uint64_t *dstRow = (uint64_t *) dstSlices[img]; const uint64_t *src = (const uint64_t *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, @@ -4268,11 +4114,10 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) { - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_ARGB2101010_UINT); - ASSERT(texelBytes == 4); + ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!srcPacking->SwapBytes && dstFormat == MESA_FORMAT_ARGB2101010_UINT && @@ -4281,7 +4126,7 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) baseInternalFormat == GL_RGBA) { /* simple memcpy path */ memcpy_texture(ctx, dims, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -4300,9 +4145,7 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[dstZoffset + img] - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; + GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint *) dstRow; @@ -4329,7 +4172,6 @@ _mesa_texstore_null(TEXSTORE_PARAMS) (void) ctx; (void) dims; (void) baseInternalFormat; (void) dstFormat; - (void) dstXoffset; (void) dstYoffset; (void) dstZoffset; (void) dstRowStride; (void) dstSlices, (void) srcWidth; (void) srcHeight; (void) srcDepth; (void) srcFormat; (void) srcType; @@ -4539,7 +4381,7 @@ _mesa_texstore(TEXSTORE_PARAMS) storeImage = _mesa_get_texstore_func(dstFormat); success = storeImage(ctx, dims, baseInternalFormat, - dstFormat, dstXoffset, dstYoffset, dstZoffset, + dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -4671,7 +4513,6 @@ store_texsubimage(struct gl_context *ctx, */ success = _mesa_texstore(ctx, dims, texImage->_BaseFormat, texImage->TexFormat, - 0, 0, 0, /* dstX/Y/Zoffset */ dstRowStride, &dstMap, width, height, 1, /* w, h, d */ @@ -4698,13 +4539,12 @@ store_texsubimage(struct gl_context *ctx, * This is the fallback for Driver.TexImage1D(). */ void -_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_teximage1d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint border, GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *packing) { if (width == 0) return; @@ -4726,13 +4566,12 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, * This is the fallback for Driver.TexImage2D(). */ void -_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_teximage2d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *packing) { if (width == 0 || height == 0) return; @@ -4755,13 +4594,12 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, * This is the fallback for Driver.TexImage3D(). */ void -_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_teximage3d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint depth, GLint border, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *packing) { if (width == 0 || height == 0 || depth == 0) return; @@ -4785,12 +4623,11 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, * This is the fallback for Driver.TexSubImage1D(). */ void -_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_texsubimage1d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint width, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *packing) { store_texsubimage(ctx, texImage, xoffset, 0, 0, width, 1, 1, @@ -4803,13 +4640,12 @@ _mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, * This is the fallback for Driver.TexSubImage2D(). */ void -_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_texsubimage2d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLint width, GLint height, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *packing) { store_texsubimage(ctx, texImage, xoffset, yoffset, 0, width, height, 1, @@ -4821,13 +4657,12 @@ _mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, * This is the fallback for Driver.TexSubImage3D(). */ void -_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_texsubimage3d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint width, GLint height, GLint depth, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *packing) { store_texsubimage(ctx, texImage, xoffset, yoffset, zoffset, width, height, depth, @@ -4840,20 +4675,16 @@ _mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, */ void _mesa_store_compressed_teximage1d(struct gl_context *ctx, - GLenum target, GLint level, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + GLsizei imageSize, const GLvoid *data) { - /* this space intentionally left blank */ + /* no compressed 1D image formats at this time */ (void) ctx; - (void) target; (void) level; (void) internalFormat; (void) width; (void) border; (void) imageSize; (void) data; - (void) texObj; (void) texImage; } @@ -4864,18 +4695,15 @@ _mesa_store_compressed_teximage1d(struct gl_context *ctx, */ void _mesa_store_compressed_teximage2d(struct gl_context *ctx, - GLenum target, GLint level, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + GLsizei imageSize, const GLvoid *data) { /* This is pretty simple, because unlike the general texstore path we don't * have to worry about the usual image unpacking or image transfer * operations. */ - ASSERT(texObj); ASSERT(texImage); ASSERT(texImage->Width > 0); ASSERT(texImage->Height > 0); @@ -4888,12 +4716,11 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx, return; } - _mesa_store_compressed_texsubimage2d(ctx, target, level, + _mesa_store_compressed_texsubimage2d(ctx, texImage, 0, 0, width, height, texImage->TexFormat, - imageSize, data, - texObj, texImage); + imageSize, data); } @@ -4903,22 +4730,18 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx, */ void _mesa_store_compressed_teximage3d(struct gl_context *ctx, - GLenum target, GLint level, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint depth, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + GLsizei imageSize, const GLvoid *data) { /* this space intentionally left blank */ (void) ctx; - (void) target; (void) level; (void) internalFormat; (void) width; (void) height; (void) depth; (void) border; (void) imageSize; (void) data; - (void) texObj; (void) texImage; } @@ -4928,21 +4751,17 @@ _mesa_store_compressed_teximage3d(struct gl_context *ctx, * Fallback for Driver.CompressedTexSubImage1D() */ void -_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, - GLint level, +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + GLsizei imageSize, const GLvoid *data) { /* there are no compressed 1D texture formats yet */ (void) ctx; - (void) target; (void) level; (void) xoffset; (void) width; (void) format; (void) imageSize; (void) data; - (void) texObj; (void) texImage; } @@ -4951,14 +4770,12 @@ _mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, * Fallback for Driver.CompressedTexSubImage2D() */ void -_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, - GLint level, +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + GLsizei imageSize, const GLvoid *data) { GLint bytesPerRow, dstRowStride, srcRowStride; GLint i, rows; @@ -5016,22 +4833,18 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, * Fallback for Driver.CompressedTexSubImage3D() */ void -_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data) { /* there are no compressed 3D texture formats yet */ (void) ctx; - (void) target; (void) level; (void) xoffset; (void) yoffset; (void) zoffset; (void) width; (void) height; (void) depth; (void) format; (void) imageSize; (void) data; - (void) texObj; (void) texImage; } diff --git a/mesalib/src/mesa/main/texstore.h b/mesalib/src/mesa/main/texstore.h index f956b0436..85e33b0fe 100644 --- a/mesalib/src/mesa/main/texstore.h +++ b/mesalib/src/mesa/main/texstore.h @@ -58,7 +58,6 @@ struct gl_context *ctx, GLuint dims, \ GLenum baseInternalFormat, \ gl_format dstFormat, \ - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ GLint dstRowStride, \ GLubyte **dstSlices, \ GLint srcWidth, GLint srcHeight, GLint srcDepth, \ @@ -91,118 +90,103 @@ _mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, GLbitfield transferOps); extern void -_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_teximage1d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint border, GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + const struct gl_pixelstore_attrib *packing); extern void -_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_teximage2d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + const struct gl_pixelstore_attrib *packing); extern void -_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_teximage3d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + const struct gl_pixelstore_attrib *packing); extern void -_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_texsubimage1d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint width, GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + const struct gl_pixelstore_attrib *packing); extern void -_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_texsubimage2d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLint width, GLint height, GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + const struct gl_pixelstore_attrib *packing); extern void -_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_texsubimage3d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint width, GLint height, GLint depth, GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + const struct gl_pixelstore_attrib *packing); extern void -_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_compressed_teximage1d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); extern void -_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_compressed_teximage2d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); extern void -_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level, +_mesa_store_compressed_teximage3d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint depth, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); extern void -_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, - GLint level, +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); extern void -_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, - GLint level, +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); + GLsizei imageSize, const GLvoid *data); extern void -_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data); #endif diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c index be0d0ff19..c2114c227 100644 --- a/mesalib/src/mesa/main/transformfeedback.c +++ b/mesalib/src/mesa/main/transformfeedback.c @@ -342,10 +342,26 @@ void GLAPIENTRY _mesa_BeginTransformFeedback(GLenum mode) { struct gl_transform_feedback_object *obj; + struct gl_transform_feedback_info *info; + int i; GET_CURRENT_CONTEXT(ctx); obj = ctx->TransformFeedback.CurrentObject; + if (ctx->Shader.CurrentVertexProgram == NULL) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBeginTransformFeedback(no program active)"); + return; + } + + info = &ctx->Shader.CurrentVertexProgram->LinkedTransformFeedback; + + if (info->NumOutputs == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBeginTransformFeedback(no varyings to record)"); + return; + } + switch (mode) { case GL_POINTS: case GL_LINES: @@ -363,6 +379,15 @@ _mesa_BeginTransformFeedback(GLenum mode) return; } + for (i = 0; i < info->NumBuffers; ++i) { + if (obj->BufferNames[i] == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBeginTransformFeedback(binding point %d does not have " + "a buffer object bound)", i); + return; + } + } + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); obj->Active = GL_TRUE; ctx->TransformFeedback.Mode = mode; @@ -461,7 +486,7 @@ _mesa_BindBufferRange(GLenum target, GLuint index, if ((size <= 0) || (size & 0x3)) { /* must be positive and multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", (int) size); + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", (int) size); return; } @@ -569,6 +594,13 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, return; } + if (offset & 0x3) { + /* must be multiple of four */ + _mesa_error(ctx, GL_INVALID_VALUE, + "glBindBufferOffsetEXT(offset=%d)", (int) offset); + return; + } + bufObj = _mesa_lookup_bufferobj(ctx, buffer); if (!bufObj) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -662,8 +694,7 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei *size, GLenum *type, GLchar *name) { const struct gl_shader_program *shProg; - const GLchar *varyingName; - GLint v; + const struct gl_transform_feedback_info *linked_xfb_info; GET_CURRENT_CONTEXT(ctx); shProg = _mesa_lookup_shader_program(ctx, program); @@ -673,36 +704,22 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, return; } - if (index >= shProg->TransformFeedback.NumVarying) { + linked_xfb_info = &shProg->LinkedTransformFeedback; + if (index >= linked_xfb_info->NumVarying) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetTransformFeedbackVaryings(index=%u)", index); return; } - varyingName = shProg->TransformFeedback.VaryingNames[index]; + /* return the varying's name and length */ + _mesa_copy_string(name, bufSize, length, + linked_xfb_info->Varyings[index].Name); - v = _mesa_lookup_parameter_index(shProg->Varying, -1, varyingName); - if (v >= 0) { - struct gl_program_parameter *param = &shProg->Varying->Parameters[v]; - - /* return the varying's name and length */ - _mesa_copy_string(name, bufSize, length, varyingName); - - /* return the datatype and value's size (in datatype units) */ - if (type) - *type = param->DataType; - if (size) - *size = param->Size; - } - else { - name[0] = 0; - if (length) - *length = 0; - if (type) - *type = 0; - if (size) - *size = 0; - } + /* return the datatype and value's size (in datatype units) */ + if (type) + *type = linked_xfb_info->Varyings[index].Type; + if (size) + *size = linked_xfb_info->Varyings[index].Size; } diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c index adac92f2c..6d95d57c1 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -291,10 +291,6 @@ st_bufferobj_map_range(struct gl_context *ctx, flags, &st_obj->transfer); if (obj->Pointer) { - obj->Pointer = (ubyte *) obj->Pointer + offset; - } - - if (obj->Pointer) { obj->Offset = offset; obj->Length = length; obj->AccessFlags = access; diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 318ba7d06..0609a54ea 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -517,7 +517,6 @@ make_texture(struct st_context *st, success = _mesa_texstore(ctx, 2, /* dims */ baseInternalFormat, /* baseInternalFormat */ mformat, /* gl_format */ - 0, 0, 0, /* dstX/Y/Zoffset */ transfer->stride, /* dstRowStride, bytes */ &dest, /* destSlices */ width, height, 1, /* size */ diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c index 37c20ebe3..5209fc795 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c +++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c @@ -125,7 +125,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target, texFormat = st_pipe_format_to_mesa_format(ps->format); - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, ps->width, ps->height, 1, 0, internalFormat, texFormat); diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 289ad5114..592d04b92 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -153,7 +153,8 @@ st_DeleteTextureObject(struct gl_context *ctx, /** called via ctx->Driver.FreeTextureImageBuffer() */ static void -st_FreeTextureImageBuffer(struct gl_context * ctx, struct gl_texture_image *texImage) +st_FreeTextureImageBuffer(struct gl_context *ctx, + struct gl_texture_image *texImage) { struct st_texture_image *stImage = st_texture_image(texImage); @@ -415,8 +416,6 @@ guess_and_alloc_texture(struct st_context *st, * Called via ctx->Driver.AllocTextureImageBuffer(). * If the texture object/buffer already has space for the indicated image, * we're done. Otherwise, allocate memory for the new texture image. - * XXX This function and st_TexImage() have some duplicated code. That - * can be cleaned up in the future. */ static GLboolean st_AllocTextureImageBuffer(struct gl_context *ctx, @@ -471,7 +470,10 @@ st_AllocTextureImageBuffer(struct gl_context *ctx, } else { /* Create a new, temporary texture/resource/buffer to hold this - * one texture image. + * one texture image. Note that when we later access this image + * (either for mapping or copying) we'll want to always specify + * mipmap level=0, even if the image represents some other mipmap + * level. */ enum pipe_format format = st_mesa_format_to_pipe_format(texImage->TexFormat); @@ -495,34 +497,24 @@ st_AllocTextureImageBuffer(struct gl_context *ctx, } } + /** - * Do glTexImage1/2/3D(). + * Preparation prior to glTexImage. Basically check the 'surface_based' + * field and switch to a "normal" tex image if necessary. */ static void -st_TexImage(struct gl_context * ctx, - GLint dims, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - GLsizei imageSize, GLboolean compressed_src) +prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type) { - struct st_context *st = st_context(ctx); + struct gl_texture_object *texObj = texImage->TexObject; struct st_texture_object *stObj = st_texture_object(texObj); - struct st_texture_image *stImage = st_texture_image(texImage); - GLuint dstRowStride = 0; - enum pipe_transfer_usage transfer_usage = 0; - GLubyte *dstMap; - - DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(target), level, width, height, depth, border); /* switch to "normal" */ if (stObj->surface_based) { + const GLenum target = texObj->Target; + const GLuint level = texImage->Level; gl_format texFormat; _mesa_clear_texture_object(ctx, texObj); @@ -532,265 +524,72 @@ st_TexImage(struct gl_context * ctx, texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, internalFormat, format, type); - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, border, internalFormat, texFormat); stObj->surface_based = GL_FALSE; } - - assert(texImage->Width == width); - assert(texImage->Height == height); - assert(texImage->Depth == depth); - - stImage->base.Face = _mesa_tex_target_to_face(target); - stImage->base.Level = level; - - /* Release the reference to a potentially orphaned buffer. - * Release any old malloced memory. - */ - if (stImage->pt) { - pipe_resource_reference(&stImage->pt, NULL); - assert(!stImage->TexData); - } - else if (stImage->TexData) { - _mesa_align_free(stImage->TexData); - } - - /* - * See if the new image is somehow incompatible with the existing - * mipmap. If so, free the old mipmap. - */ - if (stObj->pt) { - if (level > (GLint) stObj->pt->last_level || - !st_texture_match_image(stObj->pt, &stImage->base)) { - DBG("release it\n"); - pipe_resource_reference(&stObj->pt, NULL); - assert(!stObj->pt); - pipe_sampler_view_reference(&stObj->sampler_view, NULL); - } - } - - if (width == 0 || height == 0 || depth == 0) { - /* stop after freeing old image */ - return; - } - - if (!stObj->pt) { - if (!guess_and_alloc_texture(st, stObj, stImage)) { - /* Probably out of memory. - * Try flushing any pending rendering, then retry. - */ - st_finish(st); - if (!guess_and_alloc_texture(st, stObj, stImage)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); - return; - } - } - } - - assert(!stImage->pt); - - /* Check if this texture image can live inside the texture object's buffer. - * If so, store the image there. Otherwise the image will temporarily live - * in its own buffer. - */ - if (stObj->pt && - st_texture_match_image(stObj->pt, &stImage->base)) { - - pipe_resource_reference(&stImage->pt, stObj->pt); - assert(stImage->pt); - } - - if (!stImage->pt) - DBG("XXX: Image did not fit into texture - storing in local memory!\n"); - - /* Pixel data may come from regular user memory or a PBO. For the later, - * do bounds checking and map the PBO to read pixels data from it. - * - * XXX we should try to use a GPU-accelerated path to copy the image data - * from the PBO to the texture. - */ - if (compressed_src) { - pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, pixels, - unpack, - "glCompressedTexImage"); - } - else { - pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1, - format, type, - pixels, unpack, "glTexImage"); - } - - /* for a 1D array upload the image as a series of layer with height = 1 */ - if (target == GL_TEXTURE_1D_ARRAY) { - depth = height; - height = 1; - } - - /* - * Prepare to store the texture data. Either map the gallium texture buffer - * memory or malloc space for it. - */ - if (stImage->pt) { - if (!pixels) { - /* We've allocated texture resource, but have no pixel data - all done. */ - goto done; - } - - /* Store the image in the gallium transfer object */ - if (format == GL_DEPTH_COMPONENT && - util_format_is_depth_and_stencil(stImage->pt->format)) - transfer_usage = PIPE_TRANSFER_READ_WRITE; - else - transfer_usage = PIPE_TRANSFER_WRITE; - - dstMap = st_texture_image_map(st, stImage, 0, - transfer_usage, 0, 0, width, height); - if(stImage->transfer) - dstRowStride = stImage->transfer->stride; - } - else { - /* Allocate regular memory and store the image there temporarily. */ - GLuint imageSize = _mesa_format_image_size(texImage->TexFormat, - width, height, depth); - dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width); - - stImage->TexData = _mesa_align_malloc(imageSize, 16); - dstMap = stImage->TexData; - } - - if (!dstMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); - return; - } - - if (!pixels) { - /* We've allocated texture memory, but have no pixel data - all done. */ - goto done; - } - - DBG("Upload image %dx%dx%d row_len %x pitch %x\n", - width, height, depth, width, dstRowStride); - - /* Copy user texture image into the mapped texture buffer. - */ - if (compressed_src) { - const GLuint srcRowStride = - _mesa_format_row_stride(texImage->TexFormat, width); - if (dstRowStride == srcRowStride) { - memcpy(dstMap, pixels, imageSize); - } - else { - GLubyte *dst = dstMap; - const char *src = pixels; - GLuint i, bw, bh, lines; - _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); - lines = (height + bh - 1) / bh; - - for (i = 0; i < lines; ++i) { - memcpy(dst, src, srcRowStride); - dst += dstRowStride; - src += srcRowStride; - } - } - } - else { - const GLuint srcImageStride = - _mesa_image_image_stride(unpack, width, height, format, type); - GLint i; - const GLubyte *src = (const GLubyte *) pixels; - - for (i = 0; i < depth; i++) { - if (!_mesa_texstore(ctx, dims, - texImage->_BaseFormat, - texImage->TexFormat, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - (GLubyte **) &dstMap, /* dstSlice */ - width, height, 1, - format, type, src, unpack)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); - } - - if (stImage->pt && i + 1 < depth) { - /* unmap this slice */ - st_texture_image_unmap(st, stImage); - /* map next slice of 3D texture */ - dstMap = st_texture_image_map(st, stImage, i + 1, - transfer_usage, 0, 0, - width, height); - src += srcImageStride; - } - } - } - -done: - _mesa_unmap_teximage_pbo(ctx, unpack); - - if (stImage->pt && stImage->transfer) { - st_texture_image_unmap(st, stImage); - } } static void st_TexImage3D(struct gl_context * ctx, - GLenum target, GLint level, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint depth, GLint border, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *unpack) { - st_TexImage(ctx, 3, target, level, internalFormat, width, height, depth, - border, format, type, pixels, unpack, texObj, texImage, - 0, GL_FALSE); + prep_teximage(ctx, texImage, internalFormat, width, height, depth, border, + format, type); + _mesa_store_teximage3d(ctx, texImage, internalFormat, width, height, depth, + border, format, type, pixels, unpack); } static void st_TexImage2D(struct gl_context * ctx, - GLenum target, GLint level, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *unpack) { - st_TexImage(ctx, 2, target, level, internalFormat, width, height, 1, border, - format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE); + prep_teximage(ctx, texImage, internalFormat, width, height, 1, border, + format, type); + _mesa_store_teximage2d(ctx, texImage, internalFormat, width, height, + border, format, type, pixels, unpack); } static void st_TexImage1D(struct gl_context * ctx, - GLenum target, GLint level, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint border, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + const struct gl_pixelstore_attrib *unpack) { - st_TexImage(ctx, 1, target, level, internalFormat, width, 1, 1, border, - format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE); + prep_teximage(ctx, texImage, internalFormat, width, 1, 1, border, + format, type); + _mesa_store_teximage1d(ctx, texImage, internalFormat, width, + border, format, type, pixels, unpack); } static void -st_CompressedTexImage2D(struct gl_context *ctx, GLenum target, GLint level, +st_CompressedTexImage2D(struct gl_context *ctx, + struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) + GLsizei imageSize, const GLvoid *data) { - st_TexImage(ctx, 2, target, level, internalFormat, width, height, 1, border, - 0, 0, data, &ctx->Unpack, texObj, texImage, imageSize, GL_TRUE); + prep_teximage(ctx, texImage, internalFormat, width, 1, 1, border, + GL_NONE, GL_NONE); + _mesa_store_compressed_teximage2d(ctx, texImage, internalFormat, width, + height, border, imageSize, data); } @@ -929,224 +728,6 @@ st_GetTexImage(struct gl_context * ctx, } -static void -st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - struct st_context *st = st_context(ctx); - struct st_texture_image *stImage = st_texture_image(texImage); - GLuint dstRowStride; - const GLuint srcImageStride = - _mesa_image_image_stride(packing, width, height, format, type); - GLint i; - const GLubyte *src; - /* init to silence warning only: */ - enum pipe_transfer_usage transfer_usage = PIPE_TRANSFER_WRITE; - GLubyte *dstMap; - - DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(target), - level, xoffset, yoffset, width, height); - - pixels = - _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, format, - type, pixels, packing, "glTexSubImage2D"); - if (!pixels) - return; - - /* for a 1D array upload the image as a series of layer with height = 1 */ - if (target == GL_TEXTURE_1D_ARRAY) { - depth = height; - height = 1; - } - - /* Map buffer if necessary. Need to lock to prevent other contexts - * from uploading the buffer under us. - */ - if (stImage->pt) { - if (format == GL_DEPTH_COMPONENT && - util_format_is_depth_and_stencil(stImage->pt->format)) - transfer_usage = PIPE_TRANSFER_READ_WRITE; - else - transfer_usage = PIPE_TRANSFER_WRITE; - - dstMap = st_texture_image_map(st, stImage, zoffset, - transfer_usage, - xoffset, yoffset, - width, height); - } - - if (!dstMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage"); - goto done; - } - - src = (const GLubyte *) pixels; - dstRowStride = stImage->transfer->stride; - - for (i = 0; i < depth; i++) { - if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat, - texImage->TexFormat, - 0, 0, 0, - dstRowStride, - (GLubyte **) &dstMap, - width, height, 1, - format, type, src, packing)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage"); - } - - if (stImage->pt && i + 1 < depth) { - /* unmap this slice */ - st_texture_image_unmap(st, stImage); - /* map next slice of 3D texture */ - dstMap = st_texture_image_map(st, stImage, - zoffset + i + 1, - transfer_usage, - xoffset, yoffset, - width, height); - src += srcImageStride; - } - } - -done: - _mesa_unmap_teximage_pbo(ctx, packing); - - if (stImage->pt && stImage->transfer) { - st_texture_image_unmap(st, stImage); - } -} - - - -static void -st_TexSubImage3D(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - st_TexSubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type, - pixels, packing, texObj, texImage); -} - - -static void -st_TexSubImage2D(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - st_TexSubimage(ctx, 2, target, level, xoffset, yoffset, 0, - width, height, 1, format, type, - pixels, packing, texObj, texImage); -} - - -static void -st_TexSubImage1D(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, GLenum format, GLenum type, - const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - st_TexSubimage(ctx, 1, target, level, xoffset, 0, 0, width, 1, 1, - format, type, pixels, packing, texObj, texImage); -} - - -static void -st_CompressedTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - assert(0); -} - - -static void -st_CompressedTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLint height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - struct st_context *st = st_context(ctx); - struct st_texture_image *stImage = st_texture_image(texImage); - int srcBlockStride; - int dstBlockStride; - int y; - enum pipe_format pformat; - GLubyte *dstMap; - - if (stImage->pt) { - pformat = stImage->pt->format; - - dstMap = st_texture_image_map(st, stImage, 0, - PIPE_TRANSFER_WRITE, - xoffset, yoffset, - width, height); - - srcBlockStride = util_format_get_stride(pformat, width); - dstBlockStride = stImage->transfer->stride; - } else { - assert(stImage->pt); - /* TODO find good values for block and strides */ - /* TODO also adjust texImage->data for yoffset/xoffset */ - return; - } - - if (!dstMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage"); - return; - } - - assert(xoffset % util_format_get_blockwidth(pformat) == 0); - assert(yoffset % util_format_get_blockheight(pformat) == 0); - - for (y = 0; y < height; y += util_format_get_blockheight(pformat)) { - /* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */ - const char *src = (const char*)data + srcBlockStride * util_format_get_nblocksy(pformat, y); - char *dst = (char *) dstMap + dstBlockStride * util_format_get_nblocksy(pformat, y); - memcpy(dst, src, util_format_get_stride(pformat, width)); - } - - if (stImage->pt && stImage->transfer) { - st_texture_image_unmap(st, stImage); - } -} - - -static void -st_CompressedTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLint height, GLint depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - assert(0); -} - - - /** * Do a CopyTexSubImage operation using a read transfer from the source, * a write transfer to the destination and get_tile()/put_tile() to access @@ -1255,7 +836,6 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level, _mesa_texstore(ctx, dims, texImage->_BaseFormat, texImage->TexFormat, - 0, 0, 0, dstRowStride, (GLubyte **) &texDest, width, height, 1, @@ -1515,11 +1095,11 @@ st_copy_texsubimage(struct gl_context *ctx, return; fallback: - /* software fallback */ - fallback_copy_texsubimage(ctx, target, level, - strb, stImage, texBaseFormat, - destX, destY, destZ, - srcX, srcY, width, height); + /* software fallback */ + fallback_copy_texsubimage(ctx, target, level, + strb, stImage, texBaseFormat, + destX, destY, destZ, + srcX, srcY, width, height); } @@ -1582,9 +1162,15 @@ copy_image_data_to_texture(struct st_context *st, if (stImage->pt) { /* Copy potentially with the blitter: */ + GLuint src_level; + if (stImage->pt != stObj->pt) + src_level = 0; + else + src_level = stImage->base.Level; + st_texture_image_copy(st->pipe, stObj->pt, dstLevel, /* dest texture, level */ - stImage->pt, stImage->base.Level, /* src texture, level */ + stImage->pt, src_level, /* src texture, level */ stImage->base.Face); pipe_resource_reference(&stImage->pt, NULL); @@ -1777,17 +1363,15 @@ st_get_default_texture(struct st_context *st) texImg = _mesa_get_tex_image(st->ctx, texObj, target, 0); - _mesa_init_teximage_fields(st->ctx, target, texImg, + _mesa_init_teximage_fields(st->ctx, texImg, 16, 16, 1, 0, /* w, h, d, border */ GL_RGBA, MESA_FORMAT_RGBA8888); - st_TexImage(st->ctx, 2, target, - 0, GL_RGBA, /* level, intformat */ - 16, 16, 1, 0, /* w, h, d, border */ - GL_RGBA, GL_UNSIGNED_BYTE, pixels, - &st->ctx->DefaultPacking, - texObj, texImg, - 0, 0); + _mesa_store_teximage2d(st->ctx, texImg, + GL_RGBA, /* level, intformat */ + 16, 16, 1, /* w, h, d, border */ + GL_RGBA, GL_UNSIGNED_BYTE, pixels, + &st->ctx->DefaultPacking); texObj->Sampler.MinFilter = GL_NEAREST; texObj->Sampler.MagFilter = GL_NEAREST; @@ -1866,12 +1450,12 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TexImage1D = st_TexImage1D; functions->TexImage2D = st_TexImage2D; functions->TexImage3D = st_TexImage3D; - functions->TexSubImage1D = st_TexSubImage1D; - functions->TexSubImage2D = st_TexSubImage2D; - functions->TexSubImage3D = st_TexSubImage3D; - functions->CompressedTexSubImage1D = st_CompressedTexSubImage1D; - functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D; - functions->CompressedTexSubImage3D = st_CompressedTexSubImage3D; + functions->TexSubImage1D = _mesa_store_texsubimage1d; + functions->TexSubImage2D = _mesa_store_texsubimage2d; + functions->TexSubImage3D = _mesa_store_texsubimage3d; + functions->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; + functions->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; + functions->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; functions->CopyTexSubImage1D = st_CopyTexSubImage1D; functions->CopyTexSubImage2D = st_CopyTexSubImage2D; functions->CopyTexSubImage3D = st_CopyTexSubImage3D; diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index 87a997865..6d6fc858d 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -102,6 +102,13 @@ static GLuint uint_types_scale[4] = { PIPE_FORMAT_R32G32B32A32_USCALED }; +static GLuint uint_types_int[4] = { + PIPE_FORMAT_R32_UINT, + PIPE_FORMAT_R32G32_UINT, + PIPE_FORMAT_R32G32B32_UINT, + PIPE_FORMAT_R32G32B32A32_UINT +}; + static GLuint int_types_norm[4] = { PIPE_FORMAT_R32_SNORM, PIPE_FORMAT_R32G32_SNORM, @@ -116,6 +123,13 @@ static GLuint int_types_scale[4] = { PIPE_FORMAT_R32G32B32A32_SSCALED }; +static GLuint int_types_int[4] = { + PIPE_FORMAT_R32_SINT, + PIPE_FORMAT_R32G32_SINT, + PIPE_FORMAT_R32G32B32_SINT, + PIPE_FORMAT_R32G32B32A32_SINT +}; + static GLuint ushort_types_norm[4] = { PIPE_FORMAT_R16_UNORM, PIPE_FORMAT_R16G16_UNORM, @@ -130,6 +144,13 @@ static GLuint ushort_types_scale[4] = { PIPE_FORMAT_R16G16B16A16_USCALED }; +static GLuint ushort_types_int[4] = { + PIPE_FORMAT_R16_UINT, + PIPE_FORMAT_R16G16_UINT, + PIPE_FORMAT_R16G16B16_UINT, + PIPE_FORMAT_R16G16B16A16_UINT +}; + static GLuint short_types_norm[4] = { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16_SNORM, @@ -144,6 +165,13 @@ static GLuint short_types_scale[4] = { PIPE_FORMAT_R16G16B16A16_SSCALED }; +static GLuint short_types_int[4] = { + PIPE_FORMAT_R16_SINT, + PIPE_FORMAT_R16G16_SINT, + PIPE_FORMAT_R16G16B16_SINT, + PIPE_FORMAT_R16G16B16A16_SINT +}; + static GLuint ubyte_types_norm[4] = { PIPE_FORMAT_R8_UNORM, PIPE_FORMAT_R8G8_UNORM, @@ -158,6 +186,13 @@ static GLuint ubyte_types_scale[4] = { PIPE_FORMAT_R8G8B8A8_USCALED }; +static GLuint ubyte_types_int[4] = { + PIPE_FORMAT_R8_UINT, + PIPE_FORMAT_R8G8_UINT, + PIPE_FORMAT_R8G8B8_UINT, + PIPE_FORMAT_R8G8B8A8_UINT +}; + static GLuint byte_types_norm[4] = { PIPE_FORMAT_R8_SNORM, PIPE_FORMAT_R8G8_SNORM, @@ -172,6 +207,13 @@ static GLuint byte_types_scale[4] = { PIPE_FORMAT_R8G8B8A8_SSCALED }; +static GLuint byte_types_int[4] = { + PIPE_FORMAT_R8_SINT, + PIPE_FORMAT_R8G8_SINT, + PIPE_FORMAT_R8G8B8_SINT, + PIPE_FORMAT_R8G8B8A8_SINT +}; + static GLuint fixed_types[4] = { PIPE_FORMAT_R32_FIXED, PIPE_FORMAT_R32G32_FIXED, @@ -186,7 +228,7 @@ static GLuint fixed_types[4] = { */ enum pipe_format st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, - GLboolean normalized) + GLboolean normalized, GLboolean integer) { assert((type >= GL_BYTE && type <= GL_DOUBLE) || type == GL_FIXED || type == GL_HALF_FLOAT || @@ -199,6 +241,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, if (type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) { assert(size == 4); + assert(!integer); if (format == GL_BGRA) { if (type == GL_INT_2_10_10_10_REV) { @@ -234,7 +277,18 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, return PIPE_FORMAT_B8G8R8A8_UNORM; } - if (normalized) { + if (integer) { + switch (type) { + case GL_INT: return int_types_int[size-1]; + case GL_SHORT: return short_types_int[size-1]; + case GL_BYTE: return byte_types_int[size-1]; + case GL_UNSIGNED_INT: return uint_types_int[size-1]; + case GL_UNSIGNED_SHORT: return ushort_types_int[size-1]; + case GL_UNSIGNED_BYTE: return ubyte_types_int[size-1]; + default: assert(0); return 0; + } + } + else if (normalized) { switch (type) { case GL_DOUBLE: return double_types[size-1]; case GL_FLOAT: return float_types[size-1]; @@ -407,7 +461,8 @@ setup_interleaved_attribs(struct gl_context *ctx, velements[attr].src_format = st_pipe_vertex_format(array->Type, array->Size, array->Format, - array->Normalized); + array->Normalized, + array->Integer); assert(velements[attr].src_format); if (!usingVBO) { @@ -564,7 +619,8 @@ setup_non_interleaved_attribs(struct gl_context *ctx, velements[attr].src_format = st_pipe_vertex_format(array->Type, array->Size, array->Format, - array->Normalized); + array->Normalized, + array->Integer); assert(velements[attr].src_format); } @@ -584,20 +640,7 @@ setup_index_buffer(struct gl_context *ctx, if (ib) { struct gl_buffer_object *bufobj = ib->obj; - switch (ib->type) { - case GL_UNSIGNED_INT: - ibuffer->index_size = 4; - break; - case GL_UNSIGNED_SHORT: - ibuffer->index_size = 2; - break; - case GL_UNSIGNED_BYTE: - ibuffer->index_size = 1; - break; - default: - assert(0); - return; - } + ibuffer->index_size = vbo_sizeof_ib_type(ib->type); /* get/create the index buffer object */ if (_mesa_is_bufferobj(bufobj)) { @@ -781,16 +824,17 @@ handle_fallback_primitive_restart(struct pipe_context *pipe, start * ibuffer->index_size, /* start */ count * ibuffer->index_size, /* length */ PIPE_TRANSFER_READ, &transfer); + if (!ptr) + return; + + ptr = (uint8_t*)ptr + (ibuffer->offset - start * ibuffer->index_size); } else { ptr = ib->ptr; + if (!ptr) + return; } - if (!ptr) - return; - - ptr = ADD_POINTERS(ptr, ibuffer->offset); - sub_prims = find_sub_primitives(ptr, ibuffer->index_size, 0, count, orig_info->restart_index, &num_sub_prims); diff --git a/mesalib/src/mesa/state_tracker/st_draw.h b/mesalib/src/mesa/state_tracker/st_draw.h index 2623cdbb1..47bdb11f8 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.h +++ b/mesalib/src/mesa/state_tracker/st_draw.h @@ -73,7 +73,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, */ extern enum pipe_format st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, - GLboolean normalized); + GLboolean normalized, GLboolean integer); /** diff --git a/mesalib/src/mesa/state_tracker/st_draw_feedback.c b/mesalib/src/mesa/state_tracker/st_draw_feedback.c index 4c1e67495..fbf0349b4 100644 --- a/mesalib/src/mesa/state_tracker/st_draw_feedback.c +++ b/mesalib/src/mesa/state_tracker/st_draw_feedback.c @@ -196,7 +196,8 @@ st_feedback_draw_vbo(struct gl_context *ctx, st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, arrays[mesaAttr]->Format, - arrays[mesaAttr]->Normalized); + arrays[mesaAttr]->Normalized, + arrays[mesaAttr]->Integer); assert(velements[attr].src_format); /* tell draw about this attribute */ @@ -218,20 +219,9 @@ st_feedback_draw_vbo(struct gl_context *ctx, if (ib) { struct gl_buffer_object *bufobj = ib->obj; - switch (ib->type) { - case GL_UNSIGNED_INT: - ibuffer.index_size = 4; - break; - case GL_UNSIGNED_SHORT: - ibuffer.index_size = 2; - break; - case GL_UNSIGNED_BYTE: - ibuffer.index_size = 1; - break; - default: - assert(0); - goto out_unref_vertex; - } + ibuffer.index_size = vbo_sizeof_ib_type(ib->type); + if (ibuffer.index_size == 0) + goto out_unref_vertex; if (bufobj && bufobj->Name) { struct st_buffer_object *stobj = st_buffer_object(bufobj); diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c index 36fea3d7f..d817a9c2b 100644 --- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c +++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c @@ -244,7 +244,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, ctx->Driver.FreeTextureImageBuffer(ctx, dstImage); /* initialize new image */ - _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight, + _mesa_init_teximage_fields(ctx, dstImage, dstWidth, dstHeight, dstDepth, border, srcImage->InternalFormat, srcImage->TexFormat); diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 77aa0d17b..73d956ea1 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -304,6 +304,7 @@ public: int samplers_used; bool indirect_addr_temps; bool indirect_addr_consts; + int num_clip_distances; int glsl_version; bool native_integers; @@ -413,7 +414,6 @@ public: bool process_move_condition(ir_rvalue *ir); - void remove_output_reads(gl_register_file type); void simplify_cmp(void); void rename_temp_register(int index, int new_index); @@ -1781,6 +1781,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) case ir_unop_floor: emit(ir, TGSI_OPCODE_FLR, result_dst, op[0]); break; + case ir_unop_round_even: + emit(ir, TGSI_OPCODE_ROUND, result_dst, op[0]); + break; case ir_unop_fract: emit(ir, TGSI_OPCODE_FRC, result_dst, op[0]); break; @@ -1830,7 +1833,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) emit(ir, TGSI_OPCODE_OR, result_dst, op[0], op[1]); break; } - case ir_unop_round_even: + assert(!"GLSL 1.30 features unsupported"); break; @@ -2920,89 +2923,6 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx, } } -/* - * Scan/rewrite program to remove reads of custom (output) registers. - * The passed type has to be either PROGRAM_OUTPUT or PROGRAM_VARYING - * (for vertex shaders). - * In GLSL shaders, varying vars can be read and written. - * On some hardware, trying to read an output register causes trouble. - * So, rewrite the program to use a temporary register in this case. - * - * Based on _mesa_remove_output_reads from programopt.c. - */ -void -glsl_to_tgsi_visitor::remove_output_reads(gl_register_file type) -{ - GLuint i; - GLint outputMap[VERT_RESULT_MAX]; - GLint outputTypes[VERT_RESULT_MAX]; - GLuint numVaryingReads = 0; - GLboolean *usedTemps; - GLuint firstTemp = 0; - - usedTemps = new GLboolean[MAX_TEMPS]; - if (!usedTemps) { - return; - } - _mesa_find_used_registers(prog, PROGRAM_TEMPORARY, - usedTemps, MAX_TEMPS); - - assert(type == PROGRAM_VARYING || type == PROGRAM_OUTPUT); - assert(prog->Target == GL_VERTEX_PROGRAM_ARB || type != PROGRAM_VARYING); - - for (i = 0; i < VERT_RESULT_MAX; i++) - outputMap[i] = -1; - - /* look for instructions which read from varying vars */ - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); - const GLuint numSrc = num_inst_src_regs(inst->op); - GLuint j; - for (j = 0; j < numSrc; j++) { - if (inst->src[j].file == type) { - /* replace the read with a temp reg */ - const GLuint var = inst->src[j].index; - if (outputMap[var] == -1) { - numVaryingReads++; - outputMap[var] = _mesa_find_free_register(usedTemps, - MAX_TEMPS, - firstTemp); - outputTypes[var] = inst->src[j].type; - firstTemp = outputMap[var] + 1; - } - inst->src[j].file = PROGRAM_TEMPORARY; - inst->src[j].index = outputMap[var]; - } - } - } - - delete [] usedTemps; - - if (numVaryingReads == 0) - return; /* nothing to be done */ - - /* look for instructions which write to the varying vars identified above */ - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); - if (inst->dst.file == type && outputMap[inst->dst.index] >= 0) { - /* change inst to write to the temp reg, instead of the varying */ - inst->dst.file = PROGRAM_TEMPORARY; - inst->dst.index = outputMap[inst->dst.index]; - } - } - - /* insert new MOV instructions at the end */ - for (i = 0; i < VERT_RESULT_MAX; i++) { - if (outputMap[i] >= 0) { - /* MOV VAR[i], TEMP[tmp]; */ - st_src_reg src = st_src_reg(PROGRAM_TEMPORARY, outputMap[i], outputTypes[i]); - st_dst_reg dst = st_dst_reg(type, WRITEMASK_XYZW, outputTypes[i]); - dst.index = i; - this->emit(NULL, TGSI_OPCODE_MOV, dst, src); - } - } -} - /** * Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which * are read from the given src in this instruction @@ -3505,10 +3425,15 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void) switch (inst->op) { case TGSI_OPCODE_BGNLOOP: case TGSI_OPCODE_ENDLOOP: + case TGSI_OPCODE_CONT: + case TGSI_OPCODE_BRK: /* End of a basic block, clear the write array entirely. - * FIXME: This keeps us from killing dead code when the writes are + * + * This keeps us from killing dead code when the writes are * on either side of a loop, even when the register isn't touched - * inside the loop. + * inside the loop. However, glsl_to_tgsi_visitor doesn't seem to emit + * dead code of this type, so it shouldn't make a difference as long as + * the dead code elimination pass in the GLSL compiler does its job. */ memset(writes, 0, sizeof(*writes) * this->next_temp * 4); break; @@ -3708,6 +3633,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp, /* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */ v->ctx = original->ctx; v->prog = prog; + v->shader_program = NULL; v->glsl_version = original->glsl_version; v->native_integers = original->native_integers; v->options = original->options; @@ -3837,6 +3763,7 @@ get_bitmap_visitor(struct st_fragment_program *fp, /* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */ v->ctx = original->ctx; v->prog = prog; + v->shader_program = NULL; v->glsl_version = original->glsl_version; v->native_integers = original->native_integers; v->options = original->options; @@ -4550,6 +4477,15 @@ st_translate_program( t->pointSizeOutIndex = -1; t->prevInstWrotePointSize = GL_FALSE; + if (program->shader_program) { + for (i = 0; i < program->shader_program->NumUserUniformStorage; i++) { + struct gl_uniform_storage *const storage = + &program->shader_program->UniformStorage[i]; + + _mesa_uniform_detach_all_driver_storage(storage); + } + } + /* * Declare input attributes. */ @@ -4622,9 +4558,17 @@ st_translate_program( } for (i = 0; i < numOutputs; i++) { - t->outputs[i] = ureg_DECL_output(ureg, - outputSemanticName[i], - outputSemanticIndex[i]); + if (outputSemanticName[i] == TGSI_SEMANTIC_CLIPDIST) { + int mask = ((1 << (program->num_clip_distances - 4*outputSemanticIndex[i])) - 1) & TGSI_WRITEMASK_XYZW; + t->outputs[i] = ureg_DECL_output_masked(ureg, + outputSemanticName[i], + outputSemanticIndex[i], + mask); + } else { + t->outputs[i] = ureg_DECL_output(ureg, + outputSemanticName[i], + outputSemanticIndex[i]); + } if ((outputSemanticName[i] == TGSI_SEMANTIC_PSIZE) && proginfo->Id) { /* Writing to the point size result register requires special * handling to implement clamping. @@ -4776,6 +4720,20 @@ st_translate_program( t->insn[t->labels[i].branch_target]); } + if (program->shader_program) { + /* This has to be done last. Any operation the can cause + * prog->ParameterValues to get reallocated (e.g., anything that adds a + * program constant) has to happen before creating this linkage. + */ + for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + if (program->shader_program->_LinkedShaders[i] == NULL) + continue; + + _mesa_associate_uniform_storage(ctx, program->shader_program, + program->shader_program->_LinkedShaders[i]->Program->Parameters); + } + } + out: if (t) { FREE(t->insn); @@ -4801,7 +4759,8 @@ out: static struct gl_program * get_mesa_program(struct gl_context *ctx, struct gl_shader_program *shader_program, - struct gl_shader *shader) + struct gl_shader *shader, + int num_clip_distances) { glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor(); struct gl_program *prog; @@ -4846,10 +4805,18 @@ get_mesa_program(struct gl_context *ctx, v->options = options; v->glsl_version = ctx->Const.GLSLVersion; v->native_integers = ctx->Const.NativeIntegers; + v->num_clip_distances = num_clip_distances; _mesa_generate_parameters_list_for_uniforms(shader_program, shader, prog->Parameters); + if (!screen->get_shader_param(screen, pipe_shader_type, + PIPE_SHADER_CAP_OUTPUT_READ)) { + /* Remove reads to output registers, and to varyings in vertex shaders. */ + lower_output_reads(shader->ir); + } + + /* Emit intermediate IR for main(). */ visit_exec_list(shader->ir, v); @@ -4896,14 +4863,6 @@ get_mesa_program(struct gl_context *ctx, } #endif - if (!screen->get_shader_param(screen, pipe_shader_type, - PIPE_SHADER_CAP_OUTPUT_READ)) { - /* Remove reads to output registers, and to varyings in vertex shaders. */ - v->remove_output_reads(PROGRAM_OUTPUT); - if (target == GL_VERTEX_PROGRAM_ARB) - v->remove_output_reads(PROGRAM_VARYING); - } - /* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */ v->simplify_cmp(); v->copy_propagate(); @@ -4975,6 +4934,25 @@ get_mesa_program(struct gl_context *ctx, return prog; } +/** + * Searches through the IR for a declaration of gl_ClipDistance and returns the + * declared size of the gl_ClipDistance array. Returns 0 if gl_ClipDistance is + * not declared in the IR. + */ +int get_clip_distance_size(exec_list *ir) +{ + foreach_iter (exec_list_iterator, iter, *ir) { + ir_instruction *inst = (ir_instruction *)iter.get(); + ir_variable *var = inst->as_variable(); + if (var == NULL) continue; + if (!strcmp(var->name, "gl_ClipDistance")) { + return var->type->length; + } + } + + return 0; +} + extern "C" { struct gl_shader * @@ -5013,6 +4991,7 @@ st_new_shader_program(struct gl_context *ctx, GLuint name) GLboolean st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) { + int num_clip_distances[MESA_SHADER_TYPES]; assert(prog->LinkStatus); for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { @@ -5024,6 +5003,11 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) const struct gl_shader_compiler_options *options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)]; + /* We have to determine the length of the gl_ClipDistance array before + * the array is lowered to two vec4s by lower_clip_distance(). + */ + num_clip_distances[i] = get_clip_distance_size(ir); + do { progress = false; @@ -5040,6 +5024,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) || progress; progress = lower_quadop_vector(ir, false) || progress; + progress = lower_clip_distance(ir) || progress; if (options->MaxIfDepth == 0) progress = lower_discard(ir) || progress; @@ -5074,7 +5059,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) if (prog->_LinkedShaders[i] == NULL) continue; - linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); + linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i], + num_clip_distances[i]); if (linked_prog) { static const GLenum targets[] = { @@ -5120,7 +5106,8 @@ st_translate_stream_output_info(struct glsl_to_tgsi_visitor *glsl_to_tgsi, so->output[i].register_index = outputMapping[info->Outputs[i].OutputRegister]; so->output[i].register_mask = - comps_to_mask[info->Outputs[i].NumComponents]; + comps_to_mask[info->Outputs[i].NumComponents] + << info->Outputs[i].ComponentOffset; so->output[i].output_buffer = info->Outputs[i].OutputBuffer; } so->num_outputs = info->NumOutputs; diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index 828f0d81f..c0af3ce11 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -535,7 +535,7 @@ st_context_teximage(struct st_context_iface *stctxi, texFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_BGRA, GL_UNSIGNED_BYTE); - _mesa_init_teximage_fields(ctx, target, texImage, + _mesa_init_teximage_fields(ctx, texImage, tex->width0, tex->height0, 1, 0, internalFormat, texFormat); @@ -647,9 +647,13 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi, if (attribs->major > 1 || attribs->minor > 0) { _mesa_compute_version(st->ctx); - /* is the actual version less than the requested version? */ + /* Is the actual version less than the requested version? Mesa can't + * yet enforce the added restrictions of a forward-looking context, so + * fail that too. + */ if (st->ctx->VersionMajor * 10 + st->ctx->VersionMinor < - attribs->major * 10 + attribs->minor) { + attribs->major * 10 + attribs->minor + || (attribs->flags & ~ST_CONTEXT_FLAG_DEBUG) != 0) { *error = ST_CONTEXT_ERROR_BAD_VERSION; st_destroy_context(st); return NULL; diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index b83c56165..aceaaf8c5 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -244,6 +244,14 @@ st_prepare_vertex_program(struct gl_context *ctx, stvp->output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; stvp->output_semantic_index[slot] = 0; break; + case VERT_RESULT_CLIP_DIST0: + stvp->output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + stvp->output_semantic_index[slot] = 0; + break; + case VERT_RESULT_CLIP_DIST1: + stvp->output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + stvp->output_semantic_index[slot] = 1; + break; case VERT_RESULT_EDGE: assert(0); break; @@ -530,12 +538,12 @@ st_translate_fragment_program(struct st_context *st, case FRAG_ATTRIB_COL0: input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; input_semantic_index[slot] = 0; - interpMode[slot] = TGSI_INTERPOLATE_LINEAR; + interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr]); break; case FRAG_ATTRIB_COL1: input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; input_semantic_index[slot] = 1; - interpMode[slot] = TGSI_INTERPOLATE_LINEAR; + interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr]); break; case FRAG_ATTRIB_FOGC: input_semantic_name[slot] = TGSI_SEMANTIC_FOG; @@ -547,6 +555,16 @@ st_translate_fragment_program(struct st_context *st, input_semantic_index[slot] = 0; interpMode[slot] = TGSI_INTERPOLATE_CONSTANT; break; + case FRAG_ATTRIB_CLIP_DIST0: + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_LINEAR; + break; + case FRAG_ATTRIB_CLIP_DIST1: + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + input_semantic_index[slot] = 1; + interpMode[slot] = TGSI_INTERPOLATE_LINEAR; + break; /* In most cases, there is nothing special about these * inputs, so adopt a convention to use the generic * semantic name and the mesa FRAG_ATTRIB_ number as the diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index 3323bbbbe..132d7a81c 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -215,12 +215,19 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, GLuint zoffset, enum pipe_transfer_usage usage, GLuint x, GLuint y, GLuint w, GLuint h) { + struct st_texture_object *stObj = + st_texture_object(stImage->base.TexObject); struct pipe_context *pipe = st->pipe; - struct pipe_resource *pt = stImage->pt; + GLuint level; DBG("%s \n", __FUNCTION__); - stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->base.Level, + if (stObj->pt != stImage->pt) + level = 0; + else + level = stImage->base.Level; + + stImage->transfer = pipe_get_transfer(st->pipe, stImage->pt, level, stImage->base.Face + zoffset, usage, x, y, w, h); diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c index 803ad2e89..1063024fb 100644 --- a/mesalib/src/mesa/swrast/s_blit.c +++ b/mesalib/src/mesa/swrast/s_blit.c @@ -27,6 +27,8 @@ #include "main/condrender.h" #include "main/image.h" #include "main/macros.h" +#include "main/format_unpack.h" +#include "main/format_pack.h" #include "s_context.h" @@ -122,10 +124,18 @@ blit_nearest(struct gl_context *ctx, const GLboolean invertX = (srcX1 < srcX0) ^ (dstX1 < dstX0); const GLboolean invertY = (srcY1 < srcY0) ^ (dstY1 < dstY0); - + enum mode { + DIRECT, + UNPACK_RGBA_FLOAT, + UNPACK_Z_FLOAT, + UNPACK_Z_INT, + UNPACK_S, + } mode; + GLubyte *srcMap, *dstMap; + GLint srcRowStride, dstRowStride; GLint dstRow; - GLint comps, pixelSize; + GLint pixelSize; GLvoid *srcBuffer, *dstBuffer; GLint prevY = -1; @@ -138,42 +148,43 @@ blit_nearest(struct gl_context *ctx, case GL_COLOR_BUFFER_BIT: readRb = ctx->ReadBuffer->_ColorReadBuffer; drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0]; - comps = 4; + + if (readRb->Format == drawRb->Format) { + mode = DIRECT; + pixelSize = _mesa_get_format_bytes(readRb->Format); + } else { + mode = UNPACK_RGBA_FLOAT; + pixelSize = 16; + } + break; case GL_DEPTH_BUFFER_BIT: - readRb = ctx->ReadBuffer->_DepthBuffer; - drawRb = ctx->DrawBuffer->_DepthBuffer; - comps = 1; + readRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; + drawRb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; + + /* Note that for depth/stencil, the formats of src/dst must match. By + * using the core helpers for pack/unpack, we avoid needing to handle + * masking for things like DEPTH copies of Z24S8. + */ + if (readRb->Format == MESA_FORMAT_Z32_FLOAT || + readRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + mode = UNPACK_Z_FLOAT; + } else { + mode = UNPACK_Z_INT; + } + pixelSize = 4; break; case GL_STENCIL_BUFFER_BIT: - readRb = ctx->ReadBuffer->_StencilBuffer; - drawRb = ctx->DrawBuffer->_StencilBuffer; - comps = 1; + readRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; + drawRb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; + mode = UNPACK_S; + pixelSize = 1; break; default: _mesa_problem(ctx, "unexpected buffer in blit_nearest()"); return; } - switch (readRb->DataType) { - case GL_UNSIGNED_BYTE: - pixelSize = comps * sizeof(GLubyte); - break; - case GL_UNSIGNED_SHORT: - pixelSize = comps * sizeof(GLushort); - break; - case GL_UNSIGNED_INT: - pixelSize = comps * sizeof(GLuint); - break; - case GL_FLOAT: - pixelSize = comps * sizeof(GLfloat); - break; - default: - _mesa_problem(ctx, "unexpected buffer type (0x%x) in blit_nearest", - readRb->DataType); - return; - } - /* choose row resampler */ switch (pixelSize) { case 1: @@ -197,6 +208,62 @@ blit_nearest(struct gl_context *ctx, return; } + if (readRb == drawRb) { + /* map whole buffer for read/write */ + /* XXX we could be clever and just map the union region of the + * source and dest rects. + */ + GLubyte *map; + GLint rowStride; + GLint formatSize = _mesa_get_format_bytes(readRb->Format); + + ctx->Driver.MapRenderbuffer(ctx, readRb, 0, 0, + readRb->Width, readRb->Height, + GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, + &map, &rowStride); + if (!map) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFramebuffer"); + return; + } + + srcMap = map + srcYpos * rowStride + srcXpos * formatSize; + dstMap = map + dstYpos * rowStride + dstXpos * formatSize; + + /* this handles overlapping copies */ + if (srcY0 < dstY0) { + /* copy in reverse (top->down) order */ + srcMap += rowStride * (readRb->Height - 1); + dstMap += rowStride * (readRb->Height - 1); + srcRowStride = -rowStride; + dstRowStride = -rowStride; + } + else { + /* copy in normal (bottom->up) order */ + srcRowStride = rowStride; + dstRowStride = rowStride; + } + } + else { + /* different src/dst buffers */ + ctx->Driver.MapRenderbuffer(ctx, readRb, + srcXpos, srcYpos, + srcWidth, srcHeight, + GL_MAP_READ_BIT, &srcMap, &srcRowStride); + if (!srcMap) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFramebuffer"); + return; + } + ctx->Driver.MapRenderbuffer(ctx, drawRb, + dstXpos, dstYpos, + dstWidth, dstHeight, + GL_MAP_WRITE_BIT, &dstMap, &dstRowStride); + if (!dstMap) { + ctx->Driver.UnmapRenderbuffer(ctx, readRb); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFramebuffer"); + return; + } + } + /* allocate the src/dst row buffers */ srcBuffer = malloc(pixelSize * srcWidth); if (!srcBuffer) { @@ -211,9 +278,8 @@ blit_nearest(struct gl_context *ctx, } for (dstRow = 0; dstRow < dstHeight; dstRow++) { - const GLint dstY = dstYpos + dstRow; GLint srcRow = (dstRow * srcHeight) / dstHeight; - GLint srcY; + GLubyte *dstRowStart = dstMap + dstRowStride * dstRow; ASSERT(srcRow >= 0); ASSERT(srcRow < srcHeight); @@ -222,21 +288,67 @@ blit_nearest(struct gl_context *ctx, srcRow = srcHeight - 1 - srcRow; } - srcY = srcYpos + srcRow; - /* get pixel row from source and resample to match dest width */ - if (prevY != srcY) { - readRb->GetRow(ctx, readRb, srcWidth, srcXpos, srcY, srcBuffer); + if (prevY != srcRow) { + GLubyte *srcRowStart = srcMap + srcRowStride * srcRow; + + switch (mode) { + case DIRECT: + memcpy(srcBuffer, srcRowStart, pixelSize * srcWidth); + break; + case UNPACK_RGBA_FLOAT: + _mesa_unpack_rgba_row(readRb->Format, srcWidth, srcRowStart, + srcBuffer); + break; + case UNPACK_Z_FLOAT: + _mesa_unpack_float_z_row(readRb->Format, srcWidth, srcRowStart, + srcBuffer); + break; + case UNPACK_Z_INT: + _mesa_unpack_uint_z_row(readRb->Format, srcWidth, srcRowStart, + srcBuffer); + break; + case UNPACK_S: + _mesa_unpack_ubyte_stencil_row(readRb->Format, srcWidth, + srcRowStart, srcBuffer); + break; + } + (*resampleRow)(srcWidth, dstWidth, srcBuffer, dstBuffer, invertX); - prevY = srcY; + prevY = srcRow; } /* store pixel row in destination */ - drawRb->PutRow(ctx, drawRb, dstWidth, dstXpos, dstY, dstBuffer, NULL); + switch (mode) { + case DIRECT: + memcpy(dstRowStart, dstBuffer, pixelSize * srcWidth); + break; + case UNPACK_RGBA_FLOAT: + _mesa_pack_float_rgba_row(drawRb->Format, dstWidth, dstBuffer, + dstRowStart); + break; + case UNPACK_Z_FLOAT: + _mesa_pack_float_z_row(drawRb->Format, dstWidth, dstBuffer, + dstRowStart); + break; + case UNPACK_Z_INT: + _mesa_pack_uint_z_row(drawRb->Format, dstWidth, dstBuffer, + dstRowStart); + break; + case UNPACK_S: + _mesa_pack_ubyte_stencil_row(drawRb->Format, dstWidth, dstBuffer, + dstRowStart); + break; + } } free(srcBuffer); free(dstBuffer); + + ctx->Driver.UnmapRenderbuffer(ctx, readRb); + if (drawRb != readRb) { + ctx->Driver.UnmapRenderbuffer(ctx, drawRb); + } } @@ -449,117 +561,6 @@ blit_linear(struct gl_context *ctx, free(dstBuffer); } - -/** - * Simple case: Blit color, depth or stencil with no scaling or flipping. - * XXX we could easily support vertical flipping here. - */ -static void -simple_blit(struct gl_context *ctx, - GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield buffer) -{ - struct gl_renderbuffer *readRb, *drawRb; - const GLint width = srcX1 - srcX0; - const GLint height = srcY1 - srcY0; - GLint row, srcY, dstY, yStep; - GLint comps, bytesPerRow; - void *rowBuffer; - - /* only one buffer */ - ASSERT(_mesa_bitcount(buffer) == 1); - /* no flipping checks */ - ASSERT(srcX0 < srcX1); - ASSERT(srcY0 < srcY1); - ASSERT(dstX0 < dstX1); - ASSERT(dstY0 < dstY1); - /* size checks */ - ASSERT(srcX1 - srcX0 == dstX1 - dstX0); - ASSERT(srcY1 - srcY0 == dstY1 - dstY0); - - /* From the GL_ARB_framebuffer_object spec: - * - * "If the source and destination buffers are identical, and the source - * and destination rectangles overlap, the result of the blit operation - * is undefined." - * - * However, we provide the expected result anyway by flipping the order of - * the memcpy of rows. - */ - if (srcY0 > dstY0) { - /* src above dst: copy bottom-to-top */ - yStep = 1; - srcY = srcY0; - dstY = dstY0; - } - else { - /* src below dst: copy top-to-bottom */ - yStep = -1; - srcY = srcY1 - 1; - dstY = dstY1 - 1; - } - - switch (buffer) { - case GL_COLOR_BUFFER_BIT: - readRb = ctx->ReadBuffer->_ColorReadBuffer; - drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0]; - comps = 4; - break; - case GL_DEPTH_BUFFER_BIT: - readRb = ctx->ReadBuffer->_DepthBuffer; - drawRb = ctx->DrawBuffer->_DepthBuffer; - comps = 1; - break; - case GL_STENCIL_BUFFER_BIT: - readRb = ctx->ReadBuffer->_StencilBuffer; - drawRb = ctx->DrawBuffer->_StencilBuffer; - comps = 1; - break; - default: - _mesa_problem(ctx, "unexpected buffer in simple_blit()"); - return; - } - - ASSERT(readRb->DataType == drawRb->DataType); - - /* compute bytes per row */ - switch (readRb->DataType) { - case GL_UNSIGNED_BYTE: - bytesPerRow = comps * width * sizeof(GLubyte); - break; - case GL_UNSIGNED_SHORT: - bytesPerRow = comps * width * sizeof(GLushort); - break; - case GL_UNSIGNED_INT: - bytesPerRow = comps * width * sizeof(GLuint); - break; - case GL_FLOAT: - bytesPerRow = comps * width * sizeof(GLfloat); - break; - default: - _mesa_problem(ctx, "unexpected buffer type in simple_blit"); - return; - } - - /* allocate the row buffer */ - rowBuffer = malloc(bytesPerRow); - if (!rowBuffer) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT"); - return; - } - - for (row = 0; row < height; row++) { - readRb->GetRow(ctx, readRb, width, srcX0, srcY, rowBuffer); - drawRb->PutRow(ctx, drawRb, width, dstX0, dstY, rowBuffer, NULL); - srcY += yStep; - dstY += yStep; - } - - free(rowBuffer); -} - - /** * Software fallback for glBlitFramebufferEXT(). */ @@ -574,6 +575,11 @@ _swrast_BlitFramebuffer(struct gl_context *ctx, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT }; + static const GLenum buffer_enums[3] = { + GL_COLOR, + GL_DEPTH, + GL_STENCIL, + }; GLint i; if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1, @@ -584,41 +590,47 @@ _swrast_BlitFramebuffer(struct gl_context *ctx, if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived(ctx); - swrast_render_start(ctx); - + /* First, try covering whatever buffers possible using the fast 1:1 copy + * path. + */ if (srcX1 - srcX0 == dstX1 - dstX0 && srcY1 - srcY0 == dstY1 - dstY0 && srcX0 < srcX1 && srcY0 < srcY1 && dstX0 < dstX1 && dstY0 < dstY1) { - /* no stretching or flipping. - * filter doesn't matter. - */ for (i = 0; i < 3; i++) { if (mask & buffers[i]) { - simple_blit(ctx, srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, buffers[i]); - } + if (swrast_fast_copy_pixels(ctx, + srcX0, srcY0, + srcX1 - srcX0, srcY1 - srcY0, + dstX0, dstY0, + buffer_enums[i])) { + mask &= ~buffers[i]; + } + } + } + + if (!mask) + return; + } + + if (filter == GL_NEAREST) { + for (i = 0; i < 3; i++) { + if (mask & buffers[i]) { + blit_nearest(ctx, srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, buffers[i]); + } } } else { - if (filter == GL_NEAREST) { - for (i = 0; i < 3; i++) { - if (mask & buffers[i]) { - blit_nearest(ctx, srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, buffers[i]); - } - } - } - else { - ASSERT(filter == GL_LINEAR); - if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */ - blit_linear(ctx, srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1); - } + ASSERT(filter == GL_LINEAR); + if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */ + swrast_render_start(ctx); + blit_linear(ctx, srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1); + swrast_render_finish(ctx); } } - swrast_render_finish(ctx); } diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c index 1dc4286a3..1e0f9fe7d 100644 --- a/mesalib/src/mesa/swrast/s_copypix.c +++ b/mesalib/src/mesa/swrast/s_copypix.c @@ -422,13 +422,13 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, /** - * Try to do a fast copy pixels with memcpy. + * Try to do a fast 1:1 blit with memcpy. * \return GL_TRUE if successful, GL_FALSE otherwise. */ -static GLboolean -fast_copy_pixels(struct gl_context *ctx, - GLint srcX, GLint srcY, GLsizei width, GLsizei height, - GLint dstX, GLint dstY, GLenum type) +GLboolean +swrast_fast_copy_pixels(struct gl_context *ctx, + GLint srcX, GLint srcY, GLsizei width, GLsizei height, + GLint dstX, GLint dstY, GLenum type) { struct gl_framebuffer *srcFb = ctx->ReadBuffer; struct gl_framebuffer *dstFb = ctx->DrawBuffer; @@ -438,14 +438,6 @@ fast_copy_pixels(struct gl_context *ctx, GLubyte *srcMap, *dstMap; GLint srcRowStride, dstRowStride; - if (SWRAST_CONTEXT(ctx)->_RasterMask != 0x0 || - ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F || - ctx->_ImageTransferState) { - /* can't handle these */ - return GL_FALSE; - } - if (type == GL_COLOR) { if (dstFb->_NumColorDrawBuffers != 1) return GL_FALSE; @@ -508,7 +500,7 @@ fast_copy_pixels(struct gl_context *ctx, srcRb->Width, srcRb->Height, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, &map, &rowStride); - if (!srcMap) { + if (!map) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); return GL_TRUE; /* don't retry with slow path */ } @@ -582,7 +574,12 @@ _swrast_CopyPixels( struct gl_context *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - if (fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty, type)) { + if (!(SWRAST_CONTEXT(ctx)->_RasterMask != 0x0 || + ctx->Pixel.ZoomX != 1.0F || + ctx->Pixel.ZoomY != 1.0F || + ctx->_ImageTransferState) && + swrast_fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty, + type)) { /* all done */ return; } diff --git a/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c index f87adaa84..53f21cb69 100644 --- a/mesalib/src/mesa/swrast/s_depth.c +++ b/mesalib/src/mesa/swrast/s_depth.c @@ -489,7 +489,6 @@ _swrast_clear_depth_buffer(struct gl_context *ctx) { struct gl_renderbuffer *rb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; - GLuint clearValue; GLint x, y, width, height; GLubyte *map; GLint rowStride, i, j; @@ -500,14 +499,6 @@ _swrast_clear_depth_buffer(struct gl_context *ctx) return; } - /* compute integer clearing value */ - if (ctx->Depth.Clear == 1.0) { - clearValue = ctx->DrawBuffer->_DepthMax; - } - else { - clearValue = (GLuint) (ctx->Depth.Clear * ctx->DrawBuffer->_DepthMaxF); - } - /* compute region to clear */ x = ctx->DrawBuffer->_Xmin; y = ctx->DrawBuffer->_Ymin; diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 4124e444e..8f02eeae7 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -776,7 +776,7 @@ clip_span( struct gl_context *ctx, SWspan *span ) span->intTex[1] += leftClip * span->intTexStep[1]; #define SHIFT_ARRAY(ARRAY, SHIFT, LEN) \ - memcpy(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0])) + memmove(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0])) for (i = 0; i < FRAG_ATTRIB_MAX; i++) { if (span->arrayAttribs & (1 << i)) { diff --git a/mesalib/src/mesa/swrast/swrast.h b/mesalib/src/mesa/swrast/swrast.h index dd4055159..468d22f0b 100644 --- a/mesalib/src/mesa/swrast/swrast.h +++ b/mesalib/src/mesa/swrast/swrast.h @@ -110,6 +110,11 @@ _swrast_CopyPixels( struct gl_context *ctx, GLsizei width, GLsizei height, GLenum type ); +extern GLboolean +swrast_fast_copy_pixels(struct gl_context *ctx, + GLint srcX, GLint srcY, GLsizei width, GLsizei height, + GLint dstX, GLint dstY, GLenum type); + extern void _swrast_DrawPixels( struct gl_context *ctx, GLint x, GLint y, diff --git a/mesalib/src/mesa/tnl/t_draw.c b/mesalib/src/mesa/tnl/t_draw.c index 83ded1949..f949c34d3 100644 --- a/mesalib/src/mesa/tnl/t_draw.c +++ b/mesalib/src/mesa/tnl/t_draw.c @@ -349,26 +349,10 @@ static void bind_indices( struct gl_context *ctx, if (_mesa_is_bufferobj(ib->obj) && !_mesa_bufferobj_mapped(ib->obj)) { /* if the buffer object isn't mapped yet, map it now */ - unsigned map_size; - - switch (ib->type) { - case GL_UNSIGNED_BYTE: - map_size = ib->count * sizeof(GLubyte); - break; - case GL_UNSIGNED_SHORT: - map_size = ib->count * sizeof(GLushort); - break; - case GL_UNSIGNED_INT: - map_size = ib->count * sizeof(GLuint); - break; - default: - assert(0); - map_size = 0; - } - bo[*nr_bo] = ib->obj; (*nr_bo)++; - ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, map_size, + ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, + ib->count * vbo_sizeof_ib_type(ib->type), GL_MAP_READ_BIT, ib->obj); assert(ib->obj->Pointer); } else { diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h index 7384790e3..ed8fc1722 100644 --- a/mesalib/src/mesa/vbo/vbo.h +++ b/mesalib/src/mesa/vbo/vbo.h @@ -122,6 +122,10 @@ void vbo_rebase_prims( struct gl_context *ctx, GLuint min_index, GLuint max_index, vbo_draw_func draw ); + +int +vbo_sizeof_ib_type(GLenum type); + void vbo_get_minmax_index(struct gl_context *ctx, const struct _mesa_prim *prim, const struct _mesa_index_buffer *ib, diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index 2db85e2e5..fec49d35e 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -75,6 +75,22 @@ vbo_check_buffers_are_unmapped(struct gl_context *ctx) assert(!_mesa_bufferobj_mapped(exec->vtx.bufferobj)); } +int +vbo_sizeof_ib_type(GLenum type) +{ + switch (type) { + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + default: + assert(!"unsupported index data type"); + /* In case assert is turned off */ + return 0; + } +} /** @@ -96,24 +112,8 @@ vbo_get_minmax_index(struct gl_context *ctx, GLuint i; if (_mesa_is_bufferobj(ib->obj)) { - unsigned map_size; - - switch (ib->type) { - case GL_UNSIGNED_INT: - map_size = count * sizeof(GLuint); - break; - case GL_UNSIGNED_SHORT: - map_size = count * sizeof(GLushort); - break; - case GL_UNSIGNED_BYTE: - map_size = count * sizeof(GLubyte); - break; - default: - assert(0); - map_size = 0; - } - - indices = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, map_size, + indices = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, + count * vbo_sizeof_ib_type(ib->type), GL_MAP_READ_BIT, ib->obj); } else { indices = ib->ptr; @@ -1053,7 +1053,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, struct vbo_exec_context *exec = &vbo->exec; struct _mesa_index_buffer ib; struct _mesa_prim *prim; - unsigned int index_type_size = 0; + unsigned int index_type_size = vbo_sizeof_ib_type(type); uintptr_t min_index_ptr, max_index_ptr; GLboolean fallback = GL_FALSE; int i; @@ -1083,20 +1083,6 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, if (ctx->NewState) _mesa_update_state( ctx ); - switch (type) { - case GL_UNSIGNED_INT: - index_type_size = 4; - break; - case GL_UNSIGNED_SHORT: - index_type_size = 2; - break; - case GL_UNSIGNED_BYTE: - index_type_size = 1; - break; - default: - assert(0); - } - min_index_ptr = (uintptr_t)indices[0]; max_index_ptr = 0; for (i = 0; i < primcount; i++) { |