Skip to content

Commit

Permalink
Add: Support for RG11B10 and RGB9E5 vertex formats
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Jul 12, 2023
1 parent dff64e9 commit baaa4ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
1 change: 0 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,6 @@
_metalFeatures.mslVersionEnum = MTLLanguageVersion3_0;
}
#endif

#if MVK_XCODE_15
if ( mvkOSVersionIsAtLeast(17.0) ) {
_metalFeatures.mslVersionEnum = MTLLanguageVersion3_1;
Expand Down
31 changes: 28 additions & 3 deletions MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@
# define MTLPixelFormatASTC_12x12_HDR MTLPixelFormatInvalid
#endif

#if !MVK_XCODE_15
# define MTLVertexFormatFloatRG11B10 MTLVertexFormatInvalid
# define MTLVertexFormatFloatRGB9E5 MTLVertexFormatInvalid
#endif


#pragma mark -
#pragma mark MVKPixelFormats
Expand Down Expand Up @@ -975,9 +980,9 @@
addVkFormatDesc( R64G64B64A64_SINT, Invalid, Invalid, Invalid, Invalid, 1, 1, 32, ColorFloat );
addVkFormatDesc( R64G64B64A64_SFLOAT, Invalid, Invalid, Invalid, Invalid, 1, 1, 32, ColorFloat );

addVkFormatDesc( B10G11R11_UFLOAT_PACK32, RG11B10Float, Invalid, Invalid, Invalid, 1, 1, 4, ColorFloat );
addVkFormatDesc( E5B9G9R9_UFLOAT_PACK32, RGB9E5Float, Invalid, Invalid, Invalid, 1, 1, 4, ColorFloat );

addVkFormatDesc( B10G11R11_UFLOAT_PACK32, RG11B10Float, Invalid, FloatRG11B10, Invalid, 1, 1, 4, ColorFloat );
addVkFormatDesc( E5B9G9R9_UFLOAT_PACK32, RGB9E5Float, Invalid, FloatRGB9E5, Invalid, 1, 1, 4, ColorFloat );
addVkFormatDesc( D32_SFLOAT, Depth32Float, Invalid, Invalid, Invalid, 1, 1, 4, DepthStencil );
addVkFormatDesc( D32_SFLOAT_S8_UINT, Depth32Float_Stencil8, Invalid, Invalid, Invalid, 1, 1, 5, DepthStencil );

Expand Down Expand Up @@ -1391,6 +1396,11 @@
addMTLVertexFormatDesc( Half, None, None );

addMTLVertexFormatDesc( UChar4Normalized_BGRA, None, None );

#if MVK_XCODE_15
addMTLVertexFormatDesc( FloatRG11B10, None, None );
addMTLVertexFormatDesc( FloatRGB9E5, None, None );
#endif

// When adding to this list, be sure to ensure _mtlVertexFormatCount is large enough for the format count
}
Expand Down Expand Up @@ -1687,6 +1697,11 @@
addFeatSetMTLVtxFmtCaps( macOS_GPUFamily1_v3, Short, Vertex );
addFeatSetMTLVtxFmtCaps( macOS_GPUFamily1_v3, Half, Vertex );
addFeatSetMTLVtxFmtCaps( macOS_GPUFamily1_v3, UChar4Normalized_BGRA, Vertex );

#if MVK_XCODE_15
addGPUOSMTLVtxFmtCaps( Apple5, 14.0, FloatRG11B10, Vertex );
addGPUOSMTLVtxFmtCaps( Apple5, 14.0, FloatRGB9E5, Vertex );
#endif
#endif

#if MVK_TVOS
Expand Down Expand Up @@ -1780,6 +1795,11 @@
addFeatSetMTLVtxFmtCaps( tvOS_GPUFamily1_v3, Short, Vertex );
addFeatSetMTLVtxFmtCaps( tvOS_GPUFamily1_v3, Half, Vertex );
addFeatSetMTLVtxFmtCaps( tvOS_GPUFamily1_v3, UChar4Normalized_BGRA, Vertex );

#if MVK_XCODE_15
addGPUOSMTLVtxFmtCaps( Apple5, 17.0, FloatRG11B10, Vertex );
addGPUOSMTLVtxFmtCaps( Apple5, 17.0, FloatRGB9E5, Vertex );
#endif

// Disable for tvOS simulator last.
#if MVK_OS_SIMULATOR
Expand Down Expand Up @@ -1937,6 +1957,11 @@
addFeatSetMTLVtxFmtCaps( iOS_GPUFamily1_v4, Short, Vertex );
addFeatSetMTLVtxFmtCaps( iOS_GPUFamily1_v4, Half, Vertex );
addFeatSetMTLVtxFmtCaps( iOS_GPUFamily1_v4, UChar4Normalized_BGRA, Vertex );

#if MVK_XCODE_15
addGPUOSMTLVtxFmtCaps( Apple5, 17.0, FloatRG11B10, Vertex );
addGPUOSMTLVtxFmtCaps( Apple5, 17.0, FloatRGB9E5, Vertex );
#endif

// Disable for iOS simulator last.
#if MVK_OS_SIMULATOR
Expand Down

0 comments on commit baaa4ad

Please sign in to comment.