summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-01-28 21:18:02 +0100
committerMarek Olšák <[email protected]>2013-02-11 19:43:01 +0100
commit4bf27ed7ed4952bcb09d1bcde16fb9bc6a58bc4d (patch)
tree66d4112a0533c0687c2b2c0f3fa4044d554849c6 /src/mesa/main/texstore.c
parent967b21df6a9b23bfe9f3324c3e41133e41417e94 (diff)
mesa: implement common texstore memcpy function for all formats
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c60
1 files changed, 60 insertions, 0 deletions
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,