[Impeller] Add validation forbidding SamplerAddressMode::kDecal on the OpenGLES backend (flutter/engine#43094)

Fixes uncontrolled crash when kDecal is used (as seen on
https://github.com/flutter/engine/pull/43087).
This commit is contained in:
Brandon DeRosier
2023-06-22 11:35:15 -07:00
committed by GitHub
parent baef7fd849
commit 034f5e4edf
2 changed files with 14 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ ContextGLES::ContextGLES(std::unique_ptr<ProcTableGLES> gl,
.SetSupportsComputeSubgroups(false)
.SetSupportsReadFromResolve(false)
.SetSupportsReadFromOnscreenTexture(false)
.SetSupportsDecalTileMode(false)
.Build();
}

View File

@@ -5,6 +5,8 @@
#include "impeller/renderer/backend/gles/sampler_library_gles.h"
#include "impeller/base/config.h"
#include "impeller/base/validation.h"
#include "impeller/core/formats.h"
#include "impeller/renderer/backend/gles/sampler_gles.h"
namespace impeller {
@@ -17,6 +19,17 @@ SamplerLibraryGLES::~SamplerLibraryGLES() = default;
// |SamplerLibrary|
std::shared_ptr<const Sampler> SamplerLibraryGLES::GetSampler(
SamplerDescriptor descriptor) {
// TODO(bdero): Change this validation once optional support for kDecal is
// added to the OpenGLES backend:
// https://github.com/flutter/flutter/issues/129358
if (descriptor.width_address_mode == SamplerAddressMode::kDecal ||
descriptor.height_address_mode == SamplerAddressMode::kDecal ||
descriptor.depth_address_mode == SamplerAddressMode::kDecal) {
VALIDATION_LOG << "SamplerAddressMode::kDecal is not supported by the "
"OpenGLES backend.";
return nullptr;
}
auto found = samplers_.find(descriptor);
if (found != samplers_.end()) {
return found->second;