From b40b59935d108acf1d2c4d16c704d11561caa6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 19 May 2023 18:08:49 +0200 Subject: [PATCH] Metal: Force Compute shaders workgroup max thread count This forces the max thread count to be inlined with what blender expects. While this will make some shaders less eficient it avoid crashes / assert on shaders that could not compile. The performance impacts can be fixed by tackling the individual cases. --- source/blender/gpu/metal/mtl_shader.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/metal/mtl_shader.mm b/source/blender/gpu/metal/mtl_shader.mm index 94c3ef22a5d..b96de86da64 100644 --- a/source/blender/gpu/metal/mtl_shader.mm +++ b/source/blender/gpu/metal/mtl_shader.mm @@ -1390,9 +1390,15 @@ bool MTLShader::bake_compute_pipeline_state(MTLContext *ctx) } /* Compile PSO. */ + MTLComputePipelineDescriptor *desc = [[MTLComputePipelineDescriptor alloc] init]; + desc.maxTotalThreadsPerThreadgroup = 1024; + desc.computeFunction = compute_function; + id pso = [ctx->device - newComputePipelineStateWithFunction:compute_function - error:&error]; + newComputePipelineStateWithDescriptor:desc + options:MTLPipelineOptionNone + reflection:nullptr + error:&error]; if (error) { NSLog(@"Failed to create PSO for compute shader: %s error %@\n", this->name, error);