[Mesa-dev] [PATCH 4/4] mesa: handle numLevels, numSamples in _mesa_test_proxy_teximage()
Brian Paul
brianp at vmware.com
Fri Jul 15 19:34:44 UTC 2016
On 07/15/2016 01:19 PM, Anuj Phogat wrote:
> On Fri, Jul 15, 2016 at 10:14 AM, Brian Paul <brianp at vmware.com> wrote:
>> 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.
>> ---
>> src/mesa/main/teximage.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
>> 1 file changed, 45 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
>> index c75f605..0f13d61 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,53 @@ _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;
>> +
>> + /* XXX this doesn't yet account for multisampling */
>> + 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 {
> nitpick. Use } 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);
> Don't we need to multiply bytes by _mesa_num_tex_faces() here too?
Uh, that's done a few lines below.
>> + }
>> +
>> + 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;
>> }
>>
>> --
>> 1.9.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=CwIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=Chw7SvWUSVQKjs40uL5HS7a3CnCLscN8vvbeFek5DJ8&s=OMMsCQ7_rpU1xc2WbqI6X64jcC4_RwtUhV_nnNtgtCE&e=
More information about the mesa-dev
mailing list