|
13 | 13 | #include "impeller/core/formats.h"
|
14 | 14 | #include "impeller/core/sampler_descriptor.h"
|
15 | 15 | #include "impeller/core/texture_descriptor.h"
|
| 16 | +#include "impeller/core/vertex_buffer.h" |
16 | 17 | #include "impeller/entity/contents/anonymous_contents.h"
|
17 | 18 | #include "impeller/entity/contents/content_context.h"
|
18 | 19 | #include "impeller/entity/contents/contents.h"
|
@@ -152,14 +153,18 @@ static std::optional<Entity> AdvancedBlend(
|
152 | 153 | auto& host_buffer = renderer.GetTransientsBuffer();
|
153 | 154 |
|
154 | 155 | auto size = pass.GetRenderTargetSize();
|
155 |
| - VertexBufferBuilder<typename VS::PerVertexData> vtx_builder; |
156 |
| - vtx_builder.AddVertices({ |
157 |
| - {Point(0, 0), dst_uvs[0], src_uvs[0]}, |
158 |
| - {Point(size.width, 0), dst_uvs[1], src_uvs[1]}, |
159 |
| - {Point(0, size.height), dst_uvs[2], src_uvs[2]}, |
160 |
| - {Point(size.width, size.height), dst_uvs[3], src_uvs[3]}, |
161 |
| - }); |
162 |
| - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); |
| 156 | + |
| 157 | + std::array<typename VS::PerVertexData, 4> vertices = { |
| 158 | + typename VS::PerVertexData{Point(0, 0), dst_uvs[0], src_uvs[0]}, |
| 159 | + typename VS::PerVertexData{Point(size.width, 0), dst_uvs[1], |
| 160 | + src_uvs[1]}, |
| 161 | + typename VS::PerVertexData{Point(0, size.height), dst_uvs[2], |
| 162 | + src_uvs[2]}, |
| 163 | + typename VS::PerVertexData{Point(size.width, size.height), dst_uvs[3], |
| 164 | + src_uvs[3]}, |
| 165 | + }; |
| 166 | + auto vtx_buffer = |
| 167 | + CreateVertexBuffer(vertices, renderer.GetTransientsBuffer()); |
163 | 168 |
|
164 | 169 | auto options = OptionsFromPass(pass);
|
165 | 170 | options.primitive_type = PrimitiveType::kTriangleStrip;
|
@@ -282,16 +287,16 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
|
282 | 287 | using FS = BlendScreenPipeline::FragmentShader;
|
283 | 288 |
|
284 | 289 | auto& host_buffer = renderer.GetTransientsBuffer();
|
285 |
| - |
286 | 290 | auto size = dst_snapshot->texture->GetSize();
|
287 |
| - VertexBufferBuilder<VS::PerVertexData> vtx_builder; |
288 |
| - vtx_builder.AddVertices({ |
289 |
| - {{0, 0}, {0, 0}, {0, 0}}, |
290 |
| - {Point(size.width, 0), {1, 0}, {1, 0}}, |
291 |
| - {Point(0, size.height), {0, 1}, {0, 1}}, |
292 |
| - {Point(size.width, size.height), {1, 1}, {1, 1}}, |
293 |
| - }); |
294 |
| - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); |
| 291 | + |
| 292 | + std::array<VS::PerVertexData, 4> vertices = { |
| 293 | + VS::PerVertexData{{0, 0}, {0, 0}, {0, 0}}, |
| 294 | + VS::PerVertexData{Point(size.width, 0), {1, 0}, {1, 0}}, |
| 295 | + VS::PerVertexData{Point(0, size.height), {0, 1}, {0, 1}}, |
| 296 | + VS::PerVertexData{Point(size.width, size.height), {1, 1}, {1, 1}}, |
| 297 | + }; |
| 298 | + auto vtx_buffer = |
| 299 | + CreateVertexBuffer(vertices, renderer.GetTransientsBuffer()); |
295 | 300 |
|
296 | 301 | #ifdef IMPELLER_DEBUG
|
297 | 302 | pass.SetCommandLabel(SPrintF("Foreground Advanced Blend Filter (%s)",
|
@@ -434,14 +439,15 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
|
434 | 439 | auto& host_buffer = renderer.GetTransientsBuffer();
|
435 | 440 | auto size = dst_snapshot->texture->GetSize();
|
436 | 441 | auto color = foreground_color.Premultiply();
|
437 |
| - VertexBufferBuilder<VS::PerVertexData> vtx_builder; |
438 |
| - vtx_builder.AddVertices({ |
439 |
| - {{0, 0}, {0, 0}, color}, |
440 |
| - {Point(size.width, 0), {1, 0}, color}, |
441 |
| - {Point(0, size.height), {0, 1}, color}, |
442 |
| - {Point(size.width, size.height), {1, 1}, color}, |
443 |
| - }); |
444 |
| - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); |
| 442 | + |
| 443 | + std::array<VS::PerVertexData, 4> vertices = { |
| 444 | + VS::PerVertexData{{0, 0}, {0, 0}, color}, |
| 445 | + VS::PerVertexData{Point(size.width, 0), {1, 0}, color}, |
| 446 | + VS::PerVertexData{Point(0, size.height), {0, 1}, color}, |
| 447 | + VS::PerVertexData{Point(size.width, size.height), {1, 1}, color}, |
| 448 | + }; |
| 449 | + auto vtx_buffer = |
| 450 | + CreateVertexBuffer(vertices, renderer.GetTransientsBuffer()); |
445 | 451 |
|
446 | 452 | #ifdef IMPELLER_DEBUG
|
447 | 453 | pass.SetCommandLabel(SPrintF("Foreground PorterDuff Blend Filter (%s)",
|
@@ -562,14 +568,14 @@ static std::optional<Entity> PipelineBlend(
|
562 | 568 | FS::BindTextureSampler(pass, input->texture, sampler);
|
563 | 569 |
|
564 | 570 | auto size = input->texture->GetSize();
|
565 |
| - VertexBufferBuilder<VS::PerVertexData> vtx_builder; |
566 |
| - vtx_builder.AddVertices({ |
567 |
| - {Point(0, 0), Point(0, 0)}, |
568 |
| - {Point(size.width, 0), Point(1, 0)}, |
569 |
| - {Point(0, size.height), Point(0, 1)}, |
570 |
| - {Point(size.width, size.height), Point(1, 1)}, |
571 |
| - }); |
572 |
| - pass.SetVertexBuffer(vtx_builder.CreateVertexBuffer(host_buffer)); |
| 571 | + std::array<VS::PerVertexData, 4> vertices = { |
| 572 | + VS::PerVertexData{Point(0, 0), Point(0, 0)}, |
| 573 | + VS::PerVertexData{Point(size.width, 0), Point(1, 0)}, |
| 574 | + VS::PerVertexData{Point(0, size.height), Point(0, 1)}, |
| 575 | + VS::PerVertexData{Point(size.width, size.height), Point(1, 1)}, |
| 576 | + }; |
| 577 | + pass.SetVertexBuffer( |
| 578 | + CreateVertexBuffer(vertices, renderer.GetTransientsBuffer())); |
573 | 579 |
|
574 | 580 | VS::FrameInfo frame_info;
|
575 | 581 | frame_info.mvp = pass.GetOrthographicTransform() *
|
@@ -711,15 +717,14 @@ std::optional<Entity> BlendFilterContents::CreateFramebufferAdvancedBlend(
|
711 | 717 | FS::FragInfo frag_info;
|
712 | 718 | frag_info.alpha = 1.0;
|
713 | 719 |
|
714 |
| - VertexBufferBuilder<VS::PerVertexData> vtx_builder; |
715 |
| - vtx_builder.AddVertices({ |
716 |
| - {{0, 0}, {0, 0}}, |
717 |
| - {Point(1, 0), {1, 0}}, |
718 |
| - {Point(0, 1), {0, 1}}, |
719 |
| - {Point(1, 1), {1, 1}}, |
720 |
| - }); |
721 |
| - auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer); |
722 |
| - pass.SetVertexBuffer(std::move(vtx_buffer)); |
| 720 | + std::array<VS::PerVertexData, 4> vertices = { |
| 721 | + VS::PerVertexData{{0, 0}, {0, 0}}, |
| 722 | + VS::PerVertexData{Point(1, 0), {1, 0}}, |
| 723 | + VS::PerVertexData{Point(0, 1), {0, 1}}, |
| 724 | + VS::PerVertexData{Point(1, 1), {1, 1}}, |
| 725 | + }; |
| 726 | + pass.SetVertexBuffer( |
| 727 | + CreateVertexBuffer(vertices, renderer.GetTransientsBuffer())); |
723 | 728 |
|
724 | 729 | VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
|
725 | 730 | FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
|
@@ -753,20 +758,20 @@ std::optional<Entity> BlendFilterContents::CreateFramebufferAdvancedBlend(
|
753 | 758 | src_texture = src_snapshot->texture;
|
754 | 759 | }
|
755 | 760 |
|
756 |
| - VertexBufferBuilder<VS::PerVertexData> vtx_builder; |
757 |
| - vtx_builder.AddVertices({ |
758 |
| - {Point(0, 0), Point(0, 0)}, |
759 |
| - {Point(1, 0), Point(1, 0)}, |
760 |
| - {Point(0, 1), Point(0, 1)}, |
761 |
| - {Point(1, 1), Point(1, 1)}, |
762 |
| - }); |
| 761 | + std::array<VS::PerVertexData, 4> vertices = { |
| 762 | + VS::PerVertexData{Point(0, 0), Point(0, 0)}, |
| 763 | + VS::PerVertexData{Point(1, 0), Point(1, 0)}, |
| 764 | + VS::PerVertexData{Point(0, 1), Point(0, 1)}, |
| 765 | + VS::PerVertexData{Point(1, 1), Point(1, 1)}, |
| 766 | + }; |
763 | 767 |
|
764 | 768 | auto options = OptionsFromPass(pass);
|
765 | 769 | options.blend_mode = BlendMode::kSource;
|
766 | 770 | options.primitive_type = PrimitiveType::kTriangleStrip;
|
767 | 771 |
|
768 | 772 | pass.SetCommandLabel("Framebuffer Advanced Blend Filter");
|
769 |
| - pass.SetVertexBuffer(vtx_builder.CreateVertexBuffer(host_buffer)); |
| 773 | + pass.SetVertexBuffer( |
| 774 | + CreateVertexBuffer(vertices, renderer.GetTransientsBuffer())); |
770 | 775 |
|
771 | 776 | switch (blend_mode) {
|
772 | 777 | case BlendMode::kScreen:
|
|
0 commit comments