Simplify GrPipeline by removing unused functionality.
Change-Id: Ibdd662fac5b3dedd1f231a9ba32c6e35e8fdf4da Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305545 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
c8bc99ff6a
commit
d3feb6fef7
@ -109,7 +109,7 @@ public:
|
||||
SkASSERT(fCoverageFP != nullptr);
|
||||
return fCoverageFP.get();
|
||||
}
|
||||
std::unique_ptr<const GrFragmentProcessor> detachCoverageFragmentProcessor() {
|
||||
std::unique_ptr<GrFragmentProcessor> detachCoverageFragmentProcessor() {
|
||||
SkASSERT(fCoverageFP != nullptr);
|
||||
return std::move(fCoverageFP);
|
||||
}
|
||||
|
@ -107,11 +107,9 @@ public:
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/// @name GrFragmentProcessors
|
||||
|
||||
int numColorFragmentProcessors() const { return fNumColorProcessors; }
|
||||
int numCoverageFragmentProcessors() const {
|
||||
return fFragmentProcessors.count() - fNumColorProcessors;
|
||||
}
|
||||
int numFragmentProcessors() const { return fFragmentProcessors.count(); }
|
||||
bool isColorFragmentProcessor(int idx) const { return idx < fNumColorProcessors; }
|
||||
bool isCoverageFragmentProcessor(int idx) const { return idx >= fNumColorProcessors; }
|
||||
|
||||
void visitTextureEffects(const std::function<void(const GrTextureEffect&)>&) const;
|
||||
|
||||
@ -150,16 +148,6 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const GrFragmentProcessor& getColorFragmentProcessor(int idx) const {
|
||||
SkASSERT(idx < this->numColorFragmentProcessors());
|
||||
return *fFragmentProcessors[idx].get();
|
||||
}
|
||||
|
||||
const GrFragmentProcessor& getCoverageFragmentProcessor(int idx) const {
|
||||
SkASSERT(idx < this->numCoverageFragmentProcessors());
|
||||
return *fFragmentProcessors[fNumColorProcessors + idx].get();
|
||||
}
|
||||
|
||||
const GrFragmentProcessor& getFragmentProcessor(int idx) const {
|
||||
return *fFragmentProcessors[idx].get();
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ public:
|
||||
return sk_ref_sp(fXP.fProcessor);
|
||||
}
|
||||
|
||||
std::unique_ptr<const GrFragmentProcessor> detachColorFragmentProcessor() {
|
||||
std::unique_ptr<GrFragmentProcessor> detachColorFragmentProcessor() {
|
||||
return std::move(fColorFragmentProcessor);
|
||||
}
|
||||
|
||||
std::unique_ptr<const GrFragmentProcessor> detachCoverageFragmentProcessor() {
|
||||
std::unique_ptr<GrFragmentProcessor> detachCoverageFragmentProcessor() {
|
||||
return std::move(fCoverageFragmentProcessor);
|
||||
}
|
||||
|
||||
|
@ -184,26 +184,34 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, const GrRenderTarget* renderTarge
|
||||
|
||||
GrProcessorKeyBuilder b(&desc->key());
|
||||
|
||||
programInfo.primProc().getGLSLProcessorKey(*caps.shaderCaps(), &b);
|
||||
programInfo.primProc().getAttributeKey(&b);
|
||||
if (!gen_pp_meta_key(programInfo.primProc(), caps, 0, &b)) {
|
||||
const GrPrimitiveProcessor& primitiveProcessor = programInfo.primProc();
|
||||
primitiveProcessor.getGLSLProcessorKey(*caps.shaderCaps(), &b);
|
||||
primitiveProcessor.getAttributeKey(&b);
|
||||
if (!gen_pp_meta_key(primitiveProcessor, caps, 0, &b)) {
|
||||
desc->key().reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
|
||||
const GrFragmentProcessor& fp = programInfo.pipeline().getFragmentProcessor(i);
|
||||
if (!gen_frag_proc_and_meta_keys(programInfo.primProc(), fp, caps, &b)) {
|
||||
const GrPipeline& pipeline = programInfo.pipeline();
|
||||
int numColorFPs = 0, numCoverageFPs = 0;
|
||||
for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
|
||||
const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
|
||||
if (!gen_frag_proc_and_meta_keys(primitiveProcessor, fp, caps, &b)) {
|
||||
desc->key().reset();
|
||||
return false;
|
||||
}
|
||||
if (pipeline.isColorFragmentProcessor(i)) {
|
||||
++numColorFPs;
|
||||
} else if (pipeline.isCoverageFragmentProcessor(i)) {
|
||||
++numCoverageFPs;
|
||||
}
|
||||
}
|
||||
|
||||
const GrXferProcessor& xp = programInfo.pipeline().getXferProcessor();
|
||||
const GrXferProcessor& xp = pipeline.getXferProcessor();
|
||||
const GrSurfaceOrigin* originIfDstTexture = nullptr;
|
||||
GrSurfaceOrigin origin;
|
||||
if (programInfo.pipeline().dstProxyView().proxy()) {
|
||||
origin = programInfo.pipeline().dstProxyView().origin();
|
||||
if (pipeline.dstProxyView().proxy()) {
|
||||
origin = pipeline.dstProxyView().origin();
|
||||
originIfDstTexture = &origin;
|
||||
}
|
||||
xp.getGLSLProcessorKey(*caps.shaderCaps(), &b, originIfDstTexture);
|
||||
@ -213,7 +221,7 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, const GrRenderTarget* renderTarge
|
||||
}
|
||||
|
||||
if (programInfo.requestedFeatures() & GrProcessor::CustomFeatures::kSampleLocations) {
|
||||
SkASSERT(programInfo.pipeline().isHWAntialiasState());
|
||||
SkASSERT(pipeline.isHWAntialiasState());
|
||||
b.add32(renderTarget->renderTargetPriv().getSamplePatternKey());
|
||||
}
|
||||
|
||||
@ -224,16 +232,11 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, const GrRenderTarget* renderTarge
|
||||
|
||||
// make sure any padding in the header is zeroed.
|
||||
memset(header, 0, kHeaderSize);
|
||||
header->fWriteSwizzle = programInfo.pipeline().writeSwizzle().asKey();
|
||||
header->fColorFragmentProcessorCnt = programInfo.pipeline().numColorFragmentProcessors();
|
||||
header->fCoverageFragmentProcessorCnt = programInfo.pipeline().numCoverageFragmentProcessors();
|
||||
// Fail if the client requested more processors than the key can fit.
|
||||
if (header->fColorFragmentProcessorCnt != programInfo.pipeline().numColorFragmentProcessors() ||
|
||||
header->fCoverageFragmentProcessorCnt !=
|
||||
programInfo.pipeline().numCoverageFragmentProcessors()) {
|
||||
desc->key().reset();
|
||||
return false;
|
||||
}
|
||||
header->fWriteSwizzle = pipeline.writeSwizzle().asKey();
|
||||
header->fColorFragmentProcessorCnt = numColorFPs;
|
||||
header->fCoverageFragmentProcessorCnt = numCoverageFPs;
|
||||
SkASSERT(header->fColorFragmentProcessorCnt == numColorFPs);
|
||||
SkASSERT(header->fCoverageFragmentProcessorCnt == numCoverageFPs);
|
||||
// If we knew the shader won't depend on origin, we could skip this (and use the same program
|
||||
// for both origins). Instrumenting all fragment processors would be difficult and error prone.
|
||||
header->fSurfaceOriginKey =
|
||||
@ -241,7 +244,7 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, const GrRenderTarget* renderTarge
|
||||
header->fProcessorFeatures = (uint8_t)programInfo.requestedFeatures();
|
||||
// Ensure enough bits.
|
||||
SkASSERT(header->fProcessorFeatures == (int) programInfo.requestedFeatures());
|
||||
header->fSnapVerticesToPixelCenters = programInfo.pipeline().snapVerticesToPixelCenters();
|
||||
header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
|
||||
// The base descriptor only stores whether or not the primitiveType is kPoints. Backend-
|
||||
// specific versions (e.g., Vulkan) require more detail
|
||||
header->fHasPointSize = (programInfo.primitiveType() == GrPrimitiveType::kPoints);
|
||||
|
@ -90,8 +90,7 @@ protected:
|
||||
**/
|
||||
static bool Build(GrProgramDesc*, const GrRenderTarget*, const GrProgramInfo&, const GrCaps&);
|
||||
|
||||
// This is strictly an OpenGL call since the other backends have additional data in their
|
||||
// keys
|
||||
// This is strictly an OpenGL call since the other backends have additional data in their keys.
|
||||
static bool BuildFromData(GrProgramDesc* desc, const void* keyData, size_t keyLength) {
|
||||
if (!SkTFitsIn<int>(keyLength)) {
|
||||
return false;
|
||||
@ -134,7 +133,7 @@ protected:
|
||||
enum KeyOffsets {
|
||||
kHeaderOffset = 0,
|
||||
kHeaderSize = SkAlign4(sizeof(KeyHeader)),
|
||||
// This is the offset into the backenend specific part of the key, which includes
|
||||
// This is the offset into the backend-specific part of the key, which includes
|
||||
// per-processor keys.
|
||||
kProcessorKeysOffset = kHeaderOffset + kHeaderSize,
|
||||
};
|
||||
|
@ -129,22 +129,19 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(SkString* outputColor, SkStrin
|
||||
|
||||
void GrGLSLProgramBuilder::emitAndInstallFragProcs(SkString* color, SkString* coverage) {
|
||||
int transformedCoordVarsIdx = 0;
|
||||
SkString** inOut = &color;
|
||||
int fpCount = this->pipeline().numFragmentProcessors();
|
||||
fFragmentProcessors.reset(new std::unique_ptr<GrGLSLFragmentProcessor>[fpCount]);
|
||||
for (int i = 0; i < fpCount; ++i) {
|
||||
if (i == this->pipeline().numColorFragmentProcessors()) {
|
||||
inOut = &coverage;
|
||||
}
|
||||
SkString* inOut = this->pipeline().isColorFragmentProcessor(i) ? color : coverage;
|
||||
SkString output;
|
||||
const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
|
||||
fFragmentProcessors[i] = std::unique_ptr<GrGLSLFragmentProcessor>(fp.createGLSLInstance());
|
||||
output = this->emitFragProc(fp, *fFragmentProcessors[i], transformedCoordVarsIdx, **inOut,
|
||||
output = this->emitFragProc(fp, *fFragmentProcessors[i], transformedCoordVarsIdx, *inOut,
|
||||
output);
|
||||
for (const auto& subFP : GrFragmentProcessor::FPRange(fp)) {
|
||||
transformedCoordVarsIdx += subFP.numVaryingCoordsUsed();
|
||||
}
|
||||
**inOut = output;
|
||||
*inOut = std::move(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user