Repository navigation
Conversation
Chromium's validating command decoder, which Android WebView still uses, has no case for TEXTURE_MAX_ANISOTROPY_EXT in Sampler::SetParameteri, so glSamplerParameteri fails there with GL_INVALID_ENUM and the sampler keeps an anisotropy of 1. Its Sampler::SetParameterf accepts the parameter. The parameter is float-valued in EXT_texture_filter_anisotropic, and create_sampler already sets the LOD clamps with glSamplerParameterf, so the float entry point is available on every GL path wgpu-hal supports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connections
No wgpu issue. The same Chromium refusal was reported outside wgpu in emscripten-core/emscripten#4514 and KhronosGroup/WebGL#2006 (both 2016).
Description
The GLES backend's
create_samplersetsTEXTURE_MAX_ANISOTROPYwithglSamplerParameteri. Chromium's validating command decoder, which Android WebView still uses, has no case for that pname inSampler::SetParameteri(gpu/command_buffer/service/sampler_manager.cc), so the call fails withGL_INVALID_ENUMand the sampler keeps an anisotropy of 1. ItsSampler::SetParameterfaccepts the pname, as doesTexture::SetParameteri, so only the integer call on a sampler is refused.The
EXT_texture_filter_anisotropicWebGL extension says that in WebGL 2samplerParameterfandsamplerParameteriboth acceptTEXTURE_MAX_ANISOTROPY_EXT, so this is Chromium's bug. The WebGL conformance suite only exercisessamplerParameterfon samplers, which is probably why it has survived since 2016. ANGLE accepts both forms.This sends the value with
glSamplerParameterfinstead. The parameter is float-valued in the extension, andcreate_sampleralready usessampler_parameter_f32forTEXTURE_MIN_LODandTEXTURE_MAX_LOD, so the float entry point is available on every GL path wgpu-hal supports (GLES 3.0, desktop GL, and WebGL 2).On an Android phone's WebView (Chromium 156, Adreno 730), a WebGL 2 context gave:
getError()getSamplerParameterafterwardssamplerParameteri(sampler, TEXTURE_MAX_ANISOTROPY_EXT, 16)INVALID_ENUMsamplerParameteri(sampler, TEXTURE_MAX_ANISOTROPY_EXT, 2)INVALID_ENUMsamplerParameterf(sampler, TEXTURE_MAX_ANISOTROPY_EXT, 16)NO_ERRORtexParameteri(TEXTURE_2D, TEXTURE_MAX_ANISOTROPY_EXT, 16)NO_ERRORIn a wgpu app on the same phone, every sampler created with
anisotropy_clamp: 16logged that error and read back 1. With those calls rewritten tosamplerParameterf, which is what this change sends, there were no errors and every sampler read back 16.Testing
SAMPLER_ANISOTROPY, which creates samplers with anisotropy clamps 2, 4, 8, and 16 on adapters that reportDownlevelFlags::ANISOTROPIC_FILTERING. No existing test reached this branch ofcreate_sampler. On native GL, an error from the call reaches the validation canary and fails the test.getError(). Only Chromium's validating decoder refuses the integer call.GL_INVALID_VALUE. The test then failed on GL llvmpipe with Mesa'sGL_INVALID_VALUE in glSamplerParameterf(param=0.500000)and still passed on Vulkan.cargo xtask testpassed all 1,651 tests.bind_group_with_max_binding_indexran by itself on both adapters, because on GL llvmpipe it needs more memory than this machine's cap allows alongside other tests.cargo fmt --check,cargo clippy --all-targets --all-features,cargo clippy --target wasm32-unknown-unknown --tests --all-features, andcargo test -p wgpu-halalso passed.Squash or Rebase?
Squash. The second commit only fills in the changelog entry's link to this PR.
LLM Use?
An agent (Claude Code) traced the fault on the phone, wrote the change and the test, ran the checks above, and wrote this description. I reviewed the change before opening this PR.
Checklist
CHANGELOG.mdentries for the user-facing effects of this change are present.wgpumay be affected behaviorally.🤖 Generated (in part) with Claude Code