Skip to content

Commit 5e1711d

Browse files
committed
Fix github issue: #38
1 parent 2e5750d commit 5e1711d

File tree

6 files changed

+108
-6
lines changed

6 files changed

+108
-6
lines changed

tutorial01_load_vulkan/app/src/main/jni/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,23 @@ bool initialize(android_app* app) {
151151
LOGI("\tallowed transforms: %x\n", surfaceCapabilities.supportedTransforms);
152152
LOGI("\tcomposite alpha flags: %u\n", surfaceCapabilities.currentTransform);
153153

154+
// Find a GFX queue family
155+
uint32_t queueFamilyCount;
156+
vkGetPhysicalDeviceQueueFamilyProperties(tutorialGpu, &queueFamilyCount, nullptr);
157+
assert(queueFamilyCount);
158+
std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
159+
vkGetPhysicalDeviceQueueFamilyProperties(tutorialGpu, &queueFamilyCount,
160+
queueFamilyProperties.data());
161+
162+
uint32_t queueFamilyIndex;
163+
for (queueFamilyIndex=0; queueFamilyIndex < queueFamilyCount;
164+
queueFamilyIndex++) {
165+
if (queueFamilyProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
166+
break;
167+
}
168+
}
169+
assert(queueFamilyIndex < queueFamilyCount);
170+
154171
// Create a logical device from GPU we picked
155172
float priorities[] = {
156173
1.0f,
@@ -160,7 +177,7 @@ bool initialize(android_app* app) {
160177
.pNext = nullptr,
161178
.flags = 0,
162179
.queueCount = 1,
163-
.queueFamilyIndex = 0,
180+
.queueFamilyIndex = queueFamilyIndex,
164181
.pQueuePriorities = priorities,
165182
};
166183

tutorial02_prebuild_layers/app/src/main/jni/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ bool initialize(android_app* app) {
158158
LOGI("\tallowed transforms: %x\n", surfaceCapabilities.supportedTransforms);
159159
LOGI("\tcomposite alpha flags: %u\n", surfaceCapabilities.currentTransform);
160160

161+
// Find a GFX queue family
162+
uint32_t queueFamilyCount;
163+
vkGetPhysicalDeviceQueueFamilyProperties(tutorialGpu, &queueFamilyCount, nullptr);
164+
assert(queueFamilyCount);
165+
std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
166+
vkGetPhysicalDeviceQueueFamilyProperties(tutorialGpu, &queueFamilyCount,
167+
queueFamilyProperties.data());
168+
169+
uint32_t queueFamilyIndex;
170+
for (queueFamilyIndex=0; queueFamilyIndex < queueFamilyCount;
171+
queueFamilyIndex++) {
172+
if (queueFamilyProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
173+
break;
174+
}
175+
}
176+
assert(queueFamilyIndex < queueFamilyCount);
177+
161178
// Create a logical device from GPU we picked
162179
float priorities[] = {
163180
1.0f,
@@ -167,7 +184,7 @@ bool initialize(android_app* app) {
167184
.pNext = nullptr,
168185
.flags = 0,
169186
.queueCount = 1,
170-
.queueFamilyIndex = 0,
187+
.queueFamilyIndex = queueFamilyIndex,
171188
// Send nullptr for queue priority so debug extension could
172189
// catch the bug and call back app's debug function
173190
.pQueuePriorities = nullptr, // priorities,

tutorial03_traceable_layers/app/src/main/jni/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ bool initialize(android_app* app) {
158158
LOGI("\tallowed transforms: %x\n", surfaceCapabilities.supportedTransforms);
159159
LOGI("\tcomposite alpha flags: %u\n", surfaceCapabilities.currentTransform);
160160

161+
// Find a GFX queue family
162+
uint32_t queueFamilyCount;
163+
vkGetPhysicalDeviceQueueFamilyProperties(tutorialGpu, &queueFamilyCount, nullptr);
164+
assert(queueFamilyCount);
165+
std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
166+
vkGetPhysicalDeviceQueueFamilyProperties(tutorialGpu, &queueFamilyCount,
167+
queueFamilyProperties.data());
168+
169+
uint32_t queueFamilyIndex;
170+
for (queueFamilyIndex=0; queueFamilyIndex < queueFamilyCount;
171+
queueFamilyIndex++) {
172+
if (queueFamilyProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
173+
break;
174+
}
175+
}
176+
assert(queueFamilyIndex < queueFamilyCount);
177+
161178
// Create a logical device from GPU we picked
162179
float priorities[] = {
163180
1.0f,
@@ -167,7 +184,7 @@ bool initialize(android_app* app) {
167184
.pNext = nullptr,
168185
.flags = 0,
169186
.queueCount = 1,
170-
.queueFamilyIndex = 0,
187+
.queueFamilyIndex = queueFamilyIndex,
171188
// Send nullptr for queue priority so debug extension could
172189
// catch the bug and call back app's debug function
173190
.pQueuePriorities = nullptr, // priorities,

tutorial04_first_window/app/src/main/jni/VulkanMain.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ void CreateVulkanDevice(ANativeWindow* platformWindow,
119119
CALL_VK(vkEnumeratePhysicalDevices(device.instance_, &gpuCount, tmpGpus));
120120
device.gpuDevice_ = tmpGpus[0]; // Pick up the first GPU Device
121121

122+
// Find a GFX queue family
123+
uint32_t queueFamilyCount;
124+
vkGetPhysicalDeviceQueueFamilyProperties(device.gpuDevice_, &queueFamilyCount, nullptr);
125+
assert(queueFamilyCount);
126+
std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
127+
vkGetPhysicalDeviceQueueFamilyProperties(device.gpuDevice_, &queueFamilyCount,
128+
queueFamilyProperties.data());
129+
130+
uint32_t queueFamilyIndex;
131+
for (queueFamilyIndex=0; queueFamilyIndex < queueFamilyCount;
132+
queueFamilyIndex++) {
133+
if (queueFamilyProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
134+
break;
135+
}
136+
}
137+
assert(queueFamilyIndex < queueFamilyCount);
138+
122139
// Create a logical device (vulkan device)
123140
float priorities[] = {
124141
1.0f,
@@ -128,7 +145,7 @@ void CreateVulkanDevice(ANativeWindow* platformWindow,
128145
.pNext = nullptr,
129146
.flags = 0,
130147
.queueCount = 1,
131-
.queueFamilyIndex = 0,
148+
.queueFamilyIndex = queueFamilyIndex,
132149
.pQueuePriorities = priorities,
133150
};
134151

tutorial05_triangle/app/src/main/jni/VulkanMain.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,23 @@ void CreateVulkanDevice(ANativeWindow* platformWindow,
132132
CALL_VK(vkEnumeratePhysicalDevices(device.instance_, &gpuCount, tmpGpus));
133133
device.gpuDevice_ = tmpGpus[0]; // Pick up the first GPU Device
134134

135+
// Find a GFX queue family
136+
uint32_t queueFamilyCount;
137+
vkGetPhysicalDeviceQueueFamilyProperties(device.gpuDevice_, &queueFamilyCount, nullptr);
138+
assert(queueFamilyCount);
139+
std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
140+
vkGetPhysicalDeviceQueueFamilyProperties(device.gpuDevice_, &queueFamilyCount,
141+
queueFamilyProperties.data());
142+
143+
uint32_t queueFamilyIndex;
144+
for (queueFamilyIndex=0; queueFamilyIndex < queueFamilyCount;
145+
queueFamilyIndex++) {
146+
if (queueFamilyProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
147+
break;
148+
}
149+
}
150+
assert(queueFamilyIndex < queueFamilyCount);
151+
135152
// Create a logical device (vulkan device)
136153
float priorities[] = {
137154
1.0f,
@@ -141,7 +158,7 @@ void CreateVulkanDevice(ANativeWindow* platformWindow,
141158
.pNext = nullptr,
142159
.flags = 0,
143160
.queueCount = 1,
144-
.queueFamilyIndex = 0,
161+
.queueFamilyIndex = queueFamilyIndex,
145162
.pQueuePriorities = priorities,
146163
};
147164

tutorial06_texture/app/src/main/cpp/VulkanMain.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ void CreateVulkanDevice(ANativeWindow* platformWindow,
160160
vkGetPhysicalDeviceMemoryProperties(device.gpuDevice_,
161161
&device.gpuMemoryProperties_);
162162

163+
// Find a GFX queue family
164+
uint32_t queueFamilyCount;
165+
vkGetPhysicalDeviceQueueFamilyProperties(device.gpuDevice_, &queueFamilyCount, nullptr);
166+
assert(queueFamilyCount);
167+
std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
168+
vkGetPhysicalDeviceQueueFamilyProperties(device.gpuDevice_, &queueFamilyCount,
169+
queueFamilyProperties.data());
170+
171+
uint32_t queueFamilyIndex;
172+
for (queueFamilyIndex=0; queueFamilyIndex < queueFamilyCount;
173+
queueFamilyIndex++) {
174+
if (queueFamilyProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
175+
break;
176+
}
177+
}
178+
assert(queueFamilyIndex < queueFamilyCount);
179+
163180
// Create a logical device (vulkan device)
164181
float priorities[] = {
165182
1.0f,
@@ -169,7 +186,7 @@ void CreateVulkanDevice(ANativeWindow* platformWindow,
169186
.pNext = nullptr,
170187
.flags = 0,
171188
.queueCount = 1,
172-
.queueFamilyIndex = 0,
189+
.queueFamilyIndex = queueFamilyIndex,
173190
.pQueuePriorities = priorities,
174191
};
175192

0 commit comments

Comments
 (0)