patchType answered MTLPatchTypeNone and patchControlPointCount 0 for every function, where Metal answers a post-tessellation vertex function's [[patch]] type and count, and -1 for the count of every function that states none. The device draws patches, so an app that fills its tessellation state from the function built a wrong pipeline. The library now reads each function's TESS tag from the .metallib's function list: the type in its low two bits, the count above them, 63 for none, as Apple's compiler writes it and as Metal's own functions answer for those bytes on the M3 Max, the AMD 5300M and the Intel 630. A shell test checks both answers against Metal's for a library of every patch kind (aud-tests-02).
65 lines
1.6 KiB
Metal
65 lines
1.6 KiB
Metal
// The shell tests' post-tessellation vertex functions (Makefile, RGFX_PATCH): one [[patch]] of
|
|
// each type with and without a control point count, a counted one up to Metal's most (32), and
|
|
// functions of every other stage, which state no patch.
|
|
#include <metal_stdlib>
|
|
using namespace metal;
|
|
|
|
struct ControlPoint {
|
|
float4 position [[attribute(0)]];
|
|
};
|
|
|
|
[[patch(quad, 4)]] vertex float4 patch_quad4(
|
|
patch_control_point<ControlPoint> cp [[stage_in]],
|
|
float2 uv [[position_in_patch]])
|
|
{
|
|
return cp[0].position + float4(uv, 0, 0);
|
|
}
|
|
|
|
[[patch(quad)]] vertex float4 patch_quad_any(
|
|
patch_control_point<ControlPoint> cp [[stage_in]],
|
|
float2 uv [[position_in_patch]])
|
|
{
|
|
return cp[0].position + float4(uv, 0, 0);
|
|
}
|
|
|
|
[[patch(quad, 32)]] vertex float4 patch_quad32(
|
|
patch_control_point<ControlPoint> cp [[stage_in]],
|
|
float2 uv [[position_in_patch]])
|
|
{
|
|
return cp[0].position + float4(uv, 0, 0);
|
|
}
|
|
|
|
[[patch(triangle)]] vertex float4 patch_triangle_any(
|
|
patch_control_point<ControlPoint> cp [[stage_in]],
|
|
float3 uv [[position_in_patch]])
|
|
{
|
|
return cp[0].position + float4(uv, 0);
|
|
}
|
|
|
|
[[patch(triangle, 3)]] vertex float4 patch_triangle3(
|
|
patch_control_point<ControlPoint> cp [[stage_in]],
|
|
float3 uv [[position_in_patch]])
|
|
{
|
|
return cp[0].position + float4(uv, 0);
|
|
}
|
|
|
|
[[patch(quad)]] vertex float4 patch_quad_no_points(float2 uv [[position_in_patch]])
|
|
{
|
|
return float4(uv, 0, 1);
|
|
}
|
|
|
|
vertex float4 plain_vertex(uint v [[vertex_id]])
|
|
{
|
|
return float4(float(v));
|
|
}
|
|
|
|
fragment float4 plain_fragment()
|
|
{
|
|
return float4(1);
|
|
}
|
|
|
|
kernel void plain_kernel(device float *out [[buffer(0)]])
|
|
{
|
|
out[0] = 1;
|
|
}
|