Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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;
31 textureInfo.fMipmapped = skgpu::Mipmapped::kNo;
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;
58 textureInfo.fMipmapped = skgpu::Mipmapped::kNo;
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
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
#define DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT(name, reporter, graphite_context, ctsEnforcement)
Definition Test.h:381
static constexpr int kSize
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_SHARING_MODE_EXCLUSIVE
@ VK_IMAGE_CREATE_PROTECTED_BIT
@ VK_IMAGE_TILING_OPTIMAL
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
#define VK_NULL_HANDLE
Definition vulkan_core.h:46
@ VK_FORMAT_R8G8B8A8_UNORM