Direct2D性能问题 [英] Direct2D Performance Problem

查看:762
本文介绍了Direct2D性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个简单的应用程序来比较Direct2D与GDI的效率。
但我对结果感到沮丧:Direct2D的渲染速度比我的笔记本电脑上的GDI慢了大约10倍x1350图形适配器。

在创建10000多段线和硬件支持hwnd渲染目标后,我使用direct2D和GDI渲染这些折线。

我使用Direct2D测试了以下情况:
(1)每一行都有一个关联的PathGeometry对象
(2),只使用一个PathGeometry对象,其中有很多数字

初始化代码片段:

GetClientRect(& rect);

生成点
为(unsigned int i = 0; i< 10000; ++ i)
{
的std ::矢量< D2D_POINT_2F> psf;
for(unsigned int m = 0; m <10; ++ m)
{
int x = rand(); x = x%rect.right;

int y = rand(); y = y%rect.bottom;

D2D_POINT_2F _p = {x,y};

psf.push_back(_p);
}
m_GeometryF .push_back(psf);
}

确定路径几何对象和填充点的内容
ID2D1PathGeometry * pg = 0;

ID2D1GeometrySink * pgs = 0;

m_Renderer-> GetD2DFactory() - > CreatePathGeometry(& pg);

第pg->打开(& pgs) );(
对于(unsigned int i = 0; i< m_GeometryF.size(); ++ i)
{{对于每个折线,创建一个图

D2D1_FIGURE_BEGIN fg = D2D1_FIGURE_BEGIN_HOLLOW;

D2D1_FIGURE_END fe;


fe = D2D1_FIGURE_END_CLOSED;

pgs-> BeginFigure(fb ,FG);

pgs-> AddLines(安培; m_GeometryF [I] [1],m_GeometryF [I] .size() - 1);
pgs-> EndFigure( fe);



制作阶段很简单。
渲染代码片段:

RenderTarget-> DrawGeometry(pg,Brush,(FLOAT)1); //画笔是纯色画笔

我发现RenderTarget-> EndDraw()m消耗了大部分时间ethod。

有谁知道原因?我认为这可能是由于Direct2D使用不当引起的错误。

提前感谢。

I have coded a simple application to compare the efficiency of Direct2D with GDI .
but i was frustrated by the result: the rendering speed of Direct2D is about 10 times slower than GDI on my laptop which equips with a ati x1350 graphic adaptor.

after creating 10000 polylines and hardware-support hwnd render target, i render those polyline using direct2D and GDI.

i have tested the following case using Direct2D :
(1)each line has a associative PathGeometry Object
(2)using only one PathGeometry Object in which it has many figures

initialization code snippet:

GetClientRect(&rect);

//1.generating point
for(unsigned int i = 0; i < 10000;++i)
{
std::vector<D2D_POINT_2F> psf;
for(unsigned int m = 0;m<10;++m)
{
int x = rand(); x = x % rect.right;

int y = rand(); y = y % rect.bottom;

D2D_POINT_2F _p={x,y};

psf.push_back(_p);
}
m_GeometryF.push_back(psf);
}

//2.create path geometry object and fill point
ID2D1PathGeometry* pg = 0;

ID2D1GeometrySink* pgs = 0;

m_Renderer->GetD2DFactory()->CreatePathGeometry(&pg);


pg->Open(&pgs);


for(unsigned int i = 0; i < m_GeometryF.size();++i)
{// for each polyline , create a figure

D2D1_FIGURE_BEGIN fg = D2D1_FIGURE_BEGIN_HOLLOW;

D2D1_FIGURE_END fe;

fe = D2D1_FIGURE_END_CLOSED;

pgs->BeginFigure(fb,fg);

pgs->AddLines(&m_GeometryF[i][1],m_GeometryF[i].size()-1);
pgs->EndFigure(fe);

}



the rendering stage is simple.
rendering code snippet:

RenderTarget->DrawGeometry(pg,Brush,(FLOAT)1);// the brush is a solid color brush

I found that most time was consumed by the RenderTarget->EndDraw() method.

is there anyone who known the reason? i think it may be an error deriving from an improper usage of Direct2D.

thanks in advance.

推荐答案

Hi Kamimail,

Hi Kamimail,

forums.xna.com上的Direct2D论坛应该可以帮助你解决这个问题。

谢谢你,

凯利Evans
WinC ++团队

The Direct2D forum on forums.xna.com should be able to help you with this question.

Thank you,

Kelly Evans
WinC++ team


这篇关于Direct2D性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆