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

@@ -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);