diff --git a/shell/mac/AppDelegate.mm b/shell/mac/AppDelegate.mm index 16a3fb129b..b32def4347 100644 --- a/shell/mac/AppDelegate.mm +++ b/shell/mac/AppDelegate.mm @@ -109,6 +109,7 @@ - (void)setupViewController { .majorVersion = 3, .minorVersion = 0}, .swapchainColorTextureFormat = kColorFramebufferFormat, + .depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm, }, #endif #if IGL_BACKEND_OPENGL @@ -118,6 +119,7 @@ - (void)setupViewController { .majorVersion = 4, .minorVersion = 1}, .swapchainColorTextureFormat = kColorFramebufferFormat, + .depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm, }, // clang-format off // @fb-only diff --git a/shell/mac/ViewController.mm b/shell/mac/ViewController.mm index 4681ff7980..a21f7b9c07 100644 --- a/shell/mac/ViewController.mm +++ b/shell/mac/ViewController.mm @@ -196,6 +196,10 @@ - (void)loadView { #if IGL_BACKEND_OPENGL case igl::BackendFlavor::OpenGL: { + const bool enableStencilBuffer = config_.depthTextureFormat == igl::TextureFormat::S8_UInt_Z24_UNorm || + config_.depthTextureFormat == igl::TextureFormat::S_UInt8; + const NSOpenGLPixelFormatAttribute stencilSize = enableStencilBuffer ? 8 : 0; + NSOpenGLPixelFormat* pixelFormat; if (config_.backendVersion.majorVersion == 4 && config_.backendVersion.minorVersion == 1) { static NSOpenGLPixelFormatAttribute attributes[] = { @@ -211,6 +215,8 @@ - (void)loadView { 32, NSOpenGLPFADepthSize, 24, + NSOpenGLPFAStencilSize, + stencilSize, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core, 0, @@ -232,6 +238,8 @@ - (void)loadView { 32, NSOpenGLPFADepthSize, 24, + NSOpenGLPFAStencilSize, + stencilSize, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, 0, @@ -252,6 +260,8 @@ - (void)loadView { 32, NSOpenGLPFADepthSize, 24, + NSOpenGLPFAStencilSize, + stencilSize, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy, 0,