DirectX 11 SwapChain::当前问题

发布于 2024-11-15 10:49:44 字数 1777 浏览 4 评论 0原文

我手头上有一个很奇怪的问题。 我正在使用 directx 11 来制作自己的游戏框架/引擎,它一直工作得很好,直到我尝试实现视锥体剔除,这给我带来了非常奇怪的帧速率问题。

我已经稍微简化了问题,因此无需我进行任何视锥体剔除即可发生这种情况。现在我的屏幕上渲染了 250 个模型,调试时帧率为 70 fps。我已经这样做了,如果我按住按钮 H,它会跳过 Application::Render 中模型的渲染,但如果我这样做然后再次松开按钮,则大多数情况下我的帧速率会达到 40 左右甚至约 4 fps。分析显示 SwapChain::Present 突然花费了比应有的时间更长的时间。

在发行版中,这是同样的问题,只有当我附加了调试器时才会发生这种情况。我自己实在搞不清楚这个问题。

尝试重建和重新启动。

我现在的功能:

m_pSwapChain->Present( 0, 0);

我的应用程序::渲染功能:

void CApplication::Render() const
{
    CD3D::Instance()->BeginRender();

    //Render 3d
    if ( !CInputSystem::Instance()->IsKeyPressed('H'))
    {
        std::vector<CPlanet*>::const_iterator it;
        for (it = m_Planets.begin(); it != m_Planets.end(); ++it)
        {
            (*it)->Render();
        }
    }
    // Render 2d
    m_pScreenSprite->Render();

    CTextSystem::Instance()->Render2D();
    CD3D::Instance()->EndRender();
}

这是我的分析在通过按 H 停止渲染模型之前的样子:

[Profiler] BeginRender: 2.830984218768823e-005
[Profiler] Models::Render: 1.4456089627755692e-005
[Profiler] Text|Sprite ::Render: 0.00015811348030357787
[Profiler] EndRender: 0.00018853150222864715
[Profiler] CApplication::Render(): 0.00067612335863149022

在我按 H 一秒钟然后释放它之后,模型将再次渲染:

[Profiler] BeginRender: 2.4996988314660883e-005
[Profiler] Models::Render: 0.0091422720154198285
[Profiler] Text|Sprite ::Render: 0.00011655222262378027
[Profiler] EndRender: 0.2590757137694254
[Profiler] CApplication::Render(): 0.26870557764124803

我也尝试过,当我按 H 时,我不会渲染我的模型,而是在按 C 时创建一个具有相同效果的新模型。因此,如果在运行时渲染的模型数量以任何方式发生变化,我的帧速率就会变得疯狂。

如果我正在运行 fraps(将捕获该行为以便您可以看到它),则不会发生这种情况。不知道这是否是任何线索。

固定的!看下面评论

I've quite the weird problem at my hand here.
I'm using directx 11 to make my own game framework/engine and it has worked fine until i tried to implement frustum culling which gave me really weird framerate issues.

I've simplifed the problem a bit so it happens without me doing any frustum culling. Right now I have 250 models rendered on my screen, 70 fps in debug. I've made it so that if i hold in the button H it skips the rendering of my models in my Application::Render but if i do this and then let go of the button again, my framerate is tops around 40 afterwards most times around 4 fps even. Profiling shows me it's SwapChain::Present that all of a sudden takes way longer time then it ever should.

In Release it's the same problem, this only happens if i got the debugger attached btw. I can't really figure this one out myself.

Tried rebuilding and rebooting.

my present function:

m_pSwapChain->Present( 0, 0);

My Application::Render function:

void CApplication::Render() const
{
    CD3D::Instance()->BeginRender();

    //Render 3d
    if ( !CInputSystem::Instance()->IsKeyPressed('H'))
    {
        std::vector<CPlanet*>::const_iterator it;
        for (it = m_Planets.begin(); it != m_Planets.end(); ++it)
        {
            (*it)->Render();
        }
    }
    // Render 2d
    m_pScreenSprite->Render();

    CTextSystem::Instance()->Render2D();
    CD3D::Instance()->EndRender();
}

This is how my profiling looks before stopping my models to be rendered by pressing H:

[Profiler] BeginRender: 2.830984218768823e-005
[Profiler] Models::Render: 1.4456089627755692e-005
[Profiler] Text|Sprite ::Render: 0.00015811348030357787
[Profiler] EndRender: 0.00018853150222864715
[Profiler] CApplication::Render(): 0.00067612335863149022

After I've pressed H for a second then released it so the models are being rendered again:

[Profiler] BeginRender: 2.4996988314660883e-005
[Profiler] Models::Render: 0.0091422720154198285
[Profiler] Text|Sprite ::Render: 0.00011655222262378027
[Profiler] EndRender: 0.2590757137694254
[Profiler] CApplication::Render(): 0.26870557764124803

I also tried, instead of not rendering my models when i press H, I create a new model when i press C which has the same effect. So if the number of models rendered changes in any way during runtime my framerate goes crazy.

This doesn't happen if i have fraps running(was going to capture the behavior so you could see it). Duno if that's a clue to anything.

FIXED! Look at comment below

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绅刃 2024-11-22 10:49:44

终于我可以回答我自己的问题了(不得不等8个小时)

问题解决了,我应该早点想到这个,FML。当我将驱动程序升级到 11 天前发布的驱动程序时,现在工作正常(上次我只是在 1-2 个月前升级了它们)。现在工作正常,fpsdrops 在其他游戏中也消失了

Finally i can answer my own question(had to wait 8 hours)

Problem solved, I should've thought of this sooner, FML. Works fine now when i upgraded my drivers to ones that came out 11 days ago(i've upgraded them just 1-2 months ago last time). Works fine now, fpsdrops has disapeared in other games as well

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文