1*35238bceSAndroid Build Coastguard WorkerSparse resources tests 2*35238bceSAndroid Build Coastguard Worker 3*35238bceSAndroid Build Coastguard WorkerTests: 4*35238bceSAndroid Build Coastguard Worker 5*35238bceSAndroid Build Coastguard WorkerdEQP-VK.sparse_resources.* 6*35238bceSAndroid Build Coastguard Worker 7*35238bceSAndroid Build Coastguard WorkerIncludes: 8*35238bceSAndroid Build Coastguard Worker 9*35238bceSAndroid Build Coastguard Worker1. Test fully resident buffer created with VK_BUFFER_CREATE_SPARSE_BINDING_BIT flag bit 10*35238bceSAndroid Build Coastguard Worker2. Test fully resident image created with VK_IMAGE_CREATE_SPARSE_BINDING_BIT flag bit 11*35238bceSAndroid Build Coastguard Worker3. Test partially resident buffer created with VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT flag bit 12*35238bceSAndroid Build Coastguard Worker4. Test partially resident image created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag bit 13*35238bceSAndroid Build Coastguard Worker5. Test partially resident image with mipmaps, put some mipmap levels in mip tail region 14*35238bceSAndroid Build Coastguard Worker6. Test memory aliasing for fully resident buffer objects 15*35238bceSAndroid Build Coastguard Worker7. Test memory aliasing for partially resident images 16*35238bceSAndroid Build Coastguard Worker8. Test OpImageSparse* shader intrinsics 17*35238bceSAndroid Build Coastguard Worker 18*35238bceSAndroid Build Coastguard WorkerDescription: 19*35238bceSAndroid Build Coastguard Worker 20*35238bceSAndroid Build Coastguard Worker1. Test fully resident buffer created with VK_BUFFER_CREATE_SPARSE_BINDING_BIT flag bit 21*35238bceSAndroid Build Coastguard Worker 22*35238bceSAndroid Build Coastguard WorkerThe test creates buffer object with VK_BUFFER_CREATE_SPARSE_BINDING_BIT flag bit. The size of the buffer is one 23*35238bceSAndroid Build Coastguard Workerof the test parameters. The memory requirements of the buffer are being checked. Device memory is allocated 24*35238bceSAndroid Build Coastguard Workerin chunks equal to the alignment parameter of buffer's memory requirements. The number of allocations is equal to 25*35238bceSAndroid Build Coastguard WorkerbufferRequirements.size / bufferRequirements.alignment. 26*35238bceSAndroid Build Coastguard Worker 27*35238bceSAndroid Build Coastguard WorkerThe test creates two queues - one supporting sparse binding operations, the second one supporting compute and transfer operations. 28*35238bceSAndroid Build Coastguard Worker 29*35238bceSAndroid Build Coastguard WorkerFirst queue is used to perform binding of device memory to sparse buffer. The binding operation signals semaphore 30*35238bceSAndroid Build Coastguard Workerused for synchronization. 31*35238bceSAndroid Build Coastguard Worker 32*35238bceSAndroid Build Coastguard WorkerThe second queue is used to perform transfer operations. The test creates two non-sparse buffer objects, 33*35238bceSAndroid Build Coastguard Workerone used as input and the second as output. The input buffer is used to transfer data to sparse buffer. The data is then 34*35238bceSAndroid Build Coastguard Workertransfered further from sparse buffer to output buffer. The transer queue waits on a semaphore, before transfer operations 35*35238bceSAndroid Build Coastguard Workercan be issued. 36*35238bceSAndroid Build Coastguard Worker 37*35238bceSAndroid Build Coastguard WorkerThe validation part retrieves data back from output buffer to host memory. The data is then compared with reference data, 38*35238bceSAndroid Build Coastguard Workerthat was originally sent to input buffer. If the two data sets match, the test passes. 39*35238bceSAndroid Build Coastguard Worker 40*35238bceSAndroid Build Coastguard Worker2. Test fully resident image created with VK_IMAGE_CREATE_SPARSE_BINDING_BIT flag bit 41*35238bceSAndroid Build Coastguard Worker 42*35238bceSAndroid Build Coastguard WorkerThe test checks all supported types of images. It creates image with VK_IMAGE_CREATE_SPARSE_BINDING_BIT flag bit. 43*35238bceSAndroid Build Coastguard WorkerThe memory requirements of the image are being checked. Device memory is allocated in chunks equal to the alignment parameter 44*35238bceSAndroid Build Coastguard Workerof the image memory requirements. The number of allocations is equal to imageRequirements.size / imageRequirements.alignment. 45*35238bceSAndroid Build Coastguard Worker 46*35238bceSAndroid Build Coastguard WorkerThe test creates two queues - one supporting sparse binding operations, the second one supporting compute and transfer operations. 47*35238bceSAndroid Build Coastguard Worker 48*35238bceSAndroid Build Coastguard WorkerFirst queue is used to perform binding of device memory to sparse image. The binding operation signals semaphore 49*35238bceSAndroid Build Coastguard Workerused for synchronization. 50*35238bceSAndroid Build Coastguard Worker 51*35238bceSAndroid Build Coastguard WorkerThe second queue is used to perform transfer operations. The test creates two non-sparse buffer objects, 52*35238bceSAndroid Build Coastguard Workerone used as input and the second as output. The input buffer is used to transfer data to sparse image. The data is then 53*35238bceSAndroid Build Coastguard Workertransfered further from sparse image to output buffer. The transfer queue waits on a semaphore, before transfer operations 54*35238bceSAndroid Build Coastguard Workercan be issued. 55*35238bceSAndroid Build Coastguard Worker 56*35238bceSAndroid Build Coastguard WorkerThe validation part retrieves data back from output buffer to host memory. The data is then compared with reference data, 57*35238bceSAndroid Build Coastguard Workerthat was originally sent to input buffer. If the two data sets match, the test passes. 58*35238bceSAndroid Build Coastguard Worker 59*35238bceSAndroid Build Coastguard Worker3. Test partially resident buffer created with VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT flag bit 60*35238bceSAndroid Build Coastguard Worker 61*35238bceSAndroid Build Coastguard WorkerThe test creates buffer object with VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT flag bit. The size of the buffer is one 62*35238bceSAndroid Build Coastguard Workerof the test parameters. The sparse memory requirements of the buffer are being checked. Device memory is allocated 63*35238bceSAndroid Build Coastguard Workerin chunks equal to the alignment parameter of buffer's memory requirements. Memory is bound to the buffer object leaving gaps 64*35238bceSAndroid Build Coastguard Workerbetween bound blocks with the size equal to alignment. 65*35238bceSAndroid Build Coastguard Worker 66*35238bceSAndroid Build Coastguard WorkerThe test creates two queues - one supporting sparse binding operations, the second one supporting compute and transfer operations. 67*35238bceSAndroid Build Coastguard Worker 68*35238bceSAndroid Build Coastguard WorkerFirst queue is used to perform binding of device memory to sparse buffer. The binding operation signals semaphore 69*35238bceSAndroid Build Coastguard Workerused for synchronization. 70*35238bceSAndroid Build Coastguard Worker 71*35238bceSAndroid Build Coastguard WorkerThe second queue is used to perform compute and transfer operations. A compute shader is invoked to fill the whole buffer with data. 72*35238bceSAndroid Build Coastguard WorkerAfterwards the data is transfered from sparse buffer to non-sparse output buffer. 73*35238bceSAndroid Build Coastguard Worker 74*35238bceSAndroid Build Coastguard WorkerThe validation part retrieves data back from output buffer to host memory. The data is compared against the expected output 75*35238bceSAndroid Build Coastguard Workerfrom compute shader. For parts of the data that correspond to the regions of sparse buffer that have device memory bound, the comparison is done 76*35238bceSAndroid Build Coastguard Workeragainst expected output from compute shader. For parts that correspond to gaps, the data is random or should be filled with zeros if 77*35238bceSAndroid Build Coastguard WorkerresidencyNonResidentStrict device sparse property is set to TRUE. 78*35238bceSAndroid Build Coastguard Worker 79*35238bceSAndroid Build Coastguard Worker4. Test partially resident image created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag bit 80*35238bceSAndroid Build Coastguard Worker 81*35238bceSAndroid Build Coastguard WorkerThe test creates image with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag bit. The sparse memory requirements of the image are being checked. 82*35238bceSAndroid Build Coastguard WorkerDevice memory is allocated in chunks equal to the alignment parameter of image's memory requirements. 83*35238bceSAndroid Build Coastguard WorkerMemory is bound to the image leaving gaps between bound blocks with the size equal to alignment. 84*35238bceSAndroid Build Coastguard Worker 85*35238bceSAndroid Build Coastguard WorkerThe test creates two queues - one supporting sparse binding operations, the second one supporting compute and transfer operations. 86*35238bceSAndroid Build Coastguard Worker 87*35238bceSAndroid Build Coastguard WorkerFirst queue is used to perform binding of device memory to sparse image. The binding operation signals semaphore 88*35238bceSAndroid Build Coastguard Workerused for synchronization. 89*35238bceSAndroid Build Coastguard Worker 90*35238bceSAndroid Build Coastguard WorkerThe second queue is used to perform compute and transfer operations. A compute shader is invoked to fill the whole image with data. 91*35238bceSAndroid Build Coastguard WorkerAfterwards the data is transfered from sparse image to non-sparse output buffer. 92*35238bceSAndroid Build Coastguard Worker 93*35238bceSAndroid Build Coastguard WorkerThe validation part retrieves data back from output buffer to host memory. The data is compared against the expected output 94*35238bceSAndroid Build Coastguard Workerfrom compute shader. For parts of the data that correspond to the regions of image that have device memory bound, the comparison is done 95*35238bceSAndroid Build Coastguard Workeragainst expected output from compute shader. For parts that correspond to gaps, the data is random or should be filled with zeros if residencyNonResidentStrict 96*35238bceSAndroid Build Coastguard Workerdevice sparse property is set to TRUE. 97*35238bceSAndroid Build Coastguard Worker 98*35238bceSAndroid Build Coastguard Worker5. Test partially resident image with mipmaps, put some mipmap levels in mip tail region 99*35238bceSAndroid Build Coastguard Worker 100*35238bceSAndroid Build Coastguard WorkerThe test creates image with maximum allowed number of mipmap levels. The sparse memory requirements of the image are being checked. 101*35238bceSAndroid Build Coastguard WorkerEach layer of each mipmap level receives a separate device memory binding. The mipmaps levels that end up in mip tail region receive one 102*35238bceSAndroid Build Coastguard Workerbinding for each mipmap level or one binding for all levels, depending on the value of VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT. 103*35238bceSAndroid Build Coastguard Worker 104*35238bceSAndroid Build Coastguard WorkerA compute shader is invoked to fill each mipmap level with data. Afterwards the data is transfered to a non-sparse buffer object. 105*35238bceSAndroid Build Coastguard Worker 106*35238bceSAndroid Build Coastguard WorkerThe validation part retrieves data back from output buffer to host memory. The data is compared against the expected output 107*35238bceSAndroid Build Coastguard Workerfrom compute shader. The test passes if the data sets are equal. 108*35238bceSAndroid Build Coastguard Worker 109*35238bceSAndroid Build Coastguard Worker6. Test memory aliasing for fully resident buffer objects 110*35238bceSAndroid Build Coastguard Worker 111*35238bceSAndroid Build Coastguard WorkerThe test creates two fully resident buffers (READ and WRITE) with VK_BUFFER_CREATE_SPARSE_ALIASED_BIT 112*35238bceSAndroid Build Coastguard Workerand VK_BUFFER_CREATE_SPARSE_BINDING_BIT flag bits. Both buffers have the same size. 113*35238bceSAndroid Build Coastguard Worker 114*35238bceSAndroid Build Coastguard WorkerThe test creates two queues - one supporting sparse binding operations, the second one supporting compute and transfer operations. 115*35238bceSAndroid Build Coastguard Worker 116*35238bceSAndroid Build Coastguard WorkerFirst queue is used to perform binding of device memory to sparse buffers. One block of device memory is allocated 117*35238bceSAndroid Build Coastguard Workerand bound to both buffers (buffers share memory). 118*35238bceSAndroid Build Coastguard Worker 119*35238bceSAndroid Build Coastguard WorkerThe second queue is used to perform compute and transfer operations. A compute shader is invoked to fill the whole WRITE buffer with data. 120*35238bceSAndroid Build Coastguard WorkerAfterwards the data from READ buffer is being transfered to non-sparse output buffer. 121*35238bceSAndroid Build Coastguard Worker 122*35238bceSAndroid Build Coastguard WorkerThe validation part retrieves data back from output buffer to host memory. The data is compared against the expected output 123*35238bceSAndroid Build Coastguard Workerfrom compute shader. The test passes if the data sets are equal. 124*35238bceSAndroid Build Coastguard Worker 125*35238bceSAndroid Build Coastguard Worker7. Test memory aliasing for partially resident images 126*35238bceSAndroid Build Coastguard Worker 127*35238bceSAndroid Build Coastguard WorkerThe test creates two partially resident images (READ and WRITE) with VK_IMAGE_CREATE_SPARSE_ALIASED_BIT and VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag bits. 128*35238bceSAndroid Build Coastguard WorkerBoth images have the same type, format and dimensions. 129*35238bceSAndroid Build Coastguard Worker 130*35238bceSAndroid Build Coastguard WorkerThe test creates two queues - one supporting sparse binding operations, the second one supporting compute and transfer operations. 131*35238bceSAndroid Build Coastguard Worker 132*35238bceSAndroid Build Coastguard WorkerFirst queue is used to perform binding of device memory to sparse images. The memory bound via VkSparseImageMemoryBind is shared between 133*35238bceSAndroid Build Coastguard Workerboth images. The mipmap levels that land in the mip tail region have separate memory regions for both images. 134*35238bceSAndroid Build Coastguard Worker 135*35238bceSAndroid Build Coastguard WorkerThe second queue is used to perform compute and transfer operations. The test creates two non-sparse buffer objects, 136*35238bceSAndroid Build Coastguard Workerone used as input and the second as output. The input buffer is used to transfer data to READ sparse image to create some initial state. 137*35238bceSAndroid Build Coastguard WorkerAfterwards compute shaders are invoked to write data to each mipmap level of WRITE sparse image. The mipmap levels of READ image that share memory with 138*35238bceSAndroid Build Coastguard WorkerWRITE image should be overwritten by this operation, the mip tail region should be left intact. Next the data is copied from the READ image to the output buffer. 139*35238bceSAndroid Build Coastguard Worker 140*35238bceSAndroid Build Coastguard WorkerThe validation part retrieves data back from output buffer to host memory. For each mipmap level that both images share memory for, the data is 141*35238bceSAndroid Build Coastguard Workercompared against the expected output from compute shader. On the other hand for each mipmap level that landed in the mip tail region, the data is compared 142*35238bceSAndroid Build Coastguard Workeragainst data stored in the input buffer (the compute shader could not have changed this data). The test passes if for each mipmap level 143*35238bceSAndroid Build Coastguard Workerthe comparison results in both data sets being the same. 144*35238bceSAndroid Build Coastguard Worker 145*35238bceSAndroid Build Coastguard Worker8. Test OpImageSparse* shader intrinsics 146*35238bceSAndroid Build Coastguard Worker 147*35238bceSAndroid Build Coastguard WorkerThe test creates sparse partially resident image. The memory is bound to the image every second mipmap level. 148*35238bceSAndroid Build Coastguard Worker 149*35238bceSAndroid Build Coastguard WorkerThe test creates also a second non-sparse texels image with the same dimensions and format as the sparse one and 150*35238bceSAndroid Build Coastguard Workera third residency image with the same dimensions as the sparse one and unsigned int format. 151*35238bceSAndroid Build Coastguard Worker 152*35238bceSAndroid Build Coastguard WorkerFor OpImageSparse* opcodes that are fed with float image coordinates the test creates a graphics queue, otherwise a compute queue is created. 153*35238bceSAndroid Build Coastguard WorkerIn both cases the commands submited to queue have the purpose of copying the data from sparse image to texels and residency images using one 154*35238bceSAndroid Build Coastguard Workerof the OpImageSparse* shader intrinsics. For graphics operations the data is copied via rendering to two color attachments, for compute operations 155*35238bceSAndroid Build Coastguard Workerthe data is copied via image load/store. 156*35238bceSAndroid Build Coastguard Worker 157*35238bceSAndroid Build Coastguard WorkerData is retreived from the non-sparse images back to the CPU. Contents of the texels image are compared against the data originaly sent to the sparse image. 158*35238bceSAndroid Build Coastguard WorkerFor mipmap levels of the sparse image that do not have backing device memory, the fetched data is compared against zeroed memory if residencyNonResidentStrict is set to VK_TRUE, 159*35238bceSAndroid Build Coastguard Workerotherwise comparion for those mipmap levels is ommited. The data fetched from the residency image is checked, if for each mipmap level the OpImageSparseTexelsResident 160*35238bceSAndroid Build Coastguard Workerreturned correct residency information. 161