Revert "Move GrGeometryProcessor's textures out of classes and into"
This reverts commit af87483873f0b370b90ebe956301a13cc8662cbe.
Revert "GrGeometryProcessor derives from GrNonAtomicRef not GrProgramElement."
This reverts commit 607be37e3d4ddbe2163c200d6e13bcee981f6bf7.
Revert "Store GrMeshDrawOps' meshes in GrOpFlushState's arena."
This reverts commit b948572c7862214fe2e1fa6cdfcab4fc7b1666ac.
Revert "Remove multitexturing support from GrTextureOp."
This reverts commit 986f64c601f3ed99f84f0c392d1a42e298f6d618.
Revert "Make result of GrOp::combineIfPossible be an enum."
This reverts commit 641ac7daa81cbfca06b310803fb1a607d0fc2b32.
Bug: b/112244393
Change-Id: I579491a3f2f2f2093f1e2a6141fa1e4cc7b760a4
Reviewed-on: https://skia-review.googlesource.com/145646
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index f496044..c0549e9 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -364,6 +364,30 @@
GR_GL_GetIntegerv(gli, GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxSamplers);
shaderCaps->fMaxCombinedSamplers = SkTMin<GrGLint>(kMaxSaneSamplers, maxSamplers);
+ // This is all *very* approximate.
+ switch (ctxInfo.vendor()) {
+ case kNVIDIA_GrGLVendor:
+ // We've seen a range from 100 x 100 (TegraK1, GTX660) up to 300 x 300 (GTX 1070)
+ // but it doesn't clearly align with Pascal vs Maxwell vs Kepler.
+ fShaderCaps->fDisableImageMultitexturingDstRectAreaThreshold = 150 * 150;
+ break;
+ case kImagination_GrGLVendor:
+ // Two PowerVR Rogues, Nexus Player and Chromebook Cb5-312T (PowerVR GX6250), show that
+ // it is always a win to use multitexturing.
+ if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
+ fShaderCaps->fDisableImageMultitexturingDstRectAreaThreshold =
+ std::numeric_limits<size_t>::max();
+ }
+ break;
+ case kATI_GrGLVendor:
+ // So far no AMD GPU shows a performance difference. A tie goes to disabling
+ // multitexturing for simplicity's sake.
+ fShaderCaps->fDisableImageMultitexturingDstRectAreaThreshold = 0;
+ break;
+ default:
+ break;
+ }
+
// SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with
// frequently changing VBOs. We've measured a performance increase using non-VBO vertex
// data for dynamic content on these GPUs. Perhaps we should read the renderer string and
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 7ef043b..cc858a8 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1675,10 +1675,8 @@
}
void GrGLGpu::generateMipmapsForProcessorTextures(const GrPrimitiveProcessor& primProc,
- const GrPipeline& pipeline,
- const GrTextureProxy* const primProcTextures[]) {
+ const GrPipeline& pipeline) {
auto genLevelsIfNeeded = [this](GrTexture* tex, const GrSamplerState& sampler) {
- SkASSERT(tex);
if (sampler.filter() == GrSamplerState::Filter::kMipMap &&
tex->texturePriv().mipMapped() == GrMipMapped::kYes &&
tex->texturePriv().mipMapsAreDirty()) {
@@ -1688,8 +1686,8 @@
};
for (int i = 0; i < primProc.numTextureSamplers(); ++i) {
- GrTexture* tex = primProcTextures[i]->peekTexture();
- genLevelsIfNeeded(tex, primProc.textureSampler(i).samplerState());
+ const auto& textureSampler = primProc.textureSampler(i);
+ genLevelsIfNeeded(textureSampler.peekTexture(), textureSampler.samplerState());
}
GrFragmentProcessor::Iter iter(pipeline);
@@ -1710,11 +1708,8 @@
GrCapsDebugf(this->caps(), "Failed to create program!\n");
return false;
}
- const GrTextureProxy* const* primProcProxies = nullptr;
- if (fixedDynamicState) {
- primProcProxies = fixedDynamicState->fPrimitiveProcessorTextures;
- }
- this->generateMipmapsForProcessorTextures(primProc, pipeline, primProcProxies);
+
+ this->generateMipmapsForProcessorTextures(primProc, pipeline);
GrXferProcessor::BlendInfo blendInfo;
pipeline.getXferProcessor().getBlendInfo(&blendInfo);
@@ -1731,7 +1726,7 @@
this->flushBlend(blendInfo, swizzle);
}
- fHWProgram->updateUniformsAndTextureBindings(primProc, pipeline, primProcProxies);
+ fHWProgram->setData(primProc, pipeline);
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.renderTarget());
GrStencilSettings stencil;
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 0f1127a..32b2945 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -247,9 +247,7 @@
void setTextureSwizzle(int unitIdx, GrGLenum target, const GrGLenum swizzle[]);
- void generateMipmapsForProcessorTextures(
- const GrPrimitiveProcessor&, const GrPipeline&,
- const GrTextureProxy* const primitiveProcessorTextures[]);
+ void generateMipmapsForProcessorTextures(const GrPrimitiveProcessor&, const GrPipeline&);
// Flushes state from GrPipeline to GL. Returns false if the state couldn't be set.
// willDrawPoints must be true if point primitives will be rendered after setting the GL state.
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 9e90642..e0eccf2 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -72,10 +72,7 @@
///////////////////////////////////////////////////////////////////////////////
-void GrGLProgram::updateUniformsAndTextureBindings(const GrPrimitiveProcessor& primProc,
- const GrPipeline& pipeline,
- const GrTextureProxy* const primProcTextures[]) {
- SkASSERT(primProcTextures || !primProc.numTextureSamplers());
+void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) {
this->setRenderTargetState(primProc, pipeline.proxy());
// we set the textures, and uniforms for installed processors in a generic way, but subclasses
@@ -88,8 +85,9 @@
fPrimitiveProcessor->setData(fProgramDataManager, primProc,
GrFragmentProcessor::CoordTransformIter(pipeline));
for (int i = 0; i < primProc.numTextureSamplers(); ++i) {
- auto* tex = static_cast<GrGLTexture*>(primProcTextures[i]->peekTexture());
- fGpu->bindTexture(nextTexSamplerIdx++, primProc.textureSampler(i).samplerState(), tex);
+ const GrPrimitiveProcessor::TextureSampler& sampler = primProc.textureSampler(i);
+ fGpu->bindTexture(nextTexSamplerIdx++, sampler.samplerState(),
+ static_cast<GrGLTexture*>(sampler.peekTexture()));
}
this->setFragmentData(pipeline, &nextTexSamplerIdx);
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index ca9253c..b05b536 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -19,7 +19,6 @@
class GrPipeline;
class GrPrimitiveProcessor;
class GrRenderTargetProxy;
-class GrTextureProxy;
/**
* This class manages a GPU program and records per-program information. It also records the vertex
@@ -111,13 +110,12 @@
};
/**
- * This function uploads uniforms, calls each GrGLSL*Processor's setData. It binds all fragment
- * processor textures. Primitive process textures are also bound here but are passed separately.
- *
- * It is the caller's responsibility to ensure the program is bound before calling.
+ * This function uploads uniforms, calls each GrGL*Processor's setData, and retrieves the
+ * textures that need to be bound on each unit. It is the caller's responsibility to ensure
+ * the program is bound before calling, and to bind the outgoing textures to their respective
+ * units upon return. (Each index in the array corresponds to its matching GL texture unit.)
*/
- void updateUniformsAndTextureBindings(const GrPrimitiveProcessor&, const GrPipeline&,
- const GrTextureProxy* const primitiveProcessorTextures[]);
+ void setData(const GrPrimitiveProcessor&, const GrPipeline&);
int vertexStride() const { return fVertexStride; }
int instanceStride() const { return fInstanceStride; }
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index ba290ac..b60088d 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -33,7 +33,11 @@
const GrPipeline& pipeline,
GrProgramDesc* desc,
GrGLGpu* gpu) {
- SkASSERT(!pipeline.isBad());
+#ifdef SK_DEBUG
+ GrResourceProvider* resourceProvider = gpu->getContext()->contextPriv().resourceProvider();
+
+ SkASSERT(!pipeline.isBad() && primProc.instantiate(resourceProvider));
+#endif
ATRACE_ANDROID_FRAMEWORK("Shader Compile");
GrAutoLocaleSetter als("C");