error checking or some jazz
This commit is contained in:
@@ -1,25 +1,40 @@
|
||||
#include "metal_presentation_queue.h"
|
||||
#include "core/surface/metal_surface.h"
|
||||
#include "core/devices/metal_output_devices.h"
|
||||
#include "core/debugger/gryphn_debugger.h"
|
||||
|
||||
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDevice* device, struct gnPresentationQueueInfo_t presentationInfo) {
|
||||
if (presentationInfo.minImageCount > 3) {
|
||||
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
|
||||
.message = gnCreateString("On Metal you cannot have more than 3 images in a presentation queue")
|
||||
});
|
||||
return GN_UNSUPPORTED_IMAGE_COUNT;
|
||||
}
|
||||
|
||||
if (presentationInfo.minImageCount < 2) {
|
||||
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
|
||||
.message = gnCreateString("On Metal you cannot have less than 2 images in a presentation queue")
|
||||
});
|
||||
return GN_UNSUPPORTED_IMAGE_COUNT;
|
||||
}
|
||||
|
||||
presentationQueue->presentationQueue = malloc(sizeof(struct gnPlatformPresentationQueue_t));
|
||||
|
||||
MTLPixelFormat convertedFormat = mtlGryphnFormatToVulkanFormat(presentationInfo.format.format);
|
||||
CGColorSpaceRef convertedColorSpace = mtlGryphnColorSpaceToVulkanColorSpace(presentationInfo.format.colorSpace);
|
||||
|
||||
presentationQueue->presentationQueue->textureCount = presentationInfo.ImageCount;
|
||||
presentationQueue->presentationQueue->textures = malloc(sizeof(id<MTLTexture>) * presentationInfo.ImageCount);
|
||||
presentationQueue->presentationQueue->textureCount = presentationInfo.minImageCount;
|
||||
presentationQueue->presentationQueue->textures = malloc(sizeof(id<MTLTexture>) * presentationInfo.minImageCount);
|
||||
|
||||
MTLTextureDescriptor* textureDescriptor = [[MTLTextureDescriptor alloc] init];
|
||||
textureDescriptor.pixelFormat = convertedFormat;
|
||||
textureDescriptor.width = presentationInfo.ImageSize.x;
|
||||
textureDescriptor.height = presentationInfo.ImageSize.y;
|
||||
textureDescriptor.width = presentationInfo.imageSize.x;
|
||||
textureDescriptor.height = presentationInfo.imageSize.y;
|
||||
textureDescriptor.usage = MTLTextureUsageRenderTarget;
|
||||
textureDescriptor.textureType = MTLTextureType2D;
|
||||
|
||||
|
||||
for (int i = 0; i < presentationInfo.ImageCount; i++) {
|
||||
for (int i = 0; i < presentationInfo.minImageCount; i++) {
|
||||
presentationQueue->presentationQueue->textures[i] = [device->outputDevice->device newTextureWithDescriptor:textureDescriptor];
|
||||
}
|
||||
|
||||
|
@@ -43,15 +43,15 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue,
|
||||
}
|
||||
VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
VkExtent2D extent = {
|
||||
.width = presentationInfo.ImageSize.x,
|
||||
.height = presentationInfo.ImageSize.y
|
||||
.width = presentationInfo.imageSize.x,
|
||||
.height = presentationInfo.imageSize.y
|
||||
};
|
||||
|
||||
VkSwapchainCreateInfoKHR createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||
createInfo.surface = presentationInfo.surface.windowSurface->surface;
|
||||
|
||||
createInfo.minImageCount = presentationInfo.ImageCount;
|
||||
createInfo.minImageCount = presentationInfo.minImageCount;
|
||||
createInfo.imageFormat = details.formats[index].format;
|
||||
createInfo.imageColorSpace = details.formats[index].colorSpace;
|
||||
createInfo.imageExtent = extent;
|
||||
|
Reference in New Issue
Block a user