Skip to content
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

Feature/to cache pipeline #111

Open
wants to merge 13 commits into
base: metal-support
Choose a base branch
from

Conversation

Mee-gu
Copy link
Contributor

@Mee-gu Mee-gu commented Nov 7, 2018

Cache ShaderModule, RenderPass and RenderPipeline for reuse

Mee-gu and others added 7 commits October 25, 2018 10:03
…etal-support

* 'metal-support' of github.com:Mee-gu/new-renderer:
  use MTLPixelFormatDepth32Float_Stencil8 instead since it has better compatibility
  use MTLPixelFormatDepth32Float_Stencil8 instead since it has better compatibility
  【Feature】add test case (minggo#109)
cocos/math/HashAlgorithm.h Outdated Show resolved Hide resolved
src/backend/BlendState.cpp Outdated Show resolved Hide resolved
src/backend/StringUtils.hpp Outdated Show resolved Hide resolved
src/backend/Texture.cpp Outdated Show resolved Hide resolved
src/backend/Device.h Outdated Show resolved Hide resolved
src/backend/Texture.h Outdated Show resolved Hide resolved
@@ -102,4 +178,37 @@
return new (std::nothrow) RenderPipelineMTL(_mtlDevice, descriptor);
}

size_t DeviceMTL::findRenderPipelineInCache(const RenderPipelineDescriptor& descriptor)
{
Copy link
Owner

Choose a reason for hiding this comment

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

Why not just return RenderPipeline*?

@@ -248,7 +247,7 @@ MTLVertexFormat toMTLVertexFormat(VertexFormat vertexFormat)
info += StringUtils::BlendFactor2String(blendDescriptor.destinationAlphaBlendFactor);
}

return HashAlgorithm::PJWHash(info.c_str(), info.length());
return std::hash<std::string>{}(info);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use std::hash since the collision probability approaching 1.0/std::numeric_limits<size_t>::max().

// Create a auto released depth stencil state.
virtual DepthStencilState* createDepthStencilState(const DepthStencilDescriptor& descriptor) = 0;
// Create a auto released blend state.
virtual BlendState* createBlendState(const BlendDescriptor& descriptor) = 0;
// Create a render pipeline, not auto released.
virtual RenderPipeline* newRenderPipeline(const RenderPipelineDescriptor& descriptor) = 0;

// Cache RenderPipeline for reuse
// virtual RenderPipeline* cacheRenderPipeline(const RenderPipelineDescriptor& descriptor) = 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 remove unneeded codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got 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