[Mesa-dev] [PATCH] mesa/texstore: Don't use the _mesa_swizzle_and_convert if we need transfer ops
Jason Ekstrand
jason at jlekstrand.net
Wed Aug 13 11:05:21 PDT 2014
The _mesa_swizzle_and_convert path can't do transfer ops, so we should bail
if they're needed.
Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
src/mesa/main/texstore.c | 63 +++++++++++++++++++++++++-----------------------
1 file changed, 33 insertions(+), 30 deletions(-)
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 42cebbd..50c7dde 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1462,6 +1462,36 @@ invert_swizzle(uint8_t dst[4], const uint8_t src[4])
dst[i] = j;
}
+GLboolean
+_mesa_texstore_needs_transfer_ops(struct gl_context *ctx,
+ GLenum baseInternalFormat,
+ mesa_format dstFormat)
+{
+ GLenum dstType;
+
+ /* There are different rules depending on the base format. */
+ switch (baseInternalFormat) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_STENCIL:
+ return ctx->Pixel.DepthScale != 1.0f ||
+ ctx->Pixel.DepthBias != 0.0f;
+
+ case GL_STENCIL_INDEX:
+ return GL_FALSE;
+
+ default:
+ /* Color formats.
+ * Pixel transfer ops (scale, bias, table lookup) do not apply
+ * to integer formats.
+ */
+ dstType = _mesa_get_format_datatype(dstFormat);
+
+ return dstType != GL_INT && dstType != GL_UNSIGNED_INT &&
+ ctx->_ImageTransferState;
+ }
+}
+
+
/** Store a texture by per-channel conversions and swizzling.
*
* This function attempts to perform a texstore operation by doing simple
@@ -1495,6 +1525,9 @@ texstore_swizzle(TEXSTORE_PARAMS)
if (!is_array)
return GL_FALSE;
+ if (_mesa_texstore_needs_transfer_ops(ctx, baseInternalFormat, dstFormat))
+ return GL_FALSE;
+
switch (srcType) {
case GL_FLOAT:
case GL_UNSIGNED_BYTE:
@@ -1762,36 +1795,6 @@ texstore_rgba(TEXSTORE_PARAMS)
}
GLboolean
-_mesa_texstore_needs_transfer_ops(struct gl_context *ctx,
- GLenum baseInternalFormat,
- mesa_format dstFormat)
-{
- GLenum dstType;
-
- /* There are different rules depending on the base format. */
- switch (baseInternalFormat) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_STENCIL:
- return ctx->Pixel.DepthScale != 1.0f ||
- ctx->Pixel.DepthBias != 0.0f;
-
- case GL_STENCIL_INDEX:
- return GL_FALSE;
-
- default:
- /* Color formats.
- * Pixel transfer ops (scale, bias, table lookup) do not apply
- * to integer formats.
- */
- dstType = _mesa_get_format_datatype(dstFormat);
-
- return dstType != GL_INT && dstType != GL_UNSIGNED_INT &&
- ctx->_ImageTransferState;
- }
-}
-
-
-GLboolean
_mesa_texstore_can_use_memcpy(struct gl_context *ctx,
GLenum baseInternalFormat, mesa_format dstFormat,
GLenum srcFormat, GLenum srcType,
--
2.0.4
More information about the mesa-dev
mailing list