aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-06-13 09:41:19 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-13 18:06:56 +0000
commitda86e2822ab31770e989009716dd4c89966ade45 (patch)
tree66a8fe4ff7e07bd7003f317d0b29a39ebf411790 /src/gpu/vk
parente141548696bd049b0e520391ff64e64e4e02c55f (diff)
Remove unused code that was used for late mip allocations.
This also includes removing code to support changing GrGpuResource's size since we now have to way to ever change the size. Bug: skia: Change-Id: Id27a8bc3cc94f5b954beda528b209727ede10ef6 Reviewed-on: https://skia-review.googlesource.com/134503 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/vk')
-rw-r--r--src/gpu/vk/GrVkGpu.cpp53
-rw-r--r--src/gpu/vk/GrVkTexture.cpp67
-rw-r--r--src/gpu/vk/GrVkTexture.h2
3 files changed, 5 insertions, 117 deletions
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 {