Skip to content

Commit

Permalink
Make sure a texture has mipmaps before setting mipmap states
Browse files Browse the repository at this point in the history
Summary: Ensure we have mipmaps prior to setting a mipmap state.  This is also to potentially catch an error where we're calling sampler mipmap states with an ExternalOES Android sampler, which causes errors on some devices.

Reviewed By: EricGriffith

Differential Revision: D50871654

fbshipit-source-id: 86ceef81cb3a0d9a6c60b4668452118198fd2f5a
  • Loading branch information
Houman Meshkin authored and facebook-github-bot committed Nov 1, 2023
1 parent f52ebe7 commit fef09af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/igl/opengl/SamplerState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ void SamplerState::bind(ITexture* t) {

// See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTexParameter.xml
// for OpenGL version information.
if (deviceFeatures.hasFeature(DeviceFeatures::SamplerMinMaxLod)) {
// Ensure we have mipmaps before setting this state. This should also catch special
// texture types that may not support mipmaps, like ExternalOES textures on Android
if (texture->getNumMipLevels() > 1 &&
deviceFeatures.hasFeature(DeviceFeatures::SamplerMinMaxLod)) {
getContext().texParameteri(target, GL_TEXTURE_MIN_LOD, mipLodMin_);
getContext().texParameteri(target, GL_TEXTURE_MAX_LOD, mipLodMax_);
}
Expand Down

0 comments on commit fef09af

Please sign in to comment.