wrote c compatible return code structure

This commit is contained in:
Greg Wells
2025-05-06 18:29:46 -04:00
parent a3fd0e1579
commit 07624bc93d
17 changed files with 94 additions and 112 deletions

View File

@@ -30,7 +30,7 @@ GN_EXPORT gnReturnCode gnCreateFramebufferFn(gnFramebuffer* framebuffer, const g
if (vkCreateFramebuffer(renderpass.renderpass->outputDevice->outputDevice->device, &framebufferInfo, nullptr, &framebuffer->framebuffer->framebuffer) != VK_SUCCESS) {
GN_RETURN_ERROR("Failed to create framebuffer");
return gnReturnError(GN_FAILED_TO_CREATE_FRAMEBUFFER, "im to lazy to query vulkan why");
}
return GN_SUCCESS;

View File

@@ -60,7 +60,7 @@ GN_EXPORT gnReturnCode gnCreateRenderPassFn(gnRenderPass* renderPass, const gnOu
colorAttachmentRef.attachment = i;
if (renderPass->presentationQueue == nullptr) {
GN_RETURN_ERROR("the presentation queue has not been set");
return gnReturnError(GN_FAILED_CREATE_RENDERPASS, "the presentation queue has not been set");
}
if (renderPass->attachments[i].colorMode == GN_RGBA8) {

View File

@@ -70,7 +70,7 @@ void gnInstanceSetAppInfoFn(gnInstance& instance, gnAppInfo& info) {
GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance) {
if (instance->debugger != nullptr && !checkValidationLayerSupport(instance->debugger->debug_layers)) {
GN_RETURN_ERROR("validation layers requested, but not available!");
return gnReturnError(GN_FAILED_CREATE_INSTANCE, "validation layers requested, but not available!");
}
gnInstanceSetAppInfoFn(*instance, instance->AppInfo);
@@ -103,7 +103,7 @@ GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance) {
}
if (vkCreateInstance(&createInfo, nullptr, &instance->instance->vk_instance) != VK_SUCCESS) {
return GN_FAILED;
return gnReturnError(GN_FAILED_CREATE_INSTANCE, "im to lazy to query vulkan why");
}
if (instance->debugger->debugger == nullptr) instance->debugger->debugger = new gnPlatformDebugger();
@@ -121,11 +121,11 @@ GN_EXPORT gnReturnCode gnInstanceSetWindowFn(gnInstance& instance, GLFWwindow* w
instance.instance->window = window;
if (glfwVulkanSupported() != GLFW_TRUE) {
GN_RETURN_ERROR("vulkan is not actually supported\n");
return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "vulkan is not actually supported\n");
}
VkResult result = glfwCreateWindowSurface(instance.instance->vk_instance, window, nullptr, &instance.instance->window_surface);\
if (result != VK_SUCCESS)
GN_RETURN_ERROR(std::to_string(result).c_str());
return gnReturnError(GN_FAILED_TO_ATTACH_WINDOW, std::to_string(result).c_str());
return GN_SUCCESS;
}

View File

@@ -56,7 +56,7 @@ GN_EXPORT gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presenta
createInfo.oldSwapchain = VK_NULL_HANDLE;
if (vkCreateSwapchainKHR(device.outputDevice->device, &createInfo, nullptr, &presentationQueue->presentationQueue->swapChain) != VK_SUCCESS) {
GN_RETURN_ERROR("failed to create swap chain!");
gnReturnError(GN_FAILED_CREATE_PRESENTATION_QUEUE, "too lazy to query vulkan why");
}
std::vector<VkImage> swapChainImages;

View File

@@ -179,11 +179,11 @@ GN_EXPORT gnReturnCode gnCreateTextureFn(gnTexture* texture, const gnOutputDevic
if (vulkanCreateImage(outputDevice, texture->textureExtent.x, texture->textureExtent.y,
depthFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
texture->texture->textureImage, texture->texture->textureImageMemory) != GN_SUCCESS) {
GN_RETURN_ERROR("Failed to create depth image");
return gnReturnError(GN_FAILED_TO_CREATE_IMAGE, "Failed to create depth image");
}
gnReturnCode errorCode = createImageView(outputDevice, texture->texture->textureImage, depthFormat, VK_IMAGE_ASPECT_DEPTH_BIT, &texture->texture->textureImageView);
if (transitionImageLayout(outputDevice, texture->texture->textureImage, depthFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) != GN_FAILED) GN_RETURN_ERROR("Failed to transition image layout");
if (transitionImageLayout(outputDevice, texture->texture->textureImage, depthFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) != GN_SUCCESS) return gnReturnError(GN_FAILED_TO_CREATE_IMAGE, "Failed to transition image layout");
}
} else {
if (vulkanCreateCubeMap(outputDevice, texture->textureExtent.x, texture->textureExtent.y, texture->texture->textureImage, texture->texture->textureImageMemory) != GN_SUCCESS)
@@ -217,7 +217,7 @@ GN_EXPORT gnReturnCode gnCreateTextureFn(gnTexture* texture, const gnOutputDevic
samplerInfo.maxLod = 0.0f;
if (vkCreateSampler(outputDevice.outputDevice->device, &samplerInfo, nullptr, &texture->texture->textureSampler) != VK_SUCCESS)
GN_RETURN_ERROR("Failed to create texture sampler");
return gnReturnError(GN_FAILED_TO_CREATE_IMAGE, "Failed to create texture sampler");
}
return GN_SUCCESS;

View File

@@ -182,7 +182,7 @@ gnReturnCode vulkanCreateImage(const gnOutputDevice& outputDevice,
VkResult result = vkCreateImage(outputDevice.outputDevice->device, &imageInfo, nullptr, &image);
if (result != VK_SUCCESS) {
GN_RETURN_ERROR(std::to_string(result).c_str());
return gnReturnError(GN_FAILED_TO_CREATE_IMAGE, std::to_string(result).c_str());
}
VkMemoryRequirements memRequirements;
@@ -197,12 +197,12 @@ gnReturnCode vulkanCreateImage(const gnOutputDevice& outputDevice,
outputDevice.physicalOutputDevice->physicalOutputDevice->device,
memRequirements.memoryTypeBits, properties,
&memoryTypeIndex) != GN_SUCCESS) {
GN_RETURN_ERROR("Failed to find memory type");
return gnReturnError(GN_FAILED_TO_CREATE_IMAGE, "Failed to find memory type");
}
allocInfo.memoryTypeIndex = memoryTypeIndex;
if (vkAllocateMemory(outputDevice.outputDevice->device, &allocInfo, nullptr, &imageMemory) != VK_SUCCESS) {
GN_RETURN_ERROR("Failed to allocate memory");
return gnReturnError(GN_FAILED_TO_CREATE_IMAGE, "Failed to allocate memory");
}
vkBindImageMemory(outputDevice.outputDevice->device, image, imageMemory, 0);