Skip to content

Commit

Permalink
fixed 3d-tasks/18423: Rendering is not correct on VK backend. (#17526)
Browse files Browse the repository at this point in the history
* fixed 3d-tasks/18423: Rendering is not correct on VK backend.
Async tasks must be executed after present.

* fix unused parameter lint error.
  • Loading branch information
dumganhar authored Aug 13, 2024
1 parent 0d8aedb commit 2b032a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions native/cocos/bindings/manual/jsb_scene_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ static bool js_root_registerListeners(se::State &s) // NOLINT(readability-identi

DISPATCH_EVENT_TO_JS_ARGS_0(cc::Root::BeforeCommit, _onDirectorBeforeCommit, {});
DISPATCH_EVENT_TO_JS_ARGS_0(cc::Root::BeforeRender, _onDirectorBeforeRender, {});
DISPATCH_EVENT_TO_JS_ARGS_0(cc::Root::AfterRender, _onDirectorAfterRender, {
DISPATCH_EVENT_TO_JS_ARGS_0(cc::Root::AfterRender, _onDirectorAfterRender, {});
DISPATCH_EVENT_TO_JS_ARGS_0(cc::Root::PipelineChanged, _onDirectorPipelineChanged, {});

// NOTE: Async tasks must be executed after present, otherwise it will cause render issues on VK backend.
// Refer to https://github.com/cocos/3d-tasks/issues/18423
cobj->on<cc::Root::AfterPresent>([](cc::Root */*rootObj*/){
CC_CURRENT_APPLICATION()->getEngine()->getScheduler()->runFunctionsToBePerformedInCocosThread();
});
DISPATCH_EVENT_TO_JS_ARGS_0(cc::Root::PipelineChanged, _onDirectorPipelineChanged, {});

return true;
}
Expand Down
1 change: 1 addition & 0 deletions native/cocos/core/Root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ void Root::frameMoveEnd() {
emit<AfterRender>();
#endif
_device->present();
emit<AfterPresent>();
}

if (_batcher != nullptr) {
Expand Down
1 change: 1 addition & 0 deletions native/cocos/core/Root.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Root final {
TARGET_EVENT_ARG0(BeforeCommit)
TARGET_EVENT_ARG0(BeforeRender)
TARGET_EVENT_ARG0(AfterRender)
TARGET_EVENT_ARG0(AfterPresent)
TARGET_EVENT_ARG0(PipelineChanged)
DECLARE_TARGET_EVENT_END()
public:
Expand Down

0 comments on commit 2b032a2

Please sign in to comment.