Disable stencil instancing (#1778)

This commit is contained in:
Tim Sylvester
2023-10-18 17:22:14 -07:00
committed by GitHub
parent 7f785ae660
commit d43c52b9d8
2 changed files with 27 additions and 15 deletions

View File

@@ -44,30 +44,20 @@ struct VertexStage {
struct FragmentStage {
float4 position [[position, invariant]];
uint8_t stencil_ref;
};
struct FragmentResult {
// color output is only needed because we're using implicit stencil writes
half4 color [[color(0)]];
// target is `..._stencil8`, but using `uint8_t` here causes a compile error
uint16_t stencil_ref [[stencil]];
};
FragmentStage vertex vertexMain(VertexStage in [[stage_in]],
uint16_t instanceID [[instance_id]],
device const ClipUBO* clipUBOs [[buffer(1)]]) {
device const ClipUBO& clipUBO = clipUBOs[instanceID];
return {
.position = clipUBO.matrix * float4(float2(in.position.xy), 0, 1),
.stencil_ref = static_cast<uint8_t>(clipUBO.stencil_ref),
};
device const ClipUBO& clipUBO [[buffer(1)]]) {
return { clipUBO.matrix * float4(float2(in.position.xy), 0, 1) };
}
FragmentResult fragment fragmentMain(FragmentStage in [[stage_in]]) {
return {
.color = half4(1.0),
.stencil_ref = static_cast<uint16_t>(in.stencil_ref),
};
half4 fragment fragmentMain(FragmentStage in [[stage_in]]) {
return half4(1.0);
}
)";
};