redo metal graphics pipeline creation

This commit is contained in:
Greg Wells
2025-05-29 11:18:27 -04:00
parent ccc4c9d4df
commit 2796a8b65e
3 changed files with 19 additions and 3 deletions

View File

@@ -23,8 +23,20 @@ gnReturnCode gnCreateGraphicsPipelineFn(struct gnGraphicsPipeline_t* graphicsPip
graphicsPipeline->graphicsPipeline = malloc(sizeof(struct gnPlatformGraphicsPipeline_t));
MTLRenderPipelineDescriptor* descriptor = [[MTLRenderPipelineDescriptor alloc] init];
for (int i = 0; i < info.renderPassDescriptor->info.attachmentCount; i++) {
[descriptor.colorAttachments objectAtIndexedSubscript:i].pixelFormat = mtlGryphnFormatToVulkanFormat(info.renderPassDescriptor->info.attachmentInfos[i].format);
if (info.subpassIndex >= info.renderPassDescriptor->info.subpassCount) {
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
.message = gnCreateString("Subpass index is larger then the subpass count in render pass descriptor")
});
return GN_UNKNOWN_SUBPASS;
}
struct gnSubpassInfo_t subpass = info.renderPassDescriptor->info.subpassInfos[info.subpassIndex];
for (uint32_t i = 0; i < subpass.colorAttachmentCount; i++) {
gnSubpassAttachmentInfo subpassAtt = subpass.colorAttachments[i];
gnRenderPassAttachmentInfo attInfo = info.renderPassDescriptor->info.attachmentInfos[subpassAtt.index];
descriptor.colorAttachments[i].pixelFormat = mtlGryphnFormatToVulkanFormat(attInfo.format);
if (info.colorBlending.enable == gnTrue) {
[descriptor.colorAttachments objectAtIndexedSubscript:i].blendingEnabled = YES;
[descriptor.colorAttachments objectAtIndexedSubscript:i].rgbBlendOperation = vkGryphnBlendOperation(info.colorBlending.colorBlendOperation);

View File

@@ -207,4 +207,6 @@ void gnDestroyGraphicsPipelineFn(struct gnGraphicsPipeline_t *graphicsPipeline)
if (graphicsPipeline->graphicsPipeline->createdPipelineLayout)
vkDestroyPipelineLayout(graphicsPipeline->device->outputDevice->device, graphicsPipeline->graphicsPipeline->pipelineLayout, NULL);
vkDestroyPipeline(graphicsPipeline->device->outputDevice->device, graphicsPipeline->graphicsPipeline->graphicsPipeline, NULL);
free(graphicsPipeline->graphicsPipeline);
}

View File

@@ -23,7 +23,8 @@ typedef enum gnReturnCode_t {
GN_FAILED_TO_CREATE_UNIFORM_LAYOUT,
GN_FAILED_TO_CREATE_RENDER_PASS,
GN_FAILED_TO_CREATE_GRAPHICS_PIPELINE,
GN_UNSUPPORTED_SHADER_MODULE
GN_UNSUPPORTED_SHADER_MODULE,
GN_UNKNOWN_SUBPASS
} gnReturnCode;
typedef gnReturnCode gnErrorCode;
@@ -52,5 +53,6 @@ static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) {
case GN_FAILED_TO_CREATE_RENDER_PASS: return "GN_FAILED_TO_CREATE_RENDER_PASS";
case GN_FAILED_TO_CREATE_GRAPHICS_PIPELINE: return "GN_FAILED_TO_CREATE_GRAPHICS_PIPELINE";
case GN_UNSUPPORTED_SHADER_MODULE: return "GN_UNSUPPORTED_SHADER_MODULE";
case GN_UNKNOWN_SUBPASS: return "GN_UNKNOWN_SUBPASS";
}
}