Wrote test for sparse image binding with testing actual content - function BaseImage::TestContent. It uses vkCopyBufferToImage and then a compute shader to read back pixels of the image.
diff --git a/src/VulkanSample.cpp b/src/VulkanSample.cpp
index 0e5cae6..ed79925 100644
--- a/src/VulkanSample.cpp
+++ b/src/VulkanSample.cpp
@@ -149,7 +149,7 @@
ERR_GUARD_VULKAN( vkQueueWaitIdle(g_hGraphicsQueue) );
}
-static void LoadShader(std::vector<char>& out, const char* fileName)
+void LoadShader(std::vector<char>& out, const char* fileName)
{
std::ifstream file(std::string(SHADER_PATH1) + fileName, std::ios::ate | std::ios::binary);
if(file.is_open() == false)
@@ -1222,8 +1222,9 @@
{
if(queueFamilies[i].queueCount > 0)
{
+ const uint32_t flagsForGraphicsQueue = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT;
if((g_GraphicsQueueFamilyIndex != 0) &&
- ((queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0))
+ ((queueFamilies[i].queueFlags & flagsForGraphicsQueue) == flagsForGraphicsQueue))
{
g_GraphicsQueueFamilyIndex = i;
}
@@ -1785,6 +1786,23 @@
printf("ERROR: %s\n", ex.what());
}
break;
+ case 'S':
+ try
+ {
+ if(g_SparseBindingEnabled)
+ {
+ TestSparseBinding();
+ }
+ else
+ {
+ printf("Sparse binding not supported.\n");
+ }
+ }
+ catch(const std::exception& ex)
+ {
+ printf("ERROR: %s\n", ex.what());
+ }
+ break;
}
return 0;