preferred image count

This commit is contained in:
Greg Wells
2025-05-24 18:45:29 -04:00
parent 339b2c75e0
commit ffec572925
2 changed files with 23 additions and 12 deletions

View File

@@ -6,17 +6,17 @@ void gnDestroyWindowSurface(struct gnWindowSurface_t *windowSurface) {
} }
struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats( struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats(
struct gnWindowSurface_t* windowSurface, struct gnWindowSurface_t windowSurface,
struct gnPhysicalDevice_t device, struct gnPhysicalDevice_t device,
uint32_t* formatCount uint32_t* formatCount
) { ) {
struct gnSurfaceDetails_t surfaceDetails = windowSurface->instance->functions->_gnGetSurfaceDetails(windowSurface, device); struct gnSurfaceDetails_t surfaceDetails = windowSurface.instance->functions->_gnGetSurfaceDetails(&windowSurface, device);
*formatCount = surfaceDetails.formatCount; *formatCount = surfaceDetails.formatCount;
return surfaceDetails.formats; return surfaceDetails.formats;
} }
gnBool gnIsSurfaceFormatSupported( gnBool gnIsSurfaceFormatSupported(
struct gnWindowSurface_t* windowSurface, struct gnWindowSurface_t windowSurface,
struct gnPhysicalDevice_t device, struct gnPhysicalDevice_t device,
struct gnSurfaceFormat_t format struct gnSurfaceFormat_t format
) { ) {
@@ -31,7 +31,7 @@ gnBool gnIsSurfaceFormatSupported(
} }
struct gnSurfaceFormat_t gnGetPreferredSurfaceFormat( struct gnSurfaceFormat_t gnGetPreferredSurfaceFormat(
struct gnWindowSurface_t* windowSurface, struct gnWindowSurface_t windowSurface,
struct gnPhysicalDevice_t device, struct gnPhysicalDevice_t device,
struct gnSurfaceFormat_t format struct gnSurfaceFormat_t format
) { ) {
@@ -53,11 +53,21 @@ struct gnSurfaceFormat_t gnGetPreferredSurfaceFormat(
return formats[0]; return formats[0];
} }
int gnGetMinImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device) { uint32_t gnGetMinImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device) {
struct gnSurfaceDetails_t surfaceDetails = surface.instance->functions->_gnGetSurfaceDetails(&surface, device); struct gnSurfaceDetails_t surfaceDetails = surface.instance->functions->_gnGetSurfaceDetails(&surface, device);
return surfaceDetails.minImageCount; return surfaceDetails.minImageCount;
} }
int gnGetMaxImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device) { uint32_t gnGetMaxImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device) {
struct gnSurfaceDetails_t surfaceDetails = surface.instance->functions->_gnGetSurfaceDetails(&surface, device); struct gnSurfaceDetails_t surfaceDetails = surface.instance->functions->_gnGetSurfaceDetails(&surface, device);
return surfaceDetails.maxImageCount; return surfaceDetails.maxImageCount;
} }
uint32_t gnGetPreferredImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device) {
struct gnSurfaceDetails_t surfaceDetails = surface.instance->functions->_gnGetSurfaceDetails(&surface, device);
uint32_t imageCount = surfaceDetails.minImageCount;
if (surfaceDetails.maxImageCount > 0 && imageCount > surfaceDetails.maxImageCount) {
imageCount = surfaceDetails.maxImageCount;
}
return imageCount;
}

View File

@@ -15,7 +15,7 @@ typedef struct gnSurfaceDetails_t {
uint32_t formatCount; uint32_t formatCount;
struct gnSurfaceFormat_t* formats; struct gnSurfaceFormat_t* formats;
int minImageCount, maxImageCount; uint32_t minImageCount, maxImageCount;
} gnSufaceDetails; } gnSufaceDetails;
typedef struct gnWindowSurface_t { typedef struct gnWindowSurface_t {
@@ -24,12 +24,12 @@ typedef struct gnWindowSurface_t {
} gnWindowSurface; } gnWindowSurface;
void gnDestroyWindowSurface(struct gnWindowSurface_t* windowSurface); void gnDestroyWindowSurface(struct gnWindowSurface_t* windowSurface);
struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats( struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats(
struct gnWindowSurface_t* windowSurface, struct gnWindowSurface_t windowSurface,
struct gnPhysicalDevice_t device, struct gnPhysicalDevice_t device,
uint32_t* formatCount uint32_t* formatCount
); );
gnBool gnIsSurfaceFormatSupported( gnBool gnIsSurfaceFormatSupported(
struct gnWindowSurface_t* windowSurface, struct gnWindowSurface_t windowSurface,
struct gnPhysicalDevice_t device, struct gnPhysicalDevice_t device,
struct gnSurfaceFormat_t format struct gnSurfaceFormat_t format
); );
@@ -37,9 +37,10 @@ gnBool gnIsSurfaceFormatSupported(
// unless its not supported then it will give you the first supported surface format // unless its not supported then it will give you the first supported surface format
// at some point this function will attempt to give you the most simmilar surface format // at some point this function will attempt to give you the most simmilar surface format
struct gnSurfaceFormat_t gnGetPreferredSurfaceFormat( struct gnSurfaceFormat_t gnGetPreferredSurfaceFormat(
struct gnWindowSurface_t* windowSurface, struct gnWindowSurface_t windowSurface,
struct gnPhysicalDevice_t device, struct gnPhysicalDevice_t device,
struct gnSurfaceFormat_t format struct gnSurfaceFormat_t format
); );
int gnGetMinImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device); uint32_t gnGetMinImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device);
int gnGetMaxImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device); uint32_t gnGetMaxImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device);
uint32_t gnGetPreferredImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device);