summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2016-07-14 15:50:18 -0600
committerBrian Paul <[email protected]>2016-07-15 14:24:34 -0600
commit9a23a177b90ea60ba45b8b5090b832c87d595346 (patch)
treea0207872881931ca186401e0e0eea833acddeaab /src/mesa/main/teximage.c
parent39183ea971a9fd3fc001b5a5a43df1c890525681 (diff)
mesa: handle numLevels, numSamples in _mesa_test_proxy_teximage()
If numSamples > 0, we can compute the size of the whole mipmapped texture. That's the case for glTexStorage(GL_PROXY_TEXTURE_x). Also, multiply the texture size by numSamples for MSAA textures. Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index c75f60570c2..10232d65658 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -40,6 +40,7 @@
#include "image.h"
#include "imports.h"
#include "macros.h"
+#include "mipmap.h"
#include "multisample.h"
#include "pixelstore.h"
#include "state.h"
@@ -1268,12 +1269,50 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target,
mesa_format format, GLuint numSamples,
GLint width, GLint height, GLint depth)
{
+ uint64_t bytes, mbytes;
+
+ assert(numSamples > 0);
+
+ if (numLevels > 0) {
+ /* Compute total memory for a whole mipmap. This is the path
+ * taken for glTexStorage(GL_PROXY_TEXTURE_x).
+ */
+ unsigned l;
+
+ assert(level == 0);
+
+ bytes = 0;
+
+ for (l = 0; l < numLevels; l++) {
+ GLint nextWidth, nextHeight, nextDepth;
+
+ bytes += _mesa_format_image_size64(format, width, height, depth);
+
+ if (_mesa_next_mipmap_level_size(target, 0, width, height, depth,
+ &nextWidth, &nextHeight,
+ &nextDepth)) {
+ width = nextWidth;
+ height = nextHeight;
+ depth = nextDepth;
+ } else {
+ break;
+ }
+ }
+ } else {
+ /* We just compute the size of one mipmap level. This is the path
+ * taken for glTexImage(GL_PROXY_TEXTURE_x).
+ */
+ bytes = _mesa_format_image_size64(format, width, height, depth);
+ }
+
+ bytes *= _mesa_num_tex_faces(target);
+ bytes *= numSamples;
+
+ mbytes = bytes / (1024 * 1024); /* convert to MB */
+
/* We just check if the image size is less than MaxTextureMbytes.
* Some drivers may do more specific checks.
*/
- uint64_t bytes = _mesa_format_image_size64(format, width, height, depth);
- uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */
- mbytes *= _mesa_num_tex_faces(target);
return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes;
}