X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Ftexgetimage.c;h=da610798e1232822da5eb0d6e7416731bc68197e;hb=751fe9058bc15f4f8608f0fdc02209542991ff23;hp=00134ea9ffbbfb942eb05d349da45fe9809099c6;hpb=3293bcdc80cdfa20a2381aae2b94505bdf95d857;p=mesa.git diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 00134ea9ffb..da610798e12 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -35,6 +35,9 @@ #include "context.h" #include "formats.h" #include "image.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "pack.h" #include "texgetimage.h" #include "teximage.h" @@ -63,7 +66,7 @@ type_with_negative_values(GLenum type) * glGetTexImage for color index pixels. */ static void -get_tex_color_index(GLcontext *ctx, GLuint dimensions, +get_tex_color_index(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_image *texImage) { @@ -111,7 +114,7 @@ get_tex_color_index(GLcontext *ctx, GLuint dimensions, * glGetTexImage for depth/Z pixels. */ static void -get_tex_depth(GLcontext *ctx, GLuint dimensions, +get_tex_depth(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_image *texImage) { @@ -119,10 +122,15 @@ get_tex_depth(GLcontext *ctx, GLuint dimensions, const GLint height = texImage->Height; const GLint depth = texImage->Depth; GLint img, row, col; + GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat)); + + if (!depthRow) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + return; + } for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { - GLfloat depthRow[MAX_WIDTH]; void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); @@ -134,6 +142,8 @@ get_tex_depth(GLcontext *ctx, GLuint dimensions, _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); } } + + free(depthRow); } @@ -141,7 +151,7 @@ get_tex_depth(GLcontext *ctx, GLuint dimensions, * glGetTexImage for depth/stencil pixels. */ static void -get_tex_depth_stencil(GLcontext *ctx, GLuint dimensions, +get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_image *texImage) { @@ -171,7 +181,7 @@ get_tex_depth_stencil(GLcontext *ctx, GLuint dimensions, * glGetTexImage for YCbCr pixels. */ static void -get_tex_ycbcr(GLcontext *ctx, GLuint dimensions, +get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_image *texImage) { @@ -234,7 +244,7 @@ linear_to_nonlinear(GLfloat cl) * glGetTexImagefor sRGB pixels; */ static void -get_tex_srgb(GLcontext *ctx, GLuint dimensions, +get_tex_srgb(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_image *texImage) { @@ -243,6 +253,12 @@ get_tex_srgb(GLcontext *ctx, GLuint dimensions, const GLint depth = texImage->Depth; const GLbitfield transferOps = 0x0; GLint img, row; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + return; + } for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { @@ -250,7 +266,6 @@ get_tex_srgb(GLcontext *ctx, GLuint dimensions, width, height, format, type, img, row, 0); - GLfloat rgba[MAX_WIDTH][4]; GLint col; /* convert row to RGBA format */ @@ -278,6 +293,8 @@ get_tex_srgb(GLcontext *ctx, GLuint dimensions, &ctx->Pack, transferOps); } } + + free(rgba); } @@ -285,7 +302,7 @@ get_tex_srgb(GLcontext *ctx, GLuint dimensions, static INLINE void -get_tex_srgb(GLcontext *ctx, GLuint dimensions, +get_tex_srgb(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_image *texImage) { @@ -301,7 +318,7 @@ get_tex_srgb(GLcontext *ctx, GLuint dimensions, * This is the slow way since we use texture sampling. */ static void -get_tex_rgba(GLcontext *ctx, GLuint dimensions, +get_tex_rgba(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_image *texImage) { @@ -313,13 +330,18 @@ get_tex_rgba(GLcontext *ctx, GLuint dimensions, */ GLbitfield transferOps = 0x0; GLint img, row; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + return; + } for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); - GLfloat rgba[MAX_WIDTH][4]; GLint col; GLenum dataType = _mesa_get_format_datatype(texImage->TexFormat); @@ -363,6 +385,8 @@ get_tex_rgba(GLcontext *ctx, GLuint dimensions, &ctx->Pack, transferOps); } } + + free(rgba); } @@ -371,7 +395,7 @@ get_tex_rgba(GLcontext *ctx, GLuint dimensions, * \return GL_TRUE if done, GL_FALSE otherwise */ static GLboolean -get_tex_memcpy(GLcontext *ctx, GLenum format, GLenum type, GLvoid *pixels, +get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, const struct gl_texture_object *texObj, const struct gl_texture_image *texImage) { @@ -410,11 +434,21 @@ get_tex_memcpy(GLcontext *ctx, GLenum format, GLenum type, GLvoid *pixels, type == GL_UNSIGNED_BYTE) { memCopy = GL_TRUE; } + else if (texImage->TexFormat == MESA_FORMAT_L16 && + format == GL_LUMINANCE && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } else if (texImage->TexFormat == MESA_FORMAT_A8 && format == GL_ALPHA && type == GL_UNSIGNED_BYTE) { memCopy = GL_TRUE; } + else if (texImage->TexFormat == MESA_FORMAT_A16 && + format == GL_ALPHA && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } } if (memCopy) { @@ -451,7 +485,7 @@ get_tex_memcpy(GLcontext *ctx, GLenum format, GLenum type, GLvoid *pixels, * The texture image must be mapped. */ void -_mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, +_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels, struct gl_texture_object *texObj, struct gl_texture_image *texImage) @@ -528,7 +562,7 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, * All error checking will have been done before this routine is called. */ void -_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, +_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, GLvoid *img, struct gl_texture_object *texObj, struct gl_texture_image *texImage) @@ -585,7 +619,7 @@ _mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, * \return GL_TRUE if any error, GL_FALSE if no errors. */ static GLboolean -getteximage_error_check(GLcontext *ctx, GLenum target, GLint level, +getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ) { struct gl_texture_object *texObj; @@ -771,7 +805,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, * \return GL_TRUE if any error, GL_FALSE if no errors. */ static GLboolean -getcompressedteximage_error_check(GLcontext *ctx, GLenum target, GLint level, +getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, GLvoid *img) { struct gl_texture_object *texObj;