aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-06-04 09:07:26 +0200
committermarha <marha@users.sourceforge.net>2013-06-04 09:48:59 +0200
commitfd2b28971a2afbf54b6cb641aa6a2d5e940a1450 (patch)
tree1b103a8b2114125ffa8d79827d931aba3744a0d2 /mesalib/src/mesa/main/teximage.c
parent62a1ce0583cf41c173f4edb91511430b552e04da (diff)
downloadvcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.tar.gz
vcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.tar.bz2
vcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.zip
xwininfo fontconfig libX11 libXau libXdmcp libXext mesa libXinerama libxcb libxcb/xcb-proto libfontenc pixman xkbcomp mkfontscale xkeyboard-config git update 4 Jun 2013
xserver commit c21344add2fc589df83b29be5831c36a372201bd libxcb commit 9ae84ad187e2ba440c40f44b8eb21c82c2fdbf12 libxcb/xcb-proto commit bdfedfa57a13ff805580cfacafc70f9cc55df363 xkeyboard-config commit dad9ade4e83d1ef5a517fcc4cc9ad3a79b47acce libX11 commit 8496122eb00ce6cd5d2308ee54f64b68c378e455 libXdmcp commit 0b443c1b769b9c9a3b45b4252afe07e18b709ff4 libXext commit d8366afbb0d2e4fbb1e419b1187f490522270bea libfontenc commit 3acba630d8b57084f7e92c15732408711ed5137a libXinerama commit 6e1d1dc328ba8162bba2f4694e7f3c706a1491ff libXau commit 899790011304c4029e15abf410e49ce7cec17e0a xkbcomp commit ed582f4fccd4e23abcfba8b3b03649fea6414f44 pixman commit 2acfac5f8e097ee2ae225d986f981b55d65dd152 mkfontscale commit 19e2cb7c6a3ec2c5b1bc0d24866fa685eef0ee13 xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 fontconfig commit cd9b1033a68816a7acfbba1718ba0aa5888f6ec7 mesa commit 7bafd88c153e395274b632e7eae4bc9fc3aec1d2
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r--mesalib/src/mesa/main/teximage.c108
1 files changed, 65 insertions, 43 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 784b389a7..9aaa63f13 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -17,9 +17,10 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
@@ -39,7 +40,6 @@
#include "image.h"
#include "imports.h"
#include "macros.h"
-#include "mfeatures.h"
#include "multisample.h"
#include "state.h"
#include "texcompress.h"
@@ -180,7 +180,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
default:
; /* fallthrough */
}
-
+
if (ctx->Extensions.TDFX_texture_compression_FXT1) {
switch (internalFormat) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
@@ -315,15 +315,17 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
case GL_SRGB_EXT:
case GL_SRGB8_EXT:
case GL_COMPRESSED_SRGB_EXT:
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
return GL_RGB;
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ return ctx->Extensions.EXT_texture_compression_s3tc ? GL_RGB : -1;
case GL_SRGB_ALPHA_EXT:
case GL_SRGB8_ALPHA8_EXT:
case GL_COMPRESSED_SRGB_ALPHA_EXT:
+ return GL_RGBA;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return GL_RGBA;
+ return ctx->Extensions.EXT_texture_compression_s3tc ? GL_RGBA : -1;
case GL_SLUMINANCE_ALPHA_EXT:
case GL_SLUMINANCE8_ALPHA8_EXT:
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
@@ -613,7 +615,7 @@ set_tex_image(struct gl_texture_object *tObj,
/**
* Allocate a texture image structure.
- *
+ *
* Called via ctx->Driver.NewTextureImage() unless overriden by a device
* driver.
*
@@ -868,7 +870,7 @@ _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
if (!texObj)
return NULL;
-
+
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
if (!texImage) {
texImage = ctx->Driver.NewTextureImage(ctx);
@@ -974,7 +976,7 @@ get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level)
*
* \param ctx GL context.
* \param target texture target.
- *
+ *
* \return the maximum number of allowed mipmap levels for the given
* texture target, or zero if passed a bad target.
*
@@ -1536,13 +1538,13 @@ error_check_subtexture_dimensions(struct gl_context *ctx,
}
/* check xoffset and width */
- if (xoffset < -destImage->Border) {
+ if (xoffset < - (GLint) destImage->Border) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset)",
function, dims);
return GL_TRUE;
}
- if (xoffset + subWidth > destImage->Width) {
+ if (xoffset + subWidth > (GLint) destImage->Width) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset+width)",
function, dims);
return GL_TRUE;
@@ -1556,7 +1558,7 @@ error_check_subtexture_dimensions(struct gl_context *ctx,
function, dims);
return GL_TRUE;
}
- if (yoffset + subHeight > destImage->Height) {
+ if (yoffset + subHeight > (GLint) destImage->Height) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset+height)",
function, dims);
return GL_TRUE;
@@ -1594,18 +1596,24 @@ error_check_subtexture_dimensions(struct gl_context *ctx,
return GL_TRUE;
}
- /* size must be multiple of bw by bh or equal to whole texture size */
- if ((subWidth % bw != 0) && subWidth != destImage->Width) {
+ /* The size must be a multiple of bw x bh, or we must be using a
+ * offset+size that exactly hits the edge of the image. This
+ * is important for small mipmap levels (1x1, 2x1, etc) and for
+ * NPOT textures.
+ */
+ if ((subWidth % bw != 0) &&
+ (xoffset + subWidth != (GLint) destImage->Width)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s%dD(width = %d)", function, dims, subWidth);
return GL_TRUE;
}
- if ((subHeight % bh != 0) && subHeight != destImage->Height) {
+ if ((subHeight % bh != 0) &&
+ (yoffset + subHeight != (GLint) destImage->Height)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s%dD(height = %d)", function, dims, subHeight);
return GL_TRUE;
- }
+ }
}
return GL_FALSE;
@@ -1705,7 +1713,7 @@ target_can_be_compressed(const struct gl_context *ctx, GLenum target,
return ctx->Extensions.ARB_texture_cube_map_array;
default:
return GL_FALSE;
- }
+ }
}
@@ -1867,7 +1875,7 @@ compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth,
/**
* Test the glTexImage[123]D() parameters for errors.
- *
+ *
* \param ctx GL context.
* \param dimensions texture image dimensions (must be 1, 2 or 3).
* \param target texture target given by the user (already validated).
@@ -1879,7 +1887,7 @@ compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth,
* \param height image height given by the user.
* \param depth image depth given by the user.
* \param border image border given by the user.
- *
+ *
* \return GL_TRUE if a error is found, GL_FALSE otherwise
*
* Verifies each of the parameters against the constants specified in
@@ -1949,12 +1957,12 @@ texture_error_check( struct gl_context *ctx,
internalFormat);
} else {
if (format != internalFormat) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexImage%dD(format = %s, internalFormat = %s)",
- dimensions,
- _mesa_lookup_enum_by_nr(format),
- _mesa_lookup_enum_by_nr(internalFormat));
- return GL_TRUE;
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage%dD(format = %s, internalFormat = %s)",
+ dimensions,
+ _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(internalFormat));
+ return GL_TRUE;
}
err = _mesa_es_error_check_format_and_type(format, type, dimensions);
@@ -2258,7 +2266,7 @@ error:
/**
* Test glTexSubImage[123]D() parameters for errors.
- *
+ *
* \param ctx GL context.
* \param dimensions texture image dimensions (must be 1, 2 or 3).
* \param target texture target given by the user (already validated)
@@ -2271,7 +2279,7 @@ error:
* \param width image width given by the user.
* \param height image height given by the user.
* \param depth image depth given by the user.
- *
+ *
* \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
*
* Verifies each of the parameters against the constants specified in
@@ -2376,7 +2384,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
/**
* Test glCopyTexImage[12]D() parameters for errors.
- *
+ *
* \param ctx GL context.
* \param dimensions texture image dimensions (must be 1, 2 or 3).
* \param target texture target given by the user.
@@ -2385,9 +2393,9 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
* \param width image width given by the user.
* \param height image height given by the user.
* \param border texture border.
- *
+ *
* \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
- *
+ *
* Verifies each of the parameters against the constants specified in
* __struct gl_contextRec::Const and the supported extensions, and according
* to the OpenGL specification.
@@ -2407,7 +2415,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
_mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)",
dimensions, _mesa_lookup_enum_by_nr(target));
return GL_TRUE;
- }
+ }
/* level check */
if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {
@@ -2753,9 +2761,8 @@ check_rtt_cb(GLuint key, void *data, void *userData)
att->Texture == texObj &&
att->TextureLevel == level &&
att->CubeMapFace == face) {
- ASSERT(_mesa_get_attachment_teximage(att));
- /* Tell driver about the new renderbuffer texture */
- ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att);
+ _mesa_update_texture_renderbuffer(ctx, ctx->DrawBuffer, att);
+ ASSERT(att->Renderbuffer->TexImage);
/* Mark fb status as indeterminate to force re-validation */
fb->_Status = 0;
}
@@ -2920,6 +2927,7 @@ _mesa_choose_texture_format(struct gl_context *ctx,
return f;
}
+
/**
* Adjust pixel unpack params and image dimensions to strip off the
* one-pixel texture border.
@@ -2957,7 +2965,9 @@ strip_texture_border(GLenum target,
*height = *height - 2; /* reduce the height by two border pixels */
}
- if (*depth >= 3 && target != GL_TEXTURE_2D_ARRAY && target != GL_TEXTURE_CUBE_MAP_ARRAY) {
+ if (*depth >= 3 &&
+ target != GL_TEXTURE_2D_ARRAY &&
+ target != GL_TEXTURE_CUBE_MAP_ARRAY) {
unpackNew->SkipImages++; /* skip the border */
*depth = *depth - 2; /* reduce the depth by two border pixels */
}
@@ -3309,7 +3319,7 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
_mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)",
dims, _mesa_lookup_enum_by_nr(target));
return;
- }
+ }
if (ctx->NewState & _NEW_PIXEL)
_mesa_update_state(ctx);
@@ -3694,7 +3704,7 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
targetOK = GL_FALSE;
break;
}
-
+
if (!targetOK) {
_mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage%uD(target)",
dims);
@@ -4027,6 +4037,7 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
}
}
+
static gl_format
validate_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
{
@@ -4098,6 +4109,7 @@ texbufferrange(struct gl_context *ctx, GLenum target, GLenum internalFormat,
_mesa_unlock_texture(ctx, texObj);
}
+
/** GL_ARB_texture_buffer_object */
void GLAPIENTRY
_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
@@ -4124,6 +4136,7 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
texbufferrange(ctx, target, internalFormat, bufObj, 0, buffer ? -1 : 0);
}
+
/** GL_ARB_texture_buffer_range */
void GLAPIENTRY
_mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
@@ -4164,6 +4177,7 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
texbufferrange(ctx, target, internalFormat, bufObj, offset, size);
}
+
static GLboolean
is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat)
{
@@ -4174,6 +4188,7 @@ is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat)
return baseFormat != 0 && baseFormat != GL_STENCIL_INDEX;
}
+
/** GL_ARB_texture_multisample */
static GLboolean
check_multisample_target(GLuint dims, GLenum target)
@@ -4192,6 +4207,7 @@ check_multisample_target(GLuint dims, GLenum target)
}
}
+
static void
teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
GLint internalformat, GLsizei width, GLsizei height,
@@ -4309,7 +4325,6 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
texImage->FixedSampleLocations = fixedsamplelocations;
if (width > 0 && height > 0 && depth > 0) {
-
if (!ctx->Driver.AllocTextureStorage(ctx, texObj, 1,
width, height, depth)) {
/* tidy up the texture image state. strictly speaking,
@@ -4326,15 +4341,18 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
}
}
+
void GLAPIENTRY
_mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
GLint internalformat, GLsizei width,
GLsizei height, GLboolean fixedsamplelocations)
{
teximagemultisample(2, target, samples, internalformat,
- width, height, 1, fixedsamplelocations, GL_FALSE, "glTexImage2DMultisample");
+ width, height, 1, fixedsamplelocations, GL_FALSE,
+ "glTexImage2DMultisample");
}
+
void GLAPIENTRY
_mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
GLint internalformat, GLsizei width,
@@ -4342,7 +4360,8 @@ _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
GLboolean fixedsamplelocations)
{
teximagemultisample(3, target, samples, internalformat,
- width, height, depth, fixedsamplelocations, GL_FALSE, "glTexImage3DMultisample");
+ width, height, depth, fixedsamplelocations, GL_FALSE,
+ "glTexImage3DMultisample");
}
@@ -4352,9 +4371,11 @@ _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
GLsizei height, GLboolean fixedsamplelocations)
{
teximagemultisample(2, target, samples, internalformat,
- width, height, 1, fixedsamplelocations, GL_TRUE, "glTexStorage2DMultisample");
+ width, height, 1, fixedsamplelocations, GL_TRUE,
+ "glTexStorage2DMultisample");
}
+
void GLAPIENTRY
_mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width,
@@ -4362,5 +4383,6 @@ _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
GLboolean fixedsamplelocations)
{
teximagemultisample(3, target, samples, internalformat,
- width, height, depth, fixedsamplelocations, GL_TRUE, "glTexStorage3DMultisample");
+ width, height, depth, fixedsamplelocations, GL_TRUE,
+ "glTexStorage3DMultisample");
}