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

Fix WebGL glClear issue. #147

Merged
merged 2 commits into from
Aug 13, 2019
Merged

Fix WebGL glClear issue. #147

merged 2 commits into from
Aug 13, 2019

Conversation

msbaines
Copy link
Contributor

@msbaines msbaines commented Aug 13, 2019

Fixes the following GL_ERROR on WebGL:

glClear: can't be called on integer buffers

The problem is that glClear will clear all glDrawBuffers.

Motivation and Context

Before this change, the main color_attachement was not clearing.

How Has This Been Tested

Tested with work-in-progress embind patch.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Fixes the following GL_ERROR on WebGL:

glClear: can't be called on integer buffers
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Aug 13, 2019
src/esp/gfx/Renderer.cpp Show resolved Hide resolved
@erikwijmans
Copy link
Contributor

In #114 I’m switching to just a clear call as multiple clear calls has a noticeable impact on performance. So I guess we’ll need to ifdef that method?

@msbaines
Copy link
Contributor Author

In #114 I’m switching to just a clear call as multiple clear calls has a noticeable impact on performance. So I guess we’ll need to ifdef that method?

Using glClear to clear an integer buffer may be undefined behavior.

The WebGL implementation in the browser will police input for undefined behavior before calling into the driver. I suspect that is what is causing this error to only happen on WebGL and not when running natively.

The spec doesn't seem to say anything about integer buffers and glClear but it does say the following about glClearBuffer* and integer buffers:

For all forms of ClearBuffer* and ClearNamedFramebuffer*, the result of
these commands is undefined if no conversion between the type of the specified
value and the type of the buffer being cleared is defined (for example, if ClearBufferiv is called for a fixed- or floating-point buffer, or if ClearBufferfv is called
for a signed or unsigned integer buffer). This is not an error

OpenGL 4.6 (Core Profile) - 17.4.3.1 Clearing Individual Buffers https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf

So its not an error but it is undefined. If the performance benefit of a single clear is compelling you could create a driver/hardware whitelist to enable the functionality on driver/hardware combinations that have been verified.

@msbaines msbaines merged commit 02601d4 into master Aug 13, 2019
@msbaines msbaines deleted the clear branch August 13, 2019 17:19
eundersander pushed a commit to eundersander/habitat-sim that referenced this pull request Aug 6, 2020
Ram81 pushed a commit to Ram81/habitat-web-sim that referenced this pull request Dec 10, 2020
* Fix WebGL glClear issue.

Fixes the following GL_ERROR on WebGL:

glClear: can't be called on integer buffers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants