Mesa (master): mesa: added _mesa_format_image_size64()
Brian Paul
brianp at kemper.freedesktop.org
Wed Nov 24 19:12:20 UTC 2010
Module: Mesa
Branch: master
Commit: 74c324fdbaebb7accaee668f2bc54af4699d0025
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=74c324fdbaebb7accaee668f2bc54af4699d0025
Author: Brian Paul <brianp at vmware.com>
Date: Wed Nov 24 12:00:16 2010 -0700
mesa: added _mesa_format_image_size64()
---
src/mesa/main/formats.c | 30 ++++++++++++++++++++++++++++++
src/mesa/main/formats.h | 4 ++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index f689d99..cd9eb81 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1073,6 +1073,36 @@ _mesa_format_image_size(gl_format format, GLsizei width,
}
+/**
+ * Same as _mesa_format_image_size() but returns a 64-bit value to
+ * accomodate very large textures.
+ */
+uint64_t
+_mesa_format_image_size64(gl_format format, GLsizei width,
+ GLsizei height, GLsizei depth)
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ /* Strictly speaking, a conditional isn't needed here */
+ if (info->BlockWidth > 1 || info->BlockHeight > 1) {
+ /* compressed format (2D only for now) */
+ const uint64_t bw = info->BlockWidth, bh = info->BlockHeight;
+ const uint64_t wblocks = (width + bw - 1) / bw;
+ const uint64_t hblocks = (height + bh - 1) / bh;
+ const uint64_t sz = wblocks * hblocks * info->BytesPerBlock;
+ assert(depth == 1);
+ return sz;
+ }
+ else {
+ /* non-compressed */
+ const uint64_t sz = ((uint64_t) width *
+ (uint64_t) height *
+ (uint64_t) depth *
+ info->BytesPerBlock);
+ return sz;
+ }
+}
+
+
GLint
_mesa_format_row_stride(gl_format format, GLsizei width)
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index eeb460d..997229b 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -209,6 +209,10 @@ extern GLuint
_mesa_format_image_size(gl_format format, GLsizei width,
GLsizei height, GLsizei depth);
+extern uint64_t
+_mesa_format_image_size64(gl_format format, GLsizei width,
+ GLsizei height, GLsizei depth);
+
extern GLint
_mesa_format_row_stride(gl_format format, GLsizei width);
More information about the mesa-commit
mailing list