Skip to content

Commit 3c3f187

Browse files
committed
Fix one-on-one calls on Windows on ARM.
Fixes telegramdesktop#30792.
1 parent 9a8c918 commit 3c3f187

1 file changed

Lines changed: 55 additions & 30 deletions

File tree

Telegram/SourceFiles/calls/calls_video_incoming.cpp

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,33 @@ class Panel::Incoming::RendererRhi final
657657
#ifndef Q_OS_MAC
658658
const auto shadowFs = Ui::Rhi::ShaderFromFile(
659659
u":/shaders/argb32.frag.qsb"_q);
660+
661+
_shadowVertexBuffer = rhi->newBuffer(
662+
QRhiBuffer::Dynamic,
663+
QRhiBuffer::VertexBuffer,
664+
4 * 4 * sizeof(float));
665+
_shadowVertexBuffer->create();
666+
_shadowUniformBuffer = rhi->newBuffer(
667+
QRhiBuffer::Dynamic,
668+
QRhiBuffer::UniformBuffer,
669+
256);
670+
_shadowUniformBuffer->create();
671+
672+
validateShadowImage();
673+
674+
_shadowSrb = rhi->newShaderResourceBindings();
675+
_shadowSrb->setBindings({
676+
QRhiShaderResourceBinding::uniformBuffer(
677+
0,
678+
QRhiShaderResourceBinding::VertexStage,
679+
_shadowUniformBuffer),
680+
QRhiShaderResourceBinding::sampledTexture(
681+
1,
682+
QRhiShaderResourceBinding::FragmentStage,
683+
_shadowTexture, _sampler),
684+
});
685+
_shadowSrb->create();
686+
660687
QRhiGraphicsPipeline::TargetBlend blend;
661688
blend.enable = true;
662689
blend.srcColor = QRhiGraphicsPipeline::One;
@@ -672,7 +699,7 @@ class Panel::Incoming::RendererRhi final
672699
_shadowBlendPipeline->setTargetBlends({ blend });
673700
_shadowBlendPipeline->setTopology(
674701
QRhiGraphicsPipeline::TriangleStrip);
675-
_shadowBlendPipeline->setShaderResourceBindings(_argb32Srb);
702+
_shadowBlendPipeline->setShaderResourceBindings(_shadowSrb);
676703
_shadowBlendPipeline->setRenderPassDescriptor(rpDesc);
677704
_shadowBlendPipeline->create();
678705
#endif
@@ -854,6 +881,10 @@ class Panel::Incoming::RendererRhi final
854881
rub->updateDynamicBuffer(
855882
_vertexBuffer, 0, sizeof(coords), coords);
856883

884+
#ifndef Q_OS_MAC
885+
prepareTitleShadow(rub, pw, ph);
886+
#endif
887+
857888
cb->beginPass(rt, Qt::black, { 1.0f, 0 }, rub);
858889
cb->setGraphicsPipeline(pipeline);
859890
cb->setShaderResources(srb);
@@ -863,24 +894,22 @@ class Panel::Incoming::RendererRhi final
863894
cb->draw(4);
864895

865896
#ifndef Q_OS_MAC
866-
paintTitleShadow(rt, cb, pw, ph);
897+
paintTitleShadow(cb, pw, ph);
867898
#endif
868899

869900
cb->endPass();
870901
}
871902

872-
void paintTitleShadow(
873-
QRhiRenderTarget *rt,
874-
QRhiCommandBuffer *cb,
903+
// Only records resource updates, must be called outside a render
904+
// pass, the batch is then passed to beginPass.
905+
void prepareTitleShadow(
906+
QRhiResourceUpdateBatch *rub,
875907
float pw,
876908
float ph) {
877909
if (!_shadowBlendPipeline) {
878910
return;
879911
}
880-
validateShadowImage();
881-
if (!_shadowTexture) {
882-
return;
883-
}
912+
ensureShadowUploaded(rub);
884913
const auto factor = style::DevicePixelRatio();
885914
const auto widget = _owner->widget();
886915
const auto left = (_owner->_topControlsAlignment
@@ -911,37 +940,27 @@ class Panel::Incoming::RendererRhi final
911940
const auto tt = texRect.top() / atlasH;
912941
const auto tb = texRect.bottom() / atlasH;
913942

914-
auto *rub2 = _rhi->nextResourceUpdateBatch();
915-
ensureShadowUploaded(rub2);
916943
const float shadowCoords[] = {
917944
shadowRect.left(), shadowRect.bottom(), tl, tt,
918945
shadowRect.right(), shadowRect.bottom(), tr, tt,
919946
shadowRect.left(), shadowRect.top(), tl, tb,
920947
shadowRect.right(), shadowRect.top(), tr, tb,
921948
};
922-
rub2->updateDynamicBuffer(
923-
_vertexBuffer, 0, sizeof(shadowCoords), shadowCoords);
949+
rub->updateDynamicBuffer(
950+
_shadowVertexBuffer, 0, sizeof(shadowCoords), shadowCoords);
924951
const float viewport2[] = { pw, ph, 0.f, 0.f };
925-
rub2->updateDynamicBuffer(
926-
_uniformBuffer, 0, sizeof(viewport2), viewport2);
927-
928-
_argb32Srb->setBindings({
929-
QRhiShaderResourceBinding::uniformBuffer(
930-
0,
931-
QRhiShaderResourceBinding::VertexStage,
932-
_uniformBuffer),
933-
QRhiShaderResourceBinding::sampledTexture(
934-
1,
935-
QRhiShaderResourceBinding::FragmentStage,
936-
_shadowTexture, _sampler),
937-
});
938-
_argb32Srb->create();
952+
rub->updateDynamicBuffer(
953+
_shadowUniformBuffer, 0, sizeof(viewport2), viewport2);
954+
}
939955

940-
cb->resourceUpdate(rub2);
956+
void paintTitleShadow(QRhiCommandBuffer *cb, float pw, float ph) {
957+
if (!_shadowBlendPipeline) {
958+
return;
959+
}
941960
cb->setGraphicsPipeline(_shadowBlendPipeline);
942-
cb->setShaderResources(_argb32Srb);
961+
cb->setShaderResources(_shadowSrb);
943962
cb->setViewport({ 0, 0, pw, ph });
944-
const QRhiCommandBuffer::VertexInput vbuf2(_vertexBuffer, 0);
963+
const QRhiCommandBuffer::VertexInput vbuf2(_shadowVertexBuffer, 0);
945964
cb->setVertexInput(0, 1, &vbuf2);
946965
cb->draw(4);
947966
}
@@ -999,7 +1018,10 @@ class Panel::Incoming::RendererRhi final
9991018
delete _shadowBlendPipeline; _shadowBlendPipeline = nullptr;
10001019
delete _argb32Srb; _argb32Srb = nullptr;
10011020
delete _yuv420Srb; _yuv420Srb = nullptr;
1021+
delete _shadowSrb; _shadowSrb = nullptr;
10021022
delete _shadowTexture; _shadowTexture = nullptr;
1023+
delete _shadowVertexBuffer; _shadowVertexBuffer = nullptr;
1024+
delete _shadowUniformBuffer; _shadowUniformBuffer = nullptr;
10031025
delete _rgbaTexture; _rgbaTexture = nullptr;
10041026
delete _yTexture; _yTexture = nullptr;
10051027
delete _uTexture; _uTexture = nullptr;
@@ -1033,7 +1055,10 @@ class Panel::Incoming::RendererRhi final
10331055
QRhiGraphicsPipeline *_shadowBlendPipeline = nullptr;
10341056
QRhiShaderResourceBindings *_argb32Srb = nullptr;
10351057
QRhiShaderResourceBindings *_yuv420Srb = nullptr;
1058+
QRhiShaderResourceBindings *_shadowSrb = nullptr;
10361059
QRhiTexture *_shadowTexture = nullptr;
1060+
QRhiBuffer *_shadowVertexBuffer = nullptr;
1061+
QRhiBuffer *_shadowUniformBuffer = nullptr;
10371062
QSize _shadowSize;
10381063
QRect _shadowLeftRect;
10391064
QRect _shadowRightRect;

0 commit comments

Comments
 (0)