add helper functions to get queue indices
This commit is contained in:
@@ -13,3 +13,12 @@ gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const
|
||||
void gnDestroyDebugger(gnDebugger* debugger) {
|
||||
debugger->instance->functions->_gnDestroyDebugger(debugger);
|
||||
}
|
||||
|
||||
void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) {
|
||||
debugger->info.callback(
|
||||
GN_MESSAGE_ERROR,
|
||||
GN_DEBUG_MESSAGE_VALIDATION,
|
||||
data,
|
||||
debugger->info.userData
|
||||
);
|
||||
}
|
||||
|
@@ -52,3 +52,5 @@ typedef struct gnDebugger_t {
|
||||
|
||||
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info);
|
||||
void gnDestroyDebugger(gnDebugger* debugger);
|
||||
|
||||
void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data);
|
||||
|
@@ -13,15 +13,41 @@ gnPhysicalDevice* gnGetPhyscialDevices(gnInstance* instance, uint32_t* count) {
|
||||
|
||||
gnBool gnQueueCanPresentToSurface(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface) {
|
||||
if (queueIndex >= device.queueProperties.queueCount) {
|
||||
device.instance->debugger->info.callback(
|
||||
GN_MESSAGE_ERROR,
|
||||
GN_DEBUG_MESSAGE_VALIDATION,
|
||||
gnDebuggerSetErrorMessage(device.instance->debugger,
|
||||
(gnMessageData){
|
||||
.message = gnCreateString("gnQueueCanPresentToSurface queue index passed in is large then queueProperties.queueCount")
|
||||
},
|
||||
NULL
|
||||
}
|
||||
);
|
||||
return gnFalse;
|
||||
}
|
||||
return device.instance->functions->_gnQueueCanPresentToSurface(device, queueIndex, windowSurface);
|
||||
}
|
||||
|
||||
int gnGetGraphicsQueueIndex(const struct gnPhysicalDevice_t device) {
|
||||
for (int i = 0; i < device.queueProperties.queueCount; i++) {
|
||||
if (device.queueProperties.queueProperties[i].queueType & GN_QUEUE_GRAPHICS) {
|
||||
return i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
gnDebuggerSetErrorMessage(device.instance->debugger,
|
||||
(gnMessageData){
|
||||
.message = gnCreateString("gnGetGraphicsQueueIndex failed no queue that support graphics on this device")
|
||||
}
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
int gnGetPresentQueueIndex(const struct gnPhysicalDevice_t device, struct gnWindowSurface_t windowSurface) {
|
||||
for (int i = 0; i < device.queueProperties.queueCount; i++) {
|
||||
if (gnQueueCanPresentToSurface(device, i, windowSurface)) {
|
||||
return i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
gnDebuggerSetErrorMessage(device.instance->debugger,
|
||||
(gnMessageData){
|
||||
.message = gnCreateString("gnGetPresentQueueIndex failed no queue that support presenting to this window surface")
|
||||
}
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
@@ -40,3 +40,6 @@ typedef struct gnPhysicalDevice_t {
|
||||
|
||||
gnPhysicalDevice* gnGetPhyscialDevices(gnInstance* instance, uint32_t* count);
|
||||
gnBool gnQueueCanPresentToSurface(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface);
|
||||
|
||||
int gnGetGraphicsQueueIndex(const struct gnPhysicalDevice_t device);
|
||||
int gnGetPresentQueueIndex(const struct gnPhysicalDevice_t device, struct gnWindowSurface_t windowSurface);
|
||||
|
Reference in New Issue
Block a user