我正在使用cocos2d-x 3.17.2并在iPad mini 5th iOS 13.1.3上运行我的App。
当我调用utils::captureScreen时,它将导致断言失败。
_validateGetBytes:29: failed assertion `CPU access for textures with MTLResourceStorageModePrivate storage mode is disallowed.'
似乎是与MTLResourceStorageMode相关的问题。
但是我找不到解决方法。
我在iOS 11.4.1 iPod touch 6th和iOS 12.4.3 iPad mini 2nd上运行相同的代码,但是这2个设备不会引起此问题,它们运行得很完美。
这是我的代码。
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:行105
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.get());
有谁知道如何解决这个问题?
最佳答案
关于底层metal的glReadPixels()
实现的某些事情违反了iOS 13.1以来的Metal访问内存访问规则(并且自13.3.1起它尚未修复)。
好消息是,这仅是调试检查。如果不附加到Xcode调试器,它将“正常工作”。要让Xcode滑动,您可以:
关于c++ - cocos2d-x 3.17.2 utils::captureScreen在iPad mini 5上的iOS 13.1.3上断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58681004/