From 943d76fa91fd868e87fae584343661bf9efcc751 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 8 Apr 2022 22:55:27 +0200 Subject: [PATCH] No issue - Avoid WebGL crash on Mesa This prevents too high vert-count draws that Mesa doesn't handle. --- dom/canvas/WebGLContextDraw.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom/canvas/WebGLContextDraw.cpp b/dom/canvas/WebGLContextDraw.cpp index 8e437a07f3..def5fb0ef3 100644 --- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -1066,6 +1066,15 @@ WebGLContext::DoFakeVertexAttrib0(const char* funcName, GLuint vertexCount) vertexCount = 1; } + if (gl->WorkAroundDriverBugs() && gl->IsMesa()) { + // Padded/strided to vec4, so 4x4bytes. + const auto effectiveVertAttribBytes = CheckedInt(vertexCount) * 4 * 4; + if (!effectiveVertAttribBytes.isValid()) { + ErrorOutOfMemory("`offset + count` too large for Mesa."); + return false; + } + } + const auto whatDoesAttrib0Need = WhatDoesVertexAttrib0Need(); if (MOZ_LIKELY(whatDoesAttrib0Need == WebGLVertexAttrib0Status::Default)) return true;