Hello,
So before on XCode 10.3 on MacOS Mojave my code worked without any problems.
However I have since upgraded to XCode 12.4 with MacOS Catalina (10.15.7)
Now when I attempt:
id <MTLRenderPipelineState> pcMTLRenderPipeLineState = [pcMTLDevice newRenderPipelineStateWithDescriptor: pcMTLRenderPipeLineDesc error: &pcError];
I get the following error:
Compiler failed to build request
CMetalPipeLineState::Create: Failed to generate a pipeline state object: Error Domain=AGXMetalA7 Code=1 "Could not resolve texture/samplers references" UserInfo={NSLocalizedDescription=Could not resolve texture/samplers references}
Does anyone have any idea what could be causing this?
The full debug output is shown below:
CMetalPipeLineState::Create: Descriptor: <MTLRenderPipelineDescriptorInternal: 0x1701b5c40>
{
"Alpha to Coverage" = 0;
"Alpha to One" = 0;
"Blend States" = (
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = "MTLPixelFormatBGRA8Unorm_sRGB";
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
}
);
"Depth Attachment Format" = MTLPixelFormatDepth32Float;
"Fragment Depth Compare Clamp Mask" = 0x0;
"Fragment Function" = "<MTLDebugFunction: 0x170272200> -> <_MTLFunctionInternal: 0x170196da0>\n{\n attributes = \"<null>\";\n device = \"<AGXA7Device: 0x101728000>\\n{\\n name = \\\"Apple A7 GPU\\\";\\n}\";\n functionType = MTLFunctionTypeFragment;\n name = \"diffuse_main_ps\";\n}";
"Rasterization Enabled" = 1;
"Sample Count" = 1;
"Sample Coverage" = 1;
"Sample Mask" = 0xffffffffffffffff;
"Stencil Attachment Format" = MTLPixelFormatInvalid;
"Vertex Depth Compare Clamp Mask" = 0x0;
"Vertex Array" = "<null>";
"Vertex Enabled" = 1;
"Vertex Function" = "<MTLDebugFunction: 0x170271f40> -> <_MTLFunctionInternal: 0x170196720>\n{\n attributes = \"<null>\";\n device = \"<AGXA7Device: 0x101728000>\\n{\\n name = \\\"Apple A7 GPU\\\";\\n}\";\n functionType = MTLFunctionTypeVertex;\n name = \"diffuse_vp_main_vs\";\n}";
label = "<null>";
maxTessellationFactor = 16;
tessellationControlPointIndexType = MTLTessellationControlPointIndexTypeNone;
tessellationFactorFormat = MTLTessellationFactorFormatHalf;
tessellationFactorScaleEnabled = 0;
tessellationFactorStepFunction = MTLTessellationFactorStepFunctionConstant;
tessellationOutputWindingOrder = MTLWindingClockwise;
tessellationPartitionMode = MTLTessellationPartitionModePow2;
}
So before on XCode 10.3 on MacOS Mojave my code worked without any problems.
However I have since upgraded to XCode 12.4 with MacOS Catalina (10.15.7)
Now when I attempt:
id <MTLRenderPipelineState> pcMTLRenderPipeLineState = [pcMTLDevice newRenderPipelineStateWithDescriptor: pcMTLRenderPipeLineDesc error: &pcError];
I get the following error:
Compiler failed to build request
CMetalPipeLineState::Create: Failed to generate a pipeline state object: Error Domain=AGXMetalA7 Code=1 "Could not resolve texture/samplers references" UserInfo={NSLocalizedDescription=Could not resolve texture/samplers references}
Does anyone have any idea what could be causing this?
The full debug output is shown below:
CMetalPipeLineState::Create: Descriptor: <MTLRenderPipelineDescriptorInternal: 0x1701b5c40>
{
"Alpha to Coverage" = 0;
"Alpha to One" = 0;
"Blend States" = (
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = "MTLPixelFormatBGRA8Unorm_sRGB";
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
},
{
"Alpha Blend Operation" = MTLBlendOperationAdd;
"Blending Enabled" = 0;
"Destination Alpha Blend Factor" = MTLBlendFactorZero;
"Destination RGB Blend Factor" = MTLBlendFactorZero;
"Pixel Format" = MTLPixelFormatInvalid;
"RGB Blend Operation" = MTLBlendOperationAdd;
"Source Alpha Blend Factor" = MTLBlendFactorOne;
"Source RGB Blend Factor" = MTLBlendFactorOne;
"Write Mask" = RGBA;
}
);
"Depth Attachment Format" = MTLPixelFormatDepth32Float;
"Fragment Depth Compare Clamp Mask" = 0x0;
"Fragment Function" = "<MTLDebugFunction: 0x170272200> -> <_MTLFunctionInternal: 0x170196da0>\n{\n attributes = \"<null>\";\n device = \"<AGXA7Device: 0x101728000>\\n{\\n name = \\\"Apple A7 GPU\\\";\\n}\";\n functionType = MTLFunctionTypeFragment;\n name = \"diffuse_main_ps\";\n}";
"Rasterization Enabled" = 1;
"Sample Count" = 1;
"Sample Coverage" = 1;
"Sample Mask" = 0xffffffffffffffff;
"Stencil Attachment Format" = MTLPixelFormatInvalid;
"Vertex Depth Compare Clamp Mask" = 0x0;
"Vertex Array" = "<null>";
"Vertex Enabled" = 1;
"Vertex Function" = "<MTLDebugFunction: 0x170271f40> -> <_MTLFunctionInternal: 0x170196720>\n{\n attributes = \"<null>\";\n device = \"<AGXA7Device: 0x101728000>\\n{\\n name = \\\"Apple A7 GPU\\\";\\n}\";\n functionType = MTLFunctionTypeVertex;\n name = \"diffuse_vp_main_vs\";\n}";
label = "<null>";
maxTessellationFactor = 16;
tessellationControlPointIndexType = MTLTessellationControlPointIndexTypeNone;
tessellationFactorFormat = MTLTessellationFactorFormatHalf;
tessellationFactorScaleEnabled = 0;
tessellationFactorStepFunction = MTLTessellationFactorStepFunctionConstant;
tessellationOutputWindingOrder = MTLWindingClockwise;
tessellationPartitionMode = MTLTessellationPartitionModePow2;
}
OK I finally "solved" this.
The issue is that the newly compiled Metal shader library is NOT compatible with the iPhone 5s with iOS version 10.1.1. So calling the method: - (nullable id <MTLLibrary>)newDefaultLibrary; with the compiled Metal library file will not work.
The solution is to run time compile the metal shaders on the target platform with the method:
The issue is that the newly compiled Metal shader library is NOT compatible with the iPhone 5s with iOS version 10.1.1. So calling the method: - (nullable id <MTLLibrary>)newDefaultLibrary; with the compiled Metal library file will not work.
The solution is to run time compile the metal shaders on the target platform with the method:
(nullable id <MTLLibrary>)newLibraryWithSource:(NSString *)source options:(nullable MTLCompileOptions *)options error:(__autoreleasing NSError **)error;