Skip to content

Conversation

@Mee-gu
Copy link
Contributor

@Mee-gu Mee-gu commented Jan 3, 2019

update uniform location

private:
std::unordered_map<std::string, UniformInfo> _uniformInfos;
std::unordered_map<int, UniformInfo> _vertexUniformInfos;
std::unordered_map<int, UniformInfo> _fragUniformInfos;
Copy link
Owner

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.

@Mee-gu
Copy link
Contributor Author

Mee-gu commented Jan 4, 2019

update review

{
CC_SAFE_RELEASE(_vertexShader);
CC_SAFE_RELEASE(_fragmentShader);
_textureInfos.clear();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not needed

{
public:
ProgramMTL(ShaderModule* vs, ShaderModule* fs);
virtual ~ProgramMTL();
Copy link
Owner

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.


Program* DeviceMTL::createProgram(ShaderModule* vs, ShaderModule* fs)
{
return new (std::nothrow) ProgramMTL(vs, fs);
Copy link
Owner

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.

std::vector<Texture*> textures;
};

virtual int getUniformLocation(const std::string& uniform) = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add const

Copy link
Owner

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

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const is not needed

@Mee-gu
Copy link
Contributor Author

Mee-gu commented Jan 6, 2019

update review

RenderPipeline(Program* program);
virtual ~RenderPipeline();

virtual Program* getProgram() { return _program; }
Copy link
Owner

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();
Copy link
Owner

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?

_vertexTextureInfos.reserve(_maxTextureLocation);
_vertexTextureInfos.resize(_maxTextureLocation);
_fragTextureInfos.reserve(_maxTextureLocation);
_fragTextureInfos.resize(_maxTextureLocation);
Copy link
Owner

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

CC_SAFE_RETAIN(_vertexShaderModule);
CC_SAFE_RETAIN(_fragmentShaderModule);
return;
}
Copy link
Owner

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

return;

glUseProgram(_program);
for(const auto& uniforn : _uniformInfos)
Copy link
Owner

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

@Mee-gu
Copy link
Contributor Author

Mee-gu commented Jan 7, 2019

add ProgramCache

@Mee-gu
Copy link
Contributor Author

Mee-gu commented Jan 8, 2019

update ProgramCache

dt = std::chrono::duration_cast<std::chrono::microseconds>(now - prevTime).count() / 1000000.f;
}

cocos2d::backend::ProgramCache::destroyInstance();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants