@@ -57,6 +57,14 @@ class RhiView::RhiViewPrivate
5757 scene.ps ->setDepthTest (true );
5858 scene.ps ->setDepthWrite (true );
5959 // scene.ps->setCullMode(QRhiGraphicsPipeline::Back);
60+ QRhiGraphicsPipeline::TargetBlend blend;
61+ blend.enable = true ;
62+ blend.srcColor = QRhiGraphicsPipeline::SrcAlpha;
63+ blend.dstColor = QRhiGraphicsPipeline::OneMinusSrcAlpha;
64+ blend.srcAlpha = QRhiGraphicsPipeline::One;
65+ blend.dstAlpha = QRhiGraphicsPipeline::OneMinusSrcAlpha;
66+ scene.ps ->setTargetBlends ({blend});
67+
6068 scene.ps ->setShaderStages (
6169 {{QRhiShaderStage::Vertex, getShader (QLatin1String (" ://shader/vulkan.vert.qsb" ))},
6270 {QRhiShaderStage::Fragment, getShader (QLatin1String (" ://shader/vulkan.frag.qsb" ))}});
@@ -75,8 +83,8 @@ class RhiView::RhiViewPrivate
7583
7684 void initTexture ()
7785 {
78- scene.cubeTex .reset (rhi->newTexture (QRhiTexture::RGBA8 , image.size ()));
79- scene.cubeTex ->create ();
86+ scene.texture .reset (rhi->newTexture (QRhiTexture::RGBA8 , image.size ()));
87+ scene.texture ->create ();
8088
8189 scene.srb .reset (rhi->newShaderResourceBindings ());
8290 scene.srb ->setBindings (
@@ -85,9 +93,9 @@ class RhiView::RhiViewPrivate
8593 scene.ubuf .get ()),
8694 QRhiShaderResourceBinding::sampledTexture (1 ,
8795 QRhiShaderResourceBinding::FragmentStage,
88- scene.cubeTex .get (),
96+ scene.texture .get (),
8997 scene.sampler .get ())});
90- scene.srb ->create ();
98+ qInfo () << " srb create: " << scene.srb ->create ();
9199
92100 scene.ps ->destroy ();
93101 scene.ps ->setShaderResourceBindings (scene.srb .get ());
@@ -100,7 +108,7 @@ class RhiView::RhiViewPrivate
100108 {
101109 if (!scene.resourceUpdates )
102110 scene.resourceUpdates = rhi->nextResourceUpdateBatch ();
103- scene.resourceUpdates ->uploadTexture (scene.cubeTex .get (), image);
111+ scene.resourceUpdates ->uploadTexture (scene.texture .get (), image);
104112 }
105113
106114 void updateTransform ()
@@ -125,7 +133,8 @@ class RhiView::RhiViewPrivate
125133 void emitScaleFactor ()
126134 {
127135 updateTransform ();
128- auto factor = transform.toTransform ().m11 () * windowSize.width () / image.width ();
136+ auto factor = transform.toTransform ().m11 () * windowSize.width ()
137+ * q_ptr->devicePixelRatioF () / image.width ();
129138 emit q_ptr->scaleFactorChanged (factor);
130139 }
131140
@@ -144,7 +153,7 @@ class RhiView::RhiViewPrivate
144153 std::unique_ptr<QRhiShaderResourceBindings> srb;
145154 std::unique_ptr<QRhiGraphicsPipeline> ps;
146155 std::unique_ptr<QRhiSampler> sampler;
147- std::unique_ptr<QRhiTexture> cubeTex ;
156+ std::unique_ptr<QRhiTexture> texture ;
148157 QMatrix4x4 mvp;
149158 } scene;
150159
@@ -168,16 +177,16 @@ RhiView::~RhiView() {}
168177void RhiView::setImageUrl (const QString &imageUrl)
169178{
170179 QImage image;
171- if (!Utils::ImageCache::instance ()->find (imageUrl, image)) {
172- if (!imageUrl.isEmpty ()) {
173- QMessageBox::warning (this ,
174- tr (" WARNING" ),
175- tr (" Picture failed to open, Url: %1!" ).arg (imageUrl));
176- }
180+ if (imageUrl.isEmpty ()) {
177181 image = emptyImage ();
182+ } else if (!Utils::ImageCache::instance ()->find (imageUrl, image)) {
183+ QMessageBox::warning (this ,
184+ tr (" WARNING" ),
185+ tr (" Picture failed to open, Url: %1!" ).arg (imageUrl));
186+ return ;
178187 }
179188
180- d_ptr->image = image.convertToFormat (QImage::Format_RGBA8888_Premultiplied );
189+ d_ptr->image = image.convertToFormat (QImage::Format_RGBA8888 );
181190 d_ptr->initTexture ();
182191
183192 auto size = d_ptr->image .size ();
@@ -273,7 +282,8 @@ void RhiView::render(QRhiCommandBuffer *cb)
273282 cb->beginPass (renderTarget (), d_ptr->backgroundColor , {1 .0f , 0 }, resourceUpdates);
274283
275284 cb->setGraphicsPipeline (d_ptr->scene .ps .get ());
276- cb->setViewport (QRhiViewport (0 , 0 , width (), height ()));
285+ cb->setViewport (
286+ QRhiViewport (0 , 0 , width () * devicePixelRatioF (), height () * devicePixelRatioF ()));
277287 cb->setShaderResources ();
278288
279289 const QRhiCommandBuffer::VertexInput vbufBinding (d_ptr->scene .vbuf .get (), 0 );
0 commit comments