【igl nanovg part-1】shell | mac | add stencil buffer#216
Conversation
corporateshark
left a comment
There was a problem hiding this comment.
Please make it configurable, with the default setting matching the previous behavior. No stencil buffer should be enabled by default unless requested explicitly.
done |
|
|
||
| #if IGL_BACKEND_OPENGL | ||
| case igl::BackendFlavor::OpenGL: { | ||
| bool enableStencilBuffer = config_.depthTextureFormat == igl::TextureFormat::S8_UInt_Z24_UNorm || |
corporateshark
left a comment
There was a problem hiding this comment.
The default behavior should be to keep the stencil buffer disabled.
| .majorVersion = 3, | ||
| .minorVersion = 0}, | ||
| .swapchainColorTextureFormat = kColorFramebufferFormat, | ||
| .depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm, |
There was a problem hiding this comment.
This should not ne changed for all apps. Only apps using NanoVG would want to enable the stencil buffer.
There was a problem hiding this comment.
This line still stands. We should not enable the stencil buffer unconditionally for all apps.
|
I have moved the depth texture format configuration into RenderSession. |
|
@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
| std::string displayName; | ||
| BackendVersion backendVersion; | ||
| igl::TextureFormat swapchainColorTextureFormat = igl::TextureFormat::BGRA_UNorm8; | ||
| igl::TextureFormat depthTextureFormat = igl::TextureFormat::Z_UNorm16; |
There was a problem hiding this comment.
There's a lot of our internal code that relies on this field. Is it possible to add stencil buffer support without getting rid of it?
There was a problem hiding this comment.
The field depthTextureFormat is add by me in this commit.49d674c
This PR revert the commit before, add move the depthTextureFormat field into RenderSession.
There was a problem hiding this comment.
The field depthTextureFormat is add by me in this commit.49d674c
I looked into it, the tests do not pass because the file shell/ios/ViewController.mm needs to be updated as well. It still uses depthTextureFormat.
There was a problem hiding this comment.
I have fixed iOS compile error.
The complete adaptation of the iOS stencil buffer is another PR(#221).
It should be merged with the latest main branch and reviewed after this PR is approved.
|
@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
corporateshark
left a comment
There was a problem hiding this comment.
This is mixing changes to the mac shell with changes to the iOS shell.
| .majorVersion = 3, | ||
| .minorVersion = 0}, | ||
| .swapchainColorTextureFormat = igl::TextureFormat::BGRA_SRGB, | ||
| .depthTextureFormat = igl::TextureFormat::S8_UInt_Z32_UNorm, |
There was a problem hiding this comment.
This was a good change. What compilation failure is this fixing?
There was a problem hiding this comment.
I have moved the depthTextureFormat field from RenderSessionConfig to RenderSession, so the above code must be removed.
There was a problem hiding this comment.
Is it possible to achieve your goal (adding NanoVG) with minimal changes to the current main branch?
There was a problem hiding this comment.
I will make the minimal changes as much as possible.
| currentQuadLayer_ = layer; | ||
| } | ||
|
|
||
| [[nodiscard]] igl::TextureFormat getDepthTextureFormat() const { |
There was a problem hiding this comment.
What's the reason for this addition? The point of suggested+requested configs is to let a particular session choose the formats it wants without needing to create some kind of dummy session without a platform.
There was a problem hiding this comment.
You want the stencil buffer to be disabled by default. So, I can only move the depthTextureFormat field from RenderSessionConfig to RenderSession, and then NanovgRenderSession can override the default depthTextureFormat.
There was a problem hiding this comment.
Anything already merged into main is fine. For any further changes, aim to make only the minimal changes necessary. Please update your diffs to minimize the modifications required to add NanoVG.
There was a problem hiding this comment.
The minimal way to make the changes is to keep the depthTextureFormat field in RenderSessionConfig.
If I want to show the NanoVG session and make changes to depthTextureFormat locally, and avoid committing it to the main branch.
I can add comments in NanovgSession to explain that other developers can make such changes if they want to show the effect.
This approach is also well-suited for Android, because without it, the changes required for Android would be significant as well.
What do you think about this approach?
|
This is the minimal changes. I made modifications to depthTextureFormat in mac/AppDelegate.mm. If you think this is not appropriate, I can revert those changes. |
|
@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
| .majorVersion = 3, | ||
| .minorVersion = 0}, | ||
| .swapchainColorTextureFormat = kColorFramebufferFormat, | ||
| .depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm, |
There was a problem hiding this comment.
This line still stands. We should not enable the stencil buffer unconditionally for all apps.
|
|
||
| #if IGL_BACKEND_OPENGL | ||
| case igl::BackendFlavor::OpenGL: { | ||
| const bool enableStencilBuffer = config_.depthTextureFormat == igl::TextureFormat::S8_UInt_Z24_UNorm || |
There was a problem hiding this comment.
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.
|
Ok, I'm landing the |
|
@corporateshark merged this pull request in 88143c1. |
This is a prerequisite pull request for igl nanovg(#213).