thatcosmonaut / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
1 stars 2 forks source link

Texture format swizzling #71

Closed TheSpydog closed 2 days ago

TheSpydog commented 2 days ago

Fixes https://github.com/thatcosmonaut/SDL/issues/56.

Replaces:

and removes A2B10G10R10 entirely.

The reason for the last change is because I was incorrect in my initial write-up, D3D11/12 have no support for B10G10R10A2. So we'd have to swizzle R10G10B10A2 on the D3D side, which is not ideal. To keep as much swizzling logic as possible in Vulkan, I think we should exclusively offer RGBA order.

However, Vulkan's native surface support for A2R10G10B10 is ~12%. So instead we'll always use A2B10R10G10 (which has a ~62% surface support rate) and then swizzle it into RGBA order.

One remaining issue is with Metal's ABGR4 format. It doesn't support BGRA4 or any other swizzle natively, and D3D/VK don't support A4B4G4R4 natively. I'll need to set up a Metal swizzle for this format specifically.

flibitijibibo commented 2 days ago

One remaining issue is with Metal's ABGR4 format. It doesn't support BGRA4 or any other swizzle natively, and D3D/VK don't support A4B4G4R4 natively. I'll need to set up a Metal swizzle for this format specifically.

Marked this one as ready for now since I believe this is just a quick MTLTextureSwizzle, but if it's a major blocker that can be reverted (otherwise I'll apply this to the weekly update).