-
Notifications
You must be signed in to change notification settings - Fork 181
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
feature: Renderer Framebuffer type #1637
Conversation
5243a78
to
66f198f
Compare
Have you seen this fix pop-os/cosmic-comp#1078, or any similar issues, or are the synchronization issues this fixes currently theoretical and not reproducible? |
Yes I could reproduce it and the first commit already fixed that, given that this synchronizes the imports. The second commit fixes synchronization across the board for shared contexts, but we haven't run into this in cosmic-comp as we don't bind shared-textures, but just render them. |
Not having an |
Needing a |
There's a CI failure, but it looks simple enough. I like changing I guess I might need to think about it for a while before I have any sense if the |
66f198f
to
cfd0cb2
Compare
https://morestina.net/blog/1868/self-referential-types-for-fun-and-profit was the inspiration for this once I realized that this is simply self-referential. Though I'll leave seeing though those lifetime to you. I have stared long enough at the code to be confident, that it is sound, but I would really like somebody to come to the same conclusion. 😅 |
I think smithay/src/backend/renderer/element/texture.rs Lines 594 to 597 in fe31867
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1637 +/- ##
==========================================
- Coverage 19.33% 19.31% -0.02%
==========================================
Files 171 171
Lines 28375 28391 +16
==========================================
Hits 5485 5485
- Misses 22890 22906 +16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
5786ade
to
29d7079
Compare
Okay, after reading through https://morestina.net/blog/1868/self-referential-types-for-fun-and-profit, and looking through that part of the code here, I understand why this makes the struct self-referential, and it seems like a relatively straightforward case of that. As the article mentions, So I think that part of the code looks correct, as does everything else here. Alternatives:
So overall, this seems like a good approach. Hopefully Rust will have a better way to deal with self-referential types at some point. |
fn bind(&mut self, target: PixmanRenderBuffer) -> Result<(), <Self as Renderer>::Error> { | ||
self.target = Some(PixmanTarget::RenderBuffer(target)); | ||
Ok(()) | ||
impl Bind<Image<'static, 'static>> for PixmanRenderer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should allow to bind an Image
with non 'static
data lifetime. This would allow callers to bind byte[]
slices in a safe way without having to rely on the ugly hack we do in the DrmCompositor
for binding the dumb buffer slice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a way to introduce the necessary bound of Image<'a, 'a>
outlives PixmanTarget<'b>
. I want to add a where 'a: 'b
-bound to bind
, but that isn't compatible with the trait definition.
Adding 'b
to Bind<'b>
doesn't help, as we still can't express the bound in the trait, Target: 'b
doesn't help.
Nor does where Target: 'a
even though that should imply, that bind
should only be available if Image<'b, 'b>
outlives PixmanTarget<'a>
. The compiler doesn't seem smart enough.
Adding another lifetime to PixmanTarget
makes it impossible to implement RendererSuper
.
I couldn't find a way to specify the additional requirement with an higher-order bound (for<'b>
), but that feels like what is necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that's quite unfortunate. I also unsuccessfully tried to find a safe way to express this.
Would be really great if we could use this to basically bind a scoped slice :/
Theoretically is should just work as the 'bits
inside of the Image
are already guaranteed to outlive any reference to the Image
. In PixmanTarget
/PixmanTargetInternal
we only care that the 'bits
of the Image
live at least as long as the reference of the image itself. So the only thing blocking this is that we can not prove it to the compiler. I wonder if it would be safe to just cast the lifetime in bind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick test of the change: cmeissl@0e5eee5
29d7079
to
97f8d88
Compare
97f8d88
to
31e4d48
Compare
Superseeds #1616.
Original description:
I lied, I did the refactor. The changes to
Renderer
andBind
are fairly small, however the fallout was huge, but since none of this compiles without all the other changes, I wasn't sure how to split this apart further. Please excuse the giant PR/commit everybody.