| 243 | } |
| 244 | |
| 245 | void BaseImage::ValidateContent(RandomNumberGenerator& rand) |
| 246 | { |
| 247 | /* |
| 248 | dstBuf has following layout: |
| 249 | For each of texels to be sampled, [0..valueCount): |
| 250 | struct { |
| 251 | in uint32_t pixelX; |
| 252 | in uint32_t pixelY; |
| 253 | out uint32_t pixelColor; |
| 254 | } |
| 255 | */ |
| 256 | |
| 257 | const uint32_t valueCount = 128; |
| 258 | |
| 259 | VkBufferCreateInfo dstBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; |
| 260 | dstBufCreateInfo.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; |
| 261 | dstBufCreateInfo.size = valueCount * sizeof(uint32_t) * 3; |
| 262 | |
| 263 | VmaAllocationCreateInfo dstBufAllocCreateInfo = {}; |
| 264 | dstBufAllocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT; |
| 265 | dstBufAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO; |
| 266 | |
| 267 | VkBuffer dstBuf = nullptr; |
| 268 | VmaAllocation dstBufAlloc = nullptr; |
| 269 | VmaAllocationInfo dstBufAllocInfo = {}; |
| 270 | TEST( vmaCreateBuffer(g_hAllocator, &dstBufCreateInfo, &dstBufAllocCreateInfo, &dstBuf, &dstBufAlloc, &dstBufAllocInfo) == VK_SUCCESS ); |
| 271 | |
| 272 | // Fill dstBuf input data. |
| 273 | { |
| 274 | uint32_t* dstBufContent = (uint32_t*)dstBufAllocInfo.pMappedData; |
| 275 | for(uint32_t i = 0; i < valueCount; ++i) |
| 276 | { |
| 277 | const uint32_t x = rand.Generate() % m_CreateInfo.extent.width; |
| 278 | const uint32_t y = rand.Generate() % m_CreateInfo.extent.height; |
| 279 | dstBufContent[i * 3 ] = x; |
| 280 | dstBufContent[i * 3 + 1] = y; |
| 281 | dstBufContent[i * 3 + 2] = 0; |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | VkSamplerCreateInfo samplerCreateInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; |
| 286 | samplerCreateInfo.magFilter = VK_FILTER_NEAREST; |
| 287 | samplerCreateInfo.minFilter = VK_FILTER_NEAREST; |
| 288 | samplerCreateInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 289 | samplerCreateInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 290 | samplerCreateInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 291 | samplerCreateInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 292 | samplerCreateInfo.unnormalizedCoordinates = VK_TRUE; |
| 293 | |
| 294 | VkSampler sampler = nullptr; |
| 295 | TEST( vkCreateSampler( g_hDevice, &samplerCreateInfo, nullptr, &sampler) == VK_SUCCESS ); |
| 296 | |
| 297 | VkDescriptorSetLayoutBinding bindings[2] = {}; |
| 298 | bindings[0].binding = 0; |
| 299 | bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 300 | bindings[0].descriptorCount = 1; |
| 301 | bindings[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; |
| 302 | bindings[0].pImmutableSamplers = &sampler; |
nothing calls this directly
no test coverage detected