20 std::optional<Entity> SrgbToLinearFilterContents::RenderFilter(
22 const ContentContext& renderer,
24 const Matrix& effect_transform,
26 const std::optional<Rect>& coverage_hint)
const {
35 inputs[0]->GetSnapshot(
"SrgbToLinear", renderer, entity);
36 if (!input_snapshot.has_value()) {
45 const ContentContext& renderer,
46 const Entity& entity, RenderPass& pass) ->
bool {
47 pass.SetCommandLabel(
"sRGB to Linear Filter");
51 pass.SetPipeline(renderer.GetSrgbToLinearFilterPipeline(options));
53 auto size = input_snapshot->texture->GetSize();
55 std::array<VS::PerVertexData, 4> vertices = {
56 VS::PerVertexData{
Point(0, 0)},
57 VS::PerVertexData{
Point(1, 0)},
58 VS::PerVertexData{
Point(0, 1)},
59 VS::PerVertexData{
Point(1, 1)},
62 auto& host_buffer = renderer.GetTransientsBuffer();
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
80 const std::unique_ptr<const Sampler>& sampler =
81 renderer.GetContext()->GetSamplerLibrary()->GetSampler({});
82 FS::BindInputTexture(pass, input_snapshot->texture, sampler);
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());