#include "src/gpu/ganesh/ops/OpsTask.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/ganesh/GrRecordingContext.h"
#include "include/private/base/SkPoint_impl.h"
#include "src/base/SkArenaAlloc.h"
#include "src/base/SkScopeExit.h"
#include "src/core/SkRectPriv.h"
#include "src/core/SkStringUtils.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/ganesh/GrAppliedClip.h"
#include "src/gpu/ganesh/GrAttachment.h"
#include "src/gpu/ganesh/GrAuditTrail.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "src/gpu/ganesh/GrNativeRect.h"
#include "src/gpu/ganesh/GrOpFlushState.h"
#include "src/gpu/ganesh/GrOpsRenderPass.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
#include "src/gpu/ganesh/GrResourceAllocator.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/GrTextureResolveManager.h"
#include "src/gpu/ganesh/geometry/GrRect.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <utility>
class GrDrawingManager;
enum GrSurfaceOrigin : int;
usingnamespaceskia_private;
namespace {
static const int kMaxOpMergeDistance = …;
static const int kMaxOpChainDistance = …;
inline bool can_reorder(const SkRect& a, const SkRect& b) { … }
GrOpsRenderPass* create_render_pass(GrGpu* gpu,
GrRenderTarget* rt,
bool useMSAASurface,
GrAttachment* stencil,
GrSurfaceOrigin origin,
const SkIRect& bounds,
GrLoadOp colorLoadOp,
const std::array<float, 4>& loadClearColor,
GrLoadOp stencilLoadOp,
GrStoreOp stencilStoreOp,
const TArray<GrSurfaceProxy*, true>& sampledProxies,
GrXferBarrierFlags renderPassXferBarriers) { … }
}
namespace skgpu::ganesh {
inline OpsTask::OpChain::List::List(GrOp::Owner op)
: … { … }
inline OpsTask::OpChain::List::List(List&& that) { … }
inline OpsTask::OpChain::List& OpsTask::OpChain::List::operator=(List&& that) { … }
inline GrOp::Owner OpsTask::OpChain::List::popHead() { … }
inline GrOp::Owner OpsTask::OpChain::List::removeOp(GrOp* op) { … }
inline void OpsTask::OpChain::List::pushHead(GrOp::Owner op) { … }
inline void OpsTask::OpChain::List::pushTail(GrOp::Owner op) { … }
inline void OpsTask::OpChain::List::validate() const { … }
OpsTask::OpChain::OpChain(GrOp::Owner op, GrProcessorSet::Analysis processorAnalysis,
GrAppliedClip* appliedClip, const GrDstProxyView* dstProxyView)
: … { … }
void OpsTask::OpChain::visitProxies(const GrVisitProxyFunc& func) const { … }
void OpsTask::OpChain::deleteOps() { … }
OpsTask::OpChain::List OpsTask::OpChain::DoConcat(List chainA, List chainB, const GrCaps& caps,
SkArenaAlloc* opsTaskArena,
GrAuditTrail* auditTrail) { … }
bool OpsTask::OpChain::tryConcat(
List* list, GrProcessorSet::Analysis processorAnalysis, const GrDstProxyView& dstProxyView,
const GrAppliedClip* appliedClip, const SkRect& bounds, const GrCaps& caps,
SkArenaAlloc* opsTaskArena, GrAuditTrail* auditTrail) { … }
bool OpsTask::OpChain::prependChain(OpChain* that, const GrCaps& caps, SkArenaAlloc* opsTaskArena,
GrAuditTrail* auditTrail) { … }
GrOp::Owner OpsTask::OpChain::appendOp(
GrOp::Owner op, GrProcessorSet::Analysis processorAnalysis,
const GrDstProxyView* dstProxyView, const GrAppliedClip* appliedClip, const GrCaps& caps,
SkArenaAlloc* opsTaskArena, GrAuditTrail* auditTrail) { … }
inline void OpsTask::OpChain::validate() const { … }
OpsTask::OpsTask(GrDrawingManager* drawingMgr,
GrSurfaceProxyView view,
GrAuditTrail* auditTrail,
sk_sp<GrArenas> arenas)
: … { … }
void OpsTask::deleteOps() { … }
OpsTask::~OpsTask() { … }
void OpsTask::addOp(GrDrawingManager* drawingMgr, GrOp::Owner op,
GrTextureResolveManager textureResolveManager, const GrCaps& caps) { … }
void OpsTask::addDrawOp(GrDrawingManager* drawingMgr, GrOp::Owner op, bool usesMSAA,
const GrProcessorSet::Analysis& processorAnalysis, GrAppliedClip&& clip,
const GrDstProxyView& dstProxyView,
GrTextureResolveManager textureResolveManager, const GrCaps& caps) { … }
void OpsTask::endFlush(GrDrawingManager* drawingMgr) { … }
void OpsTask::onPrePrepare(GrRecordingContext* context) { … }
void OpsTask::onPrepare(GrOpFlushState* flushState) { … }
bool OpsTask::onExecute(GrOpFlushState* flushState) { … }
void OpsTask::setColorLoadOp(GrLoadOp op, std::array<float, 4> color) { … }
void OpsTask::reset() { … }
bool OpsTask::canMerge(const OpsTask* opsTask) const { … }
int OpsTask::mergeFrom(SkSpan<const sk_sp<GrRenderTask>> tasks) { … }
bool OpsTask::resetForFullscreenClear(CanDiscardPreviousOps canDiscardPreviousOps) { … }
void OpsTask::discard() { … }
#if defined(GPU_TEST_UTILS)
void OpsTask::dump(const SkString& label,
SkString indent,
bool printDependencies,
bool close) const {
GrRenderTask::dump(label, indent, printDependencies, false);
SkDebugf("%sfColorLoadOp: ", indent.c_str());
switch (fColorLoadOp) {
case GrLoadOp::kLoad:
SkDebugf("kLoad\n");
break;
case GrLoadOp::kClear:
SkDebugf("kClear {%g, %g, %g, %g}\n",
fLoadClearColor[0],
fLoadClearColor[1],
fLoadClearColor[2],
fLoadClearColor[3]);
break;
case GrLoadOp::kDiscard:
SkDebugf("kDiscard\n");
break;
}
SkDebugf("%sfInitialStencilContent: ", indent.c_str());
switch (fInitialStencilContent) {
case StencilContent::kDontCare:
SkDebugf("kDontCare\n");
break;
case StencilContent::kUserBitsCleared:
SkDebugf("kUserBitsCleared\n");
break;
case StencilContent::kPreserved:
SkDebugf("kPreserved\n");
break;
}
SkDebugf("%s%d ops:\n", indent.c_str(), fOpChains.size());
for (int i = 0; i < fOpChains.size(); ++i) {
SkDebugf("%s*******************************\n", indent.c_str());
if (!fOpChains[i].head()) {
SkDebugf("%s%d: <combined forward or failed instantiation>\n", indent.c_str(), i);
} else {
SkDebugf("%s%d: %s\n", indent.c_str(), i, fOpChains[i].head()->name());
SkRect bounds = fOpChains[i].bounds();
SkDebugf("%sClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
indent.c_str(),
bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
for (const auto& op : GrOp::ChainRange<>(fOpChains[i].head())) {
SkString info = SkTabString(op.dumpInfo(), 1);
SkDebugf("%s%s\n", indent.c_str(), info.c_str());
bounds = op.bounds();
SkDebugf("%s\tClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
indent.c_str(),
bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
}
}
}
if (close) {
SkDebugf("%s--------------------------------------------------------------\n\n",
indent.c_str());
}
}
#endif
#ifdef SK_DEBUG
void OpsTask::visitProxies_debugOnly(const GrVisitProxyFunc& func) const { … }
#endif
void OpsTask::onMakeSkippable() { … }
bool OpsTask::onIsUsed(GrSurfaceProxy* proxyToCheck) const { … }
void OpsTask::gatherProxyIntervals(GrResourceAllocator* alloc) const { … }
void OpsTask::recordOp(
GrOp::Owner op, bool usesMSAA, GrProcessorSet::Analysis processorAnalysis,
GrAppliedClip* clip, const GrDstProxyView* dstProxyView, const GrCaps& caps) { … }
void OpsTask::forwardCombine(const GrCaps& caps) { … }
GrRenderTask::ExpectedOutcome OpsTask::onMakeClosed(GrRecordingContext* rContext,
SkIRect* targetUpdateBounds) { … }
}