Add HDR to Metal

This commit is contained in:
Sam Belliveau 2024-03-10 03:25:33 -04:00
parent f3d1cda672
commit 153d0201a8
3 changed files with 19 additions and 0 deletions

View File

@ -164,8 +164,23 @@ void Metal::VideoBackend::PrepareWindow(WindowSystemInfo& wsi)
return;
NSView* view = static_cast<NSView*>(wsi.render_surface);
CAMetalLayer* layer = [CAMetalLayer layer];
Util::PopulateBackendInfo(&g_Config);
if (g_Config.backend_info.bSupportsHDROutput && g_Config.bHDR)
{
[layer setWantsExtendedDynamicRangeContent:YES];
[layer setPixelFormat:MTLPixelFormatRGBA16Float];
const CFStringRef name = kCGColorSpaceExtendedLinearSRGB;
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(name);
[layer setColorspace:colorspace];
CGColorSpaceRelease(colorspace);
}
[view setWantsLayer:YES];
[view setLayer:layer];
wsi.render_surface = layer;
#endif
}

View File

@ -3,7 +3,9 @@
#pragma once
#include <AppKit/NSScreen.h>
#include <Metal/Metal.h>
#include <vector>
#include "VideoCommon/AbstractShader.h"

View File

@ -77,6 +77,8 @@ void Metal::Util::PopulateBackendInfo(VideoConfig* config)
config->backend_info.bSupportsPartialMultisampleResolve = false;
config->backend_info.bSupportsDynamicVertexLoader = true;
config->backend_info.bSupportsVSLinePointExpand = true;
config->backend_info.bSupportsHDROutput =
1.0 < [[NSScreen deepestScreen] maximumPotentialExtendedDynamicRangeColorComponentValue];
}
void Metal::Util::PopulateBackendInfoAdapters(VideoConfig* config,