Skip to content

Commit 1256617

Browse files
committed
Merge branch 'RuiwenTang-dev'
2 parents 8763f10 + 1e6de08 commit 1256617

File tree

2 files changed

+73
-9
lines changed

2 files changed

+73
-9
lines changed

en/03_Drawing_a_triangle/00_Setup/01_Instance.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,37 @@ if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
109109

110110
Now run the program to make sure that the instance is created successfully.
111111

112+
## Encountered VK_ERROR_INCOMPATIBLE_DRIVER:
113+
If using MacOS with the latest MoltenVK sdk, you may get `VK_ERROR_INCOMPATIBLE_DRIVER`
114+
returned from `vkCreateInstance`. Accroding to the [Getting Start Notes](https://vulkan.lunarg.com/doc/sdk/1.3.216.0/mac/getting_started.html). Beginning with the 1.3.216 Vulkan SDK, the `VK_KHR_PORTABILITY_subset`
115+
extension is mandatory.
116+
117+
To get over this error, first add the `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` bit
118+
to `VkInstanceCreateInfo` struct's flags, then add `VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME`
119+
to instance enabled extension list.
120+
121+
Typically the code could be like this:
122+
```c++
123+
...
124+
125+
std::vector<const char*> requiredExtensions;
126+
127+
for(uint32_t i = 0; i < glfwExtensionCount; i++) {
128+
requiredExtensions.emplace_back(glfwExtensions[i]);
129+
}
130+
131+
requiredExtensions.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME)
132+
133+
createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
134+
135+
createInfo.enabledExtensionCount = (uint32_t) requiredExtensions.size();
136+
createInfo.ppEnabledExtensionNames = requiredExtensions.data();
137+
138+
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
139+
throw std::runtime_error("failed to create instance!");
140+
}
141+
```
142+
112143
## Checking for extension support
113144

114145
If you look at the `vkCreateInstance` documentation then you'll see that one of

en/90_FAQ.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
This page lists solutions to common problems that you may encounter while
22
developing Vulkan applications.
33

4-
* **I get an access violation error in the core validation layer**: Make sure
4+
## I get an access violation error in the core validation layer
5+
6+
Make sure
57
that MSI Afterburner / RivaTuner Statistics Server is not running, because it
68
has some compatibility problems with Vulkan.
79

8-
* **I don't see any messages from the validation layers / Validation layers are not available**: First make sure that
9-
the validation layers get a chance to print errors by keeping the terminal open
10-
after your program exits. You can do this from Visual Studio by running your
11-
program with Ctrl-F5 instead of F5, and on Linux by executing your program from
12-
a terminal window. If there are still no messages and you are sure that
13-
validation layers are turned on, then you should ensure that your Vulkan SDK is
14-
correctly installed by following the "Verify the Installation" instructions [on this page](https://vulkan.lunarg.com/doc/view/1.2.135.0/windows/getting_started.html). Also ensure that your SDK version is at least 1.1.106.0 to support the `VK_LAYER_KHRONOS_validation` layer.
10+
## I don't see any messages from the validation layers / Validation layers are not available
11+
12+
First make sure that the validation layers get a chance to print errors by keeping the
13+
terminal open after your program exits. You can do this from Visual Studio by running
14+
your program with Ctrl-F5 instead of F5, and on Linux by executing your program from
15+
a terminal window. If there are still no messages and you are sure that validation
16+
layers are turned on, then you should ensure that your Vulkan SDK is correctly
17+
installed by following the "Verify the Installation" instructions [on this page](https://vulkan.lunarg.com/doc/view/1.2.135.0/windows/getting_started.html). Also ensure that your SDK version is at least 1.1.106.0 to support the `VK_LAYER_KHRONOS_validation` layer.
18+
19+
## vkCreateSwapchainKHR triggers an error in SteamOverlayVulkanLayer64.dll
1520

16-
* **vkCreateSwapchainKHR triggers an error in SteamOverlayVulkanLayer64.dll**:
1721
This appears to be a compatibility problem in the Steam client beta. There are a
1822
few possible workarounds:
1923
* Opt out of the Steam beta program.
@@ -23,3 +27,32 @@ few possible workarounds:
2327
Example:
2428

2529
![](/images/steam_layers_env.png)
30+
31+
## vkCreateInstance fails with VK_ERROR_INCOMPATIBLE_DRIVER
32+
33+
If you are using MacOS with the latest MoltenVK SDK then `vkCreateInstance` may return the `VK_ERROR_INCOMPATIBLE_DRIVER` error. This is because [Vulkan SDK version 1.3.216 or newer](https://vulkan.lunarg.com/doc/sdk/1.3.216.0/mac/getting_started.html) requires you to enable the `VK_KHR_PORTABILITY_subset` extension to use MoltenVK, because it is currently not fully conformant.
34+
35+
You have to add the `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` flag to your `VkInstanceCreateInfo` and add `VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME` to your instance extension list.
36+
37+
Code example:
38+
39+
```c++
40+
...
41+
42+
std::vector<const char*> requiredExtensions;
43+
44+
for(uint32_t i = 0; i < glfwExtensionCount; i++) {
45+
requiredExtensions.emplace_back(glfwExtensions[i]);
46+
}
47+
48+
requiredExtensions.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
49+
50+
createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
51+
52+
createInfo.enabledExtensionCount = (uint32_t) requiredExtensions.size();
53+
createInfo.ppEnabledExtensionNames = requiredExtensions.data();
54+
55+
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
56+
throw std::runtime_error("failed to create instance!");
57+
}
58+
```

0 commit comments

Comments
 (0)