Progress of new backend API

Progress of new backend API
0

#22

Update:

  • implement some basic feature of metal backend
  • can run the project, but nothing is drawn, i found the vertex data is correct, don’t know why

If somebody is metal expert, please help to fix it too.


#23

Update:

the first metal test case can run, it is because i don’t set window width and height, then the view port size is 0. Currently, i just write metal shader by hand, not translate it to metal shader in runtime. It can polish the API more quickly.


IOS and openGL?
#24

Update:

GLSL shader works on metal backend. We are using glsl-optimizer to translate GLSL shader to metal shader. glsl-optimizer doesn’t translate GLSL builtin functions, we are fixing it.


#25

Update: texture is supported in metal backend, texture array currently is not supported. And i created an issue to trace the progress of GLSL builtin functions supporting.


#26

I think this is a standalone project which should not depend on cocos2d-x.
It’s cocos2d-x uses this module instead.
So autorelease stuff may not be in this project.


#27

It seems that this design doesn’t consider multi-thread usage.
There isn’t any concept of Fence, Event, Semaphore.


#28

@dumganhar it is part of cocos2d-x. For convenient, i use a separate repo when developing. I learned from mac and fixed it:

  • createXXX return an autoreleased object
  • newXXX return a not autoreleased object

Yep, multiple thread concept is not included now. I don’t know if it is needed, the first purpose is to support metal, and we can optimize it if it is needed.


#29

Update: blending is supported on metal, and the API is simplified a bit. I will add more test case for it.


#30

Update:

  • texture can be used as color attachment
  • can update sub image of a texture
  • make stencil work correctly
  • make some API more meaningful
  • add more test cases

#31

wow it seems like you are making terrific progress - thanks for the updates!!


#32

We almost finish the backend API, and will start integrating it into cocos2d-x soon.


#33

Wow, That was Quick


#34

@zhangxm Crashing for me when i tried running tests. See attachment


#35

@kiranb47 i will take a look.


#36

@kiranb47 it works for me and my co-worker. What’s your macOS version? And what’s the pixel format?


#37

Mac Version: 10.14 Mojave. We tested in 2 Macs. A Mac Mini & a Mac Book Pro. How i find my device pixel format? I tried changing pixel formal in RootView, but still crashing


#38

@zhangxm We changed to #define DEPTH_STENCIL_ATTACHMENT_PIXEL_FORMAT MTLPixelFormatDepth32Float_Stencil8 in Utils.h. Now working


#39

Interesting, MTLPixelFormatDepth24Unorm_Stencil8 is available since macOS 10.11, the same as MTLPixelFormatDepth32Float_Stencil8. And the macOS version of my Mac Book Pro is also 10.14.


#40

What are the years of your MacMini and MBP? I wouldn’t be surprised if all MacMinis do not support that capability. My guess is maybe both of your devices do not support it?

You can check the depth24Stencil8PixelFormatSupported feature capability if you want to use 24_N_8 and revert to 32_8 as fallback which I believe all Metal-capable devices must support??
https://developer.apple.com/documentation/metal/mtldevice/1433371-depth24stencil8pixelformatsuppor?language=objc .


#41

Thanks for the information, change to MTLPixelFormatDepth32Float_Stencil8 is ok.