message: Fix STREAM uniform buffers for web.
diff: @@ -1617,7 +1617,14 @@ void OpenGLDriver::updateBuffer(GLenum target,
  assert(buffer->id);
  bindBuffer(target, buffer->id);
  - if (buffer->usage == driver::BufferUsage::STREAM && HAS_MAPBUFFERS) {
  + if (buffer->usage == driver::BufferUsage::STREAM) {
  +
  + buffer->size = (uint32_t)p.size;
  +
  + // If MapBufferRange is supported, then attempt to use that instead of BufferSubData, which
  + // can be quite inefficient on some platforms. Note that WebGL does not support
  + // MapBufferRange, but we still allow STREAM semantics for the web platform.
  + if (HAS_MAPBUFFERS) {
  uint32_t offset = buffer->base + buffer->size;
  offset = (offset + (alignment - 1u)) & ~(alignment - 1u);
  @@ -1636,7 +1643,9 @@ retry:
  if (vaddr) {
  memcpy(vaddr, p.buffer, p.size);
  if (glUnmapBuffer(target) == GL_FALSE) {
  - // it should be extremely rare, but must be handled
  + // According to the spec, UnmapBuffer can return FALSE in rare conditions (e.g.
  + // during a screen mode change). Note that is not a GL error, and we can handle
  + // it by simply making a second attempt.
  goto retry;
  }
  } else {
  @@ -1644,10 +1653,12 @@ retry:
  glBufferSubData(target, offset, p.size, p.buffer);
  }
  buffer->base = offset;
  - buffer->size = (uint32_t)p.size;
  CHECK_GL_ERROR(utils::slog.e)
  - } else {
  + return;
  + }
  + }
  +
  if (p.size == buffer->capacity) {
  // it looks like it's generally faster (or not worse) to use glBufferData()
  glBufferData(target, buffer->capacity, p.buffer, getBufferUsage(buffer->usage));
  @@ -1659,7 +1670,6 @@ retry:
  CHECK_GL_ERROR(utils::slog.e)
  }
  -}
  void OpenGLDriver::updateSamplerBuffer(Driver::SamplerBufferHandle sbh,
  @@ -2424,6 +2434,7 @@ void OpenGLDriver::bindUniformBufferRange(size_t index, Driver::UniformBufferHan
  DEBUG_MARKER()
  GLUniformBuffer* ub = handle_cast<GLUniformBuffer*>(ubh);
  + // TODO: Is this assert really needed? Note that size is only populated for STREAM buffers.
  assert(size <= ub->gl.ubo.size);
  assert(ub->gl.ubo.base + offset + size <= ub->gl.ubo.capacity);
  bindBufferRange(GL_UNIFORM_BUFFER, GLuint(index), ub->gl.ubo.id, ub->gl.ubo.base + offset, size);
  