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 Dec 27, 2023
1 parent 76233bc commit d77f614
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static const uint32_t _vkFormatCount = 256;
static const uint32_t _vkFormatCoreCount = VK_FORMAT_ASTC_12x12_SRGB_BLOCK + 1;
static const uint32_t _mtlPixelFormatCount = 256;
static const uint32_t _mtlPixelFormatCoreCount = MTLPixelFormatX32_Stencil8 + 2; // The actual last enum value is not available on iOS
static const uint32_t _mtlVertexFormatCount = MTLVertexFormatHalf + 1;
static const uint32_t _mtlVertexFormatCount = MTLVertexFormatFloatRGB9E5 + 1;


#pragma mark -
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 @@ -976,9 +981,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 @@ -1392,6 +1397,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 @@ -1683,6 +1693,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 @@ -1776,6 +1791,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 @@ -1933,6 +1953,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 d77f614

Please sign in to comment.