You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can find discussion of related issues here.
After discussion with @minggo , we want to simplify the work of ProgramState and Program in following ways:
for Program usage, it was create in following two ways:
for engine built-in Program, we can use static way static Program* Program::getBuiltinProgram(ProgramType type); to get a Program instance. An internal ProgramCache will caching those built-in Program.
for user-define Program, we can use Program* Device::newProgram(const std::string& vertexShader, const std::string& fragmentShader); to new a Program instance. The developers can do caching for those user-define Program themselves.
for ProgramState usage, there is only one way to create a instance of the ProgramState by its constructor: ProgramState(Program* program);, the parameter program either comes from step 1 or step 2.
scenario 1, use built-in Program to create the ProgramState
auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
auto programState = new (std::nothrow) backend::ProgramState(program);
...
CC_SAFE_RELEASE(programState);
...
scenario 2, use user-define 'Program' to create the ProgramState
auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, positionTextureColor_frag);
auto programState = new (std::nothrow) backend::ProgramState(program);
...
CC_SAFE_RELEASE(program);
CC_SAFE_RELEASE(programState);
...
Any feedback would appreciate.
The text was updated successfully, but these errors were encountered:
Personally, I don't mind adding my own caching layer to handle the caching of Program instances (user-defined or built-in, it won't matter).
I can imagine that a significant number of developers would end up having to create their own caching layer, and this fact alone is usually an indicator that it would have been better served to make it part of the Cocos2d-x framework.
Regardless, if you feel strongly about not adding caching in the framework for user-defined scripts in a way that allows for custom identifiers, or returning of the hash keys, then that's fine.
The only thing that we really need, and which doesn't exist in v4rc0, is this public constructor:
ProgramState(Program* program);
Once that function is added, then it will allow developers to create ProgramState from previously created Program instances, and we can implement our own caching layer to handle these.
You can find discussion of related issues here.
After discussion with @minggo , we want to simplify the work of
ProgramState
andProgram
in following ways:Program
usage, it was create in following two ways:Program
, we can use static waystatic Program* Program::getBuiltinProgram(ProgramType type);
to get aProgram
instance. An internalProgramCache
will caching those built-inProgram
.Program
, we can useProgram* Device::newProgram(const std::string& vertexShader, const std::string& fragmentShader);
to new aProgram
instance. The developers can do caching for those user-defineProgram
themselves.ProgramState
usage, there is only one way to create a instance of theProgramState
by its constructor:ProgramState(Program* program);
, the parameter program either comes from step 1 or step 2.Program
to create theProgramState
ProgramState
Any feedback would appreciate.
The text was updated successfully, but these errors were encountered: