summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/formats.c22
-rw-r--r--src/mesa/main/formats.h4
2 files changed, 25 insertions, 1 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 82843a3291..ebe59f8960 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -602,12 +602,13 @@ _mesa_format_image_size(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 */
const GLuint bw = info->BlockWidth, bh = info->BlockHeight;
const GLuint wblocks = (width + bw - 1) / bw;
const GLuint hblocks = (height + bh - 1) / bh;
- const GLuint sz = wblocks * hblocks * info->BytesPerBlock;
+ const GLuint sz = wblocks * hblocks * info->BytesPerBlock;
return sz;
}
else {
@@ -619,6 +620,25 @@ _mesa_format_image_size(gl_format format, GLsizei width,
+GLint
+_mesa_format_row_stride(gl_format format, GLsizei width)
+{
+ 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 */
+ const GLuint bw = info->BlockWidth;
+ const GLuint wblocks = (width + bw - 1) / bw;
+ const GLint stride = wblocks * info->BytesPerBlock;
+ return stride;
+ }
+ else {
+ const GLint stride = width * info->BytesPerBlock;
+ return stride;
+ }
+}
+
+
/**
* Do sanity checking of the format info table.
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index b91682809f..316ff1a8ec 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -206,6 +206,10 @@ extern GLuint
_mesa_format_image_size(gl_format format, GLsizei width,
GLsizei height, GLsizei depth);
+extern GLint
+_mesa_format_row_stride(gl_format format, GLsizei width);
+
+
extern void
_mesa_test_formats(void);