MacOS: Enable support for EDR rendering #105662

Merged
Brecht Van Lommel merged 26 commits from Jason-Fielder/blender:macos_EDR_support into main 2023-08-09 14:25:23 +02:00
2 changed files with 13 additions and 11 deletions
Showing only changes of commit 9cfe3fd876 - Show all commits

View File

@ -92,10 +92,11 @@ GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual,
m_metalLayer.allowsNextDrawableTimeout = NO;
if (m_useMetalForRendering) {
// Enable EDR support. This is done by:
// 1. Using a floating point render target, so that values ouside 0..1 can be used
// 2. Informing the OS that we are EDR aware, and intend to use values outside 0..1
// 3. Setting the extended sRGB color space so that the OS knows how to interpret the values
/* Enable EDR support. This is done by:
* 1. Using a floating point render target, so that values ouside 0..1 can be used
* 2. Informing the OS that we are EDR aware, and intend to use values outside 0..1
* 3. Setting the extended sRGB color space so that the OS knows how to interpret the
* values. */
m_metalLayer.wantsExtendedDynamicRangeContent = YES;
m_metalLayer.pixelFormat = MTLPixelFormatRGBA16Float;
const CFStringRef name = kCGColorSpaceExtendedSRGB;
@ -607,8 +608,8 @@ void GHOST_ContextCGL::metalInit()
/* Ensure library is released. */
[library autorelease];
MTLPixelFormat attachmentFormat = m_useMetalForRendering ?
METAL_FRAMEBUFFERPIXEL_FORMAT_EDR : METAL_FRAMEBUFFERPIXEL_FORMAT_SDR;
MTLPixelFormat attachmentFormat = m_useMetalForRendering ? METAL_FRAMEBUFFERPIXEL_FORMAT_EDR :
METAL_FRAMEBUFFERPIXEL_FORMAT_SDR;
[desc.colorAttachments objectAtIndexedSubscript:0].pixelFormat = attachmentFormat;
m_metalRenderPipeline = (MTLRenderPipelineState *)[device

View File

@ -343,12 +343,13 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
[m_metalLayer setPresentsWithTransaction:NO];
[m_metalLayer removeAllAnimations];
[m_metalLayer setDevice:metalDevice];
if (type == GHOST_kDrawingContextTypeMetal) {
// Enable EDR support. This is done by:
// 1. Using a floating point render target, so that values ouside 0..1 can be used
// 2. Informing the OS that we are EDR aware, and intend to use values outside 0..1
// 3. Setting the extended sRGB color space so that the OS knows how to interpret the values
/* Enable EDR support. This is done by:
* 1. Using a floating point render target, so that values ouside 0..1 can be used
* 2. Informing the OS that we are EDR aware, and intend to use values outside 0..1
* 3. Setting the extended sRGB color space so that the OS knows how to interpret the
* values. */
m_metalLayer.wantsExtendedDynamicRangeContent = YES;
m_metalLayer.pixelFormat = MTLPixelFormatRGBA16Float;
const CFStringRef name = kCGColorSpaceExtendedSRGB;