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

Method InitHostVisibleWithData

tests/framework/binding.cpp:1120–1138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118}
1119
1120void Buffer::InitHostVisibleWithData(const Device& dev, VkBufferUsageFlags usage, const void* data, size_t data_size,
1121 const vvl::span<uint32_t>& queue_families) {
1122 const auto create_info = CreateInfo(static_cast<VkDeviceSize>(data_size), usage, queue_families);
1123 InitNoMemory(dev, create_info);
1124
1125 // According to the specification there is always a host visible coherent memory type.
1126 // It can always be bound to a buffer created without SPARSE_BINDING/PROTECTED flags.
1127 const VkMemoryPropertyFlags memory_properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
1128 const VkMemoryRequirements memory_requirements = MemoryRequirements();
1129 VkMemoryAllocateInfo alloc_info = vku::InitStructHelper();
1130 alloc_info.allocationSize = memory_requirements.size;
1131 dev.Physical().SetMemoryType(memory_requirements.memoryTypeBits, &alloc_info, memory_properties);
1132 internal_mem_.Init(dev, alloc_info);
1133 BindMemory(internal_mem_, 0);
1134
1135 void* ptr = internal_mem_.Map();
1136 std::memcpy(ptr, data, data_size);
1137 internal_mem_.Unmap();
1138}
1139
1140void Buffer::InitNoMemory(const Device& dev, const VkBufferCreateInfo& info) {
1141 NON_DISPATCHABLE_HANDLE_INIT(vk::CreateBuffer, dev, &info);

Callers

nothing calls this directly

Calls 4

SetMemoryTypeMethod · 0.80
InitMethod · 0.45
MapMethod · 0.45
UnmapMethod · 0.45

Tested by

no test coverage detected