20 std::optional<Entity> LinearToSrgbFilterContents::RenderFilter(
22 const ContentContext& renderer,
24 const Matrix& effect_transform,
26 const std::optional<Rect>& coverage_hint)
const {
35 inputs[0]->GetSnapshot(
"LinearToSrgb", renderer, entity);
36 if (!input_snapshot.has_value()) {
45 const ContentContext& renderer,
46 const Entity& entity, RenderPass& pass) ->
bool {
47 pass.SetCommandLabel(
"Linear to sRGB Filter");
51 pass.SetPipeline(renderer.GetLinearToSrgbFilterPipeline(options));
53 auto size = input_snapshot->texture->GetSize();
55 VertexBufferBuilder<VS::PerVertexData> vtx_builder;
56 vtx_builder.AddVertices({
63 auto& host_buffer = renderer.GetTransientsBuffer();
64 pass.SetVertexBuffer(vtx_builder.CreateVertexBuffer(host_buffer));
66 VS::FrameInfo frame_info;
68 entity.GetShaderClipDepth(), pass,
69 entity.GetTransform() * input_snapshot->transform *
71 frame_info.texture_sampler_y_coord_scale =
72 input_snapshot->texture->GetYCoordScale();
74 FS::FragInfo frag_info;
75 frag_info.input_alpha =
77 ? input_snapshot->opacity
81 pass, input_snapshot->texture,
82 renderer.GetContext()->GetSamplerLibrary()->GetSampler({}));
83 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
84 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
86 return pass.Draw().ok();
90 [coverage](
const Entity& entity) -> std::optional<Rect> {
91 return coverage.TransformBounds(entity.GetTransform());
97 sub_entity.SetContents(std::move(contents));
98 sub_entity.SetBlendMode(entity.GetBlendMode());