1

我正在使用 cocos2d-x 3.17.2 并在 iPad mini 5th iOS 13.1.3 上运行我的应用程序。

当我调用 utils::captureScreen 时,它会导致断言失败。

_validateGetBytes:29:断言“不允许使用 MTLResourceStorageModePrivate 存储模式对纹理进行 CPU 访问”失败。

这似乎是一个与 MTLResourceStorageMode 相关的问题。

但我不知道如何解决这个问题。

我在 iOS 11.4.1 iPod touch 6th 和 iOS 12.4.3 iPad mini 2nd 上运行相同的代码,但这两个设备不会导致这个问题,它们运行完美。

这是我的代码。

 string path = FileUtils::getInstance()->getWritablePath().append("screenshot.jpg");
 Label *path_lbl = Label::createWithSystemFont(path, "", 20.0);
 const char* filename = path_lbl->getString().c_str();
 utils::captureScreen([&](bool succeed,const std::string &fileName){}, filename);

并且断言失败:ccUtils.cpp: Line 105

glReadPixels(0, 0, 宽度, 高度, GL_RGBA, GL_UNSIGNED_BYTE, buffer.get());

有谁知道如何解决这个问题?

4

1 回答 1

0

从 iOS 13.1 开始,关于 Metal 的底层实现glReadPixels()违反了 Metal 的内存访问规则(并且从 13.3.1 开始还没有修复)。

好消息是,这只是一个调试检查。当不附加到 Xcode 调试器时,它将“正常工作”。要让 Xcode 让它滑动,你可以:

  1. 转到编辑方案
  2. 选择边栏中的运行选项
  3. 转到选项选项卡
  4. 禁用 Metal API 验证

于 2020-04-27T21:15:14.737 回答