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

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

Issue 1970293002: Support allowSRGBInputs on Vulkan (via secondary texture views) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: default case for switch Created 4 years, 7 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/GrVkTexture.h ('k') | src/gpu/vk/GrVkUtil.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkTexture.cpp
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 8278d2743748a80028aa171bf6ededb7efe47421..c2a30a27f4184bb00317c963bcb776a51a85bd7c 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -24,7 +24,8 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
: GrSurface(gpu, desc)
, GrVkImage(imageResource)
, INHERITED(gpu, desc, kSampler2D_GrSLType, desc.fIsMipMapped)
- , fTextureView(view) {
+ , fTextureView(view)
+ , fLinearTextureView(nullptr) {
this->registerWithCache(budgeted);
}
@@ -36,7 +37,8 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
: GrSurface(gpu, desc)
, GrVkImage(imageResource)
, INHERITED(gpu, desc, kSampler2D_GrSLType, desc.fIsMipMapped)
- , fTextureView(view) {
+ , fTextureView(view)
+ , fLinearTextureView(nullptr) {
this->registerWithCacheWrapped();
}
@@ -48,7 +50,8 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
: GrSurface(gpu, desc)
, GrVkImage(imageResource)
, INHERITED(gpu, desc, kSampler2D_GrSLType, desc.fIsMipMapped)
- , fTextureView(view) {}
+ , fTextureView(view)
+ , fLinearTextureView(nullptr) {}
template<typename ResourceType>
@@ -126,6 +129,7 @@ GrVkTexture* GrVkTexture::CreateWrappedTexture(GrVkGpu* gpu,
GrVkTexture::~GrVkTexture() {
// either release or abandon should have been called by the owner of this object.
SkASSERT(!fTextureView);
+ SkASSERT(!fLinearTextureView);
}
void GrVkTexture::onRelease() {
@@ -135,6 +139,11 @@ void GrVkTexture::onRelease() {
fTextureView = nullptr;
}
+ if (fLinearTextureView) {
+ fLinearTextureView->unref(this->getVkGpu());
+ fLinearTextureView = nullptr;
+ }
+
this->releaseImage(this->getVkGpu());
INHERITED::onRelease();
@@ -146,6 +155,11 @@ void GrVkTexture::onAbandon() {
fTextureView = nullptr;
}
+ if (fLinearTextureView) {
+ fLinearTextureView->unrefAndAbandon();
+ fLinearTextureView = nullptr;
+ }
+
this->abandonImage();
INHERITED::onAbandon();
}
@@ -160,6 +174,22 @@ GrVkGpu* GrVkTexture::getVkGpu() const {
return static_cast<GrVkGpu*>(this->getGpu());
}
+const GrVkImageView* GrVkTexture::textureView(bool allowSRGB) {
+ VkFormat linearFormat;
+ if (allowSRGB || !GrVkFormatIsSRGB(fResource->fFormat, &linearFormat)) {
+ return fTextureView;
+ }
+
+ if (!fLinearTextureView) {
+ fLinearTextureView = GrVkImageView::Create(this->getVkGpu(), fResource->fImage,
+ linearFormat, GrVkImageView::kColor_Type,
+ fResource->fLevelCount);
+ SkASSERT(fLinearTextureView);
+ }
+
+ return fLinearTextureView;
+}
+
bool GrVkTexture::reallocForMipmap(const GrVkGpu* gpu, uint32_t mipLevels) {
if (mipLevels == 1) {
// don't need to do anything for a 1x1 texture
@@ -210,6 +240,10 @@ bool GrVkTexture::reallocForMipmap(const GrVkGpu* gpu, uint32_t mipLevels) {
oldResource->unref(gpu);
oldView->unref(gpu);
+ if (fLinearTextureView) {
+ fLinearTextureView->unref(gpu);
+ fLinearTextureView = nullptr;
+ }
fResource = imageResource;
fTextureView = textureView;
fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED;
« no previous file with comments | « src/gpu/vk/GrVkTexture.h ('k') | src/gpu/vk/GrVkUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698