mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] use IPSampleDecal in advanced blends. (flutter/engine#39523)
* [impeller] use IPSampleDecal in advanced blends * update framebuffr_blend * ++ * ++ * YAY * fix relative paths from local work * Update malioc_diff.py
This commit is contained in:
parent
327c0dfeaa
commit
4e4af6119e
@ -116,11 +116,12 @@ static std::optional<Entity> AdvancedBlend(
|
||||
cmd.pipeline = std::move(pipeline);
|
||||
|
||||
typename FS::BlendInfo blend_info;
|
||||
typename VS::FrameInfo frame_info;
|
||||
|
||||
auto dst_sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
dst_snapshot->sampler_descriptor);
|
||||
FS::BindTextureSamplerDst(cmd, dst_snapshot->texture, dst_sampler);
|
||||
blend_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale();
|
||||
frame_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale();
|
||||
blend_info.dst_input_alpha = absorb_opacity ? dst_snapshot->opacity : 1.0;
|
||||
|
||||
if (foreground_color.has_value()) {
|
||||
@ -135,12 +136,11 @@ static std::optional<Entity> AdvancedBlend(
|
||||
src_snapshot->sampler_descriptor);
|
||||
blend_info.color_factor = 0;
|
||||
FS::BindTextureSamplerSrc(cmd, src_snapshot->texture, src_sampler);
|
||||
blend_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
|
||||
frame_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
|
||||
}
|
||||
auto blend_uniform = host_buffer.EmplaceUniform(blend_info);
|
||||
FS::BindBlendInfo(cmd, blend_uniform);
|
||||
|
||||
typename VS::FrameInfo frame_info;
|
||||
frame_info.mvp = Matrix::MakeOrthographic(size);
|
||||
|
||||
auto uniform_view = host_buffer.EmplaceUniform(frame_info);
|
||||
|
||||
@ -122,19 +122,15 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer,
|
||||
return false;
|
||||
}
|
||||
|
||||
FS::BlendInfo blend_info;
|
||||
VS::FrameInfo frame_info;
|
||||
|
||||
auto src_sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
src_snapshot->sampler_descriptor);
|
||||
FS::BindTextureSamplerSrc(cmd, src_snapshot->texture, src_sampler);
|
||||
blend_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
|
||||
|
||||
auto blend_uniform = host_buffer.EmplaceUniform(blend_info);
|
||||
FS::BindBlendInfo(cmd, blend_uniform);
|
||||
|
||||
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
|
||||
src_snapshot->transform;
|
||||
frame_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
|
||||
|
||||
auto uniform_view = host_buffer.EmplaceUniform(frame_info);
|
||||
VS::BindFrameInfo(cmd, uniform_view);
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
|
||||
uniform BlendInfo {
|
||||
float dst_input_alpha;
|
||||
float dst_y_coord_scale;
|
||||
float src_y_coord_scale;
|
||||
float color_factor;
|
||||
vec4 color; // This color input is expected to be unpremultiplied.
|
||||
}
|
||||
@ -25,22 +23,17 @@ in vec2 v_src_texture_coords;
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
vec4 dst_sample =
|
||||
IPSampleWithTileMode(texture_sampler_dst, // sampler
|
||||
v_dst_texture_coords, // texture coordinates
|
||||
blend_info.dst_y_coord_scale, // y coordinate scale
|
||||
kTileModeDecal // tile mode
|
||||
) *
|
||||
blend_info.dst_input_alpha;
|
||||
vec4 dst_sample = IPSampleDecal(texture_sampler_dst, // sampler
|
||||
v_dst_texture_coords // texture coordinates
|
||||
) *
|
||||
blend_info.dst_input_alpha;
|
||||
|
||||
vec4 dst = IPUnpremultiply(dst_sample);
|
||||
vec4 src = blend_info.color_factor > 0
|
||||
? blend_info.color
|
||||
: IPUnpremultiply(IPSampleWithTileMode(
|
||||
texture_sampler_src, // sampler
|
||||
v_src_texture_coords, // texture coordinates
|
||||
blend_info.src_y_coord_scale, // y coordinate scale
|
||||
kTileModeDecal // tile mode
|
||||
: IPUnpremultiply(IPSampleDecal(
|
||||
texture_sampler_src, // sampler
|
||||
v_src_texture_coords // texture coordinates
|
||||
));
|
||||
|
||||
vec4 blended = vec4(Blend(dst.rgb, src.rgb), 1) * dst.a;
|
||||
|
||||
@ -2,10 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <impeller/texture.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
float dst_y_coord_scale;
|
||||
float src_y_coord_scale;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
@ -18,6 +21,8 @@ out vec2 v_src_texture_coords;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0);
|
||||
v_dst_texture_coords = dst_texture_coords;
|
||||
v_src_texture_coords = src_texture_coords;
|
||||
v_dst_texture_coords =
|
||||
IPRemapCoords(dst_texture_coords, frame_info.dst_y_coord_scale);
|
||||
v_src_texture_coords =
|
||||
IPRemapCoords(src_texture_coords, frame_info.src_y_coord_scale);
|
||||
}
|
||||
|
||||
@ -24,12 +24,6 @@ vec4 ReadDestination() {
|
||||
}
|
||||
#endif
|
||||
|
||||
uniform BlendInfo {
|
||||
float dst_input_alpha;
|
||||
float src_y_coord_scale;
|
||||
}
|
||||
blend_info;
|
||||
|
||||
uniform sampler2D texture_sampler_src;
|
||||
|
||||
in vec2 v_src_texture_coords;
|
||||
@ -39,12 +33,10 @@ out vec4 frag_color;
|
||||
void main() {
|
||||
vec4 dst_sample = ReadDestination();
|
||||
vec4 dst = IPUnpremultiply(dst_sample);
|
||||
vec4 src = IPUnpremultiply(IPSampleWithTileMode(
|
||||
texture_sampler_src, // sampler
|
||||
v_src_texture_coords, // texture coordinates
|
||||
blend_info.src_y_coord_scale, // y coordinate scale
|
||||
kTileModeDecal // tile mode
|
||||
));
|
||||
vec4 src =
|
||||
IPUnpremultiply(IPSampleDecal(texture_sampler_src, // sampler
|
||||
v_src_texture_coords // texture coordinates
|
||||
));
|
||||
|
||||
vec4 blended = vec4(Blend(dst.rgb, src.rgb), 1) * dst.a;
|
||||
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <impeller/texture.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
float src_y_coord_scale;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
@ -16,5 +18,6 @@ out vec2 v_src_texture_coords;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0);
|
||||
v_src_texture_coords = src_texture_coords;
|
||||
v_src_texture_coords =
|
||||
IPRemapCoords(src_texture_coords, frame_info.src_y_coord_scale);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -116,7 +116,10 @@ def read_malioc_file(malioc_tree, json_file):
|
||||
if shader['hardware']['core'] not in CORES:
|
||||
continue
|
||||
result = {}
|
||||
result['filename'] = os.path.relpath(shader['filename'], build_gen_dir)
|
||||
filename = os.path.relpath(shader['filename'], build_gen_dir)
|
||||
if filename.startswith('../..'):
|
||||
filename = filename[6:]
|
||||
result['filename'] = filename
|
||||
result['core'] = shader['hardware']['core']
|
||||
result['type'] = shader['shader']['type']
|
||||
for prop in shader['properties']:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user