Bug 1784338 - Clamp webgl.blendColor in no-ext webgl1. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D215672
This commit is contained in:
Kelsey Gilbert
2024-07-03 20:25:23 +00:00
parent 0e5a53528d
commit 800ebc4c42
3 changed files with 11 additions and 5 deletions

View File

@@ -2904,6 +2904,17 @@ void ClientWebGLContext::BlendColor(GLclampf r, GLclampf g, GLclampf b,
if (IsContextLost()) return;
auto& state = State();
const bool unclamped =
(mIsWebGL2 ||
IsExtensionEnabled(WebGLExtensionID::WEBGL_color_buffer_float) ||
IsExtensionEnabled(WebGLExtensionID::EXT_color_buffer_half_float));
if (!unclamped) {
r = std::clamp(r, 0.0f, 1.0f);
g = std::clamp(g, 0.0f, 1.0f);
b = std::clamp(b, 0.0f, 1.0f);
a = std::clamp(a, 0.0f, 1.0f);
}
auto& cache = state.mBlendColor;
cache[0] = r;
cache[1] = g;