Retract GrRenderTarget from GrCaps & GrProgramDesc where possible
Fully retracting GrRenderTarget is still blocked on Dawn, D3D,
and Vk uses.
Change-Id: I59ebce40d85134f8ee18c143df2a3f4b70c3dcb1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386840
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index ebe66ff..d2ed7e8 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -137,7 +137,6 @@
}
static void gen_key(GrProcessorKeyBuilder* b,
- GrRenderTarget* renderTarget,
const GrProgramInfo& programInfo,
const GrCaps& caps) {
gen_geomproc_key(programInfo.geomProc(), caps, b);
@@ -167,25 +166,19 @@
}
void GrProgramDesc::Build(GrProgramDesc* desc,
- GrRenderTarget* renderTarget,
const GrProgramInfo& programInfo,
const GrCaps& caps) {
- SkASSERT(!renderTarget || programInfo.backendFormat() == renderTarget->backendFormat());
-
desc->reset();
GrProcessorKeyBuilder b(desc->key());
- gen_key(&b, renderTarget, programInfo, caps);
+ gen_key(&b, programInfo, caps);
desc->fInitialKeyLength = desc->keyLength();
}
-SkString GrProgramDesc::Describe(GrRenderTarget* renderTarget,
- const GrProgramInfo& programInfo,
+SkString GrProgramDesc::Describe(const GrProgramInfo& programInfo,
const GrCaps& caps) {
- SkASSERT(!renderTarget || programInfo.backendFormat() == renderTarget->backendFormat());
-
GrProgramDesc desc;
GrProcessorStringKeyBuilder b(desc.key());
- gen_key(&b, renderTarget, programInfo, caps);
+ gen_key(&b, programInfo, caps);
b.flush();
return b.description();
}
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index 910751e..96dec23 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -132,7 +132,7 @@
// TODO(skia:11372): Incorporate this into caps interface (part of makeDesc, or a parallel
// function), so other backends can include their information in the description.
- static SkString Describe(GrRenderTarget*, const GrProgramInfo&, const GrCaps&);
+ static SkString Describe(const GrProgramInfo&, const GrCaps&);
protected:
friend class GrDawnCaps;
@@ -152,11 +152,10 @@
* Builds a program descriptor.
*
* @param desc The built descriptor
- * @param renderTarget The target of the draw
* @param programInfo Program information need to build the key
* @param caps the caps
**/
- static void Build(GrProgramDesc*, GrRenderTarget*, const GrProgramInfo&, const GrCaps&);
+ static void Build(GrProgramDesc*, const GrProgramInfo&, const GrCaps&);
// 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) {
diff --git a/src/gpu/d3d/GrD3DCaps.cpp b/src/gpu/d3d/GrD3DCaps.cpp
index ba58c0a..99977cb 100644
--- a/src/gpu/d3d/GrD3DCaps.cpp
+++ b/src/gpu/d3d/GrD3DCaps.cpp
@@ -1036,7 +1036,7 @@
ProgramDescOverrideFlags overrideFlags) const {
SkASSERT(overrideFlags == ProgramDescOverrideFlags::kNone);
GrProgramDesc desc;
- GrProgramDesc::Build(&desc, rt, programInfo, *this);
+ GrProgramDesc::Build(&desc, programInfo, *this);
GrProcessorKeyBuilder b(desc.key());
diff --git a/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp b/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp
index cad1923..a1cb092 100644
--- a/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp
+++ b/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp
@@ -634,8 +634,7 @@
}
sk_sp<SkData> key =
SkData::MakeWithoutCopy(this->desc().asKey(), this->desc().initialKeyLength());
- SkString description =
- GrProgramDesc::Describe(fRenderTarget, fProgramInfo, *this->caps());
+ SkString description = GrProgramDesc::Describe(fProgramInfo, *this->caps());
sk_sp<SkData> data = GrPersistentCacheUtils::PackCachedShaders(
cacheSkSL ? kSKSL_Tag : kHLSL_Tag, hlsl, inputs, kGrShaderTypeCount);
persistentCache->store(*key, *data, description);
diff --git a/src/gpu/dawn/GrDawnCaps.cpp b/src/gpu/dawn/GrDawnCaps.cpp
index 7bcf741..978d18e 100644
--- a/src/gpu/dawn/GrDawnCaps.cpp
+++ b/src/gpu/dawn/GrDawnCaps.cpp
@@ -169,7 +169,7 @@
ProgramDescOverrideFlags overrideFlags) const {
SkASSERT(overrideFlags == ProgramDescOverrideFlags::kNone);
GrProgramDesc desc;
- GrProgramDesc::Build(&desc, rt, programInfo, *this);
+ GrProgramDesc::Build(&desc, programInfo, *this);
wgpu::TextureFormat format;
if (!programInfo.backendFormat().asDawnFormat(&format)) {
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 4816af9..af821c8 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -4510,12 +4510,12 @@
return (uint64_t)(glFormat);
}
-GrProgramDesc GrGLCaps::makeDesc(GrRenderTarget* rt,
+GrProgramDesc GrGLCaps::makeDesc(GrRenderTarget* /* rt */,
const GrProgramInfo& programInfo,
ProgramDescOverrideFlags overrideFlags) const {
SkASSERT(overrideFlags == ProgramDescOverrideFlags::kNone);
GrProgramDesc desc;
- GrProgramDesc::Build(&desc, rt, programInfo, *this);
+ GrProgramDesc::Build(&desc, programInfo, *this);
return desc;
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 77103df..3019c3e 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -168,7 +168,7 @@
return;
}
sk_sp<SkData> key = SkData::MakeWithoutCopy(this->desc().asKey(), this->desc().keyLength());
- SkString description = GrProgramDesc::Describe(fRenderTarget, fProgramInfo, *fGpu->caps());
+ SkString description = GrProgramDesc::Describe(fProgramInfo, *fGpu->caps());
if (fGpu->glCaps().programBinarySupport()) {
// binary cache
GrGLsizei length = 0;
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.h b/src/gpu/glsl/GrGLSLProgramBuilder.h
index 576f9fe..6097d07 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.h
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.h
@@ -11,7 +11,6 @@
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrGeometryProcessor.h"
#include "src/gpu/GrProgramInfo.h"
-#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
@@ -24,6 +23,7 @@
#include <vector>
class GrProgramDesc;
+class GrRenderTarget;
class GrShaderVar;
class GrGLSLVaryingHandler;
class SkString;
diff --git a/src/gpu/mock/GrMockCaps.cpp b/src/gpu/mock/GrMockCaps.cpp
index 4a8633b..7fefc0d 100644
--- a/src/gpu/mock/GrMockCaps.cpp
+++ b/src/gpu/mock/GrMockCaps.cpp
@@ -9,12 +9,12 @@
#include "src/gpu/GrProgramDesc.h"
-GrProgramDesc GrMockCaps::makeDesc(GrRenderTarget* rt,
+GrProgramDesc GrMockCaps::makeDesc(GrRenderTarget* /* rt */,
const GrProgramInfo& programInfo,
ProgramDescOverrideFlags overrideFlags) const {
SkASSERT(overrideFlags == ProgramDescOverrideFlags::kNone);
GrProgramDesc desc;
- GrProgramDesc::Build(&desc, rt, programInfo, *this);
+ GrProgramDesc::Build(&desc, programInfo, *this);
return desc;
}
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 5a43cda..f475fa4 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -1096,7 +1096,7 @@
ProgramDescOverrideFlags overrideFlags) const {
SkASSERT(overrideFlags == ProgramDescOverrideFlags::kNone);
GrProgramDesc desc;
- GrProgramDesc::Build(&desc, rt, programInfo, *this);
+ GrProgramDesc::Build(&desc, programInfo, *this);
GrProcessorKeyBuilder b(desc.key());
diff --git a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
index a07d36a..0ca0d91 100644
--- a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
+++ b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
@@ -74,10 +74,7 @@
bool isSkSL) {
sk_sp<SkData> key = SkData::MakeWithoutCopy(this->desc().asKey(),
this->desc().keyLength());
- // TODO(skia:11372): We don't have the render target here, so pass null. This just means that
- // any render-target state won't be accurately included in the description.
- SkString description =
- GrProgramDesc::Describe(/*renderTarget=*/nullptr, fProgramInfo, *this->caps());
+ SkString description = GrProgramDesc::Describe(fProgramInfo, *this->caps());
// cache metadata to allow for a complete precompile in either case
GrPersistentCacheUtils::ShaderMetadata meta;
meta.fSettings = settings;
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 236be79..e31e180 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -1769,7 +1769,7 @@
const GrProgramInfo& programInfo,
ProgramDescOverrideFlags overrideFlags) const {
GrProgramDesc desc;
- GrProgramDesc::Build(&desc, rt, programInfo, *this);
+ GrProgramDesc::Build(&desc, programInfo, *this);
GrProcessorKeyBuilder b(desc.key());
diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp
index c951dc8..1d6d312 100644
--- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp
+++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp
@@ -162,7 +162,7 @@
// to the key right after the base key.
sk_sp<SkData> key = SkData::MakeWithoutCopy(this->desc().asKey(),
this->desc().initialKeyLength()+4);
- SkString description = GrProgramDesc::Describe(fRenderTarget, fProgramInfo, *this->caps());
+ SkString description = GrProgramDesc::Describe(fProgramInfo, *this->caps());
sk_sp<SkData> data = GrPersistentCacheUtils::PackCachedShaders(isSkSL ? kSKSL_Tag : kSPIRV_Tag,
shaders,