Confused about the generation of mipmap in metal?Generate mipmaped MTLTextures from AVFoundation camera streamInitialising texture of MTLPixelFormatR32Float in metalMetal kernel shader not workingHow are mipmapped textures sampled?Passing textures with UInt8 component type to Metal compute shaderMipmap sampler in Metal compute kernel (not vertex or fragment shader)Render to an offscreen framebuffer in metal2D Metal Rendering, Rotation, and Aspect RatioCan you generate only a subset of mipmaps for an MTLTexture using a texture view?Mixing Two Textures in Metal Shader

ICO or PNG Format?

How can I solve for the intersection points of two ellipses?

Not going forward with internship interview process

Different inverter (logic gate) symbols

What are the conventions for transcribing Semitic languages into Greek?

What game uses dice with sides powers of 2?

Is it legal for a company to enter an agreement not to hire employees from another company?

Why did the RAAF procure the F/A-18 despite being purpose-built for carriers?

Multirow in tabularx?

What does this double-treble double-bass staff mean?

How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?

Y2K... in 2019?

If "more guns less crime", how do gun advocates explain that the EU has less crime than the US?

Why do oscilloscopes use SMPSes instead of linear power supplies?

(11 of 11: Meta) What is Pyramid Cult's All-Time Favorite?

Why is transplanting a specific intact brain impossible if it is generally possible?

In SQL Server, why does backward scan of clustered index cannot use parallelism?

CTCI Chapter 1 : Palindrome Permutation

How is this kind of structure made?

A tool to replace all words with antonyms

As a 16 year old, how can I keep my money safe from my mother?

How many different ways are there to checkmate in the early game?

Bitcoin successfully deducted on sender wallet but did not reach receiver wallet

What does "sardine box" mean?



Confused about the generation of mipmap in metal?


Generate mipmaped MTLTextures from AVFoundation camera streamInitialising texture of MTLPixelFormatR32Float in metalMetal kernel shader not workingHow are mipmapped textures sampled?Passing textures with UInt8 component type to Metal compute shaderMipmap sampler in Metal compute kernel (not vertex or fragment shader)Render to an offscreen framebuffer in metal2D Metal Rendering, Rotation, and Aspect RatioCan you generate only a subset of mipmaps for an MTLTexture using a texture view?Mixing Two Textures in Metal Shader






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I set mipmapped to YES in texture2DDescriptorWithPixelFormat and call generateMipmapsForTexture method of MTLBlitCommandEncoder on given texture to automatically generate mipmaps.



The question is if I have set the mipmapped to YES, doesn't it means that the resulting image should be mipmapped, why should I need MTLBlitCommandEncoder to explicit generate mipmaps?










share|improve this question






























    2















    I set mipmapped to YES in texture2DDescriptorWithPixelFormat and call generateMipmapsForTexture method of MTLBlitCommandEncoder on given texture to automatically generate mipmaps.



    The question is if I have set the mipmapped to YES, doesn't it means that the resulting image should be mipmapped, why should I need MTLBlitCommandEncoder to explicit generate mipmaps?










    share|improve this question


























      2












      2








      2








      I set mipmapped to YES in texture2DDescriptorWithPixelFormat and call generateMipmapsForTexture method of MTLBlitCommandEncoder on given texture to automatically generate mipmaps.



      The question is if I have set the mipmapped to YES, doesn't it means that the resulting image should be mipmapped, why should I need MTLBlitCommandEncoder to explicit generate mipmaps?










      share|improve this question














      I set mipmapped to YES in texture2DDescriptorWithPixelFormat and call generateMipmapsForTexture method of MTLBlitCommandEncoder on given texture to automatically generate mipmaps.



      The question is if I have set the mipmapped to YES, doesn't it means that the resulting image should be mipmapped, why should I need MTLBlitCommandEncoder to explicit generate mipmaps?







      metal






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 8:31









      coulsonwangcoulsonwang

      366 bronze badges




      366 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1














          It's a bit confusing, so let's walk through it.



          texture2DDescriptorWithPixelFormat takes format, width, height and mipmapped as parameters. The mipmapped parameter is there to tell Metal to calculate the number of mip levels that resulting image will have, since there is no parameter to pass mip level count. Here's how it's described in documentation:




          mipmapped



          A Boolean indicating whether the resulting image should be
          mipmapped. If YES, then the mipmapLevelCount property in the returned
          descriptor is computed from width and height. If NO, then
          mipmapLevelCount is 1.




          If you would use newTextureWithDescriptor with texture descriptor you created explicitly, then there's no mipmapped parameter, since you explicitly pass number of mip levels in mipmapLevelCount property of MTLTextureDescriptor.



          Since you create a new texture, there's no reason to generate mipmaps, since the texture is empty.



          The generateMipmapsForTexture method is used to generate mipmaps for a texture that already has mip levels and you just need to populate them with mipmaps generated automatically.



          So, to get this straight, mipmapped parameter just tells Metal to create a texture that has mip levels, that you can later populate (if you want) with generateMipmapsForTexture (or in some other ways, such as using texture as color attachment in render pass with level specified).






          share|improve this answer



























          • What if set mipmapped to NO when creating texture, however in the later process found out that I need to generate mipmaps for that texture, what should I do then?

            – coulsonwang
            Mar 27 at 9:00











          • Create a new texture with mipmapped set to YES, copy the first mip layer of original texture to the new texture's first layer generate mipmap using blit encoder.

            – Egor Shkorov
            Mar 27 at 9:06












          • But, I think, since mipmapped texture should only take ~1.5 the space the texture withtout mipmaps takes, you should probably just create the textures that are likely to need mipmaps with mipmapped set to YES, if you aren't memory constrained.

            – Egor Shkorov
            Mar 27 at 9:11











          • If you are still confused, I can edit the answer, just try to describe the confusing part.

            – Egor Shkorov
            Mar 27 at 9:12











          • Always set mipmapped to `YES' seems a good way to avoid additional blit operation when need to generate mipmaps, does it will cause a performance issue?

            – coulsonwang
            Mar 27 at 9:13










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372742%2fconfused-about-the-generation-of-mipmap-in-metal%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          It's a bit confusing, so let's walk through it.



          texture2DDescriptorWithPixelFormat takes format, width, height and mipmapped as parameters. The mipmapped parameter is there to tell Metal to calculate the number of mip levels that resulting image will have, since there is no parameter to pass mip level count. Here's how it's described in documentation:




          mipmapped



          A Boolean indicating whether the resulting image should be
          mipmapped. If YES, then the mipmapLevelCount property in the returned
          descriptor is computed from width and height. If NO, then
          mipmapLevelCount is 1.




          If you would use newTextureWithDescriptor with texture descriptor you created explicitly, then there's no mipmapped parameter, since you explicitly pass number of mip levels in mipmapLevelCount property of MTLTextureDescriptor.



          Since you create a new texture, there's no reason to generate mipmaps, since the texture is empty.



          The generateMipmapsForTexture method is used to generate mipmaps for a texture that already has mip levels and you just need to populate them with mipmaps generated automatically.



          So, to get this straight, mipmapped parameter just tells Metal to create a texture that has mip levels, that you can later populate (if you want) with generateMipmapsForTexture (or in some other ways, such as using texture as color attachment in render pass with level specified).






          share|improve this answer



























          • What if set mipmapped to NO when creating texture, however in the later process found out that I need to generate mipmaps for that texture, what should I do then?

            – coulsonwang
            Mar 27 at 9:00











          • Create a new texture with mipmapped set to YES, copy the first mip layer of original texture to the new texture's first layer generate mipmap using blit encoder.

            – Egor Shkorov
            Mar 27 at 9:06












          • But, I think, since mipmapped texture should only take ~1.5 the space the texture withtout mipmaps takes, you should probably just create the textures that are likely to need mipmaps with mipmapped set to YES, if you aren't memory constrained.

            – Egor Shkorov
            Mar 27 at 9:11











          • If you are still confused, I can edit the answer, just try to describe the confusing part.

            – Egor Shkorov
            Mar 27 at 9:12











          • Always set mipmapped to `YES' seems a good way to avoid additional blit operation when need to generate mipmaps, does it will cause a performance issue?

            – coulsonwang
            Mar 27 at 9:13















          1














          It's a bit confusing, so let's walk through it.



          texture2DDescriptorWithPixelFormat takes format, width, height and mipmapped as parameters. The mipmapped parameter is there to tell Metal to calculate the number of mip levels that resulting image will have, since there is no parameter to pass mip level count. Here's how it's described in documentation:




          mipmapped



          A Boolean indicating whether the resulting image should be
          mipmapped. If YES, then the mipmapLevelCount property in the returned
          descriptor is computed from width and height. If NO, then
          mipmapLevelCount is 1.




          If you would use newTextureWithDescriptor with texture descriptor you created explicitly, then there's no mipmapped parameter, since you explicitly pass number of mip levels in mipmapLevelCount property of MTLTextureDescriptor.



          Since you create a new texture, there's no reason to generate mipmaps, since the texture is empty.



          The generateMipmapsForTexture method is used to generate mipmaps for a texture that already has mip levels and you just need to populate them with mipmaps generated automatically.



          So, to get this straight, mipmapped parameter just tells Metal to create a texture that has mip levels, that you can later populate (if you want) with generateMipmapsForTexture (or in some other ways, such as using texture as color attachment in render pass with level specified).






          share|improve this answer



























          • What if set mipmapped to NO when creating texture, however in the later process found out that I need to generate mipmaps for that texture, what should I do then?

            – coulsonwang
            Mar 27 at 9:00











          • Create a new texture with mipmapped set to YES, copy the first mip layer of original texture to the new texture's first layer generate mipmap using blit encoder.

            – Egor Shkorov
            Mar 27 at 9:06












          • But, I think, since mipmapped texture should only take ~1.5 the space the texture withtout mipmaps takes, you should probably just create the textures that are likely to need mipmaps with mipmapped set to YES, if you aren't memory constrained.

            – Egor Shkorov
            Mar 27 at 9:11











          • If you are still confused, I can edit the answer, just try to describe the confusing part.

            – Egor Shkorov
            Mar 27 at 9:12











          • Always set mipmapped to `YES' seems a good way to avoid additional blit operation when need to generate mipmaps, does it will cause a performance issue?

            – coulsonwang
            Mar 27 at 9:13













          1












          1








          1







          It's a bit confusing, so let's walk through it.



          texture2DDescriptorWithPixelFormat takes format, width, height and mipmapped as parameters. The mipmapped parameter is there to tell Metal to calculate the number of mip levels that resulting image will have, since there is no parameter to pass mip level count. Here's how it's described in documentation:




          mipmapped



          A Boolean indicating whether the resulting image should be
          mipmapped. If YES, then the mipmapLevelCount property in the returned
          descriptor is computed from width and height. If NO, then
          mipmapLevelCount is 1.




          If you would use newTextureWithDescriptor with texture descriptor you created explicitly, then there's no mipmapped parameter, since you explicitly pass number of mip levels in mipmapLevelCount property of MTLTextureDescriptor.



          Since you create a new texture, there's no reason to generate mipmaps, since the texture is empty.



          The generateMipmapsForTexture method is used to generate mipmaps for a texture that already has mip levels and you just need to populate them with mipmaps generated automatically.



          So, to get this straight, mipmapped parameter just tells Metal to create a texture that has mip levels, that you can later populate (if you want) with generateMipmapsForTexture (or in some other ways, such as using texture as color attachment in render pass with level specified).






          share|improve this answer















          It's a bit confusing, so let's walk through it.



          texture2DDescriptorWithPixelFormat takes format, width, height and mipmapped as parameters. The mipmapped parameter is there to tell Metal to calculate the number of mip levels that resulting image will have, since there is no parameter to pass mip level count. Here's how it's described in documentation:




          mipmapped



          A Boolean indicating whether the resulting image should be
          mipmapped. If YES, then the mipmapLevelCount property in the returned
          descriptor is computed from width and height. If NO, then
          mipmapLevelCount is 1.




          If you would use newTextureWithDescriptor with texture descriptor you created explicitly, then there's no mipmapped parameter, since you explicitly pass number of mip levels in mipmapLevelCount property of MTLTextureDescriptor.



          Since you create a new texture, there's no reason to generate mipmaps, since the texture is empty.



          The generateMipmapsForTexture method is used to generate mipmaps for a texture that already has mip levels and you just need to populate them with mipmaps generated automatically.



          So, to get this straight, mipmapped parameter just tells Metal to create a texture that has mip levels, that you can later populate (if you want) with generateMipmapsForTexture (or in some other ways, such as using texture as color attachment in render pass with level specified).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 27 at 9:08

























          answered Mar 27 at 8:41









          Egor ShkorovEgor Shkorov

          1,6781 gold badge16 silver badges22 bronze badges




          1,6781 gold badge16 silver badges22 bronze badges















          • What if set mipmapped to NO when creating texture, however in the later process found out that I need to generate mipmaps for that texture, what should I do then?

            – coulsonwang
            Mar 27 at 9:00











          • Create a new texture with mipmapped set to YES, copy the first mip layer of original texture to the new texture's first layer generate mipmap using blit encoder.

            – Egor Shkorov
            Mar 27 at 9:06












          • But, I think, since mipmapped texture should only take ~1.5 the space the texture withtout mipmaps takes, you should probably just create the textures that are likely to need mipmaps with mipmapped set to YES, if you aren't memory constrained.

            – Egor Shkorov
            Mar 27 at 9:11











          • If you are still confused, I can edit the answer, just try to describe the confusing part.

            – Egor Shkorov
            Mar 27 at 9:12











          • Always set mipmapped to `YES' seems a good way to avoid additional blit operation when need to generate mipmaps, does it will cause a performance issue?

            – coulsonwang
            Mar 27 at 9:13

















          • What if set mipmapped to NO when creating texture, however in the later process found out that I need to generate mipmaps for that texture, what should I do then?

            – coulsonwang
            Mar 27 at 9:00











          • Create a new texture with mipmapped set to YES, copy the first mip layer of original texture to the new texture's first layer generate mipmap using blit encoder.

            – Egor Shkorov
            Mar 27 at 9:06












          • But, I think, since mipmapped texture should only take ~1.5 the space the texture withtout mipmaps takes, you should probably just create the textures that are likely to need mipmaps with mipmapped set to YES, if you aren't memory constrained.

            – Egor Shkorov
            Mar 27 at 9:11











          • If you are still confused, I can edit the answer, just try to describe the confusing part.

            – Egor Shkorov
            Mar 27 at 9:12











          • Always set mipmapped to `YES' seems a good way to avoid additional blit operation when need to generate mipmaps, does it will cause a performance issue?

            – coulsonwang
            Mar 27 at 9:13
















          What if set mipmapped to NO when creating texture, however in the later process found out that I need to generate mipmaps for that texture, what should I do then?

          – coulsonwang
          Mar 27 at 9:00





          What if set mipmapped to NO when creating texture, however in the later process found out that I need to generate mipmaps for that texture, what should I do then?

          – coulsonwang
          Mar 27 at 9:00













          Create a new texture with mipmapped set to YES, copy the first mip layer of original texture to the new texture's first layer generate mipmap using blit encoder.

          – Egor Shkorov
          Mar 27 at 9:06






          Create a new texture with mipmapped set to YES, copy the first mip layer of original texture to the new texture's first layer generate mipmap using blit encoder.

          – Egor Shkorov
          Mar 27 at 9:06














          But, I think, since mipmapped texture should only take ~1.5 the space the texture withtout mipmaps takes, you should probably just create the textures that are likely to need mipmaps with mipmapped set to YES, if you aren't memory constrained.

          – Egor Shkorov
          Mar 27 at 9:11





          But, I think, since mipmapped texture should only take ~1.5 the space the texture withtout mipmaps takes, you should probably just create the textures that are likely to need mipmaps with mipmapped set to YES, if you aren't memory constrained.

          – Egor Shkorov
          Mar 27 at 9:11













          If you are still confused, I can edit the answer, just try to describe the confusing part.

          – Egor Shkorov
          Mar 27 at 9:12





          If you are still confused, I can edit the answer, just try to describe the confusing part.

          – Egor Shkorov
          Mar 27 at 9:12













          Always set mipmapped to `YES' seems a good way to avoid additional blit operation when need to generate mipmaps, does it will cause a performance issue?

          – coulsonwang
          Mar 27 at 9:13





          Always set mipmapped to `YES' seems a good way to avoid additional blit operation when need to generate mipmaps, does it will cause a performance issue?

          – coulsonwang
          Mar 27 at 9:13








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372742%2fconfused-about-the-generation-of-mipmap-in-metal%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript