Skip to content

Commit

Permalink
metal: work around texture swizzle bug in the github runner VM
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Apr 26, 2024
1 parent d423def commit 4a2a25f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/modules/graphics/metal/Graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ class Graphics final : public love::graphics::Graphics

DeviceFamilies families;

bool isVMDevice;

}; // Graphics

} // metal
Expand Down
12 changes: 10 additions & 2 deletions src/modules/graphics/metal/Graphics.mm
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ static inline void setSampler(id<MTLComputeCommandEncoder> encoder, Graphics::Re
, uniformBufferGPUStart(0)
, defaultAttributesBuffer(nullptr)
, families()
, isVMDevice(false)
{ @autoreleasepool {
if (@available(macOS 10.15, iOS 13.0, *))
{
Expand All @@ -296,6 +297,8 @@ static inline void setSampler(id<MTLComputeCommandEncoder> encoder, Graphics::Re
throw love::Exception("LOVE's Metal graphics backend requires macOS 10.15+ or iOS 13+.");
}

isVMDevice = [device.name containsString:@("Apple Paravirtual device")];

#ifdef LOVE_MACOS
// On multi-GPU macOS systems with a low and high power GPU (e.g. a 2016
// Macbook Pro), the OS doesn't activate the high power GPU for final
Expand Down Expand Up @@ -1940,8 +1943,13 @@ static inline void advanceVertexOffsets(const VertexAttributes &attributes, Buff
// Requires texture swizzle support.
if (@available(macOS 10.15, iOS 13, *))
{
if (families.apple[1] || families.mac[2] || families.macCatalyst[2])
flags |= commonsample;
// As of early 2024, the VM device doesn't properly support texture swizzles
// (observed on GitHub's runners) which is required for LA8 support.
if (!isVMDevice)
{
if (families.apple[1] || families.mac[2] || families.macCatalyst[2])
flags |= commonsample;
}
}
break;
case PIXELFORMAT_RG16_UNORM:
Expand Down

0 comments on commit 4a2a25f

Please sign in to comment.