【问题标题】:Accessing Mipmap levels in Metal在 Metal 中访问 Mipmap 级别
【发布时间】:2015-03-18 06:11:58
【问题描述】:

我是 Metal 编程新手,我想知道如何访问纹理的特定 mipmap 级别。我可以使用 BlitEncoder 来完成 mipmapping,但我不太确定如何访问特定的 miplevel 以供我使用。

我们将不胜感激。

【问题讨论】:

    标签: ios graphics metal


    【解决方案1】:

    详情可以查看我的https://github.com/haawa799/MipMaper

    但简短的回答是 - 您可以使用它从 MTLTexture 获取原始字节:

    var region = MTLRegionMake2D(0, 0, mipmapedWidth, mipmapedHeight)
    var pointer = malloc(UInt(rowBytes * mipmapedHeight))
    texture.getBytes(pointer, bytesPerRow: rowBytes, fromRegion: region, mipmapLevel: mipLevel)
    

    【讨论】:

    • 嗨!感谢你的回答!我会检查一下,并尽快回来。
    【解决方案2】:

    如果你的应用在行中崩溃

    texture.getBytes(pointer, bytesPerRow: rowBytes, fromRegion: region, mipmapLevel: mipLevel)
    

    请注意代码

       self.metalLayer.framebufferOnly = YES; 
    

    你应该设置如下

    self.metalLayer.framebufferOnly = NO; 
    

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-05
      • 1970-01-01
      • 1970-01-01
      • 2019-07-24
      • 1970-01-01
      • 1970-01-01
      • 2013-02-27
      相关资源
      最近更新 更多