-
Notifications
You must be signed in to change notification settings - Fork 7
Feature/uniform location #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: metal-support
Are you sure you want to change the base?
Conversation
src/backend/BindGroup.h
Outdated
| private: | ||
| std::unordered_map<std::string, UniformInfo> _uniformInfos; | ||
| std::unordered_map<int, UniformInfo> _vertexUniformInfos; | ||
| std::unordered_map<int, UniformInfo> _fragUniformInfos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use std::vector instead, and reserve 3/5 elements at start.
|
update review |
src/backend/Program.cpp
Outdated
| { | ||
| CC_SAFE_RELEASE(_vertexShader); | ||
| CC_SAFE_RELEASE(_fragmentShader); | ||
| _textureInfos.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not needed
src/backend/metal/ProgramMTL.h
Outdated
| { | ||
| public: | ||
| ProgramMTL(ShaderModule* vs, ShaderModule* fs); | ||
| virtual ~ProgramMTL(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't have to be virtual.
src/backend/metal/DeviceMTL.mm
Outdated
|
|
||
| Program* DeviceMTL::createProgram(ShaderModule* vs, ShaderModule* fs) | ||
| { | ||
| return new (std::nothrow) ProgramMTL(vs, fs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create function should be auto released.
src/backend/Program.h
Outdated
| std::vector<Texture*> textures; | ||
| }; | ||
|
|
||
| virtual int getUniformLocation(const std::string& uniform) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and i think should use getVertexUniformLoacation and getFragmentUniformLoacation instead
src/backend/metal/ProgramMTL.h
Outdated
| virtual void setVertexUniform(int location, void* data, uint32_t size) override; | ||
| virtual void setFragmentUniform(int location, void* data, uint32_t size) override; | ||
|
|
||
| void fillUniformBuffer(uint8_t* buffer, uint32_t offset, void* uniformData, uint32_t uniformSize) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const is not needed
|
update review |
src/backend/RenderPipeline.h
Outdated
| RenderPipeline(Program* program); | ||
| virtual ~RenderPipeline(); | ||
|
|
||
| virtual Program* getProgram() { return _program; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add const
| { | ||
| public: | ||
| RenderPipeline(Program* program); | ||
| virtual ~RenderPipeline(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it need to be public?
src/backend/opengl/ProgramGL.cpp
Outdated
| _vertexTextureInfos.reserve(_maxTextureLocation); | ||
| _vertexTextureInfos.resize(_maxTextureLocation); | ||
| _fragTextureInfos.reserve(_maxTextureLocation); | ||
| _fragTextureInfos.resize(_maxTextureLocation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't have to use reserve and resize at the same time
src/backend/opengl/ProgramGL.cpp
Outdated
| CC_SAFE_RETAIN(_vertexShaderModule); | ||
| CC_SAFE_RETAIN(_fragmentShaderModule); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can not understand the logic
src/backend/opengl/ProgramGL.cpp
Outdated
| return; | ||
|
|
||
| glUseProgram(_program); | ||
| for(const auto& uniforn : _uniformInfos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can optimize it, don't have to loop every time
|
add ProgramCache |
|
update ProgramCache |
| dt = std::chrono::duration_cast<std::chrono::microseconds>(now - prevTime).count() / 1000000.f; | ||
| } | ||
|
|
||
| cocos2d::backend::ProgramCache::destroyInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should remove it
update uniform location