aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrGpuResource.cpp11
-rw-r--r--src/gpu/GrResourceCache.cpp23
-rw-r--r--src/gpu/GrResourceCache.h8
-rw-r--r--src/gpu/GrTexturePriv.h4
-rw-r--r--src/gpu/gl/GrGLGpu.cpp25
-rw-r--r--src/gpu/vk/GrVkGpu.cpp53
-rw-r--r--src/gpu/vk/GrVkTexture.cpp67
-rw-r--r--src/gpu/vk/GrVkTexture.h2
8 files changed, 6 insertions, 187 deletions
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index ec7113562b..27e0e4ab74 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -118,17 +118,6 @@ GrContext* GrGpuResource::getContext() {
}
}
-void GrGpuResource::didChangeGpuMemorySize() const {
- if (this->wasDestroyed()) {
- return;
- }
-
- size_t oldSize = fGpuMemorySize;
- SkASSERT(kInvalidGpuMemorySize != oldSize);
- fGpuMemorySize = kInvalidGpuMemorySize;
- get_resource_cache(fGpu)->resourceAccess().didChangeGpuMemorySize(this, oldSize);
-}
-
void GrGpuResource::removeUniqueKey() {
if (this->wasDestroyed()) {
return;
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 8e41ba69a7..2e072533a2 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -413,29 +413,6 @@ void GrResourceCache::notifyCntReachedZero(GrGpuResource* resource, uint32_t fla
this->validate();
}
-void GrResourceCache::didChangeGpuMemorySize(const GrGpuResource* resource, size_t oldSize) {
- SkASSERT(resource);
- SkASSERT(this->isInCache(resource));
-
- ptrdiff_t delta = resource->gpuMemorySize() - oldSize;
-
- fBytes += delta;
-#if GR_CACHE_STATS
- fHighWaterBytes = SkTMax(fBytes, fHighWaterBytes);
-#endif
- if (SkBudgeted::kYes == resource->resourcePriv().isBudgeted()) {
- fBudgetedBytes += delta;
- TRACE_COUNTER2("skia.gpu.cache", "skia budget", "used",
- fBudgetedBytes, "free", fMaxBytes - fBudgetedBytes);
-#if GR_CACHE_STATS
- fBudgetedHighWaterBytes = SkTMax(fBudgetedBytes, fBudgetedHighWaterBytes);
-#endif
- }
-
- this->purgeAsNeeded();
- this->validate();
-}
-
void GrResourceCache::didChangeBudgetStatus(GrGpuResource* resource) {
SkASSERT(resource);
SkASSERT(this->isInCache(resource));
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index b91e664d18..771b13fb26 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -265,7 +265,6 @@ private:
void insertResource(GrGpuResource*);
void removeResource(GrGpuResource*);
void notifyCntReachedZero(GrGpuResource*, uint32_t flags);
- void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize);
void changeUniqueKey(GrGpuResource*, const GrUniqueKey&);
void removeUniqueKey(GrGpuResource*);
void willRemoveScratchKey(const GrGpuResource*);
@@ -413,13 +412,6 @@ private:
}
/**
- * Called by GrGpuResources when their sizes change.
- */
- void didChangeGpuMemorySize(const GrGpuResource* resource, size_t oldSize) {
- fCache->didChangeGpuMemorySize(resource, oldSize);
- }
-
- /**
* Called by GrGpuResources to change their unique keys.
*/
void changeUniqueKey(GrGpuResource* resource, const GrUniqueKey& newKey) {
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index 2979e8bd94..1cdd2dc9f5 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -36,10 +36,6 @@ public:
return GrMipMapped::kNo;
}
- void setMaxMipMapLevel(int maxMipMapLevel) const {
- fTexture->fMaxMipMapLevel = maxMipMapLevel;
- }
-
int maxMipMapLevel() const {
return fTexture->fMaxMipMapLevel;
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 3e2c1b48b8..2c7d977659 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2905,8 +2905,6 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, GrGLTexture* texture
}
texture->texturePriv().markMipMapsClean();
- texture->texturePriv().setMaxMipMapLevel(SkMipMap::ComputeLevelCount(
- texture->width(), texture->height()));
// We have potentially set lots of state on the texture. Easiest to dirty it all:
texture->textureParamsModified();
@@ -3849,28 +3847,7 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin
int width = texture->width();
int height = texture->height();
int levelCount = SkMipMap::ComputeLevelCount(width, height) + 1;
-
- // Define all mips, if we haven't previously done so:
- if (0 == texture->texturePriv().maxMipMapLevel()) {
- GrGLenum internalFormat;
- GrGLenum externalFormat;
- GrGLenum externalType;
- if (!this->glCaps().getTexImageFormats(texture->config(), texture->config(),
- &internalFormat, &externalFormat, &externalType)) {
- return false;
- }
-
- this->unbindCpuToGpuXferBuffer();
-
- for (GrGLint level = 1; level < levelCount; ++level) {
- // Define the next mip:
- width = SkTMax(1, width / 2);
- height = SkTMax(1, height / 2);
- GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D, level, internalFormat,
- width, height, 0,
- externalFormat, externalType, nullptr));
- }
- }
+ SkASSERT(levelCount == texture->texturePriv().maxMipMapLevel() + 1);
// Create (if necessary), then bind temporary FBO:
if (0 == fTempDstFBOID) {
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index a99931188d..346d95b0c2 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -359,12 +359,7 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, int left, int top, int width, in
success = this->uploadTexDataLinear(vkTex, left, top, width, height, srcColorType,
texels[0].fPixels, texels[0].fRowBytes);
} else {
- int currentMipLevels = vkTex->texturePriv().maxMipMapLevel() + 1;
- if (mipLevelCount > currentMipLevels) {
- if (!vkTex->reallocForMipmap(this, mipLevelCount)) {
- return false;
- }
- }
+ SkASSERT(mipLevelCount <= vkTex->texturePriv().maxMipMapLevel() + 1);
success = this->uploadTexDataOptimal(vkTex, left, top, width, height, srcColorType, texels,
mipLevelCount);
}
@@ -932,49 +927,11 @@ void GrVkGpu::generateMipmap(GrVkTexture* tex, GrSurfaceOrigin texOrigin) {
// SkMipMap doesn't include the base level in the level count so we have to add 1
uint32_t levelCount = SkMipMap::ComputeLevelCount(tex->width(), tex->height()) + 1;
- if (levelCount != tex->mipLevels()) {
- const GrVkResource* oldResource = tex->resource();
- oldResource->ref();
- // grab handle to the original image resource
- VkImage oldImage = tex->image();
-
- // change the original image's layout so we can copy from it
- tex->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
- VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, false);
-
- if (!tex->reallocForMipmap(this, levelCount)) {
- oldResource->unref(this);
- return;
- }
- // change the new image's layout so we can blit to it
- tex->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
- VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, false);
+ SkASSERT(levelCount == tex->mipLevels());
- // Blit original image to top level of new image
- blitRegion.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 };
- blitRegion.srcOffsets[0] = { 0, 0, 0 };
- blitRegion.srcOffsets[1] = { width, height, 1 };
- blitRegion.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 };
- blitRegion.dstOffsets[0] = { 0, 0, 0 };
- blitRegion.dstOffsets[1] = { width, height, 1 };
-
- fCurrentCmdBuffer->blitImage(this,
- oldResource,
- oldImage,
- VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
- tex->resource(),
- tex->image(),
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
- 1,
- &blitRegion,
- VK_FILTER_LINEAR);
-
- oldResource->unref(this);
- } else {
- // change layout of the layers so we can write to them.
- tex->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
- VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, false);
- }
+ // change layout of the layers so we can write to them.
+ tex->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+ VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, false);
// setup memory barrier
SkASSERT(GrVkFormatIsSupported(tex->imageFormat()));
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index c4c7a8f1e1..1f1d1bbc1a 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -160,70 +160,3 @@ const GrVkImageView* GrVkTexture::textureView() {
return fTextureView;
}
-bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) {
- if (mipLevels == 1) {
- // don't need to do anything for a 1x1 texture
- return false;
- }
-
- const GrVkResource* oldResource = this->resource();
-
- // We shouldn't realloc something that doesn't belong to us
- if (fIsBorrowed) {
- return false;
- }
-
- bool renderTarget = SkToBool(this->asRenderTarget());
-
- VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
- if (renderTarget) {
- usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
- }
- usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
-
- GrVkImage::ImageDesc imageDesc;
- imageDesc.fImageType = VK_IMAGE_TYPE_2D;
- imageDesc.fFormat = fInfo.fFormat;
- imageDesc.fWidth = this->width();
- imageDesc.fHeight = this->height();
- imageDesc.fLevels = mipLevels;
- imageDesc.fSamples = 1;
- imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
- imageDesc.fUsageFlags = usageFlags;
- imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
-
- GrVkImageInfo info;
- if (!GrVkImage::InitImageInfo(gpu, imageDesc, &info)) {
- return false;
- }
-
- // have to create a new image view for new resource
- const GrVkImageView* oldView = fTextureView;
- VkImage image = info.fImage;
- const GrVkImageView* textureView = GrVkImageView::Create(gpu, image, info.fFormat,
- GrVkImageView::kColor_Type, mipLevels);
- if (!textureView) {
- GrVkImage::DestroyImageInfo(gpu, &info);
- return false;
- }
-
- if (renderTarget) {
- GrVkTextureRenderTarget* texRT = static_cast<GrVkTextureRenderTarget*>(this);
- if (!texRT->updateForMipmap(gpu, info)) {
- GrVkImage::DestroyImageInfo(gpu, &info);
- return false;
- }
- }
-
- oldResource->unref(gpu);
- oldView->unref(gpu);
-
- this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling);
- fTextureView = textureView;
- fInfo = info;
- this->updateImageLayout(info.fImageLayout);
- // SetMaxMipMapLevel stores the max level not the number of levels
- this->texturePriv().setMaxMipMapLevel(mipLevels-1);
-
- return true;
-}
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index 91ed671c12..c6f7c277bb 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -35,8 +35,6 @@ public:
const GrVkImageView* textureView();
- bool reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels);
-
// In Vulkan we call the release proc after we are finished with the underlying
// GrVkImage::Resource object (which occurs after the GPU has finsihed all work on it).
void setRelease(sk_sp<GrReleaseProcHelper> releaseHelper) override {