Skip to content

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

Closed
vinsentli wants to merge 9 commits into
facebook:mainfrom
vinsentli:igl_nanovg_part1_mac_add_stencil_buffer
Closed

【igl nanovg part-1】shell | mac | add stencil buffer#216
vinsentli wants to merge 9 commits into
facebook:mainfrom
vinsentli:igl_nanovg_part1_mac_add_stencil_buffer

Conversation

@vinsentli

Copy link
Copy Markdown
Contributor

This is a prerequisite pull request for igl nanovg(#213).

@vinsentli vinsentli changed the title shell | mac | add stencil buffer Nov 26, 2024

@corporateshark corporateshark left a comment

Copy link
Copy Markdown
Contributor

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.

@vinsentli

Copy link
Copy Markdown
Contributor Author

Please make it configurable, with the default setting matching the previous behavior. No stencil buffer should be enabled by default unless requested explicitly.

done

Comment thread shell/mac/ViewController.mm Outdated

#if IGL_BACKEND_OPENGL
case igl::BackendFlavor::OpenGL: {
bool enableStencilBuffer = config_.depthTextureFormat == igl::TextureFormat::S8_UInt_Z24_UNorm ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

const

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@corporateshark corporateshark left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread shell/mac/AppDelegate.mm
.majorVersion = 3,
.minorVersion = 0},
.swapchainColorTextureFormat = kColorFramebufferFormat,
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm,

Copy link
Copy Markdown
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
Copy Markdown
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.

@vinsentli

Copy link
Copy Markdown
Contributor Author

I have moved the depth texture format configuration into RenderSession.
And iOS has create a new PR #221 base on this PR.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@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;

Copy link
Copy Markdown
Contributor

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?

@vinsentli vinsentli Dec 3, 2024

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@corporateshark corporateshark left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread shell/ios/AppDelegate.mm
.majorVersion = 3,
.minorVersion = 0},
.swapchainColorTextureFormat = igl::TextureFormat::BGRA_SRGB,
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z32_UNorm,

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

currentQuadLayer_ = layer;
}

[[nodiscard]] igl::TextureFormat getDepthTextureFormat() const {

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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.

@vinsentli vinsentli Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

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?

@vinsentli

vinsentli commented Dec 10, 2024

Copy link
Copy Markdown
Contributor Author

This is the minimal changes.
iOS is currently appropriate, and no further modifications are needed.

I made modifications to depthTextureFormat in mac/AppDelegate.mm. If you think this is not appropriate, I can revert those changes.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment thread shell/mac/AppDelegate.mm
.majorVersion = 3,
.minorVersion = 0},
.swapchainColorTextureFormat = kColorFramebufferFormat,
.depthTextureFormat = igl::TextureFormat::S8_UInt_Z24_UNorm,

Copy link
Copy Markdown
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.


#if IGL_BACKEND_OPENGL
case igl::BackendFlavor::OpenGL: {
const bool enableStencilBuffer = config_.depthTextureFormat == igl::TextureFormat::S8_UInt_Z24_UNorm ||

Copy link
Copy Markdown
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.

@corporateshark

Copy link
Copy Markdown
Contributor

Ok, I'm landing the shell/mac/ViewController.mm part of this PR. The AppDelegate.mm part should be reimplemented to keep the existing default depth format.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark merged this pull request in 88143c1.

@vinsentli vinsentli deleted the igl_nanovg_part1_mac_add_stencil_buffer branch December 18, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants