Skip to content

Commit 6ed3be9

Browse files
authored
[Impeller] Cache GLES sampler configuration in RenderPassStateCache (flutter#193922)
### Rationale Split out from flutter#193427 per @gaaclarke's review feedback. OpenGL ES does not expose standalone sampler objects on the paths used by `SamplerGLES`; instead, `SamplerGLES::ConfigureBoundTexture` emits up to 5 `glTexParameteri` calls (`GL_TEXTURE_MIN_FILTER`, `GL_TEXTURE_MAG_FILTER`, `GL_TEXTURE_MAX_LEVEL`, `GL_TEXTURE_WRAP_S`, `GL_TEXTURE_WRAP_T`) plus optional `GL_TEXTURE_MAX_ANISOTROPY_EXT` on the bound GL texture object every time a texture is bound for a draw call. On glyph-atlas-heavy and tiled scenes (`bouncy@128`, `grid@1000`), hundreds or thousands of consecutive draw calls sample the same texture with an identical `SamplerDescriptor`, issuing up to `12,258` redundant `glTexParameteri`/`glTexParameterf` calls per frame after flutter#193427. Within a render pass, non-wrapped `TextureGLES` instances own an immutable `UniqueHandleGLES` (`HandleGLES`) and immutable `TextureDescriptor` / `mip_count`. Caching the last configured `SamplerDescriptor::ToKey` per `HandleGLES` in `SamplerStateCache` inside `RenderPassStateCache` (alongside `BlendStateCache`, `StencilStateCache`, and `DepthStateCache`) skips redundant `glTexParameter*` calls across draws and pipelines within the pass without storing mutable cached state on `TextureGLES`. ### Summary of Changes - [`engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h`](https://github.com/kevmoo/flutter/blob/f9f4ba51255/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h): Add a read-only `const HandleGLES& GetHandle() const` accessor matching `PipelineGLES::GetProgramHandle()`. - [`engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.h`](https://github.com/kevmoo/flutter/blob/f9f4ba51255/engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.h) & [`engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.cc`](https://github.com/kevmoo/flutter/blob/f9f4ba51255/engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.cc): Add `struct SamplerStateCache` (`absl::flat_hash_map<HandleGLES, uint64_t, HandleGLES::Hash, HandleGLES::Equal> configured_samplers;` + `ConfigureBoundTexture(...)`) and pass an optional `SamplerStateCache*` into `BufferBindingsGLES::BindUniformData` and `BufferBindingsGLES::BindTextures`. Wrapped external textures (`IsWrapped()`) bypass the cache so external callers mutating raw GL texture parameters are unaffected. - [`engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc`](https://github.com/kevmoo/flutter/blob/f9f4ba51255/engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc): Add `SamplerStateCache sampler;` to `RenderPassStateCache` and pass `&state_cache.sampler` into `vertex_desc_gles->BindUniformData(...)`. - [`engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles_unittests.cc`](https://github.com/kevmoo/flutter/blob/f9f4ba51255/engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles_unittests.cc): Add `BufferBindingsGLESTest.SkipsRedundantSamplerConfigurationOnSameTexture` covering repeated binds with an identical sampler descriptor, re-configuration when the sampler descriptor changes, cross-pipeline deduplication/invalidation via a shared `SamplerStateCache`, and cache bypass for wrapped external textures (`TextureGLES::WrapTexture`). ### Flow / Surface Delta #### 1. Deterministic WebGL2 Call-Count Reductions (`0%` Variance) Measured on top of merged flutter#193427 (`origin/master` @ `a554b8ac180` vs. `daad7727f54` across steady-state frames): | Workload (`1280x720`, `wimp_st`) | Metric | Pre-Change (post-`flutter#193427`) | Post-Change | Absolute Delta | Delta (%) | Reduction | | :--- | :--- | :---: | :---: | :---: | :---: | :--- | | **`bouncy` (`128` nodes, `441` draws, `247` textured)** | `glTexParameteri` + `glTexParameterf` / frame | `1,482` (`1,235` + `247`) | `~6` (`1` per pass) | `-1,476` | **`-99.6%`** | **Deduplicated per pass** | | | Total GL calls / frame | `7,827` | `6,336` | `-1,491` | **`-19.0%`** | **`1.24x` fewer calls** (`-52.2%` / `2.09x` cumulative w/ `flutter#193427`) | | **`grid` (`100` nodes, `660` draws, `245` textured)** | `glTexParameteri` + `glTexParameterf` / frame | `1,470` (`1,225` + `245`) | `~6` (`1` per pass) | `-1,464` | **`-99.6%`** | **Deduplicated per pass** | | | Total GL calls / frame | `10,674` | `9,213` | `-1,461` | **`-13.7%`** | **`1.16x` fewer calls** | | **`grid` (`1000` nodes, `5,908` draws, `2,043` textured)** | `glTexParameteri` + `glTexParameterf` / frame | `12,258` (`10,215` + `2,043`) | `~6` (`1` per pass) | `-12,252` | **`-99.95%`** | **Deduplicated per pass** | | | Total GL calls / frame | `93,669` | `81,285` | `-12,384` | **`-13.2%`** | **`1.15x` fewer calls** (`-47.4%` / `1.90x` cumulative w/ `flutter#193427`) | In `100us` V8/Wasm CPU profiling of the `DedicatedWorker` raster thread on `grid@1000` (`--profile --no-strip-wasm`), redundant `glTexParameteri` (`9.75 ms` Wasm self-time + `19.76 ms` JS binding) and `glTexParameterf` (`12.80 ms` JS binding) accounted for **`42.31 ms` (`2.09%` of total active worker CPU time)** across a `2.02s` steady-state window. #### 2. Hardware WebGL2 `rasterTimeMs` A/B (`AMD Radeon 780M`, `n=5` Interleaved ABBA Pairs) Measured on headed Chrome 154 (`ANGLE (AMD, AMD Radeon 780M Graphics (radeonsi phoenix ACO), OpenGL ES 3.2)`, `--disable-gpu-vsync --disable-frame-rate-limit`, `10` samples/run × `5` interleaved ABBA pairs per arm): | Workload (`1280x720`, `wimp_st`) | Pre-Change (`a554b8ac180`) | Post-Change (`daad7727f54`) | Absolute Delta | Delta (%) | Speedup | | :--- | :---: | :---: | :---: | :---: | :---: | | **`bouncy` (`64` nodes)** | `1.412 ms` | `1.382 ms` | `-0.030 ms` | `-2.15%` | `1.02x` | | **`bouncy` (`128` nodes)** | `1.842 ms` | `1.756 ms` | `-0.086 ms` | **`-4.66%`** | **`1.05x`** | | **`grid` (`100` nodes)** | `1.783 ms` | `1.727 ms` | `-0.057 ms` | **`-3.17%`** | **`1.03x`** | | **`grid` (`1000` nodes)** | `16.385 ms` | `15.996 ms` | `-0.389 ms` | **`-2.37%`** | **`1.02x`** | **How much to trust these numbers:** - **Call counts (Table 1) are exact (`0%` run-to-run variance)**: Every frame deterministically eliminates `1,464`–`12,252` redundant `glTexParameter*` calls across the boundary. - **Wall-clock `rasterTimeMs` (Table 2) has a `~1.2%–2.0%` run-to-run noise floor**: - **`bouncy@128` (`-4.66%`)** and **`grid@100` (`-3.17%`)** clear the noise floor consistently (`5/5` interleaved Post runs beat Pre). - **`grid@1000` (`-2.37%`, `-0.39 ms`)** sits just above the `~1.5%–2.0%` noise floor (`4/5` pairs faster) and aligns with the `2.09%` worker CPU profile share of `glTexParameter*` when `5,908` draw calls dominate frame time. - **`bouncy@64` (`-2.15%`, `-0.03 ms`)** is inside the noise floor at `<1.5 ms` frame times and should be treated as flat/within noise. ### Verification - Built and ran `host_debug_unopt:impeller_unittests --gtest_filter="*BufferBindingsGLES*:*RenderPassGLES*:*SamplerGLES*:*TextureGLES*"` locally (`37/37` passed, including `BufferBindingsGLESTest.SkipsRedundantSamplerConfigurationOnSameTexture`). - Built `wasm_release:skwasm/wimp.js` and verified both deterministic WebGL2 call counts and `n=5` interleaved hardware WebGL2 `rasterTimeMs` medians (`AMD Radeon 780M`) in Chrome 154 via `flutter-wasm-compare`. Related to flutter#192147 Towards flutter#174980 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 099a0b8 commit 6ed3be9

5 files changed

Lines changed: 156 additions & 8 deletions

File tree

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.cc‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,24 +262,46 @@ bool BufferBindingsGLES::BindVertexAttributes(const ProcTableGLES& gl,
262262
return true;
263263
}
264264

265+
bool SamplerStateCache::ConfigureBoundTexture(const SamplerGLES& sampler,
266+
const TextureGLES& texture,
267+
const ProcTableGLES& gl) {
268+
if (texture.IsWrapped()) {
269+
return sampler.ConfigureBoundTexture(texture, gl);
270+
}
271+
const uint64_t sampler_key =
272+
SamplerDescriptor::ToKey(sampler.GetDescriptor());
273+
const HandleGLES& handle = texture.GetHandle();
274+
auto it = configured_samplers_.find(handle);
275+
if (it != configured_samplers_.end() && it->second == sampler_key) {
276+
return true;
277+
}
278+
if (!sampler.ConfigureBoundTexture(texture, gl)) {
279+
return false;
280+
}
281+
configured_samplers_[handle] = sampler_key;
282+
return true;
283+
}
284+
265285
bool BufferBindingsGLES::BindUniformData(
266286
const ProcTableGLES& gl,
267287
const std::vector<TextureAndSampler>& bound_textures,
268288
const std::vector<BufferResource>& bound_buffers,
269289
Range texture_range,
270-
Range buffer_range) {
290+
Range buffer_range,
291+
SamplerStateCache* sampler_cache) {
271292
for (auto i = 0u; i < buffer_range.length; i++) {
272293
if (!BindUniformBuffer(gl, bound_buffers[buffer_range.offset + i])) {
273294
return false;
274295
}
275296
}
276297
std::optional<size_t> next_unit_index =
277-
BindTextures(gl, bound_textures, texture_range, ShaderStage::kVertex);
298+
BindTextures(gl, bound_textures, texture_range, ShaderStage::kVertex,
299+
/*unit_start_index=*/0, sampler_cache);
278300
if (!next_unit_index.has_value()) {
279301
return false;
280302
}
281303
if (!BindTextures(gl, bound_textures, texture_range, ShaderStage::kFragment,
282-
*next_unit_index)
304+
*next_unit_index, sampler_cache)
283305
.has_value()) {
284306
return false;
285307
}
@@ -491,7 +513,8 @@ std::optional<size_t> BufferBindingsGLES::BindTextures(
491513
const std::vector<TextureAndSampler>& bound_textures,
492514
Range texture_range,
493515
ShaderStage stage,
494-
size_t unit_start_index) {
516+
size_t unit_start_index,
517+
SamplerStateCache* sampler_cache) {
495518
size_t active_index = unit_start_index;
496519
size_t stage_texture_count = 0;
497520
for (auto i = 0u; i < texture_range.length; i++) {
@@ -549,7 +572,12 @@ std::optional<size_t> BufferBindingsGLES::BindTextures(
549572
/// bound texture using that sampler.
550573
///
551574
const auto& sampler_gles = SamplerGLES::Cast(*data.sampler);
552-
if (!sampler_gles.ConfigureBoundTexture(texture_gles, gl)) {
575+
const bool configured =
576+
sampler_cache != nullptr
577+
? sampler_cache->ConfigureBoundTexture(sampler_gles, texture_gles,
578+
gl)
579+
: sampler_gles.ConfigureBoundTexture(texture_gles, gl);
580+
if (!configured) {
553581
return std::nullopt;
554582
}
555583

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.h‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
#include "impeller/core/shader_types.h"
1111
#include "impeller/renderer/backend/gles/device_buffer_gles.h"
1212
#include "impeller/renderer/backend/gles/gles.h"
13+
#include "impeller/renderer/backend/gles/handle_gles.h"
1314
#include "impeller/renderer/backend/gles/proc_table_gles.h"
15+
#include "impeller/renderer/backend/gles/sampler_gles.h"
16+
#include "impeller/renderer/backend/gles/texture_gles.h"
1417
#include "impeller/renderer/command.h"
1518
#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
1619

@@ -25,8 +28,33 @@ FML_TEST_CLASS(BufferBindingsGLESTest,
2528
BindsTexturesAcrossThePerStageUnitBoundary);
2629
FML_TEST_CLASS(BufferBindingsGLESTest, RejectsTexturesBeyondThePerStageLimit);
2730
FML_TEST_CLASS(BufferBindingsGLESTest, RejectsTexturesBeyondTheCombinedLimit);
31+
FML_TEST_CLASS(BufferBindingsGLESTest,
32+
SkipsRedundantSamplerConfigurationOnSameTexture);
2833
} // namespace testing
2934

35+
//------------------------------------------------------------------------------
36+
/// @brief Caches the sampler configuration state applied to GL texture
37+
/// objects during a render pass.
38+
///
39+
class SamplerStateCache {
40+
public:
41+
SamplerStateCache() = default;
42+
43+
~SamplerStateCache() = default;
44+
45+
bool ConfigureBoundTexture(const SamplerGLES& sampler,
46+
const TextureGLES& texture,
47+
const ProcTableGLES& gl);
48+
49+
private:
50+
absl::flat_hash_map<HandleGLES, uint64_t, HandleGLES::Hash, HandleGLES::Equal>
51+
configured_samplers_;
52+
53+
SamplerStateCache(const SamplerStateCache&) = delete;
54+
55+
SamplerStateCache& operator=(const SamplerStateCache&) = delete;
56+
};
57+
3058
//------------------------------------------------------------------------------
3159
/// @brief Sets up stage bindings for single draw call in the OpenGLES
3260
/// backend.
@@ -59,7 +87,8 @@ class BufferBindingsGLES {
5987
const std::vector<TextureAndSampler>& bound_textures,
6088
const std::vector<BufferResource>& bound_buffers,
6189
Range texture_range,
62-
Range buffer_range);
90+
Range buffer_range,
91+
SamplerStateCache* sampler_cache = nullptr);
6392

6493
bool UnbindVertexAttributes(const ProcTableGLES& gl);
6594

@@ -76,6 +105,8 @@ class BufferBindingsGLES {
76105
RejectsTexturesBeyondThePerStageLimit);
77106
FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
78107
RejectsTexturesBeyondTheCombinedLimit);
108+
FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
109+
SkipsRedundantSamplerConfigurationOnSameTexture);
79110
//----------------------------------------------------------------------------
80111
/// @brief The arguments to glVertexAttribPointer.
81112
///
@@ -131,7 +162,8 @@ class BufferBindingsGLES {
131162
const std::vector<TextureAndSampler>& bound_textures,
132163
Range texture_range,
133164
ShaderStage stage,
134-
size_t unit_start_index = 0);
165+
size_t unit_start_index = 0,
166+
SamplerStateCache* sampler_cache = nullptr);
135167

136168
BufferBindingsGLES(const BufferBindingsGLES&) = delete;
137169

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles_unittests.cc‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,5 +500,88 @@ TEST(BufferBindingsGLESTest, RejectsTexturesBeyondTheCombinedLimit) {
500500
Range{0, fixture.bound_textures.size()}, Range{0, 0}));
501501
}
502502

503+
TEST(BufferBindingsGLESTest, SkipsRedundantSamplerConfigurationOnSameTexture) {
504+
auto impl = MakeSixteenUnitMockImpl();
505+
auto* raw_impl = impl.get();
506+
std::shared_ptr<MockGLES> mock_gl = MockGLES::Init(std::move(impl));
507+
BoundTexturesFixture fixture(
508+
std::make_unique<ProcTableGLES>(kMockResolverGLES));
509+
fixture.AddTextures(ShaderStage::kFragment, 1);
510+
ASSERT_TRUE(fixture.reactor->React());
511+
512+
BufferBindingsGLES bindings;
513+
bindings.SetUniformBindings(fixture.uniform_bindings);
514+
BufferBindingsGLES other_bindings;
515+
other_bindings.SetUniformBindings(std::move(fixture.uniform_bindings));
516+
std::vector<BufferResource> bound_buffers;
517+
SamplerStateCache sampler_cache;
518+
519+
auto expect_sampler_params = [&](int count) {
520+
EXPECT_CALL(*raw_impl,
521+
TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _))
522+
.Times(count);
523+
EXPECT_CALL(*raw_impl,
524+
TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _))
525+
.Times(count);
526+
EXPECT_CALL(*raw_impl,
527+
TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, _))
528+
.Times(count);
529+
EXPECT_CALL(*raw_impl, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _))
530+
.Times(count);
531+
EXPECT_CALL(*raw_impl, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _))
532+
.Times(count);
533+
};
534+
535+
// First bind on ES 3.0 configures all 5 sampler parameters; subsequent binds
536+
// with the same sampler descriptor (including across different
537+
// BufferBindingsGLES instances sharing the pass cache) skip all
538+
// TexParameteri calls.
539+
expect_sampler_params(1);
540+
541+
EXPECT_TRUE(bindings.BindUniformData(
542+
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
543+
Range{0, fixture.bound_textures.size()}, Range{0, 0}, &sampler_cache));
544+
EXPECT_TRUE(bindings.BindUniformData(
545+
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
546+
Range{0, fixture.bound_textures.size()}, Range{0, 0}, &sampler_cache));
547+
EXPECT_TRUE(other_bindings.BindUniformData(
548+
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
549+
Range{0, fixture.bound_textures.size()}, Range{0, 0}, &sampler_cache));
550+
551+
// Changing the sampler descriptor must re-configure the texture once.
552+
SamplerDescriptor linear_desc;
553+
linear_desc.min_filter = MinMagFilter::kLinear;
554+
linear_desc.mag_filter = MinMagFilter::kLinear;
555+
fixture.bound_textures[0].sampler =
556+
fixture.sampler_library->GetSampler(linear_desc);
557+
expect_sampler_params(1);
558+
EXPECT_TRUE(other_bindings.BindUniformData(
559+
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
560+
Range{0, fixture.bound_textures.size()}, Range{0, 0}, &sampler_cache));
561+
562+
// Wrapped external textures must bypass the sampler parameter cache and
563+
// re-emit TexParameteri on every bind (2 consecutive binds with the same
564+
// sampler descriptor configure each parameter twice).
565+
TextureDescriptor wrapped_desc;
566+
wrapped_desc.storage_mode = StorageMode::kDevicePrivate;
567+
wrapped_desc.type = TextureType::kTexture2D;
568+
wrapped_desc.format = PixelFormat::kR8G8B8A8UNormInt;
569+
wrapped_desc.size = {1, 1};
570+
wrapped_desc.mip_count = 1u;
571+
wrapped_desc.usage = TextureUsage::kShaderRead;
572+
auto wrapped_texture = TextureGLES::WrapTexture(
573+
fixture.reactor, wrapped_desc,
574+
fixture.reactor->CreateHandle(HandleType::kTexture, 99u));
575+
fixture.bound_textures[0].texture =
576+
TextureResource(fixture.metadata[0].get(), std::move(wrapped_texture));
577+
expect_sampler_params(2);
578+
EXPECT_TRUE(bindings.BindUniformData(
579+
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
580+
Range{0, fixture.bound_textures.size()}, Range{0, 0}, &sampler_cache));
581+
EXPECT_TRUE(bindings.BindUniformData(
582+
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
583+
Range{0, fixture.bound_textures.size()}, Range{0, 0}, &sampler_cache));
584+
}
585+
503586
} // namespace testing
504587
} // namespace impeller

‎engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ struct RenderPassStateCache {
253253
BlendStateCache blend;
254254
StencilStateCache stencil;
255255
DepthStateCache depth;
256+
SamplerStateCache sampler;
256257
std::optional<HandleGLES> program;
257258
CullMode cull_mode = CullMode::kNone;
258259
WindingOrder winding_order = WindingOrder::kClockwise;
@@ -681,7 +682,8 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
681682
bound_textures, //
682683
bound_buffers, //
683684
/*texture_range=*/command.bound_textures, //
684-
/*buffer_range=*/command.bound_buffers //
685+
/*buffer_range=*/command.bound_buffers, //
686+
&state_cache.sampler //
685687
)) {
686688
return false;
687689
}

‎engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class TextureGLES final : public Texture,
171171
/// false, the FBO must be re-attached before use.
172172
bool CachedFBOMatchesSubresource(uint32_t mip_level, uint32_t slice) const;
173173

174+
/// Retrieve the reactor handle for this texture.
175+
const HandleGLES& GetHandle() const { return handle_.Get(); }
176+
174177
// Visible for testing.
175178
std::optional<HandleGLES> GetSyncFence() const;
176179

0 commit comments

Comments
 (0)