kinda start to fix render pass descriptors in metal
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include "renderpass/gryphn_render_pass_descriptor.h"
|
||||
#import <Metal/MTLRenderPass.h>
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
typedef MTLRenderPassDescriptor* mtlSubpass;
|
||||
|
||||
typedef struct mtlColorAttachmentCopyInfo {
|
||||
MTLPixelFormat format;
|
||||
|
||||
uint32_t attachmentIndex;
|
||||
int resolveAttachmentIndex; // -1 means no resolve attachment
|
||||
} mtlColorAttachmentCopyInfo;
|
||||
@@ -12,6 +15,7 @@ typedef struct mtlColorAttachmentCopyInfo {
|
||||
typedef struct mtlSubpassCopyInfo {
|
||||
uint32_t colorAttachmentCount;
|
||||
mtlColorAttachmentCopyInfo* colorAttachments;
|
||||
int depthAttachmentIndex; // -1 means no depth attachment
|
||||
} mtlSubpassCopyInfo;
|
||||
|
||||
typedef struct gnPlatformRenderPassDescriptor_t {
|
||||
|
||||
@@ -45,28 +45,32 @@ gnReturnCode createMetalRenderPass(gnRenderPassDescriptor renderPass, gnDevice d
|
||||
uint32_t attachmentIndex = info.subpassInfos[i].colorAttachments[c].index;
|
||||
int resolveAttachmentIndex = -1;
|
||||
|
||||
renderPass->renderPassDescriptor->subpasses[i].colorAttachments[c] = [[MTLRenderPassColorAttachmentDescriptor alloc] init];
|
||||
MTLRenderPassColorAttachmentDescriptor* color = renderPass->renderPassDescriptor->subpasses[i].colorAttachments[c];
|
||||
if (resolve) {
|
||||
resolveAttachmentIndex = info.subpassInfos[i].resolveAttachments[c].index;
|
||||
color.storeAction = mtlGryphnStoreOperationResolve(info.attachmentInfos[attachmentIndex].storeOperation);
|
||||
} else {
|
||||
} else
|
||||
color.storeAction = mtlGryphnStoreOperation(info.attachmentInfos[attachmentIndex].storeOperation);
|
||||
}
|
||||
color.loadAction = mtlGryphnLoadOperation(info.attachmentInfos[attachmentIndex].loadOperation);
|
||||
color.storeAction = MTLStoreActionStoreAndMultisampleResolve;
|
||||
|
||||
if (color.loadAction == MTLLoadActionClear)
|
||||
color.clearColor = MTLClearColorMake(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
renderPass->renderPassDescriptor->copyInfos[i].colorAttachments[i].attachmentIndex = attachmentIndex;
|
||||
renderPass->renderPassDescriptor->copyInfos[i].colorAttachments[i].resolveAttachmentIndex = resolveAttachmentIndex;
|
||||
renderPass->renderPassDescriptor->copyInfos[i].colorAttachments[c].format = MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
renderPass->renderPassDescriptor->copyInfos[i].colorAttachments[c].attachmentIndex = attachmentIndex;
|
||||
renderPass->renderPassDescriptor->copyInfos[i].colorAttachments[c].resolveAttachmentIndex = resolveAttachmentIndex;
|
||||
}
|
||||
|
||||
renderPass->renderPassDescriptor->copyInfos[i].depthAttachmentIndex = -1;
|
||||
if (info.subpassInfos[i].depthAttachment != NULL) {
|
||||
MTLRenderPassDepthAttachmentDescriptor* depthAttachment = renderPass->renderPassDescriptor->subpasses[i].depthAttachment;
|
||||
uint32_t attachmentIndex = info.subpassInfos[i].depthAttachment->index;
|
||||
depthAttachment.loadAction = mtlGryphnLoadOperation(info.attachmentInfos[attachmentIndex].loadOperation);
|
||||
depthAttachment.storeAction = mtlGryphnStoreOperation(info.attachmentInfos[attachmentIndex].storeOperation);
|
||||
depthAttachment.clearDepth = 1.0f;
|
||||
renderPass->renderPassDescriptor->copyInfos[i].depthAttachmentIndex = attachmentIndex;
|
||||
}
|
||||
}
|
||||
return GN_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user