Skip to content

Commit 38b6165

Browse files
[Impeller] fix downsample with decal tile mode. (#56316)
Fixes #157956 Fixes #157959 Decal tile mode needs to be emulated on platforms that don't support it.
1 parent baffbc6 commit 38b6165

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

‎impeller/entity/contents/content_context.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ ContentContext::ContentContext(
337337
clip_pipelines_.SetDefault(
338338
options,
339339
std::make_unique<ClipPipeline>(*context_, clip_pipeline_descriptor));
340-
texture_downsample_pipelines_.CreateDefault(*context_,
341-
options_trianglestrip);
340+
texture_downsample_pipelines_.CreateDefault(
341+
*context_, options_trianglestrip, {supports_decal});
342342
rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
343343
texture_strict_src_pipelines_.CreateDefault(*context_, options);
344344
tiled_texture_pipelines_.CreateDefault(*context_, options,

‎impeller/entity/contents/filters/gaussian_blur_filter_contents.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "flutter/fml/make_copyable.h"
1010
#include "impeller/entity/contents/clip_contents.h"
1111
#include "impeller/entity/contents/content_context.h"
12+
#include "impeller/entity/entity.h"
1213
#include "impeller/entity/texture_downsample.frag.h"
1314
#include "impeller/entity/texture_fill.frag.h"
1415
#include "impeller/entity/texture_fill.vert.h"
@@ -406,6 +407,8 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(
406407
frag_info.edge = edge;
407408
frag_info.ratio = ratio;
408409
frag_info.pixel_size = Vector2(1.0f / Size(input_texture->GetSize()));
410+
frag_info.use_decal =
411+
(tile_mode == Entity::TileMode::kDecal) ? 1.0 : 0.0;
409412

410413
const Quad& uvs = pass_args.uvs;
411414
std::array<VS::PerVertexData, 4> vertices = {

‎impeller/entity/shaders/texture_downsample.frag‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ precision mediump float;
77
#include <impeller/constants.glsl>
88
#include <impeller/types.glsl>
99

10+
layout(constant_id = 0) const float supports_decal = 1.0;
11+
1012
uniform f16sampler2D texture_sampler;
1113

1214
uniform FragInfo {
1315
float edge;
1416
float ratio;
17+
float use_decal;
1518
vec2 pixel_size;
1619
}
1720
frag_info;
@@ -20,13 +23,24 @@ in highp vec2 v_texture_coords;
2023

2124
out vec4 frag_color;
2225

26+
vec4 Sample(vec2 uv) {
27+
if (supports_decal == 1.0) {
28+
return texture(texture_sampler, uv, float16_t(kDefaultMipBias));
29+
} else {
30+
if (frag_info.use_decal == 1.0 &&
31+
(uv.x < 0 || uv.y < 0 || uv.x > 1 || uv.y > 1)) {
32+
return vec4(0);
33+
} else {
34+
return texture(texture_sampler, uv, float16_t(kDefaultMipBias));
35+
}
36+
}
37+
}
38+
2339
void main() {
2440
vec4 total = vec4(0.0);
2541
for (float i = -frag_info.edge; i <= frag_info.edge; i += 2) {
2642
for (float j = -frag_info.edge; j <= frag_info.edge; j += 2) {
27-
total += (texture(texture_sampler,
28-
v_texture_coords + frag_info.pixel_size * vec2(i, j),
29-
float16_t(kDefaultMipBias)) *
43+
total += (Sample(v_texture_coords + frag_info.pixel_size * vec2(i, j)) *
3044
frag_info.ratio);
3145
}
3246
}

‎impeller/tools/malioc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4845,7 +4845,7 @@
48454845
},
48464846
"thread_occupancy": 100,
48474847
"uniform_registers_used": 1,
4848-
"work_registers_used": 4
4848+
"work_registers_used": 3
48494849
}
48504850
}
48514851
}

0 commit comments

Comments
 (0)