summaryrefslogtreecommitdiff
path: root/src/mesa/main/formats.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-11-24 12:00:16 -0700
committerBrian Paul <brianp@vmware.com>2010-11-24 12:11:23 -0700
commit74c324fdbaebb7accaee668f2bc54af4699d0025 (patch)
treebfe3e0e7425af3f1f804b1cfb0c40a2a79acae1e /src/mesa/main/formats.c
parent7bfbd88d2cc4c7e7c1c2fe02b0d223f4a3ea8db2 (diff)
mesa: added _mesa_format_image_size64()
Diffstat (limited to 'src/mesa/main/formats.c')
-rw-r--r--src/mesa/main/formats.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index f689d99df8..cd9eb81852 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)