From 4bf27ed7ed4952bcb09d1bcde16fb9bc6a58bc4d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 28 Jan 2013 21:18:02 +0100 Subject: [PATCH] mesa: implement common texstore memcpy function for all formats Reviewed-by: Brian Paul --- src/mesa/main/texstore.c | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 6e7ce237f6f..edbe4b9a31a 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -4317,6 +4317,58 @@ _mesa_get_texstore_func(gl_format format) } +static GLboolean +_mesa_texstore_memcpy(TEXSTORE_PARAMS) +{ + GLenum dstType; + + /* There are different restrictions depending on the base format... */ + switch (baseInternalFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL: + /* Depth scale and bias are not allowed. */ + if (ctx->Pixel.DepthScale != 1.0f || + ctx->Pixel.DepthBias != 0.0f) { + return GL_FALSE; + } + break; + + case GL_STENCIL_INDEX: + break; + + default: + /* Color formats. + * Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + dstType = _mesa_get_format_datatype(dstFormat); + + if (dstType != GL_INT && dstType != GL_UNSIGNED_INT && + ctx->_ImageTransferState) { + return GL_FALSE; + } + } + + /* The base internal format and the base Mesa format must match. */ + if (baseInternalFormat != _mesa_get_format_base_format(dstFormat)) { + return GL_FALSE; + } + + /* The Mesa format must match the input format and type. */ + if (!_mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType, + srcPacking->SwapBytes)) { + return GL_FALSE; + } + + memcpy_texture(ctx, dims, + dstFormat, + dstRowStride, dstSlices, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + return GL_TRUE; +} + + /** * Store user data into texture memory. * Called via glTex[Sub]Image1/2/3D() @@ -4327,6 +4379,14 @@ _mesa_texstore(TEXSTORE_PARAMS) StoreTexImageFunc storeImage; GLboolean success; + if (_mesa_texstore_memcpy(ctx, dims, baseInternalFormat, + dstFormat, + dstRowStride, dstSlices, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking)) { + return GL_TRUE; + } + storeImage = _mesa_get_texstore_func(dstFormat); success = storeImage(ctx, dims, baseInternalFormat, -- 2.30.2