aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texstore.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/texstore.c')
-rw-r--r--mesalib/src/mesa/main/texstore.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 9281aa9ea..0e13d8903 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -3791,24 +3791,22 @@ _mesa_get_texstore_func(gl_format format)
}
-static GLboolean
-_mesa_texstore_memcpy(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_needs_transfer_ops(struct gl_context *ctx,
+ GLenum baseInternalFormat,
+ gl_format dstFormat)
{
GLenum dstType;
- /* There are different restrictions depending on the base format... */
+ /* There are different rules 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;
+ return ctx->Pixel.DepthScale != 1.0f ||
+ ctx->Pixel.DepthBias != 0.0f;
case GL_STENCIL_INDEX:
- break;
+ return GL_FALSE;
default:
/* Color formats.
@@ -3817,10 +3815,20 @@ _mesa_texstore_memcpy(TEXSTORE_PARAMS)
*/
dstType = _mesa_get_format_datatype(dstFormat);
- if (dstType != GL_INT && dstType != GL_UNSIGNED_INT &&
- ctx->_ImageTransferState) {
- return GL_FALSE;
- }
+ return dstType != GL_INT && dstType != GL_UNSIGNED_INT &&
+ ctx->_ImageTransferState;
+ }
+}
+
+
+GLboolean
+_mesa_texstore_can_use_memcpy(struct gl_context *ctx,
+ GLenum baseInternalFormat, gl_format dstFormat,
+ GLenum srcFormat, GLenum srcType,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ if (_mesa_texstore_needs_transfer_ops(ctx, baseInternalFormat, dstFormat)) {
+ return GL_FALSE;
}
/* The base internal format and the base Mesa format must match. */
@@ -3834,6 +3842,17 @@ _mesa_texstore_memcpy(TEXSTORE_PARAMS)
return GL_FALSE;
}
+ return GL_TRUE;
+}
+
+static GLboolean
+_mesa_texstore_memcpy(TEXSTORE_PARAMS)
+{
+ if (!_mesa_texstore_can_use_memcpy(ctx, baseInternalFormat, dstFormat,
+ srcFormat, srcType, srcPacking)) {
+ return GL_FALSE;
+ }
+
memcpy_texture(ctx, dims,
dstFormat,
dstRowStride, dstSlices,