Skip to content

Add Metal render pass state caching and sampler cache.#1321

Merged
shlzxjp merged 7 commits intomainfrom
feature/partyhuang_metal_optimize
Mar 12, 2026
Merged

Add Metal render pass state caching and sampler cache.#1321
shlzxjp merged 7 commits intomainfrom
feature/partyhuang_metal_optimize

Conversation

@Hparty
Copy link
Copy Markdown
Collaborator

@Hparty Hparty commented Mar 6, 2026

Summary

  • Add render pass state caching in MetalRenderPass to skip redundant Metal API calls for scissor rect, cull mode, uniform buffers, textures, samplers and vertex buffers when state has not changed.
  • Add sampler cache in MetalGPU to reuse sampler state objects across frames.
  • Extract MetalPixelFormatToPixelFormat from Backend.cpp to shared PixelFormatUtil, using hardcoded constants to avoid Metal header dependency.
  • Add ShaderVisibility flags to BindingEntry, allowing precise per-stage uniform buffer binding on Metal instead of binding to both stages unconditionally.

Test plan

  • Verify existing tests pass with no regressions
  • Profile Metal rendering to confirm reduced API call overhead

Hparty added 4 commits March 6, 2026 18:20
…tal_optimize

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@Hparty Hparty force-pushed the feature/partyhuang_metal_optimize branch from 0b9734e to d7bff00 Compare March 12, 2026 11:49
Comment thread src/gpu/metal/MetalUtil.h Outdated

MTLWinding ToMTLWinding(FrontFace frontFace);

PixelFormat MTLPixelFormatToPixelFormat(MTLPixelFormat metalFormat);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个函数和MetalPixelFormatToPixelFormat的作用有什么不一样?看实现差不多

@Hparty Hparty force-pushed the feature/partyhuang_metal_optimize branch from d7bff00 to 441df69 Compare March 12, 2026 12:23
@shlzxjp shlzxjp merged commit 4a89412 into main Mar 12, 2026
9 checks passed
@shlzxjp shlzxjp deleted the feature/partyhuang_metal_optimize branch March 12, 2026 12:34
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