Reland "Revert "Use ManagedBackendTexture in place of TestUtils backend texture helpers.""
This reverts commit 21f8b5109951b16ff327f39072d7b5b141ac5c09.
Reason for revert: D3D traced resource assert from unit test
Original change's description:
> Revert "Revert "Use ManagedBackendTexture in place of TestUtils backend texture helpers.""
>
> This reverts commit f625e4ce4504facbf0cfa210f8d9770b8431cdd9.
>
> Change-Id: Id73c53ec7ab8d4a5951712dc150d86e6349addbf
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325658
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=egdaniel@google.com,bsalomon@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: I407f1d522d5c4f28d070cc2ce87af7faffca11fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325860
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/tests/VkBackendSurfaceTest.cpp b/tests/VkBackendSurfaceTest.cpp
index b9f2847..dc61c39 100644
--- a/tests/VkBackendSurfaceTest.cpp
+++ b/tests/VkBackendSurfaceTest.cpp
@@ -11,11 +11,15 @@
#if defined(SK_VULKAN)
+#include "include/gpu/vk/GrVkVulkan.h"
+
+#include "tests/Test.h"
+#include "tests/TestUtils.h"
+
#include "include/core/SkImage.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/vk/GrVkTypes.h"
-#include "include/gpu/vk/GrVkVulkan.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
@@ -26,50 +30,41 @@
#include "src/image/SkImage_Base.h"
#include "src/image/SkImage_GpuBase.h"
#include "src/image/SkSurface_Gpu.h"
-#include "tests/Test.h"
-#include "tools/gpu/ManagedBackendTexture.h"
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
auto dContext = ctxInfo.directContext();
- auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
- dContext, 1, 1, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kNo);
- if (!mbet) {
- ERRORF(reporter, "Could not create backend texture.");
- return;
- }
+ GrBackendTexture backendTex;
+ CreateBackendTexture(dContext, &backendTex, 1, 1, kRGBA_8888_SkColorType,
+ SkColors::kTransparent, GrMipmapped::kNo,
+ GrRenderable::kNo, GrProtected::kNo);
+ REPORTER_ASSERT(reporter, backendTex.isValid());
GrVkImageInfo info;
- REPORTER_ASSERT(reporter, mbet->texture().getVkImageInfo(&info));
+ REPORTER_ASSERT(reporter, backendTex.getVkImageInfo(&info));
VkImageLayout initLayout = info.fImageLayout;
// Verify that setting that layout via a copy of a backendTexture is reflected in all the
// backendTextures.
- GrBackendTexture backendTex1 = mbet->texture();
- GrBackendTexture backendTex2 = backendTex1;
- REPORTER_ASSERT(reporter, backendTex2.getVkImageInfo(&info));
+ GrBackendTexture backendTexCopy = backendTex;
+ REPORTER_ASSERT(reporter, backendTexCopy.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, initLayout == info.fImageLayout);
- backendTex2.setVkImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ backendTexCopy.setVkImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
- REPORTER_ASSERT(reporter, backendTex1.getVkImageInfo(&info));
+ REPORTER_ASSERT(reporter, backendTex.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == info.fImageLayout);
- REPORTER_ASSERT(reporter, backendTex2.getVkImageInfo(&info));
+ REPORTER_ASSERT(reporter, backendTexCopy.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == info.fImageLayout);
// Setting back the layout since we didn't actually change it
- backendTex1.setVkImageLayout(initLayout);
+ backendTex.setVkImageLayout(initLayout);
- sk_sp<SkImage> wrappedImage = SkImage::MakeFromTexture(
- dContext,
- backendTex1,
- kTopLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- kPremul_SkAlphaType,
- /*color space*/ nullptr,
- sk_gpu_test::ManagedBackendTexture::ReleaseProc,
- mbet->releaseContext());
+ sk_sp<SkImage> wrappedImage = SkImage::MakeFromTexture(dContext, backendTex,
+ kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ kPremul_SkAlphaType, nullptr);
REPORTER_ASSERT(reporter, wrappedImage.get());
const GrSurfaceProxyView* view = as_IB(wrappedImage)->view(dContext);
@@ -83,7 +78,7 @@
REPORTER_ASSERT(reporter, initLayout == vkTexture->currentLayout());
vkTexture->updateImageLayout(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
- REPORTER_ASSERT(reporter, backendTex1.getVkImageInfo(&info));
+ REPORTER_ASSERT(reporter, backendTex.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == info.fImageLayout);
GrBackendTexture backendTexImage = wrappedImage->getBackendTexture(false);
@@ -96,10 +91,10 @@
vkTexture->updateImageLayout(initLayout);
- REPORTER_ASSERT(reporter, backendTex1.getVkImageInfo(&info));
+ REPORTER_ASSERT(reporter, backendTex.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, initLayout == info.fImageLayout);
- REPORTER_ASSERT(reporter, backendTex2.getVkImageInfo(&info));
+ REPORTER_ASSERT(reporter, backendTexCopy.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, initLayout == info.fImageLayout);
REPORTER_ASSERT(reporter, backendTexImage.getVkImageInfo(&info));
@@ -108,23 +103,25 @@
// Check that we can do things like assigning the backend texture to invalid one, assign an
// invalid one, assin a backend texture to inself etc. Success here is that we don't hit any of
// our ref counting asserts.
- REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(backendTex1, backendTex2));
+ REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(backendTex, backendTexCopy));
GrBackendTexture invalidTexture;
REPORTER_ASSERT(reporter, !invalidTexture.isValid());
- REPORTER_ASSERT(reporter, !GrBackendTexture::TestingOnly_Equals(invalidTexture, backendTex2));
+ REPORTER_ASSERT(reporter, !GrBackendTexture::TestingOnly_Equals(invalidTexture, backendTexCopy));
- backendTex2 = invalidTexture;
- REPORTER_ASSERT(reporter, !backendTex2.isValid());
- REPORTER_ASSERT(reporter, !GrBackendTexture::TestingOnly_Equals(invalidTexture, backendTex2));
+ backendTexCopy = invalidTexture;
+ REPORTER_ASSERT(reporter, !backendTexCopy.isValid());
+ REPORTER_ASSERT(reporter, !GrBackendTexture::TestingOnly_Equals(invalidTexture, backendTexCopy));
- invalidTexture = backendTex1;
+ invalidTexture = backendTex;
REPORTER_ASSERT(reporter, invalidTexture.isValid());
- REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(invalidTexture, backendTex1));
+ REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(invalidTexture, backendTex));
invalidTexture = static_cast<decltype(invalidTexture)&>(invalidTexture);
REPORTER_ASSERT(reporter, invalidTexture.isValid());
REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(invalidTexture, invalidTexture));
+
+ dContext->deleteBackendTexture(backendTex);
}
// This test is disabled because it executes illegal vulkan calls which cause the validations layers