[graphite] Use depthstencilflags in RenderStep and up
Bug: skia:12700 Change-Id: Ie20156e3a7a9dec4524b379a617724cca21402d4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/481998 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
ca916f705f
commit
85d6190f60
@ -125,17 +125,10 @@ sk_sp<Task> DrawContext::snapRenderPassTask(Recorder* recorder,
|
||||
std::tie(desc.fColorAttachment.fLoadOp, desc.fColorAttachment.fStoreOp) = drawPass->ops();
|
||||
desc.fClearColor = drawPass->clearColor();
|
||||
|
||||
skgpu::Mask<DepthStencilFlags> dsFlags = DepthStencilFlags::kNone;
|
||||
if (drawPass->requiresDepth()) {
|
||||
dsFlags |= DepthStencilFlags::kDepth;
|
||||
}
|
||||
if (drawPass->requiresStencil()) {
|
||||
dsFlags |= DepthStencilFlags::kStencil;
|
||||
}
|
||||
if (dsFlags != DepthStencilFlags::kNone) {
|
||||
if (drawPass->depthStencilFlags() != DepthStencilFlags::kNone) {
|
||||
const Caps* caps = recorder->context()->priv().gpu()->caps();
|
||||
desc.fDepthStencilAttachment.fTextureInfo =
|
||||
caps->getDefaultDepthStencilTextureInfo(dsFlags,
|
||||
caps->getDefaultDepthStencilTextureInfo(drawPass->depthStencilFlags(),
|
||||
1 /*sampleCount*/, // TODO: MSAA
|
||||
Protected::kNo);
|
||||
// TODO: handle clears
|
||||
|
@ -217,10 +217,7 @@ DrawPass::DrawPass(sk_sp<TextureProxy> target,
|
||||
, fTarget(std::move(target))
|
||||
, fBounds(SkIRect::MakeEmpty())
|
||||
, fOps(ops)
|
||||
, fClearColor(clearColor)
|
||||
, fRequiresStencil(false)
|
||||
, fRequiresDepth(false)
|
||||
, fRequiresMSAA(false) {
|
||||
, fClearColor(clearColor) {
|
||||
// TODO: Tune this estimate and the above "itemPerBlock" value for the command buffer sequence
|
||||
// After merging, etc. one pipeline per recorded draw+step combo is likely unnecessary.
|
||||
fPipelineDescs.reserve(renderStepCount);
|
||||
@ -321,8 +318,7 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
||||
}
|
||||
|
||||
passBounds.join(draw.fClip.drawBounds());
|
||||
drawPass->fRequiresStencil |= draw.fRenderer.requiresStencil();
|
||||
drawPass->fRequiresDepth |= draw.fRenderer.requiresDepth();
|
||||
drawPass->fDepthStencilFlags |= draw.fRenderer.depthStencilFlags();
|
||||
drawPass->fRequiresMSAA |= draw.fRenderer.requiresMSAA();
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "experimental/graphite/src/DrawTypes.h"
|
||||
#include "experimental/graphite/src/GraphicsPipelineDesc.h"
|
||||
#include "experimental/graphite/src/ResourceTypes.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
@ -59,10 +60,10 @@ public:
|
||||
std::array<float, 4> clearColor() const { return fClearColor; }
|
||||
|
||||
bool requiresDstTexture() const { return false; }
|
||||
bool requiresStencil() const { return fRequiresStencil; }
|
||||
bool requiresDepth() const { return fRequiresDepth; }
|
||||
bool requiresMSAA() const { return fRequiresMSAA; }
|
||||
|
||||
Mask<DepthStencilFlags> depthStencilFlags() const { return fDepthStencilFlags; }
|
||||
|
||||
size_t vertexBufferSize() const { return 0; }
|
||||
size_t uniformBufferSize() const { return 0; }
|
||||
|
||||
@ -193,9 +194,8 @@ private:
|
||||
std::pair<LoadOp, StoreOp> fOps;
|
||||
std::array<float, 4> fClearColor;
|
||||
|
||||
bool fRequiresStencil;
|
||||
bool fRequiresDepth;
|
||||
bool fRequiresMSAA;
|
||||
Mask<DepthStencilFlags> fDepthStencilFlags = DepthStencilFlags::kNone;
|
||||
bool fRequiresMSAA = false;
|
||||
};
|
||||
|
||||
} // namespace skgpu
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "experimental/graphite/src/Attribute.h"
|
||||
#include "experimental/graphite/src/DrawTypes.h"
|
||||
#include "experimental/graphite/src/EnumBitMask.h"
|
||||
#include "experimental/graphite/src/ResourceTypes.h"
|
||||
#include "experimental/graphite/src/Uniform.h"
|
||||
|
||||
#include "include/core/SkSpan.h"
|
||||
@ -70,9 +71,6 @@ public:
|
||||
// and then including the function bodies returned here.
|
||||
virtual const char* vertexSkSL() const = 0;
|
||||
|
||||
bool requiresStencil() const { return fDepthStencilSettings.fStencilTestEnabled; }
|
||||
bool requiresDepth() const { return fDepthStencilSettings.fDepthTestEnabled ||
|
||||
fDepthStencilSettings.fDepthWriteEnabled; }
|
||||
bool requiresMSAA() const { return fFlags & Flags::kRequiresMSAA; }
|
||||
bool performsShading() const { return fFlags & Flags::kPerformsShading; }
|
||||
|
||||
@ -82,6 +80,13 @@ public:
|
||||
|
||||
const DepthStencilSettings& depthStencilSettings() const { return fDepthStencilSettings; }
|
||||
|
||||
Mask<DepthStencilFlags> depthStencilFlags() const {
|
||||
return (fDepthStencilSettings.fStencilTestEnabled
|
||||
? DepthStencilFlags::kStencil : DepthStencilFlags::kNone) |
|
||||
(fDepthStencilSettings.fDepthTestEnabled || fDepthStencilSettings.fDepthWriteEnabled
|
||||
? DepthStencilFlags::kDepth : DepthStencilFlags::kNone);
|
||||
}
|
||||
|
||||
size_t numUniforms() const { return fUniforms.size(); }
|
||||
size_t numVertexAttributes() const { return fVertexAttrs.size(); }
|
||||
size_t numInstanceAttributes() const { return fInstanceAttrs.size(); }
|
||||
@ -92,6 +97,7 @@ public:
|
||||
SkSpan<const Attribute> vertexAttributes() const { return SkMakeSpan(fVertexAttrs); }
|
||||
SkSpan<const Attribute> instanceAttributes() const { return SkMakeSpan(fInstanceAttrs); }
|
||||
|
||||
|
||||
// TODO: Actual API to do things
|
||||
// 1. Provide stencil settings
|
||||
// 6. Some Renderers benefit from being able to share vertices between RenderSteps. Must find a
|
||||
@ -193,10 +199,10 @@ public:
|
||||
|
||||
const char* name() const { return fName.c_str(); }
|
||||
int numRenderSteps() const { return fStepCount; }
|
||||
bool requiresStencil() const { return fRequiresStencil; }
|
||||
bool requiresDepth() const { return fRequiresDepth; }
|
||||
bool requiresMSAA() const { return fRequiresMSAA; }
|
||||
|
||||
Mask<DepthStencilFlags> depthStencilFlags() const { return fDepthStencilFlags; }
|
||||
|
||||
private:
|
||||
// max render steps is 4, so just spell the options out for now...
|
||||
Renderer(const char* name, const RenderStep* s1)
|
||||
@ -215,17 +221,12 @@ private:
|
||||
template<size_t N>
|
||||
Renderer(const char* name, std::array<const RenderStep*, N> steps)
|
||||
: fName(name)
|
||||
, fStepCount(SkTo<int>(N))
|
||||
, fRequiresStencil(false)
|
||||
, fRequiresDepth(false)
|
||||
, fRequiresMSAA(false) {
|
||||
, fStepCount(SkTo<int>(N)) {
|
||||
static_assert(N <= kMaxRenderSteps);
|
||||
SkDEBUGCODE(bool performsShading = false;)
|
||||
for (int i = 0 ; i < fStepCount; ++i) {
|
||||
fSteps[i] = steps[i];
|
||||
fRequiresStencil |= fSteps[i]->requiresStencil();
|
||||
fRequiresDepth |= fSteps[i]->requiresDepth();
|
||||
fRequiresMSAA |= fSteps[i]->requiresMSAA();
|
||||
fDepthStencilFlags |= fSteps[i]->depthStencilFlags();
|
||||
SkDEBUGCODE(performsShading |= fSteps[i]->performsShading());
|
||||
}
|
||||
SkASSERT(performsShading); // at least one step needs to actually shade
|
||||
@ -239,9 +240,9 @@ private:
|
||||
|
||||
SkString fName;
|
||||
int fStepCount;
|
||||
bool fRequiresStencil;
|
||||
bool fRequiresDepth;
|
||||
bool fRequiresMSAA;
|
||||
bool fRequiresMSAA = false;
|
||||
|
||||
Mask<DepthStencilFlags> fDepthStencilFlags = DepthStencilFlags::kNone;
|
||||
};
|
||||
|
||||
} // skgpu namespace
|
||||
|
@ -362,13 +362,7 @@ sk_sp<GraphicsPipeline> GraphicsPipeline::Make(const Gpu* gpu,
|
||||
|
||||
(*psoDescriptor).colorAttachments[0] = mtlColorAttachment;
|
||||
|
||||
Mask<DepthStencilFlags> depthStencilFlags = DepthStencilFlags::kNone;
|
||||
if (desc.renderStep()->requiresDepth()) {
|
||||
depthStencilFlags |= DepthStencilFlags::kDepth;
|
||||
}
|
||||
if (desc.renderStep()->requiresStencil()){
|
||||
depthStencilFlags |= DepthStencilFlags::kStencil;
|
||||
}
|
||||
Mask<DepthStencilFlags> depthStencilFlags = desc.renderStep()->depthStencilFlags();
|
||||
if (depthStencilFlags != DepthStencilFlags::kNone) {
|
||||
skgpu::TextureInfo texInfo =
|
||||
gpu->caps()->getDefaultDepthStencilTextureInfo(depthStencilFlags,
|
||||
|
Loading…
Reference in New Issue
Block a user