Flutter Engine
The Flutter Engine
VulkanBackendTextureTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "tests/Test.h"
9
16
17using namespace skgpu::graphite;
18
19namespace {
20const SkISize kSize = {16, 16};
21}
22
23DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT(VulkanBackendTextureSimpleCreationTest, reporter, context,
25 auto recorder = context->makeRecorder();
26
27 bool isProtected = context->priv().caps()->protectedSupport();
28
29 VulkanTextureInfo textureInfo;
30 textureInfo.fSampleCount = 1;
32 textureInfo.fFlags = isProtected ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
37
38 auto beTexture = recorder->createBackendTexture(kSize, textureInfo);
39 REPORTER_ASSERT(reporter, beTexture.isValid());
40 recorder->deleteBackendTexture(beTexture);
41
42 // It should also pass if we set the usage to be a render target
44 beTexture = recorder->createBackendTexture(kSize, textureInfo);
45 REPORTER_ASSERT(reporter, beTexture.isValid());
46 recorder->deleteBackendTexture(beTexture);
47}
48
49// Test that copying BackendTexture variables works.
50DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT(VulkanBackendTextureCopyVariableTest, reporter, context,
52 auto recorder = context->makeRecorder();
53
54 bool isProtected = context->priv().caps()->protectedSupport();
55
56 VulkanTextureInfo textureInfo;
57 textureInfo.fSampleCount = 1;
59 textureInfo.fFlags = isProtected ? VK_IMAGE_CREATE_PROTECTED_BIT : 0;
64
65 BackendTexture beTexture = recorder->createBackendTexture(kSize, textureInfo);
66 REPORTER_ASSERT(reporter, beTexture.isValid());
67
68 BackendTexture beTexture2;
69 REPORTER_ASSERT(reporter, beTexture2 != beTexture);
70 REPORTER_ASSERT(reporter, beTexture2.getVkImage() == VK_NULL_HANDLE);
71 REPORTER_ASSERT(reporter, beTexture2.getVkImageLayout() == VK_IMAGE_LAYOUT_UNDEFINED);
72
73 beTexture2 = beTexture;
74 REPORTER_ASSERT(reporter, beTexture2 == beTexture);
75 REPORTER_ASSERT(reporter, beTexture2.getVkImage() == beTexture.getVkImage());
76 REPORTER_ASSERT(reporter, beTexture2.getVkImageLayout() == beTexture.getVkImageLayout());
78 reporter, beTexture2.getVkQueueFamilyIndex() == beTexture.getVkQueueFamilyIndex());
79
80 recorder->deleteBackendTexture(beTexture);
81 // The backend memory of beTexture2 == that of beTexture, so only call delete once.
82}
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT(VulkanBackendTextureSimpleCreationTest, reporter, context, CtsEnforcement::kNextRelease)
constexpr int kSize
Definition: SkSize.h:16
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan_core.h:1331
@ VK_SHARING_MODE_EXCLUSIVE
Definition: vulkan_core.h:1813
@ VK_IMAGE_CREATE_PROTECTED_BIT
Definition: vulkan_core.h:2320
@ VK_IMAGE_TILING_OPTIMAL
Definition: vulkan_core.h:1767
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan_core.h:2354
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan_core.h:2356
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496