| 17 | class PositiveSparseBuffer : public VkLayerTest {}; |
| 18 | |
| 19 | TEST_F(PositiveSparseBuffer, NonOverlappingBufferCopy) { |
| 20 | TEST_DESCRIPTION("Test correct non overlapping sparse buffers' copy"); |
| 21 | AddRequiredFeature(vkt::Feature::sparseBinding); |
| 22 | RETURN_IF_SKIP(Init()); |
| 23 | |
| 24 | if (m_device->QueuesWithSparseCapability().empty()) { |
| 25 | GTEST_SKIP() << "Required SPARSE_BINDING queue families not present"; |
| 26 | } |
| 27 | |
| 28 | // 2 semaphores needed since we need to bind twice before copying |
| 29 | vkt::Semaphore semaphore(*m_device); |
| 30 | vkt::Semaphore semaphore2(*m_device); |
| 31 | |
| 32 | VkBufferCopy copy_info; |
| 33 | copy_info.srcOffset = 0; |
| 34 | copy_info.dstOffset = 0; |
| 35 | copy_info.size = 0x10000; |
| 36 | |
| 37 | VkBufferCreateInfo b_info = |
| 38 | vkt::Buffer::CreateInfo(copy_info.size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT); |
| 39 | b_info.flags = VK_BUFFER_CREATE_SPARSE_BINDING_BIT; |
| 40 | vkt::Buffer buffer_sparse(*m_device, b_info, vkt::no_mem); |
| 41 | vkt::Buffer buffer_sparse2(*m_device, b_info, vkt::no_mem); |
| 42 | |
| 43 | VkMemoryRequirements buffer_mem_reqs; |
| 44 | vk::GetBufferMemoryRequirements(device(), buffer_sparse, &buffer_mem_reqs); |
| 45 | VkMemoryAllocateInfo buffer_mem_alloc = |
| 46 | vkt::DeviceMemory::GetResourceAllocInfo(*m_device, buffer_mem_reqs, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); |
| 47 | |
| 48 | vkt::DeviceMemory buffer_mem(*m_device, buffer_mem_alloc); |
| 49 | vkt::DeviceMemory buffer_mem2(*m_device, buffer_mem_alloc); |
| 50 | |
| 51 | VkSparseMemoryBind buffer_memory_bind = {}; |
| 52 | buffer_memory_bind.size = buffer_mem_reqs.size; |
| 53 | buffer_memory_bind.memory = buffer_mem; |
| 54 | |
| 55 | VkSparseBufferMemoryBindInfo buffer_memory_bind_infos[2] = {}; |
| 56 | buffer_memory_bind_infos[0].buffer = buffer_sparse; |
| 57 | buffer_memory_bind_infos[0].bindCount = 1; |
| 58 | buffer_memory_bind_infos[0].pBinds = &buffer_memory_bind; |
| 59 | buffer_memory_bind_infos[1].buffer = buffer_sparse2; |
| 60 | buffer_memory_bind_infos[1].bindCount = 1; |
| 61 | buffer_memory_bind_infos[1].pBinds = &buffer_memory_bind; |
| 62 | |
| 63 | VkBindSparseInfo bind_info = vku::InitStructHelper(); |
| 64 | bind_info.bufferBindCount = 2; |
| 65 | bind_info.pBufferBinds = buffer_memory_bind_infos; |
| 66 | bind_info.signalSemaphoreCount = 1; |
| 67 | bind_info.pSignalSemaphores = &semaphore.handle(); |
| 68 | |
| 69 | vkt::Queue* sparse_queue = m_device->QueuesWithSparseCapability()[0]; |
| 70 | vk::QueueBindSparse(sparse_queue->handle(), 1, &bind_info, VK_NULL_HANDLE); |
| 71 | sparse_queue->Wait(); |
| 72 | // Set up complete |
| 73 | |
| 74 | m_command_buffer.Begin(); |
| 75 | // This copy is be completely legal as long as we change the memory for buffer_sparse to not overlap with |
| 76 | // buffer_sparse2's memory on queue submission |
nothing calls this directly
no test coverage detected