mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 17:50:11 +01:00
mesa: added _mesa_format_image_size64()
This commit is contained in:
parent
7bfbd88d2c
commit
74c324fdba
2 changed files with 34 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue