Skip to content
Discussion options

You must be logged in to vote

感谢建议!现状确实如你所说:

  1. 为什么现在没做。tgfx 要同时跑 GL/Vulkan/Metal/WebGPU,RuntimeEffect 的做法是把最底层开放出来——你直接用当前后端的原生着色语言(重写 onDraw 操作 CommandEncoder),自由度开到最大,不做中间层的限制。所以能力上业务方已经可以自足:想生成什么内容都可以自己实现。原生支持 SkRuntimeEffect::MakeForShader 的价值主要剩两点——性能(作为颜色源直接画,不用像变通方案那样多一次离屏 RT)和易用性(一份代码跨后端、能作为真正的 Shader 参与 Blend 等组合)。但要做到那样得引入一套着色语言编译器或跨后端 IR,相对这两点收益,投入产出不划算,所以一直没排期。

  2. 现有能力下怎么实现自定义填充。三条路:一是用 RuntimeEffect 做 ImageFilter,onDraw 里忽略源图、自己输出颜色,重写 filterBounds 扩大输出范围,再画个占位矩形挂上 filter;二是离屏画成 Image 后用 Shader::MakeImageShader 填充;三是更彻底——直接用 tgfx/gpu 的公开接口(Device / CommandEncoder / RenderPipeline)自己管理 pipeline 绘制,RuntimeEffect::onDraw 拿到的 CommandEncoder 就是这套接口。都能用,就是没有 runtime shader 来得直接。

  3. 以后会不会做。这个方向我们考虑过,但按现有架构实现起来难度不小…

Replies: 3 comments 14 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Hparty
Comment options

You must be logged in to vote
3 replies
@Hparty
Comment options

@0x1306a94
Comment options

@0x1306a94
Comment options

Comment options

You must be logged in to vote
11 replies
@0x1306a94
Comment options

@0x1306a94
Comment options

@Hparty
Comment options

@0x1306a94
Comment options

@Hparty
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants