Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
GrMtlCommandBuffer.mm File Reference
#include "src/gpu/ganesh/mtl/GrMtlCommandBuffer.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/ganesh/mtl/GrMtlGpu.h"
#include "src/gpu/ganesh/mtl/GrMtlOpsRenderPass.h"
#include "src/gpu/ganesh/mtl/GrMtlPipelineState.h"
#include "src/gpu/ganesh/mtl/GrMtlRenderCommandEncoder.h"
#include "src/gpu/ganesh/mtl/GrMtlSemaphore.h"
#include "src/gpu/mtl/MtlUtilsPriv.h"

Go to the source code of this file.

Functions

static bool compatible (const MTLRenderPassAttachmentDescriptor *first, const MTLRenderPassAttachmentDescriptor *second, const GrMtlPipelineState *pipelineState)
 

Function Documentation

◆ compatible()

static bool compatible ( const MTLRenderPassAttachmentDescriptor *  first,
const MTLRenderPassAttachmentDescriptor *  second,
const GrMtlPipelineState pipelineState 
)
static

Definition at line 80 of file GrMtlCommandBuffer.mm.

82 {
83 // From the Metal Best Practices Guide:
84 // Check to see if the previous descriptor is compatible with the new one.
85 // They are compatible if:
86 // * they share the same rendertargets
87 // * the first's store actions are either Store or DontCare
88 // * the second's load actions are either Load or DontCare
89 // * the second doesn't sample from any rendertargets in the first
90 bool renderTargetsMatch = (first.texture == second.texture);
91 bool storeActionsValid = first.storeAction == MTLStoreActionStore ||
92 first.storeAction == MTLStoreActionDontCare;
93 bool loadActionsValid = second.loadAction == MTLLoadActionLoad ||
94 second.loadAction == MTLLoadActionDontCare;
95 bool secondDoesntSampleFirst = (!pipelineState ||
96 pipelineState->doesntSampleAttachment(first));
97
98 // Since we are trying to use the same encoder rather than merging two,
99 // we have to check to see if both store actions are mutually compatible.
100 bool secondStoreValid = true;
101 if (second.storeAction == MTLStoreActionDontCare) {
102 secondStoreValid = (first.storeAction == MTLStoreActionDontCare);
103 // TODO: if first.storeAction is Store and second.loadAction is Load,
104 // we could reset the active RenderCommandEncoder's store action to DontCare
105 } else if (second.storeAction == MTLStoreActionStore) {
106 if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
107 secondStoreValid = (first.storeAction == MTLStoreActionStore ||
108 first.storeAction == MTLStoreActionStoreAndMultisampleResolve);
109 } else {
110 secondStoreValid = (first.storeAction == MTLStoreActionStore);
111 }
112 // TODO: if the first store action is DontCare we could reset the active
113 // RenderCommandEncoder's store action to Store, but it's not clear if it's worth it.
114 } else if (second.storeAction == MTLStoreActionMultisampleResolve) {
115 if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
116 secondStoreValid = (first.resolveTexture == second.resolveTexture) &&
117 (first.storeAction == MTLStoreActionMultisampleResolve ||
118 first.storeAction == MTLStoreActionStoreAndMultisampleResolve);
119 } else {
120 secondStoreValid = (first.resolveTexture == second.resolveTexture) &&
121 (first.storeAction == MTLStoreActionMultisampleResolve);
122 }
123 // When we first check whether store actions are valid we don't consider resolves,
124 // so we need to reset that here.
125 storeActionsValid = secondStoreValid;
126 } else {
127 if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
128 if (second.storeAction == MTLStoreActionStoreAndMultisampleResolve) {
129 secondStoreValid = (first.resolveTexture == second.resolveTexture) &&
130 (first.storeAction == MTLStoreActionStoreAndMultisampleResolve);
131 // TODO: if the first store action is simply MultisampleResolve we could reset
132 // the active RenderCommandEncoder's store action to StoreAndMultisampleResolve,
133 // but it's not clear if it's worth it.
134
135 // When we first check whether store actions are valid we don't consider resolves,
136 // so we need to reset that here.
137 storeActionsValid = secondStoreValid;
138 }
139 }
140 }
141
142 return renderTargetsMatch &&
143 (nil == first.texture ||
144 (storeActionsValid && loadActionsValid && secondDoesntSampleFirst && secondStoreValid));
145}
bool doesntSampleAttachment(const MTLRenderPassAttachmentDescriptor *) const