Reputation: 4356
I am trying to create a vulkan instance. Here is my code:
vk::ApplicationInfo appInfo("Test", 1, nullptr, 0, 0);
vk::InstanceCreateInfo info;
info.pApplicationInfo(&appInfo);
vk::Instance instance;
const auto result = vk::createInstance(&info, nullptr, &instance);
std::cout << vkResultToString(result) << std::endl;
However this returns VK_ERROR_INCOMPATIBLE_DRIVER.
If I don't provide my own ApplicationInfo
and instead use a default constructed one, it works.
In the specification it says
If
apiVersion
is 0 the implementation must ignore it, otherwise if the implementation does not support the requestedapiVersion
it must returnVK_ERROR_INCOMPATIBLE_DRIVER
As you can see I set apiVersion
to 0. To my understanding it should not give me the VK_ERROR_INCOMPATIBLE_DRIVER
error then.
Is this a bug or am I forgetting something or thinking wrong?
EDIT:
In the html version of the specification the part about ignoring apiVersion
isn't there. Is the pdf version of the specification just outdated?
EDIT:
If I am setting apiVersion
to 1.0.3 it also works:
std::bitset<32> apiVersion;
apiVersion.set(22);
apiVersion.set(1);
apiVersion.set(0);
vk::ApplicationInfo appInfo("Test", 1, nullptr, 0, apiVersion.to_ulong());
Upvotes: 4
Views: 7794
Reputation: 9960
You ask the question:
Is this a bug or am I forgetting something or thinking wrong?
Since the specification is canonical, yes it is a bug. The specification says these two relevant things:
apiVersion is the version of the Vulkan API against which the application expects to run, encoded as described in the API Version Numbers and Semantics section. If apiVersion is 0 the implementation must ignore it, otherwise if the implementation does not support the requested apiVersion it must return VK_ERROR_INCOMPATIBLE_DRIVER.
apiVersion must be zero, or otherwise it must be a version that the implementation supports, or supports an effective substitute for
For now, you can keep doing what you are doing and request a version that is both <=
the version in the SDK you are building against and <=
the versions of the drivers you want to be able to run on.
Upvotes: 1
Reputation: 186
This sounds entirely like a developmental option that was removed from the final spec. If you consider how much any graphics API changes from one major version to another, it seems unsafe to allow such behavior as default. That being said, it would be entirely up to the graphics driver manufacturer to support this as they are the ones with final say over whether or not something like this is accepted.
Additionally, if you look at the official API spec: https://www.khronos.org/registry/vulkan/specs/1.0/apispec.html.
That merely states: "Finally, apiVersion is the version of the Vulkan API that the application expects to use."
Upvotes: 3
Reputation: 1935
I believe the html spec you are looking at is outdated:
Revision 0.9 Provisional Wed Nov 11 18:11:51 PST 2015
It has the quote about apiVersion
here https://www.khronos.org/registry/vulkan/specs/1.0/pdf/vkspec.pdf and here https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html These are version 1.0
As for the results, it may be a bug. What driver/platform are you using?
Upvotes: 2