-
Notifications
You must be signed in to change notification settings - Fork 173
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
【igl nanovg part-1】shell | mac | add stencil buffer #216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it configurable, with the default setting matching the previous behavior. No stencil buffer should be enabled by default unless requested explicitly.
done |
shell/mac/ViewController.mm
Outdated
@@ -196,6 +196,10 @@ - (void)loadView { | |||
|
|||
#if IGL_BACKEND_OPENGL | |||
case igl::BackendFlavor::OpenGL: { | |||
bool enableStencilBuffer = config_.depthTextureFormat == igl::TextureFormat::S8_UInt_Z24_UNorm || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default behavior should be to keep the stencil buffer disabled.
@@ -109,6 +109,7 @@ - (void)setupViewController { | |||
.majorVersion = 3, | |||
.minorVersion = 0}, | |||
.swapchainColorTextureFormat = kColorFramebufferFormat, | |||
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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. |
@@ -16,7 +16,6 @@ struct RenderSessionConfig { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mixing changes to the mac shell with changes to the iOS shell.
shell/ios/AppDelegate.mm
Outdated
@@ -42,7 +42,6 @@ - (BOOL)application:(UIApplication*)application | |||
.majorVersion = 3, | |||
.minorVersion = 0}, | |||
.swapchainColorTextureFormat = igl::TextureFormat::BGRA_SRGB, | |||
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z32_UNorm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a good change. What compilation failure is this fixing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved the depthTextureFormat field from RenderSessionConfig to RenderSession, so the above code must be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to achieve your goal (adding NanoVG) with minimal changes to the current main
branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make the minimal changes as much as possible.
@@ -45,6 +49,10 @@ class RenderSession { | |||
void setCurrentQuadLayer(size_t layer) noexcept { | |||
currentQuadLayer_ = layer; | |||
} | |||
|
|||
[[nodiscard]] igl::TextureFormat getDepthTextureFormat() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -109,6 +109,7 @@ - (void)setupViewController { | |||
.majorVersion = 3, | |||
.minorVersion = 0}, | |||
.swapchainColorTextureFormat = kColorFramebufferFormat, | |||
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm, |
There was a problem hiding this comment.
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.
@@ -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 || |
There was a problem hiding this comment.
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.
Ok, I'm landing the |
@corporateshark merged this pull request in 88143c1. |
This is a prerequisite pull request for igl nanovg(#213).