This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Encode directly to command buffer for Metal. #49785
Merged
auto-submit
merged 19 commits into
flutter:main
from
jonahwilliams:direct_encoding_metal
Jan 20, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f8d98b1
[Impeller] direct encoding Metal.
26e4d6e
fix SetVertexBuffer
e504245
Merge branch 'main' of github.com:flutter/engine into direct_encoding…
c8ccb10
merge fixes.
bdd499c
++
d651b88
++
3fa0a9a
fix unit tests.
4e31962
Merge branch 'main' into direct_encoding_metal
087d202
chinmay review.
cd5901c
Merge branch 'direct_encoding_metal' of github.com:jonahwilliams/engi…
403e151
test fixes
8818531
Make encode commands non-const.
be04fa0
Revert "Make encode commands non-const."
3470e36
fix forgetting to forward encode.
2d59557
end render pass in checkerboard test.
275f9c7
more test fixes.
411676d
more test fixes.
fce4518
work around for dart gpu tests.
b0ac5ca
Merge branch 'main' into direct_encoding_metal
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_PASS_BINDINGS_CACHE_MTL_H_ | ||
| #define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_PASS_BINDINGS_CACHE_MTL_H_ | ||
|
|
||
| #include <Metal/Metal.h> | ||
|
|
||
| #include "impeller/renderer/render_pass.h" | ||
| #include "impeller/renderer/render_target.h" | ||
|
|
||
| namespace impeller { | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /// @brief Ensures that bindings on the pass are not redundantly set or | ||
| /// updated. Avoids making the driver do additional checks and makes | ||
| /// the frame insights during profiling and instrumentation not | ||
| /// complain about the same. | ||
| /// | ||
| /// There should be no change to rendering if this caching was | ||
| /// absent. | ||
| /// | ||
| struct PassBindingsCacheMTL { | ||
| explicit PassBindingsCacheMTL() {} | ||
|
|
||
| ~PassBindingsCacheMTL() = default; | ||
|
|
||
| PassBindingsCacheMTL(const PassBindingsCacheMTL&) = delete; | ||
|
|
||
| PassBindingsCacheMTL(PassBindingsCacheMTL&&) = delete; | ||
|
|
||
| void SetEncoder(id<MTLRenderCommandEncoder> encoder); | ||
|
|
||
| void SetRenderPipelineState(id<MTLRenderPipelineState> pipeline); | ||
|
|
||
| void SetDepthStencilState(id<MTLDepthStencilState> depth_stencil); | ||
|
|
||
| bool SetBuffer(ShaderStage stage, | ||
| uint64_t index, | ||
| uint64_t offset, | ||
| id<MTLBuffer> buffer); | ||
|
|
||
| bool SetTexture(ShaderStage stage, uint64_t index, id<MTLTexture> texture); | ||
|
|
||
| bool SetSampler(ShaderStage stage, | ||
| uint64_t index, | ||
| id<MTLSamplerState> sampler); | ||
|
|
||
| void SetViewport(const Viewport& viewport); | ||
|
|
||
| void SetScissor(const IRect& scissor); | ||
|
|
||
| private: | ||
| struct BufferOffsetPair { | ||
| id<MTLBuffer> buffer = nullptr; | ||
| size_t offset = 0u; | ||
| }; | ||
| using BufferMap = std::map<uint64_t, BufferOffsetPair>; | ||
| using TextureMap = std::map<uint64_t, id<MTLTexture>>; | ||
| using SamplerMap = std::map<uint64_t, id<MTLSamplerState>>; | ||
|
|
||
| id<MTLRenderCommandEncoder> encoder_; | ||
| id<MTLRenderPipelineState> pipeline_ = nullptr; | ||
| id<MTLDepthStencilState> depth_stencil_ = nullptr; | ||
| std::map<ShaderStage, BufferMap> buffers_; | ||
| std::map<ShaderStage, TextureMap> textures_; | ||
| std::map<ShaderStage, SamplerMap> samplers_; | ||
| std::optional<Viewport> viewport_; | ||
| std::optional<IRect> scissor_; | ||
| }; | ||
|
|
||
| } // namespace impeller | ||
|
|
||
| #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_PASS_BINDINGS_CACHE_MTL_H_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Get rid of the corresponding Foundation.h header import above?
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.
Done