swapChain->存在(0,0)阻塞 [英] swapChain->Present(0, 0) blocking

查看:111
本文介绍了swapChain->存在(0,0)阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< EDIT>


我基本上只是想找到一种方法,在vsync之前没有Present阻止。 我可以对我的交换链或其他地方执行此操作吗?


< / EDIT>


使用VS中的默认direct3d metro app模板Express 2012,swapChain-> Present(0,0)阻止了vsync。  (我把一个计时器放在上面,每次通话需要1/60秒。)


一点点的研究似乎表明这可能是因为交换链正在使用flip sequential进行交换效果:

 //为交换链创建描述符。 
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
swapChainDesc.Width = 0; //使用自动调整大小
swapChainDesc.Height = 0;
swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; //这是最常见的交换链格式
swapChainDesc.Stereo = false;
swapChainDesc.SampleDesc.Count = 1; //不要使用多次采样
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 2; //使用两个缓冲区来启用翻转效果
swapChainDesc.Scaling = DXGI_SCALING_NONE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; //我们建议对所有应用程序使用此交换效果
swapChainDesc.Flags = 0;

我基本上不希望Present阻止直到vsync,但只是抛出离开任何排队(?)后备缓冲区并使用最新版本进行更新,然后返回。  (如果我完全误解它是如何工作的,那么链接到一个好的教程/概述就会对我很有帮助 - 我来自ac#/ xna背景。)


谢谢!


 

解决方案

Metro应用只能使用DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL。 使用此模型,如果您将syncInterval 0传递给Present(),则会在较新的帧排队时自动丢弃帧。 这应该与您以前获得的
行为基本相同D3DSWAPEFFECT_FLIPEX  + D3DPRESENT_FORCEIMMEDIATE,如果我理解正确,这听起来就像您正在寻找的那样。 你仍然可以以任意频率进行渲染,但一般情况下它不会有用
以比硬件支持更高的频率呈现,因为a)显示器无论如何都只能快速更新,并且b)它会不必要地增加功率消费并减少移动设备上的电池寿命。


此处还有一些信息:


http://msdn.microsoft.com/en-us/library/windows/desktop/hh446797(v = VS。 85)的.aspx


<EDIT>

I'm basically just looking for a way to not have Present block until vsync.  What can I do to my swap chain or elsewhere to do this?

</EDIT>

With the default direct3d metro app template in VS Express 2012, swapChain->Present(0, 0) is blocking for vsync.  (I put a timer on it, and it is taking 1/60th of a second for every call.)

A little bit of research seems to indicate that this might be because the swap chain is using flip sequential for the swap effect:

// Create a descriptor for the swap chain.
        DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
        swapChainDesc.Width = 0;                                     // use automatic sizing
        swapChainDesc.Height = 0;
        swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;           // this is the most common swapchain format
        swapChainDesc.Stereo = false; 
        swapChainDesc.SampleDesc.Count = 1;                          // don't use multi-sampling
        swapChainDesc.SampleDesc.Quality = 0;
        swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
        swapChainDesc.BufferCount = 2;                               // use two buffers to enable flip effect
        swapChainDesc.Scaling = DXGI_SCALING_NONE;
        swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // we recommend using this swap effect for all applications
        swapChainDesc.Flags = 0;

I basically don't want Present to block until vsync, but just throw away any queued(?) backbuffers and update it with the most recent version and then return.  (If I'm totally misunderstanding how it works, a link to a good tutorial/overview would be very helpful to me--I come from a c#/xna background.)

Thanks!

 

解决方案

Metro apps can only use DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL.  With this model, if you pass a syncInterval of 0 to Present() it will automatically discard frames if a newer frame is queued.  This should be essentially the same as the behavior you'd previously get with D3DSWAPEFFECT_FLIPEX + D3DPRESENT_FORCEIMMEDIATE, which sounds like what you're looking for if I'm understanding correctly.  You can still render at arbitrary frequency, but it in general it's not useful to present at a higher frequency than the hardware supports since a) the display can only update that fast anyway, and b) it would unnecessarily increases power consumption and decrease battery life on mobile devices.

There's some further info here:

http://msdn.microsoft.com/en-us/library/windows/desktop/hh446797(v=vs.85).aspx


这篇关于swapChain-&gt;存在(0,0)阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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