aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/VkWrapTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/VkWrapTests.cpp')
-rw-r--r--tests/VkWrapTests.cpp150
1 files changed, 84 insertions, 66 deletions
diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp
index 07b82a8a2d..cf28586196 100644
--- a/tests/VkWrapTests.cpp
+++ b/tests/VkWrapTests.cpp
@@ -32,110 +32,128 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
- GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig,
- false, GrMipMapped::kNo);
- const GrVkImageInfo* imageInfo = reinterpret_cast<const GrVkImageInfo*>(backendObj);
+ GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
+ kPixelConfig, false,
+ GrMipMapped::kNo);
+ const GrVkImageInfo* imageInfo = origBackendTex.getVkImageInfo();
- GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo);
- sk_sp<GrTexture> tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership);
+ sk_sp<GrTexture> tex = gpu->wrapBackendTexture(origBackendTex, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
// image is null
- GrVkImageInfo backendCopy = *imageInfo;
- backendCopy.fImage = VK_NULL_HANDLE;
- backendTex = GrBackendTexture(kW, kH, backendCopy);
- tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
- tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ backendCopy.fImage = VK_NULL_HANDLE;
+ GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
+ tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ }
// alloc is null
- backendCopy.fImage = imageInfo->fImage;
- backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
- backendTex = GrBackendTexture(kW, kH, backendCopy);
- tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
- tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
+ GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
+ tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ }
+
// check adopt creation
- backendCopy.fAlloc = imageInfo->fAlloc;
- backendTex = GrBackendTexture(kW, kH, backendCopy);
- tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
+ tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
- REPORTER_ASSERT(reporter, tex);
+ REPORTER_ASSERT(reporter, tex);
+ }
- gpu->deleteTestingOnlyBackendTexture(backendObj, true);
+ gpu->deleteTestingOnlyBackendTexture(&origBackendTex, true);
}
void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
- GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig,
- true, GrMipMapped::kNo);
- const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
+ GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
+ kPixelConfig, true,
+ GrMipMapped::kNo);
+ const GrVkImageInfo* imageInfo = origBackendTex.getVkImageInfo();
- GrBackendRenderTarget backendRT(kW, kH, 0, 0, *backendTex);
+ GrBackendRenderTarget origBackendRT(kW, kH, 0, 0, *imageInfo);
- sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(backendRT);
+ sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(origBackendRT);
REPORTER_ASSERT(reporter, rt);
// image is null
- GrVkImageInfo backendCopy = *backendTex;
- backendCopy.fImage = VK_NULL_HANDLE;
- GrBackendRenderTarget backendRT2(kW, kH, 0, 0, backendCopy);
- rt = gpu->wrapBackendRenderTarget(backendRT2);
- REPORTER_ASSERT(reporter, !rt);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ backendCopy.fImage = VK_NULL_HANDLE;
+ GrBackendRenderTarget backendRT(kW, kH, 0, 0, backendCopy);
+ rt = gpu->wrapBackendRenderTarget(backendRT);
+ REPORTER_ASSERT(reporter, !rt);
+ }
// alloc is null
- backendCopy.fImage = backendTex->fImage;
- backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
- // can wrap null alloc
- GrBackendRenderTarget backendRT3(kW, kH, 0, 0, backendCopy);
- rt = gpu->wrapBackendRenderTarget(backendRT3);
- REPORTER_ASSERT(reporter, rt);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
+ // can wrap null alloc
+ GrBackendRenderTarget backendRT(kW, kH, 0, 0, backendCopy);
+ rt = gpu->wrapBackendRenderTarget(backendRT);
+ REPORTER_ASSERT(reporter, rt);
+ }
// When we wrapBackendRenderTarget it is always borrowed, so we must make sure to free the
// resource when we're done.
- gpu->deleteTestingOnlyBackendTexture(backendObj, false);
+ gpu->deleteTestingOnlyBackendTexture(&origBackendTex);
}
void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
- GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig,
- true, GrMipMapped::kNo);
- const GrVkImageInfo* imageInfo = reinterpret_cast<const GrVkImageInfo*>(backendObj);
+ GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
+ kPixelConfig, true,
+ GrMipMapped::kNo);
+ const GrVkImageInfo* imageInfo = origBackendTex.getVkImageInfo();
- GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo);
- sk_sp<GrTexture> tex = gpu->wrapRenderableBackendTexture(backendTex, 0,
+ sk_sp<GrTexture> tex = gpu->wrapRenderableBackendTexture(origBackendTex, 0,
kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
// image is null
- GrVkImageInfo backendCopy = *imageInfo;
- backendCopy.fImage = VK_NULL_HANDLE;
- backendTex = GrBackendTexture(kW, kH, backendCopy);
- tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
- tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ backendCopy.fImage = VK_NULL_HANDLE;
+ GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
+ tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ }
// alloc is null
- backendCopy.fImage = imageInfo->fImage;
- backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
- backendTex = GrBackendTexture(kW, kH, backendCopy);
- tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
- tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership);
- REPORTER_ASSERT(reporter, !tex);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
+ GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
+ tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, !tex);
+ }
// check adopt creation
- backendCopy.fAlloc = imageInfo->fAlloc;
- backendTex = GrBackendTexture(kW, kH, backendCopy);
- tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership);
- REPORTER_ASSERT(reporter, tex);
-
- gpu->deleteTestingOnlyBackendTexture(backendObj, true);
+ {
+ GrVkImageInfo backendCopy = *imageInfo;
+ GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
+ tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership);
+ REPORTER_ASSERT(reporter, tex);
+ }
+
+ gpu->deleteTestingOnlyBackendTexture(&origBackendTex, true);
}
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) {