diff options
author | Dave Airlie <[email protected]> | 2015-04-05 13:19:18 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2015-04-23 10:11:26 +1000 |
commit | 782e71cc078308dddd5d6f9505bff0cb8e67f455 (patch) | |
tree | 709dce5d40f64874735cb0907c54cb6738d87703 /src/mesa/main/texgetimage.c | |
parent | 1948880720a631f959c6fa7f5bc533f26619a31a (diff) |
mesa: finish implementing ARB_texture_stencil8 (v5)
Parts of this were implemented previously, so finish it off.
v2: fix getteximage falling into the integer check
add fixes for the FBO paths, (fbo-stencil8 test).
v3: fix getteximage path harder.
v4: remove swapbytes from getteximage path (Ilia)
v5: brown paper bag the swapbytes removal. (Ilia)
Reviewed-by: Ilia Mirkin <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/main/texgetimage.c')
-rw-r--r-- | src/mesa/main/texgetimage.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 908bb9b1ce6..92b4d6795c6 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -175,6 +175,51 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, } } +/** + * glGetTexImage for stencil pixels. + */ +static void +get_tex_stencil(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + GLint img, row; + + assert(format == GL_STENCIL_INDEX); + + for (img = 0; img < depth; img++) { + GLubyte *srcMap; + GLint rowstride; + + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, img, + 0, 0, width, height, GL_MAP_READ_BIT, + &srcMap, &rowstride); + + if (srcMap) { + for (row = 0; row < height; row++) { + const GLubyte *src = srcMap + row * rowstride; + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + _mesa_unpack_ubyte_stencil_row(texImage->TexFormat, + width, + (const GLuint *) src, + dest); + } + + ctx->Driver.UnmapTextureImage(ctx, texImage, img); + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + break; + } + } +} + /** * glGetTexImage for YCbCr pixels. @@ -684,6 +729,9 @@ _mesa_GetTexImage_sw(struct gl_context *ctx, else if (format == GL_DEPTH_STENCIL_EXT) { get_tex_depth_stencil(ctx, dimensions, format, type, pixels, texImage); } + else if (format == GL_STENCIL_INDEX) { + get_tex_stencil(ctx, dimensions, format, type, pixels, texImage); + } else if (format == GL_YCBCR_MESA) { get_tex_ycbcr(ctx, dimensions, format, type, pixels, texImage); } @@ -879,7 +927,7 @@ getteximage_error_check(struct gl_context *ctx, "glGetTex%sImage(format mismatch)", suffix); return GL_TRUE; } - else if (_mesa_is_enum_format_integer(format) != + else if (!_mesa_is_stencil_format(format) && _mesa_is_enum_format_integer(format) != _mesa_is_format_integer(texImage->TexFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTex%sImage(format mismatch)", suffix); |