6

If I understand it correctly, I'm supposed to create an empty VkPipelineCache object, pass it into vkCreateGraphicsPipelinesand data will be written into it. I can then reuse it with other pipelines I'm creating or save it to a file and use it on the next run.

I've tried following the LunarG example to extra the info:

uint32_t headerLength = pData[0];
uint32_t cacheHeaderVersion = pData[1];
uint32_t vendorID = pData[2];
uint32_t deviceID = pData[3];

But I always get headerLength is 32 and the rest 0. Looking at the spec (https://vulkan.lunarg.com/doc/view/1.0.26.0/linux/vkspec.chunked/ch09s06.html Table 9.1), the cacheHeaderVersion should always be 1, as the only available cache header version is VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1.

Also the size of pData is usually only 32 bytes, even when I create 10 pipelines with it. What am I doing wrong?

Rhu Mage
  • 667
  • 1
  • 8
  • 21

1 Answers1

2

A Vulkan pipeline cache is an opaque object that's only meaningful to the driver. There are very few operations that you're supposed to use on it.

The idea is that the driver can use the cache to speed up creation of pipelines within your program, and also to speed up pipeline creation on subsequent runs of your application.

You should not be attempting to interpret the cache data returned from vkGetPipelineCacheData at all. The only purpose for that data is to be passed into a later call to vkCreatePipelineCache.

Also the size of pData is usually only 32 bytes, even when I create 10 pipelines with it. What am I doing wrong?

Drivers must implement vkCreatePipelineCache, vkGetPipelineCacheData, etc. But they don't actually have to support caching. So if you're working with a driver that doesn't have anything it can cache, or hasn't done the work to support caching, then you'd naturally get back an empty cache (other than the header).

Jherico
  • 28,584
  • 8
  • 61
  • 87
  • 1
    First 32 bits do give your application information, LunarG has an example: https://github.com/LunarG/VulkanSamples/blob/master/API-Samples/pipeline_cache/pipeline_cache.cpp – Rhu Mage Feb 08 '19 at 20:12
  • @RhuMage Do you think there is something inadequate about this answer? – Krupip Feb 08 '19 at 21:11
  • 1
    @opa Well my question wasn't answered. Why are my values 0 and why is there no other data? I create 10 pipelines with a cache and the only thing I get out of it is the empty header, no actual cache data. – Rhu Mage Feb 08 '19 at 21:29
  • @Jherico I agree with Rhu Mage, what ever the standard says, it doesn't make sense that a pipeline cache is completely empty. As it stands this answer, while it provides important information, doesn't help us understand what is going on here, is Rhu Mage wrong in stating `cacheHeaderVersion` should always be 1? – Krupip Feb 08 '19 at 21:34
  • 1
    @opa https://vulkan.lunarg.com/doc/view/1.0.26.0/linux/vkspec.chunked/ch09s06.html Table 9.1: a VkPipelineCacheHeaderVersion value, and the only one available is `VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1` – Rhu Mage Feb 08 '19 at 21:42
  • 1
    @RhuMage I would recommend sourcing that in your question – Krupip Feb 08 '19 at 21:47
  • @Jherico I have the latest nVidia drivers. I've tried running Sascha Willems examples and I do get cache data there, but I can't find a difference between his code and mine. – Rhu Mage Feb 09 '19 at 08:17
  • I suggest you post a minimal example then. – Jherico Feb 09 '19 at 17:45