-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gles: Define a TextureShaderElement
#1560
Conversation
41a243d
to
2baba0e
Compare
`GlesFrame` has support for using a custom shader, but there doesn't seem to be a particularly convenient way to use this. I'm not sure exactly how `override_default_tex_program` would best be used, and it's probably not a good way to use a shader for one specific element. `TextureShaderElement` wraps a `TextureRenderElement` with a shader and uniforms. So doesn't have to duplicate the implementation of different constructors `TextureRenderElement` provides.
2baba0e
to
d5a3772
Compare
This seems to be working. I think implementing |
This looks useful and mostly is in line of what I thought a higher-level abstraction could look like, when I designed the lower-level renderer apis. I would be intrigued though to here, if this would be actually useful or would be too limited for real life use-cases. |
My code for testing this in cosmic-comp is rather hacky at the moment but my use-case is to apply a post-process shader to the whole screen. Which we discussed wanting for a couple features and for testing purposes. (Invert colors accessibility feature, color blindness simulation shader, etc.) Something like this |
I guess in niri I could use this as the backbone for the ClippedSurfaceRenderElement instead of manual It works on a I am also planning to have post-process shaders, and when ClippedSurface is in use I guess I might just append the code into its shader, but when ClipperSurface is not in use, this PR's TextureShaderElement should work. Unfortunately, it doesn't really help with any of the unobvious math required to pass the toplevel geometry into the shader and relate it to the texture geometry (this gets complex when i.e. drawing a subsurface or with viewporter, etc.). For my animation shaders, I need some more functionality like bigger shader area or passing multiple textures (think resize crossfade between two buffers), which is a different use case from this PR. |
I guess it works if you follow certain rules, but
That's true with either Though how best to handle that is a good question, and may be a common use case for something like this. I guess Not sure the best way to handle that. |
Okay so we have two quite different use-cases here:
It seems for the first one this is more than enough, but for the second it seems possibly too simplistic and secondly not helpful for the additional complexity, that is I would like to solve the second in smithay eventually, as every compositor implements it's own clipping atm, rounded corners were also a highly requested feature and it might make sense to standardize some uniforms/attributes for user-provided window-shaders to make sharing easier. But for the first use-case, maybe we could just add an optional |
I couldn't think of a good way to add this as a feature to |
Ah, so this is essentially a specialization for a specific renderer. Maybe we should call it We could internally still wrap it and/or provide constructors/ |
It could work that way. I guess that would be slightly more ergonomic, though it's not really that hard to call I guess where it matters more is which works better for generic code that wants to also have a pixman renderer, but use the shader feature only with gles (either using nothing, or something different with pixman). But I don't know exactly how we'd want to handle that, or what API would be most useful for it. |
Good point. I guess changing the constructor later isn't so bad, we have had worse api breakage for sure. |
Yeah, and it's likely we'll want some API changes in Smithay to better handle dynamic renderer switching like that regardless. |
GlesFrame
has support for using a custom shader, but there doesn't seem to be a particularly convenient way to use this. I'm not sure exactly howoverride_default_tex_program
would best be used, and it's probably not a good way to use a shader for one specific element.TextureShaderElement
wraps aTextureRenderElement
with a shader and uniforms. So doesn't have to duplicate the implementation of different constructorsTextureRenderElement
provides.Leaving as a draft until I test this (and add some documentation).