Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Unified Diff: src/gpu/vk/GrVkTextureRenderTarget.cpp

Issue 2146103002: Update RT views and framebuffer in vulkan after mipmaping (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkTextureRenderTarget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkTextureRenderTarget.cpp
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp
index df2ad69ce0f0f260b80b1aa05a5c4178e0135fbe..bee6a04fd28b6570b916ccf7cedf5a7646016296 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.cpp
+++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp
@@ -25,13 +25,9 @@ GrVkTextureRenderTarget* GrVkTextureRenderTarget::Create(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped) {
VkImage image = info.fImage;
// Create the texture ImageView
- uint32_t mipLevels = 1;
- //TODO: does a mipmapped textureRenderTarget make sense?
- //if (desc.fIsMipMapped) {
- // mipLevels = SkMipMap::ComputeLevelCount(this->width(), this->height()) + 1;
- //}
const GrVkImageView* imageView = GrVkImageView::Create(gpu, image, info.fFormat,
- GrVkImageView::kColor_Type, mipLevels);
+ GrVkImageView::kColor_Type,
+ info.fLevelCount);
if (!imageView) {
return nullptr;
}
@@ -63,44 +59,31 @@ GrVkTextureRenderTarget* GrVkTextureRenderTarget::Create(GrVkGpu* gpu,
// Set color attachment image
colorImage = msInfo.fImage;
- // Create resolve attachment view if necessary.
- // If the format matches, this is the same as the texture imageView.
- if (pixelFormat == info.fFormat) {
- resolveAttachmentView = imageView;
- resolveAttachmentView->ref();
- } else {
- resolveAttachmentView = GrVkImageView::Create(gpu, image, pixelFormat,
- GrVkImageView::kColor_Type, 1);
- if (!resolveAttachmentView) {
- GrVkImage::DestroyImageInfo(gpu, &msInfo);
- imageView->unref(gpu);
- return nullptr;
- }
+ // Create resolve attachment view.
+ resolveAttachmentView = GrVkImageView::Create(gpu, image, pixelFormat,
+ GrVkImageView::kColor_Type,
+ info.fLevelCount);
+ if (!resolveAttachmentView) {
+ GrVkImage::DestroyImageInfo(gpu, &msInfo);
+ imageView->unref(gpu);
+ return nullptr;
}
} else {
// Set color attachment image
colorImage = info.fImage;
}
- const GrVkImageView* colorAttachmentView;
- // Get color attachment view.
- // If the format matches and there's no multisampling,
- // this is the same as the texture imageView
- if (pixelFormat == info.fFormat && !resolveAttachmentView) {
- colorAttachmentView = imageView;
- colorAttachmentView->ref();
- } else {
- colorAttachmentView = GrVkImageView::Create(gpu, colorImage, pixelFormat,
- GrVkImageView::kColor_Type, 1);
- if (!colorAttachmentView) {
- if (desc.fSampleCnt) {
- resolveAttachmentView->unref(gpu);
- GrVkImage::DestroyImageInfo(gpu, &msInfo);
- }
- imageView->unref(gpu);
- return nullptr;
+ const GrVkImageView* colorAttachmentView = GrVkImageView::Create(gpu, colorImage, pixelFormat,
+ GrVkImageView::kColor_Type, 1);
+ if (!colorAttachmentView) {
+ if (desc.fSampleCnt) {
+ resolveAttachmentView->unref(gpu);
+ GrVkImage::DestroyImageInfo(gpu, &msInfo);
}
+ imageView->unref(gpu);
+ return nullptr;
}
+
GrVkTextureRenderTarget* texRT;
if (desc.fSampleCnt) {
if (GrVkImage::kNot_Wrapped == wrapped) {
@@ -165,3 +148,36 @@ GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu,
return trt;
}
+
+bool GrVkTextureRenderTarget::updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo) {
+ VkFormat pixelFormat;
+ GrPixelConfigToVkFormat(fDesc.fConfig, &pixelFormat);
+ if (fDesc.fSampleCnt) {
+ const GrVkImageView* resolveAttachmentView =
+ GrVkImageView::Create(gpu,
+ newInfo.fImage,
+ pixelFormat,
+ GrVkImageView::kColor_Type,
+ newInfo.fLevelCount);
+ if (!resolveAttachmentView) {
+ return false;
+ }
+ fResolveAttachmentView->unref(gpu);
+ fResolveAttachmentView = resolveAttachmentView;
+ } else {
+ const GrVkImageView* colorAttachmentView = GrVkImageView::Create(gpu,
+ newInfo.fImage,
+ pixelFormat,
+ GrVkImageView::kColor_Type,
+ 1);
+ if (!colorAttachmentView) {
+ return false;
+ }
+ fColorAttachmentView->unref(gpu);
+ fColorAttachmentView = colorAttachmentView;
+ }
+
+ this->createFramebuffer(gpu);
+ return true;
+}
+
« no previous file with comments | « src/gpu/vk/GrVkTextureRenderTarget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698