@yangyc
2018-05-01T02:53:06.000000Z
字数 1654
阅读 590
functional_3d_engine_pattern
section3
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.
/*
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: {
...
}
}
" ?
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
need refactor state service to operate the same data which can be shared by two worker.
need split state data
operate state, inject getData func(accept main/render state)
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!