@@ -698,14 +698,10 @@ constexpr GLenum PIXEL_BUFFER_FORMAT = GL_RGBA;
698
698
699
699
void CDRMRenderer::readBuffer (Hyprutils::Memory::CSharedPointer<IBuffer> buf, std::span<uint8_t > out) {
700
700
CEglContextGuard eglContext (*this );
701
- auto hadAttachment = buf->attachments .get (AQ_ATTACHMENT_DRM_RENDERER_DATA);
702
- auto att = (CDRMRendererBufferAttachment*)hadAttachment.get ();
703
- if (!hadAttachment) {
704
- // should never remove anything, but JIC. We'll leak an EGLImage if this removes anything.
705
- buf->attachments .removeByType (AQ_ATTACHMENT_DRM_RENDERER_DATA);
706
- auto newAttachment = makeShared<CDRMRendererBufferAttachment>(self, buf, nullptr , 0 , 0 , SGLTex{}, std::vector<uint8_t >());
707
- att = newAttachment.get ();
708
- buf->attachments .add (newAttachment);
701
+ auto att = buf->attachments .get <CDRMRendererBufferAttachment>();
702
+ if (!att) {
703
+ att = makeShared<CDRMRendererBufferAttachment>(self, buf, nullptr , 0 , 0 , SGLTex{}, std::vector<uint8_t >());
704
+ buf->attachments .add (att);
709
705
}
710
706
711
707
auto dma = buf->dmabuf ();
@@ -886,31 +882,28 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP<IBuffer> from, SP<IBuffer> to, S
886
882
auto fromDma = from->dmabuf ();
887
883
std::span<uint8_t > intermediateBuf;
888
884
{
889
- auto attachment = from->attachments .get (AQ_ATTACHMENT_DRM_RENDERER_DATA );
885
+ auto attachment = from->attachments .get <CDRMRendererBufferAttachment>( );
890
886
if (attachment) {
891
887
TRACE (backend->log (AQ_LOG_TRACE, " EGL (blit): From attachment found" ));
892
- auto att = (CDRMRendererBufferAttachment*)attachment.get ();
893
- fromTex = att->tex ;
894
- intermediateBuf = att->intermediateBuf ;
888
+ fromTex = attachment->tex ;
889
+ intermediateBuf = attachment->intermediateBuf ;
895
890
}
896
891
897
892
if (!fromTex.image && intermediateBuf.empty ()) {
898
893
backend->log (AQ_LOG_DEBUG, " EGL (blit): No attachment in from, creating a new image" );
899
894
fromTex = glTex (from);
900
895
901
- auto newAttachment = makeShared<CDRMRendererBufferAttachment>(self, from, nullptr , 0 , 0 , fromTex, std::vector<uint8_t >());
896
+ attachment = makeShared<CDRMRendererBufferAttachment>(self, from, nullptr , 0 , 0 , fromTex, std::vector<uint8_t >());
897
+ from->attachments .add (attachment);
898
+
902
899
if (!fromTex.image && primaryRenderer) {
903
900
backend->log (AQ_LOG_DEBUG, " EGL (blit): Failed to create image from source buffer directly, allocating intermediate buffer" );
904
901
static_assert (PIXEL_BUFFER_FORMAT == GL_RGBA); // If the pixel buffer format changes, the below size calculation probably needs to as well.
905
- newAttachment ->intermediateBuf .resize (fromDma.size .x * fromDma.size .y * 4 );
906
- intermediateBuf = newAttachment ->intermediateBuf ;
902
+ attachment ->intermediateBuf .resize (fromDma.size .x * fromDma.size .y * 4 );
903
+ intermediateBuf = attachment ->intermediateBuf ;
907
904
fromTex.target = GL_TEXTURE_2D;
908
905
GLCALL (glGenTextures (1 , &fromTex.texid ));
909
906
}
910
-
911
- // should never remove anything, but JIC. We'll leak an EGLImage if this removes anything.
912
- from->attachments .removeByType (AQ_ATTACHMENT_DRM_RENDERER_DATA);
913
- from->attachments .add (newAttachment);
914
907
}
915
908
916
909
if (!intermediateBuf.empty () && primaryRenderer) {
@@ -936,13 +929,12 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP<IBuffer> from, SP<IBuffer> to, S
936
929
}
937
930
938
931
{
939
- auto attachment = to->attachments .get (AQ_ATTACHMENT_DRM_RENDERER_DATA );
932
+ auto attachment = to->attachments .get <CDRMRendererBufferAttachment>( );
940
933
if (attachment) {
941
934
TRACE (backend->log (AQ_LOG_TRACE, " EGL (blit): To attachment found" ));
942
- auto att = (CDRMRendererBufferAttachment*)attachment.get ();
943
- rboImage = att->eglImage ;
944
- fboID = att->fbo ;
945
- rboID = att->rbo ;
935
+ rboImage = attachment->eglImage ;
936
+ fboID = attachment->fbo ;
937
+ rboID = attachment->rbo ;
946
938
}
947
939
948
940
if (!rboImage) {
@@ -968,8 +960,6 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP<IBuffer> from, SP<IBuffer> to, S
968
960
return {};
969
961
}
970
962
971
- // should never remove anything, but JIC. We'll leak an RBO and FBO if this removes anything.
972
- to->attachments .removeByType (AQ_ATTACHMENT_DRM_RENDERER_DATA);
973
963
to->attachments .add (makeShared<CDRMRendererBufferAttachment>(self, to, rboImage, fboID, rboID, SGLTex{}, std::vector<uint8_t >()));
974
964
}
975
965
}
0 commit comments