Metal support alpha0 version released

How cocos2d-x decides if it should use Metal or OpenGl in phones that support both?

What if we want to use simulator and openGl? will that not work anymore?

Yes, Performance is low too. Very noticeable. Let me know if you need a video.

@kerryk yep, it is not supported now.
@kiranb47 yes, please. And could you please provide a test case for it as we could’t reproduce it in the cpp-tests. Thanks.

@zhangxm oh i thought that there would be some config like in unity and we can choose so maybe devices running ios12 and lower could continue to use opengl, even ios13 if opengl is not stripped out. So to get this straight, ios renderer will use only metal from now? The purpose of backend renderer was not to support multiple so both opengl and metal? Its pretty useful to have opengl since you claim metal cant run on simulators at all otherwise we are forces to have 1 of each device to test, correct?

Currently, there is not plan for it. As you know, cocos2d-x doesn’t use glfw/sdl for all platforms, it uses system dependent codes on iOS, so it is not easy to switch between GL/metal easily. And we may support it after metal integrating using cmake for more convenient configuration.

Please. Do not remove cocosBuilder.

The editor is not maintained for a long time, and the corresponding runtime is not maintained for a long time too. You can port it when metal integrating is finished.

1 Like

And what about iphone 4s which uses A5 and ihpone 5 which uses A6? I believe metal is only supported since A7 on iphone 5s? Many of us still support those devices.

I think you can older engine versions currently. Is there any market share of these devices? We don’t have time to do it now, may be after all things finished.

As i see, visit is no longer working for

auto toBeClipped = DrawNode::create();
toBeClipped->drawSolidRect(Vec2::ZERO, Vec2(cutZone->getContentSize().width * cutZone->getScaleX(), cutZone->getContentSize().height* cutZone->gt;getScaleY()), Color4F::WHITE);

auto rt = RenderTexture::create(cutZone->getContentSize().width,cutZone->getContentSize().height,Texture2D::PixelFormat::RGBA8888);
rt->beginWithClear(0, 0, 0, 0);
toBeClipped->visit();

As i undestand, the new visit is as follows?

toBeClipped->visit(<#Renderer *renderer#>, <#const Mat4 &parentTransform#>, <#uint32_t parentFlags#>)

Can you please let me know what exact params does it need in this case? I used to provide none.

@zhangxm After all things finished and in case you have time to bring back open-gl, game will be able in run-time to switch between?

  1. Run open-gl in devices that support only open-gl.
  2. Developer can choose if to run metal or open-gl in devices that support both.
  3. Run only metal if some devices will support only metal.
1 Like

What i mean is engine can provide a way to let developers to choose before releasing, not choose it in runtime. We will treat iOS + OpenGL as a new platform.

I think it should work, because DrawNode inherits Node, and there is Node::visit().

Sprite visit works ok. Xcode only complains about DrawNode visit.

" What i mean is engine can provide a way to let developers to choose before releasing, not choose it in runtime. We will treat iOS + OpenGL as a new platform."

Will it be possible using defines to run iOS + OpenGl for iphone 4s, 5 and any other devices we like and iOS + Metal for the rest? All packed in 1 ipa. If not, having iOS + OpenGl will be kind of unecessary in case OpenGL is removed if we cant have an ipa that support both.

I am not sure if it is possible, may be it is something with IPA operation? Is it something with engine codes? I’d suggest to create a new thread for it.

But since both opengl and metal versions are available, is it not possible when cocos is initialised, that developer passes argument if you want metal or open-gl and cocos will switch what files to include? In case developer chooses open-gl, open-gl cocos is loaded, in case metal, metal cocos is loaded.

@zhangxm I tried visit on DrawNode in cocos2d-x tests and face the same compile issue. Can you check it out?

I do see autocompletion for no argument visit.

New thread opened: https://discuss.cocos2d-x.org/t/drawnode-visit-not-available-in-cocos2d-x-metal/45387

If these codes are compiled at the same time, then it will have conflict in link stage, or we should make all platform dependent codes in a library, and load it in runtime, it is a big change.

We faced the exact same issue on radial bar. Is there a ticket open in git for this issue?