Progress of graphics backend integration

This thread will update the progress of graphics backend integration. If you don’t know graphics backend, you can refer to this thread for more detail information.

Current status is that, can draw sprite with opengl/metal backend. Because current implementation is a bit hack, so now just do it in my personal repo, and i will move it to official repo after Sprite is done.

If you want to run the test case, you can do it as:

Currently, only cpp-empty-test work, and only work on mac/iOS.

5 Likes

Seems like overall quality of all this will be measured of by how many users will try it and test something or not, reported or not, some bugs fixed or not, and idea is just to make it work in some way, so we finally get this done/?
Open-source without real support of community looks like what we have for cocos now…

@squares I’m not sure what you mean by this. Metal isn’t done yet. Minggo is putting out progress releases because our community asked him to. We have a QA team that does official testing/QC

Yep, it is not done. I just update the progress here to let developers know it. After finishing it, we will do more test, and of course the community is helpful to test it too, that’s the advantage of open source project.

I mean the quality of all this, what it will be and how you understand quality for this overall?

There are many tests shifted with engine, if all tests pass, then i think the logic doesn’t have big issue. And developers will help to test it too. We don’t modify the engine logic very much, just modify the rendering part.

Looking forward to this )))

Update: Label with system font works. Label with TTF is in progress. And cpp-tests works on mac with metal though you may meet crash on some test cases, because not all modules are adapted.

Thank you for your hard work. I get an error while downloading deps:

=======================================================
==> Prepare to download external libraries!
==> version file doesn't exist
==> Ready to download 'metal-support-1.zip' from 'https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin/archive/metal-support-1.zip'
==> WARNING: Couldn't grab the file size from remote, use 'zip_file_size' section in '/Users/max/Developer/Library/Gaming/cocos2d-x/external/config.json'
==> Start to download, please wait ...
==> Downloading finished!                                                   
==> Extracting files, please wait ...
==> Extraction done!
==> Cleaning cocos2d-x/external folder ...
==> Copying files...
Traceback (most recent call last):
  File "./download-deps.py", line 379, in <module>
    main()
  File "./download-deps.py", line 374, in main
    installer.run(workpath, external_path, opts.remove_downloaded, opts.force_update, opts.download_only)
  File "./download-deps.py", line 318, in run
    distutils.dir_util.copy_tree(self._extracted_folder_name, folder_for_extracting)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dir_util.py", line 128, in copy_tree
    "cannot copy tree '%s': not a directory" % src
DistutilsFileError: cannot copy tree '/Users/max/Developer/Library/Gaming/cocos2d-x/cocos2d-x-3rd-party-libs-bin-etal-support-1': not a directory

possibly cocos2d-x-3rd-party-libs-bin-etal-support-1 missing an ‘m’

Thanks for the information, it is fixed in https://github.com/minggo/cocos2d-x/commit/9eac5b364c129ebfe528bbb3f937daefc31280a1. It is because the script remove a character because github will remove v, but now the path doesn’t include v.

Thx I’ll try it asap

Hi @zhangxm thank you for your hard work on providing the new graphics backend.

A small question from my side: Will I be able to do custom drawing(GL_TRIANGLE_STRIP etc) in nodes?
In the old API I was able to create a CustomCommand containing my custom draw function that I would then pass to the renderer.

Best regards,
Rambazamba

Hello there,
is the CMake integration working? I try to build but I get errors:

cmake ..
-- PROJECT_NAME:Cocos2d-x
-- PROJECT_SOURCE_DIR:/Users/max/Developer/Library/Gaming/cocos2d-x
-- COCOS2DX_ROOT_PATH:/Users/max/Developer/Library/Gaming/cocos2d-x
-- CMAKE_MODULE_PATH:/Users/max/Developer/Library/Gaming/cocos2d-x/cmake/Modules/
-- COCOS_EXTERNAL_DIR:/Users/max/Developer/Library/Gaming/cocos2d-x/external
-- PROJECT_BINARY_DIR:/Users/max/Developer/Library/Gaming/cocos2d-x/cmake-build
-- ENGINE_BINARY_PATH:/Users/max/Developer/Library/Gaming/cocos2d-x/cmake-build/engine
-- CMAKE_BUILD_TYPE: Debug
-- It appears you are building natively for Mac OSX with AppleClang
-- Configuring done
CMake Error at cocos/CMakeLists.txt:118 (add_library):
  Cannot find source file:

    2d/CCDrawingPrimitives.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at tests/cpp-tests/CMakeLists.txt:466 (add_executable):
  Cannot find source file:

    Classes/LabelTest/LabelTest.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at cocos/CMakeLists.txt:118 (add_library):
  No SOURCES given to target: cocos2d


CMake Error at tests/cpp-tests/CMakeLists.txt:466 (add_executable):
  No SOURCES given to target: cpp-tests

I checked in the 2d dir and actually CCDrawingPrimitives.cpp appears to be missing…

@zhangxm anything i did wrong? none seems to run

Something similar here:

In file included from /Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/CommandBufferGL.cpp:1:
/Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/CommandBufferGL.h:30:18: error: 'drawElements' marked 'override' but does not override any member functions
    virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, size_t count, size_t offset) override;
                 ^
/Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/CommandBufferGL.h:30:18: warning: 'cocos2d::backend::CommandBufferGL::drawElements' hides overloaded virtual function [-Woverloaded-virtual]
In file included from /Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/CommandBufferGL.cpp:1:
In file included from /Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/CommandBufferGL.h:4:
/Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/../CommandBuffer.h:28:18: note: hidden overloaded virtual function 'cocos2d::backend::CommandBuffer::drawElements' declared here: type mismatch at 3rd parameter ('uint32_t' (aka 'unsigned int') vs 'size_t' (aka 'unsigned long'))
    virtual void drawElements(PrimitiveType primitiveType, IndexFormat indexType, uint32_t count, uint32_t offset) = 0;
                 ^
In file included from /Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/CommandBufferGL.cpp:2:
/Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/BufferGL.h:15:18: error: 'updateData' marked 'override' but does not override any member functions
    virtual void updateData(const void* data, uint32_t size) override;
                 ^
/Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/BufferGL.h:15:18: warning: 'cocos2d::backend::BufferGL::updateData' hides overloaded virtual function [-Woverloaded-virtual]
In file included from /Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/CommandBufferGL.cpp:2:
In file included from /Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/BufferGL.h:3:
/Users/max/Developer/Library/Gaming/cocos2d-x/cocos/renderer/backend/opengl/../Buffer.h:12:18: note: hidden overloaded virtual function 'cocos2d::backend::Buffer::updateData' declared here: type mismatch at 2nd parameter ('size_t' (aka 'unsigned long') vs 'uint32_t' (aka 'unsigned int'))
    virtual void updateData(const void* data, size_t size) = 0;
                 ^
2 warnings and 2 errors generated.

@crittergorge @kerryk sorry, it is in developing, so it may not work sometimes. We will make the branch work all the time in future. And cmake doesn’t work currently.
@Rambazamba with new backend, i think you can not use custom function, as it is graphics API related, and i thin you don’t have to do it too. You just pass needed data and states to renderer, renderer will cover all the other things.

We meets a problem that, sprite with moving action is blur. If you run Actions - Basic you will notice it. But the same backend in new renderer repo doesn’t have problem (the Xcode project is under test).

I have not idea currently, you are appreciated if you have some idea of it.

Ok, i fixed it. It is because Renderer::render() is invoked more than one time in a frame.

1 Like

Runs ok now! @zhangxm can you make it to print in console if it’s using metal or opengl as backend during runtime as part of initial info being printed?

Also, is there a way to let us know which tests should run fine? I am experiencing some crashes when i click on a test or a next green arrow but i guess its because you didn’t finish yet so i dont want to spam forum with false reports. So please let us know what is ready for testing. We are ready to help )