[关闭]
@yangyc 2018-05-01T02:53:06.000000Z 字数 1654 阅读 590

多线程

functional_3d_engine_pattern section3


job pipeline->frp的设计

defer dispose

defer init material(created new material at loop)

problem

solution

two solutions:
A.generate and set shader index when initGameObject in main worker, only defer create gl shader in render worker

B.
render array buffer not contain "shaderIndices";
find shader shader index by material index when render;

use B solution.

main, cull, render->three workers example

limit

editor not support multi thread

not support redo undo

problems

different merged worker jobs->同步state的问题

/*

description

reason

solution

1.worker job should operate separated mutable data
2.not set state in worker job(only job in sync phase can use immutable data and set data!)

e.g.

use "state.transformRecord = xxx;" instead of "
{
...state,
transformRecord: {
...
}
}
" ?

but custom worker job may need set state(set state by user, not by engine!!!)!

e.g. createAndDispose benchmark run test:

createAndDispose custom main loop worker job need set state!

because some create operation(e.g. increase transform index) are immutable!

*/

main, render worker job should not mutable state, set state instead!!!!!

because main worker jobs' merged jobs are all read-only jobs(get message jobs) which don't change state, so each main worker job can set state safely
because the execute order of all render worker jobs is concat, the each render worker job can also set state safely

share code between main worker and render worker

description

reason

solution

need refactor state service to operate the same data which can be shared by two worker.

need split state data

  1. operate state, inject getData func(accept main/render state)

  2. convert main state, render state to the same state data for both worker

convert to initMaterial,sendAttribute,sendUniform,render all state;

then all state/record service can share handle these data!

use 2 solution!

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注