From f4fe8c8a2ccfb5ab41c507ba1db4c0497d2f6f47 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Fri, 26 May 2023 16:43:37 -0500 Subject: [PATCH] OptNoneFail tester --- compiler_explorer_tools/metal-compile-tool.m | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/compiler_explorer_tools/metal-compile-tool.m b/compiler_explorer_tools/metal-compile-tool.m index 799c602..5eea9e8 100644 --- a/compiler_explorer_tools/metal-compile-tool.m +++ b/compiler_explorer_tools/metal-compile-tool.m @@ -7,6 +7,22 @@ #error Please compile with -fobjc-arc #endif +@implementation MTLVertexBufferLayoutDescriptor (SetAll) +- (void)setStride:(NSUInteger)stride stepRate:(NSUInteger)rate function:(MTLVertexStepFunction)fn { + [self setStride:stride]; + [self setStepRate:rate]; + [self setStepFunction:fn]; +} +@end + +@implementation MTLVertexAttributeDescriptor (SetAll) +- (void)setBufferIndex:(NSUInteger)bufferIndex offset:(NSUInteger)offset format:(MTLVertexFormat)format { + [self setBufferIndex:bufferIndex]; + [self setOffset:offset]; + [self setFormat:format]; +} +@end + static void printUsageAndExit(const char* argv0) { fprintf(stderr, "Usage: %s --output binary_archive.bin shader.metal\n", argv0); exit(EXIT_FAILURE); @@ -182,7 +198,13 @@ int main(int argc, char* argv[]) { MTLRenderPipelineDescriptor* desc = [MTLRenderPipelineDescriptor new]; [desc setVertexFunction:vs]; [desc setFragmentFunction:fs]; - [[desc colorAttachments][0] setPixelFormat:targetFmt]; + MTLVertexDescriptor* vdesc = [desc vertexDescriptor]; + [[vdesc layouts][30] setStride:24 stepRate:1 function:MTLVertexStepFunctionPerVertex]; + [[vdesc attributes][1] setBufferIndex:30 offset: 0 format:MTLVertexFormatShort4Normalized]; + [[vdesc attributes][2] setBufferIndex:30 offset: 8 format:MTLVertexFormatChar4Normalized]; + [[vdesc attributes][4] setBufferIndex:30 offset:16 format:MTLVertexFormatUChar4Normalized]; + [[vdesc attributes][5] setBufferIndex:30 offset:20 format:MTLVertexFormatHalf2]; + [desc setDepthAttachmentPixelFormat:MTLPixelFormatDepth32Float]; [arc addRenderPipelineFunctionsWithDescriptor:desc error:&err]; if (err) { if (vs && fs) { -- 2.39.2 (Apple Git-143)