MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / TEST_F

Function TEST_F

tests/unit/image_drm_positive.cpp:48–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46class PositiveImageDrm : public ImageDrmTest {};
47
48TEST_F(PositiveImageDrm, Basic) {
49 // See https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/2610
50 // for more detailed checking, we could export the image to dmabuf
51 // and then import it again (using VkImageDrmFormatModifierExplicitCreateInfoEXT)
52 TEST_DESCRIPTION("Create image and imageView using VK_EXT_image_drm_format_modifier");
53 RETURN_IF_SKIP(InitBasicImageDrm());
54
55 // we just hope that one of these formats supports modifiers
56 // for more detailed checking, we could also check multi-planar formats.
57 auto format_list = {
58 VK_FORMAT_B8G8R8A8_UNORM,
59 VK_FORMAT_B8G8R8A8_SRGB,
60 VK_FORMAT_R8G8B8A8_UNORM,
61 VK_FORMAT_R8G8B8A8_SRGB,
62 };
63
64 for (auto format : format_list) {
65 std::vector<uint64_t> mods =
66 GetFormatModifier(format, VK_FORMAT_FEATURE_TRANSFER_DST_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
67 if (mods.empty()) {
68 continue;
69 }
70
71 // create image
72 VkImageCreateInfo ci = vku::InitStructHelper();
73 ci.flags = 0;
74 ci.imageType = VK_IMAGE_TYPE_2D;
75 ci.format = format;
76 ci.extent = {128, 128, 1};
77 ci.mipLevels = 1;
78 ci.arrayLayers = 1;
79 ci.samples = VK_SAMPLE_COUNT_1_BIT;
80 ci.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
81 ci.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
82 ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
83 ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
84
85 VkImageDrmFormatModifierListCreateInfoEXT mod_list = vku::InitStructHelper();
86 mod_list.pDrmFormatModifiers = mods.data();
87 mod_list.drmFormatModifierCount = mods.size();
88 ci.pNext = &mod_list;
89
90 vkt::Image image(*m_device, ci, vkt::no_mem);
91
92 VkMemoryRequirements mem_reqs = image.MemoryRequirements();
93 VkMemoryAllocateInfo alloc_info = vku::InitStructHelper();
94 alloc_info.allocationSize = mem_reqs.size;
95 if (!m_device->Physical().SetMemoryType(mem_reqs.memoryTypeBits, &alloc_info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
96 GTEST_SKIP() << "Memory type not found";
97 }
98
99 vkt::DeviceMemory memory(*m_device, alloc_info);
100 ASSERT_EQ(VK_SUCCESS, vk::BindImageMemory(device(), image, memory, 0));
101 vkt::ImageView image_view = image.CreateView();
102 }
103}
104
105TEST_F(PositiveImageDrm, ExternalMemory) {

Callers

nothing calls this directly

Calls 13

BindImageMemoryFunction · 0.85
size32Function · 0.85
MemoryRequirementsMethod · 0.80
SetMemoryTypeMethod · 0.80
CreateViewMethod · 0.80
initializedMethod · 0.80
emptyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected