Commit c5b346e
metal: match pipeline attachment formats to the view
The Metal backend unconditionally configured every render pipeline
state for two color attachments (`for i in 0..2`) plus depth and
stencil at `Depth32Float_Stencil8`, while MTKView by default exposes
only color attachment 0 and `depthStencilPixelFormat = Invalid`. Metal
validation fires on the first draw:
failed assertion `Set Render Pipeline State Validation
For color attachment 1, the renderPipelineState pixelFormat must
be MTLPixelFormatInvalid, as no texture is set.
For depth attachment, the renderPipelineState pixelFormat must be
MTLPixelFormatInvalid, as no texture is set.
For stencil attachment, the renderPipelineState pixelFormat must
be MTLPixelFormatInvalid, as no texture is set.
Configure only color attachment 0 (the backend has no MRT path) and
mirror the view's `depthStencilPixelFormat` onto the pipeline's depth
+ stencil formats — but only when the view actually has one. When
MTKView reports `Invalid`, skip the `set*AttachmentPixelFormat:` calls
so the descriptor keeps its `Invalid` defaults instead of having that
sentinel passed in explicitly.
Adds `MTLPixelFormat::Invalid = 0` to the binding (Apple's `MTLPixelFormatInvalid`).1 parent df7d8ed commit c5b346e
2 files changed
Lines changed: 22 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
991 | 994 | | |
992 | | - | |
| 995 | + | |
993 | 996 | | |
994 | 997 | | |
995 | 998 | | |
| |||
1036 | 1039 | | |
1037 | 1040 | | |
1038 | 1041 | | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1047 | 1059 | | |
1048 | 1060 | | |
1049 | 1061 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
| 635 | + | |
635 | 636 | | |
636 | 637 | | |
637 | 638 | | |
| |||
0 commit comments