Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11247 from tellowkrinkle/MetalHeadless
VideoBackends:Metal: Headless render support
  • Loading branch information
AdmiralCurtiss committed Nov 4, 2022
2 parents 7a76aee + 83ca1ad commit c2e6d85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/Core/VideoBackends/Metal/MTLMain.mm
Expand Up @@ -54,6 +54,7 @@ static bool WindowSystemTypeSupportsMetal(WindowSystemType type)
switch (type)
{
case WindowSystemType::MacOS:
case WindowSystemType::Headless:
return true;
default:
return false;
Expand All @@ -64,7 +65,8 @@ static bool WindowSystemTypeSupportsMetal(WindowSystemType type)
{
@autoreleasepool
{
if (!WindowSystemTypeSupportsMetal(wsi.type) || !wsi.render_surface)
const bool surface_ok = wsi.type == WindowSystemType::Headless || wsi.render_surface;
if (!WindowSystemTypeSupportsMetal(wsi.type) || !surface_ok)
{
PanicAlertFmt("Bad WindowSystemInfo for Metal renderer.");
return false;
Expand Down Expand Up @@ -100,6 +102,8 @@ static bool WindowSystemTypeSupportsMetal(WindowSystemType type)
[layer setPixelFormat:MTLPixelFormatBGRA8Unorm];
CGSize size = [layer bounds].size;
float scale = [layer contentsScale];
if (!layer) // headless
scale = 1.0;

ObjectCache::Initialize(std::move(adapter));
g_state_tracker = std::make_unique<StateTracker>();
Expand Down

0 comments on commit c2e6d85

Please sign in to comment.