aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-02-09 10:49:23 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-09 16:14:51 +0000
commit3b2ebbb2d49d41553ff17d64202e2046b1af1560 (patch)
treed8b617014c9bf9a0943031a9c97251cbb72bdd26
parent1fabd51f585383b0f7b8f82c4489989e9379627b (diff)
When querying mipmapped on proxies return targets state if possible
In the non-ddl world where we are still using lazy proxies, we may create those proxies with no mipmaps, but when we instantiate them immediately we end up getting a surface with mips. This allows future queries on that proxy to take advatage of the fact that we actaully have mips. For lazy ddl proxies, this makes it work in a world where we may decide to uninstantiate the proxies and we continue to track the request mip level as well as the actually one from instantiation. Bug: skia: Change-Id: I4824e74d5e2a2fdf860709c85469aa8cf74632d5 Reviewed-on: https://skia-review.googlesource.com/106121 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
-rw-r--r--include/private/GrTextureProxy.h7
-rw-r--r--src/gpu/GrTextureProxy.cpp11
-rw-r--r--src/gpu/GrTextureProxyPriv.h3
-rw-r--r--src/gpu/GrTextureRenderTargetProxy.cpp6
4 files changed, 22 insertions, 5 deletions
diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h
index 3adfa58b74..92754d6075 100644
--- a/include/private/GrTextureProxy.h
+++ b/include/private/GrTextureProxy.h
@@ -29,7 +29,12 @@ public:
GrSamplerState::Filter highestFilterMode() const;
- GrMipMapped mipMapped() const { return fMipMapped; }
+ // If we are instantiated and have a target, return the mip state of that target. Otherwise
+ // returns the proxy's mip state from creation time. This is useful for lazy proxies which may
+ // claim to not need mips at creation time, but the instantiation happens to give us a mipped
+ // target. In that case we should use that for our benefit to avoid possible copies/mip
+ // generation later.
+ GrMipMapped mipMapped() const;
/**
* Return the texture proxy's unique key. It will be invalid if the proxy doesn't have one.
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index d15b611edb..834d92b345 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -118,9 +118,16 @@ GrSamplerState::Filter GrTextureProxy::highestFilterMode() const {
return GrSamplerState::Filter::kMipMap;
}
+GrMipMapped GrTextureProxy::mipMapped() const {
+ if (this->priv().isInstantiated()) {
+ return this->priv().peekTexture()->texturePriv().mipMapped();
+ }
+ return fMipMapped;
+}
+
size_t GrTextureProxy::onUninstantiatedGpuMemorySize() const {
return GrSurface::ComputeSize(this->config(), this->width(), this->height(), 1,
- this->mipMapped(), !this->priv().isExact());
+ this->texPriv().proxyMipMapped(), !this->priv().isExact());
}
void GrTextureProxy::setUniqueKey(GrProxyProvider* proxyProvider, const GrUniqueKey& key) {
@@ -149,7 +156,7 @@ void GrTextureProxy::validateLazySurface(const GrSurface* surface) {
// Anything that is checked here should be duplicated in GrTextureRenderTargetProxy's version
SkASSERT(surface->asTexture());
- SkASSERT(GrMipMapped::kNo == this->mipMapped() ||
+ SkASSERT(GrMipMapped::kNo == this->texPriv().proxyMipMapped() ||
GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped());
}
#endif
diff --git a/src/gpu/GrTextureProxyPriv.h b/src/gpu/GrTextureProxyPriv.h
index e961493179..3b68374d49 100644
--- a/src/gpu/GrTextureProxyPriv.h
+++ b/src/gpu/GrTextureProxyPriv.h
@@ -27,6 +27,9 @@ public:
// Clears any deferred uploader object on the proxy. Used to free the CPU data after the
// contents have been uploaded.
void resetDeferredUploader();
+ // Returns the GrMipMapped value of the proxy from creation time regardless of whether it has
+ // been instantiated or not.
+ GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
private:
explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp
index b4889faa57..1160756728 100644
--- a/src/gpu/GrTextureRenderTargetProxy.cpp
+++ b/src/gpu/GrTextureRenderTargetProxy.cpp
@@ -10,6 +10,7 @@
#include "GrCaps.h"
#include "GrTexture.h"
#include "GrTexturePriv.h"
+#include "GrTextureProxyPriv.h"
#include "GrRenderTarget.h"
#include "GrSurfaceProxyPriv.h"
@@ -63,7 +64,8 @@ size_t GrTextureRenderTargetProxy::onUninstantiatedGpuMemorySize() const {
// TODO: do we have enough information to improve this worst case estimate?
return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
- colorSamplesPerPixel, this->mipMapped(), !this->priv().isExact());
+ colorSamplesPerPixel, this->texPriv().proxyMipMapped(),
+ !this->priv().isExact());
}
bool GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
@@ -109,7 +111,7 @@ sk_sp<GrSurface> GrTextureRenderTargetProxy::createSurface(
void GrTextureRenderTargetProxy::validateLazySurface(const GrSurface* surface) {
// Anything checked here should also be checking the GrTextureProxy version
SkASSERT(surface->asTexture());
- SkASSERT(GrMipMapped::kNo == this->mipMapped() ||
+ SkASSERT(GrMipMapped::kNo == this->texPriv().proxyMipMapped() ||
GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped());
// Anything checked here should also be checking the GrRenderTargetProxy version