gallium/aux: include nr_samples in util_resource_size() computation
authorBrian Paul <brianp@vmware.com>
Thu, 7 Dec 2017 21:47:32 +0000 (14:47 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 12 Dec 2017 16:44:59 +0000 (09:44 -0700)
This function is only used in two places:
1. VMware driver, but only for HUD reporting
2. st/nine state tracker, used for texture memory accounting

Fixes: a69efa9482d ("util: add new util_resource_size() function in
u_resource.[ch]")

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/util/u_resource.c

index 66caaae840565ab5b8cd5b59bd456be5c8d6b133..ed6c1504fd8ca2e7d6d39fb0ab3de28ee11a9809 100644 (file)
@@ -42,6 +42,7 @@ util_resource_size(const struct pipe_resource *res)
    unsigned depth = res->depth0;
    unsigned size = 0;
    unsigned level;
+   unsigned samples = MAX2(1, res->nr_samples);
 
    for (level = 0; level <= res->last_level; level++) {
       unsigned slices;
@@ -54,7 +55,7 @@ util_resource_size(const struct pipe_resource *res)
          slices = res->array_size;
 
       size += (util_format_get_nblocksy(res->format, height) *
-               util_format_get_stride(res->format, width) * slices);
+               util_format_get_stride(res->format, width) * slices * samples);
 
       width  = u_minify(width, 1);
       height = u_minify(height, 1);