If you don’t know what’s
backend API, then you can refer to this ticket for detail information. The backend API is to design a API that cross metal/opengl/vulkan. This ticket will update the progress of the API design and implementation.
After about one or two months discussion and learning, i started implementing the API about weeks ago, and i added some test cases. My plan is to implement opengl backend first to polish the API, then use metal to implement it. Of course the API may change when implementing metal backend, but i think the architecture will not change, just adjust some API, such as the API names, parameters and so on.
You can download the codes to take a look of the API and run the test cases. The steps of downloading source codes and running tests are:
- clone https://github.com/minggo/new-renderer
- check out metal-support branch
- open test/Test.xcodeproj
- select Test -> My Mac and run the test
Currently, there are 3 test cases, you can change
tests/main.cpp to run different test cases.
All the codes of new backend API is in
src/backend, all the test cases are in
test/tests/backend. As you can see, in order to draw a frame, you should use command buffer to commit things:
- start render pass
- set view port
- set renderpipeline
- set vertex buffer/index buffer
- draw arrays/elements
- end render pass
The backend API is not completed, but most parts are included. Some questions i have currently are:
- Is it too complex to clear color/depth/stencil? But metal clear these values like this.
Device.createXXXreturn autoreleased objects as other cocos2d-x API, but most times, you don’t want autoreleased objects, they are retained to be used later. Should change it? Or use other better function names?
- Command queue seems not needed in opengl, and metal also can have only one queue, should remove command queue, and use default command queue in metal?
- Are there any important features missed?
Any feedback is appreciated. Thanks in advanced.