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;
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
add a comment |
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
add a comment |
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
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
metal
asked Mar 27 at 8:31
coulsonwangcoulsonwang
366 bronze badges
366 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
Booleanindicating whether the resulting image should be
mipmapped. IfYES, then themipmapLevelCountproperty in the returned
descriptor is computed fromwidthandheight. IfNO, then
mipmapLevelCountis1.
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).
What if setmipmappedtoNOwhen 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 withmipmappedset toYES, 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 withmipmappedset toYES, 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 setmipmappedto `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
|
show 3 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
Booleanindicating whether the resulting image should be
mipmapped. IfYES, then themipmapLevelCountproperty in the returned
descriptor is computed fromwidthandheight. IfNO, then
mipmapLevelCountis1.
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).
What if setmipmappedtoNOwhen 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 withmipmappedset toYES, 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 withmipmappedset toYES, 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 setmipmappedto `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
|
show 3 more comments
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
Booleanindicating whether the resulting image should be
mipmapped. IfYES, then themipmapLevelCountproperty in the returned
descriptor is computed fromwidthandheight. IfNO, then
mipmapLevelCountis1.
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).
What if setmipmappedtoNOwhen 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 withmipmappedset toYES, 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 withmipmappedset toYES, 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 setmipmappedto `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
|
show 3 more comments
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
Booleanindicating whether the resulting image should be
mipmapped. IfYES, then themipmapLevelCountproperty in the returned
descriptor is computed fromwidthandheight. IfNO, then
mipmapLevelCountis1.
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).
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
Booleanindicating whether the resulting image should be
mipmapped. IfYES, then themipmapLevelCountproperty in the returned
descriptor is computed fromwidthandheight. IfNO, then
mipmapLevelCountis1.
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).
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 setmipmappedtoNOwhen 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 withmipmappedset toYES, 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 withmipmappedset toYES, 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 setmipmappedto `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
|
show 3 more comments
What if setmipmappedtoNOwhen 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 withmipmappedset toYES, 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 withmipmappedset toYES, 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 setmipmappedto `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
|
show 3 more comments
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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