From a1ddf4060b67e78f67f804a7e30568b603db3c57 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Wed, 12 Feb 2025 01:25:43 +0100 Subject: [PATCH] Format code --- .../Metal/Sources/kope/metal/commandlist.m | 28 +++++++++---------- .../Metal/Sources/kope/metal/device.m | 2 +- .../Metal/Sources/kope/metal/pipeline.m | 20 +++++++------ 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Backends/Graphics5/Metal/Sources/kope/metal/commandlist.m b/Backends/Graphics5/Metal/Sources/kope/metal/commandlist.m index 818477702..828c56baa 100644 --- a/Backends/Graphics5/Metal/Sources/kope/metal/commandlist.m +++ b/Backends/Graphics5/Metal/Sources/kope/metal/commandlist.m @@ -17,7 +17,7 @@ void kope_metal_command_list_destroy(kope_g5_command_list *list) {} void kope_metal_command_list_begin_render_pass(kope_g5_command_list *list, const kope_g5_render_pass_parameters *parameters) { id texture = (__bridge id)parameters->color_attachments[0].texture.texture->metal.texture; - + MTLRenderPassDescriptor *render_pass_descriptor = [MTLRenderPassDescriptor renderPassDescriptor]; render_pass_descriptor.colorAttachments[0].texture = texture; render_pass_descriptor.colorAttachments[0].loadAction = MTLLoadActionClear; @@ -44,10 +44,10 @@ void kope_metal_command_list_end_render_pass(kope_g5_command_list *list) { void kope_metal_command_list_present(kope_g5_command_list *list) { id command_buffer = (__bridge id)list->metal.command_buffer; - + CAMetalLayer *metal_layer = getMetalLayer(); id drawable = [metal_layer nextDrawable]; - + [command_buffer presentDrawable:drawable]; } @@ -60,14 +60,14 @@ void kope_metal_command_list_set_index_buffer(kope_g5_command_list *list, kope_g void kope_metal_command_list_set_vertex_buffer(kope_g5_command_list *list, uint32_t slot, kope_metal_buffer *buffer, uint64_t offset, uint64_t size, uint64_t stride) { id metal_buffer = (__bridge id)buffer->buffer; - + id render_command_encoder = (__bridge id)list->metal.render_command_encoder; [render_command_encoder setVertexBuffer:metal_buffer offset:offset atIndex:slot]; } void kope_metal_command_list_set_render_pipeline(kope_g5_command_list *list, kope_metal_render_pipeline *pipeline) { id metal_pipeline = (__bridge id)pipeline->pipeline; - + id render_command_encoder = (__bridge id)list->metal.render_command_encoder; [render_command_encoder setRenderPipelineState:metal_pipeline]; } @@ -77,17 +77,17 @@ void kope_metal_command_list_draw(kope_g5_command_list *list, uint32_t vertex_co void kope_metal_command_list_draw_indexed(kope_g5_command_list *list, uint32_t index_count, uint32_t instance_count, uint32_t first_index, int32_t base_vertex, uint32_t first_instance) { id index_buffer = (__bridge id)list->metal.index_buffer; - + id render_command_encoder = (__bridge id)list->metal.render_command_encoder; - + [render_command_encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle - indexCount:index_count - indexType:(list->metal.sixteen_bit_indices ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32) - indexBuffer:index_buffer - indexBufferOffset:first_index - instanceCount:instance_count - baseVertex:base_vertex - baseInstance:first_instance]; + indexCount:index_count + indexType:list->metal.sixteen_bit_indices ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 + indexBuffer:index_buffer + indexBufferOffset:first_index + instanceCount:instance_count + baseVertex:base_vertex + baseInstance:first_instance]; } void kope_metal_command_list_set_descriptor_table(kope_g5_command_list *list, uint32_t table_index, kope_metal_descriptor_set *set, diff --git a/Backends/Graphics5/Metal/Sources/kope/metal/device.m b/Backends/Graphics5/Metal/Sources/kope/metal/device.m index a09e8c3a9..c82ddf89e 100644 --- a/Backends/Graphics5/Metal/Sources/kope/metal/device.m +++ b/Backends/Graphics5/Metal/Sources/kope/metal/device.m @@ -63,7 +63,7 @@ kope_g5_texture_format kope_metal_device_framebuffer_format(kope_g5_device *devi void kope_metal_device_execute_command_list(kope_g5_device *device, kope_g5_command_list *list) { id command_buffer = (__bridge id)list->metal.command_buffer; [command_buffer commit]; - + id command_queue = (__bridge id)list->metal.command_queue; command_buffer = [command_queue commandBuffer]; list->metal.command_buffer = (__bridge_retained void *)[command_queue commandBuffer]; diff --git a/Backends/Graphics5/Metal/Sources/kope/metal/pipeline.m b/Backends/Graphics5/Metal/Sources/kope/metal/pipeline.m index 46f375257..78aa0d879 100644 --- a/Backends/Graphics5/Metal/Sources/kope/metal/pipeline.m +++ b/Backends/Graphics5/Metal/Sources/kope/metal/pipeline.m @@ -4,23 +4,25 @@ #include void kope_metal_render_pipeline_init(kope_metal_device *device, kope_metal_render_pipeline *pipe, const kope_metal_render_pipeline_parameters *parameters) { - id vertex_function = [getMetalLibrary() newFunctionWithName:[NSString stringWithCString:parameters->vertex.shader.function_name encoding:NSUTF8StringEncoding]]; - id fragment_function = [getMetalLibrary() newFunctionWithName:[NSString stringWithCString:parameters->fragment.shader.function_name encoding:NSUTF8StringEncoding]]; - + id vertex_function = [getMetalLibrary() newFunctionWithName:[NSString stringWithCString:parameters->vertex.shader.function_name + encoding:NSUTF8StringEncoding]]; + id fragment_function = [getMetalLibrary() newFunctionWithName:[NSString stringWithCString:parameters->fragment.shader.function_name + encoding:NSUTF8StringEncoding]]; + MTLRenderPipelineDescriptor *render_pipeline_descriptor = [[MTLRenderPipelineDescriptor alloc] init]; render_pipeline_descriptor.vertexFunction = vertex_function; render_pipeline_descriptor.fragmentFunction = fragment_function; - + // TODO - + NSError *errors = nil; MTLRenderPipelineReflection *reflection = nil; id metal_device = (__bridge id)device->device; - + pipe->pipeline = (__bridge_retained void *)[metal_device newRenderPipelineStateWithDescriptor:render_pipeline_descriptor - options:MTLPipelineOptionBufferTypeInfo - reflection:&reflection - error:&errors]; + options:MTLPipelineOptionBufferTypeInfo + reflection:&reflection + error:&errors]; } void kope_metal_render_pipeline_destroy(kope_metal_render_pipeline *pipe) {}