Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【igl nanovg part-1】shell | mac | add stencil buffer #216

2 changes: 2 additions & 0 deletions shell/mac/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ - (void)setupViewController {
.majorVersion = 3,
.minorVersion = 0},
.swapchainColorTextureFormat = kColorFramebufferFormat,
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not ne changed for all apps. Only apps using NanoVG would want to enable the stencil buffer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line still stands. We should not enable the stencil buffer unconditionally for all apps.

},
#endif
#if IGL_BACKEND_OPENGL
Expand All @@ -118,6 +119,7 @@ - (void)setupViewController {
.majorVersion = 4,
.minorVersion = 1},
.swapchainColorTextureFormat = kColorFramebufferFormat,
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm,
},
// clang-format off
// @fb-only
Expand Down
10 changes: 10 additions & 0 deletions shell/mac/ViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you extract all these changes in shell/mac/ViewController.mm into a separate PR, it will be easier to review and merge because it does not change any existing behaviors.

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[] = {
Expand All @@ -211,6 +215,8 @@ - (void)loadView {
32,
NSOpenGLPFADepthSize,
24,
NSOpenGLPFAStencilSize,
stencilSize,
NSOpenGLPFAOpenGLProfile,
NSOpenGLProfileVersion4_1Core,
0,
Expand All @@ -232,6 +238,8 @@ - (void)loadView {
32,
NSOpenGLPFADepthSize,
24,
NSOpenGLPFAStencilSize,
stencilSize,
NSOpenGLPFAOpenGLProfile,
NSOpenGLProfileVersion3_2Core,
0,
Expand All @@ -252,6 +260,8 @@ - (void)loadView {
32,
NSOpenGLPFADepthSize,
24,
NSOpenGLPFAStencilSize,
stencilSize,
NSOpenGLPFAOpenGLProfile,
NSOpenGLProfileVersionLegacy,
0,
Expand Down
Loading