【3D技术宅公社】XR数字艺术论坛  XR技术讨论 XR互动电影 定格动画

 找回密码
 立即注册

QQ登录

只需一步,快速开始

调查问卷
论坛即将给大家带来全新的技术服务,面向三围图形学、游戏、动画的全新服务论坛升级为UTF8版本后,中文用户名和用户密码中有中文的都无法登陆,请发邮件到324007255(at)QQ.com联系手动修改密码

3D技术论坛将以计算机图形学为核心,面向教育 推出国内的三维教育引擎该项目在持续研发当中,感谢大家的关注。

查看: 5163|回复: 14

想請問有關於 D3DPRESENT_PARAMETERS 資料結構的問題

[复制链接]
发表于 2009-2-23 06:14:07 | 显示全部楼层 |阅读模式

typedef struct _D3DPRESENT_PARAMETERS_
{
    UINT                                     BackBufferWidth;
    UINT                                     BackBufferHeight;
    D3DFORMAT                          BackBufferFormat;
    UINT                                     BackBufferCount;

    D3DMULTISAMPLE_TYPE         MultiSampleType;
    DWORD                                MultiSampleQuality;

    D3DSWAPEFFECT                  SwapEffect;
    HWND                                   hDeviceWindow;
    BOOL                                    Windowed;
    BOOL                                    EnableAutoDepthStencil;
    D3DFORMAT                          AutoDepthStencilFormat;
    DWORD                                Flags;

    /* FullScreen_RefreshRateInHz must be zero for Windowed mode */
    UINT                                     FullScreen_RefreshRateInHz;
    UINT                                     resentationInterval;
} D3DPRESENT_PARAMETERS;

 

在下想請問各位大人就是 D3DPRESENT_PARAMETERS 這個資料結構裡每個參數的用處!!!

像是 PresentationInterval 這個參數在下用時不知道為什麼CPU都跑50%

總感覺CPU快燒掉的樣子

如果不用 PresentationInterval 這個參數的話

程式也是可以執行的

感覺 resentationInterval 這個參數好像可以不用!!!

所以想請各位大人幫在下解答一下 D3DPRESENT_PARAMETERS 這個資料結構裡每個參數的用處!!!

拜託各位大人了

謝謝!!!

发表于 2009-3-2 09:45:38 | 显示全部楼层

限定每秒60帧是不可能的

全国计算机硬件差别很大,有的机器很烂,怎么也没办法用软件提高帧数呀

不过倒是可以限定帧数,上面说过帧数多也不一定是好事,所以限制不要把CPU都用在刷新上也是一个优化的办法

限制帧数不超过每秒60方法很多,我说个最简单的

 

FPS++;

if(FPS>30)  //30毫秒

{

  Draw();  //渲染

  FPS=0;

}

 

 楼主| 发表于 2009-3-2 21:12:31 | 显示全部楼层
QUOTE:
以下是引用鼯鼠在2009-3-2 9:45:38的发言:

限定每秒60帧是不可能的

全国计算机硬件差别很大,有的机器很烂,怎么也没办法用软件提高帧数呀

不过倒是可以限定帧数,上面说过帧数多也不一定是好事,所以限制不要把CPU都用在刷新上也是一个优化的办法

限制帧数不超过每秒60方法很多,我说个最简单的

 

FPS++;

if(FPS>30)  //30毫秒

{

  Draw();  //渲染

  FPS=0;

}

 

FPS 的初值一開始是利用timeGetTime()給初值嗎???

1秒60張圖

這樣一張圖不就是0.0167秒

用30毫秒好像會超過1秒耶!!!

发表于 2009-2-24 11:09:29 | 显示全部楼层

我很懒,下面这些是直接从DX 的 SDK COPY过来的。。。

Describes the relationship between the adapter refresh rate and the rate at which MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/IDirect3DDevice9__Present.htm">IDirect3DDevice9:resent or MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/IDirect3DSwapChain9__Present.htm">IDirect3DSwapChain9:resent operations are completed. These values also serve as flag values for the PresentationIntervals field of MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/D3DCAPS9.htm">D3DCAPS9.

#define Description
D3DPRESENT_DONOTFLIP Use the front buffer as both the source and target surface during rendering. A frame synch is scheduled but the displayed surface does not change. This flag is only available in fullscreen mode.

Differences between Direct3D 9 and Direct3D 9Ex:

This flag is available in Direct3D 9Ex only.

D3DPRESENT_DONOTWAIT A presentation cannot be scheduled by a hal device. If this flag is set in a call to IDirect3DSwapChain9:resent, and the hardware is busy processing or waiting for a vertical sync interval, then Present will return D3DERR_WASSTILLDRAWING to indicate that the blit operation is incomplete.
D3DPRESENT_FLIPRESTART The application will discard all previously queued frames and presents the current frame next. This is useful in situations where the queued frames are out of sync with other aspects of the application (for example, audio or external UI).

Differences between Direct3D 9 and Direct3D 9Ex:

This flag is available in Direct3D 9Ex only.

D3DPRESENT_INTERVAL_DEFAULT This is nearly equivalent to D3DPRESENT_INTERVAL_ONE. See remarks.
D3DPRESENT_INTERVAL_ONE The driver will wait for the vertical retrace period (the runtime will "beam follow" to prevent tearing). IDirect3DDevice9:resent operations will not be affected more frequently than the screen refresh; the runtime will complete at most one Present operation per adapter refresh period. This is equivalent to using D3DSWAPEFFECT_COPYVSYNC in DirectX 8.1. This option is always available for both windowed and full-screen swap chains. See remarks.
D3DPRESENT_INTERVAL_TWO The driver will wait for the vertical retrace period. IDirect3DDevice9:resent operations will not be affected more frequently than every second screen refresh. Check the PresentationIntervals cap (see D3DCAPS9) to see if D3DPRESENT_INTERVAL_TWO is supported by the driver.
D3DPRESENT_INTERVAL_THREE The driver will wait for the vertical retrace period. IDirect3DDevice9:resent operations will not be affected more frequently than every third screen refresh. Check the PresentationIntervals cap (see D3DCAPS9) to see if D3DPRESENT_INTERVAL_THREE is supported by the driver.
D3DPRESENT_INTERVAL_FOUR The driver will wait for the vertical retrace period. IDirect3DDevice9:resent operations will not be affected more frequently than every fourth screen refresh. Check the PresentationIntervals member (see D3DCAPS9) to see if D3DPRESENT_INTERVAL_FOUR is supported by the driver.
D3DPRESENT_INTERVAL_IMMEDIATE The runtime updates the window client area immediately and might do so more than once during the adapter refresh period. This is equivalent to using D3DSWAPEFFECT_COPY in DirectX 8. IDirect3DDevice9:resent operations might be affected immediately. This option is always available for both windowed and full-screen swap chains. See remarks.
D3DPRESENT_LINEAR_CONTENT The content of the back buffer to be presented is in the linear color space.
  • The presentation will implicitly convert from linear space to sRGB (gamma = 2.2). This is the only conversion that is supported.
  • Because this flag represents a property of the content of the back buffer, the flag can be specified during an IDirect3DSwapChain9:resent call. In other words, an application can present linear content in one frame, and then switch to corrected content in the next.
  • This flag is ignored when the swap chain is full screen. (Note that this flag is available only on the explicit swap chain version of IDirect3DSwapChain9:resent. The IDirect3DDevice9::Present method does not take a flags parameter.)
  • This flag is always accepted, but will only take effect when the driver exposes >D3DCAPS3_LINEAR_TO_SRGB_PresentATION.
  • The only back buffer format supported is MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/D3DFORMAT.htm">X8R8G8B8.
See MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/Gamma.htm#Windowed_Swap_Chains">Windowed Swap Chains.
D3DPRESENT_VIDEO_RESTRICT_TO_MONITOR Clips the rendered contents to the monitor/device the adapter is targeting, shows thumbnails for the content in the Flip3D view and taskbar thumbnails on other monitors.

Differences between Direct3D 9 and Direct3D 9Ex:

This flag is available in Direct3D 9Ex only.

See Desktop Window Manager for further details on this feature of Windows Vista. If you are not running in desktop composition mode, the flag gives the same behavior as MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/D3DPRESENTFLAG.htm">D3DPRESENTFLAG_DEVICECLIP.

Remarks

Windowed mode supports D3DPRESENT_INTERVAL_DEFAULT, D3DPRESENT_INTERVAL_IMMEDIATE, and D3DPRESENT_INTERVAL_ONE. D3DPRESENT_INTERVAL_DEFAULT and the D3DPRESENT_INTERVAL_ONE are nearly equivalent (see the information regarding timer resolution below). They perform similarly to COPY_VSYNC in that there is only one present per frame, and they prevent tearing with beam-following. In contrast, D3DPRESENT_INTERVAL_IMMEDIATE will attempt to provide an unlimited presentation rate.

Full-screen mode supports similar usage as windowed mode by supporting D3DPRESENT_INTERVAL_IMMEDIATE regardless of the refresh rate or swap effect. D3DPRESENT_INTERVAL_DEFAULT uses the default system timer resolution whereas the D3DPRESENT_INTERVAL_ONE calls timeBeginPeriod to enhance system timer resolution. This improves the quality of vertical sync, but consumes slightly more processing time. Both parameters attempt to synchronize vertically.

发表于 2009-2-24 11:14:32 | 显示全部楼层

PresentationInterval 这个参数并不是说,你不设置,它就不生效

而是,它本身有个默认值为:D3DPRESENT_INTERVAL_DEFAULT 好像吧。。。

 

也就是说,如果你的代码里面不设置 PresentationInterval 这个参数,那么它将会使用自己默认的参数

 

你的CPU 耗费过多,可能与两个问题相关:

1.你的 Windows 消息循环是怎么处理的

2.你的 PresentationInterval 参数设置的是多少,一般来说,使用 D3DPRESENT_INTERVAL_ONE ,CPU就不会跑到 3%以上,当然,如果使用 D3DPRESENT_INTERVAL_TWO,D3DPRESENT_INTERVAL_THREE,D3DPRESENT_INTERVAL_FOUR,那么CPU就不会超过 0%。但是,画面会比较卡了。。。

 

其实这些东西都可以从SDK上查到的,如果楼主英语不好,直接找个翻译软件,我就是这样的,看得多了,英语水平就自然上去了

发表于 2009-2-24 11:16:27 | 显示全部楼层

在给你帖个关于 D3DPRESENT_PARAMETERS 所有参数含义的,也是从SDK COPY的。。。

 

D3DPRESENT_PARAMETERS

Describes the presentation parameters.

typedef struct D3DPRESENT_PARAMETERS {
    UINT BackBufferWidth, BackBufferHeight;
    D3DFORMAT BackBufferFormat;
    UINT BackBufferCount;
    D3DMULTISAMPLE_TYPE MultiSampleType;
    DWORD MultiSampleQuality;
    D3DSWAPEFFECT SwapEffect;
    HWND hDeviceWindow;
    BOOL Windowed;
    BOOL EnableAutoDepthStencil;
    D3DFORMAT AutoDepthStencilFormat;
    DWORD Flags;
    UINT FullScreen_RefreshRateInHz;
    UINT PresentationInterval;
} D3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS;

Members

BackBufferWidth, BackBufferHeight
Width and height of the new swap chain's back buffers, in pixels. If Windowed is FALSE (the presentation is full-screen), these values must equal the width and height of one of the enumerated display modes found through MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/IDirect3D9__EnumAdapterModes.htm">IDirect3D9::EnumAdapterModes. If Windowed is TRUE and either of these values is zero, the corresponding dimension of the client area of the hDeviceWindow (or the focus window, if hDeviceWindow is NULL) is taken.
BackBufferFormat
The back buffer format. For more information about formats, see MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/D3DFORMAT.htm">D3DFORMAT. This value must be one of the render-target formats as validated by MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/IDirect3D9__CheckDeviceType.htm">IDirect3D9::CheckDeviceType. You can use MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/IDirect3DDevice9__Getdisplaymode.htm">IDirect3DDevice9::GetDisplayMode to obtain the current format.

In fact, D3DFMT_UNKNOWN can be specified for the BackBufferFormat while in windowed mode. This tells the runtime to use the current display-mode format and eliminates the need to call IDirect3DDevice9::GetDisplayMode.

For windowed applications, the back buffer format no longer needs to match the display-mode format because color conversion can now be done by the hardware (if the hardware supports color conversion). The set of possible back buffer formats is constrained, but the runtime will allow any valid back buffer format to be presented to any desktop format. (There is the additional requirement that the device be operable in the desktop mode; devices typically do not operate in 8 bits per pixel modes.)

Full-screen applications cannot do color conversion.

BackBufferCount
This value can be between 0 and MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/D3DPRESENT_BACK_BUFFERS.htm">D3DPRESENT_BACK_BUFFERS_MAX (or MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/D3DPRESENT_BACK_BUFFERS.htm">D3DPRESENT_BACK_BUFFERS_MAX_EX when using Direct3D 9Ex). Values of 0 are treated as 1. If the number of back buffers cannot be created, the runtime will fail the method call and fill this value with the number of back buffers that could be created. As a result, an application can call the method twice with the same D3DPRESENT_PARAMETERS structure and expect it to work the second time.

The method fails if one back buffer cannot be created. The value of BackBufferCount influences what set of swap effects are allowed. Specifically, any D3DSWAPEFFECT_COPY swap effect requires that there be exactly one back buffer.

MultiSampleType
Member of the MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/d3dmultisample_type.htm">D3DMULTISAMPLE_TYPE enumerated type. The value must be D3DMULTISAMPLE_NONE unless SwapEffect has been set to D3DSWAPEFFECT_DISCARD. Multisampling is supported only if the swap effect is D3DSWAPEFFECT_DISCARD.
MultiSampleQuality
Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/IDirect3D9__CheckDeviceMultiSampleType.htm">IDirect3D9::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. Paired values of render targets or of depth stencil surfaces and D3DMULTISAMPLE_TYPE must match.
SwapEffect
Member of the MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/D3DSWAPEFFECT.htm">D3DSWAPEFFECT enumerated type. The runtime will guarantee the implied semantics concerning buffer swap behavior; therefore, if Windowed is TRUE and SwapEffect is set to D3DSWAPEFFECT_FLIP, the runtime will create one extra back buffer and copy whichever becomes the front buffer at presentation time.

D3DSWAPEFFECT_COPY requires that BackBufferCount be set to 1.

D3DSWAPEFFECT_DISCARD will be enforced in the debug runtime by filling any buffer with noise after it is presented.

hDeviceWindow
The device window determines the location and size of the back buffer on screen. This is used by Direct3D when the back buffer contents are copied to the front buffer during MSITStore:C:\Program%20Files\Microsoft%20DirectX%20SDK%20(August%202008)\Documentation\DirectX9\directx_sdk.chm::/IDirect3DDevice9__Present.htm">IDirect3DDevice9:resent.
  • For a full-screen application, this is a handle to the top window (which is the focus window).

    For applications that use multiple full-screen devices (such as a multimonitor system), exactly one device can use the focus window as the device window. All other devices must have unique device windows.

  • For a windowed-mode application, this handle will be the default target window for IDirect3DDevice9:resent. If this handle is NULL, the focus window will be taken.

Note that no attempt is made by the runtime to reflect user changes in window size. The back buffer is not implicitly reset when this window is reset. However, the IDirect3DDevice9:resent method does automatically track window position changes.

Windowed
TRUE if the application runs windowed; FALSE if the application runs full-screen.
EnableAutoDepthStencil
If this value is TRUE, Direct3D will manage depth buffers for the application. The device will create a depth-stencil buffer when it is created. The depth-stencil buffer will be automatically set as the render target of the device. When the device is reset, the depth-stencil buffer will be automatically destroyed and recreated in the new size.

If EnableAutoDepthStencil is TRUE, then AutoDepthStencilFormat must be a valid depth-stencil format.

AutoDepthStencilFormat
Member of the D3DFORMAT enumerated type. The format of the automatic depth-stencil surface that the device will create. This member is ignored unless EnableAutoDepthStencil is TRUE.
Flags
One of the D3DPRESENTFLAG constants.
FullScreen_RefreshRateInHz
The rate at which the display adapter refreshes the screen. The value depends on the mode in which the application is running:
  • For windowed mode, the refresh rate must be 0.
  • For full-screen mode, the refresh rate is one of the refresh rates returned by IDirect3D9::EnumAdapterModes.
PresentationInterval
The maximum rate at which the swap chain's back buffers can be presented to the front buffer. For a detailed explanation of the modes and the intervals that are supported, see D3DPRESENT.
发表于 2009-2-24 11:17:00 | 显示全部楼层
你看看,SDK里写的多么清楚啊。。。
发表于 2009-2-24 14:49:39 | 显示全部楼层

CPU跑到50% 很紧张吗?我觉得在没做优化的情况下是正常的;

我也觉得你的代码跑到50%不是因为一个参数就能决定的,可能会有影响,也不会那么多。

如果是单纯想降低CUP使用率,在你的运行循环里面放一个Sleep(1);这样的函数效果会明显很多。

 楼主| 发表于 2009-2-24 19:07:21 | 显示全部楼层
QUOTE:
以下是引用drucula在2009-2-24 11:14:32的发言:

PresentationInterval 这个参数并不是说,你不设置,它就不生效

而是,它本身有个默认值为:D3DPRESENT_INTERVAL_DEFAULT 好像吧。。。

 

也就是说,如果你的代码里面不设置 PresentationInterval 这个参数,那么它将会使用自己默认的参数

 

你的CPU 耗费过多,可能与两个问题相关:

1.你的 Windows 消息循环是怎么处理的

2.你的 PresentationInterval 参数设置的是多少,一般来说,使用 D3DPRESENT_INTERVAL_ONE ,CPU就不会跑到 3%以上,当然,如果使用 D3DPRESENT_INTERVAL_TWO,D3DPRESENT_INTERVAL_THREE,D3DPRESENT_INTERVAL_FOUR,那么CPU就不会超过 0%。但是,画面会比较卡了。。。

 

其实这些东西都可以从SDK上查到的,如果楼主英语不好,直接找个翻译软件,我就是这样的,看得多了,英语水平就自然上去了

我的PresentationInterval是設定D3DPRESENT_INTERVAL_DEFAULT

原本是設定D3DPRESENT_INTERVAL_IMMEDIATE

但後來好像發現D3DPRESENT_INTERVAL_DEFAULT比較好

所以就用D3DPRESENT_INTERVAL_DEFAULT

請問一下D3DPRESENT_INTERVAL_DEFAULT了和D3DPRESENT_INTERVAL_IMMEDIATE有什麼不同呢???

 

http://www.badongo.com/file/13541843

這是在下的程式↑

不介意的話可以請您指導嗎???

謝謝!!!

发表于 2009-2-25 00:52:26 | 显示全部楼层
D3DPRESENT_INTERVAL_DEFAULT This is nearly equivalent to D3DPRESENT_INTERVAL_ONE. See remarks.
D3DPRESENT_INTERVAL_ONE The driver will wait for the vertical retrace period (the runtime will "beam follow" to prevent tearing). IDirect3DDevice9:resent operations will not be affected more frequently than the screen refresh; the runtime will complete at most one Present operation per adapter refresh period. This is equivalent to using D3DSWAPEFFECT_COPYVSYNC in DirectX 8.1. This option is always available for both windowed and full-screen swap chains. See remarks.
D3DPRESENT_INTERVAL_TWO The driver will wait for the vertical retrace period. IDirect3DDevice9:resent operations will not be affected more frequently than every second screen refresh. Check the PresentationIntervals cap (see D3DCAPS9) to see if D3DPRESENT_INTERVAL_TWO is supported by the driver.
D3DPRESENT_INTERVAL_THREE The driver will wait for the vertical retrace period. IDirect3DDevice9:resent operations will not be affected more frequently than every third screen refresh. Check the PresentationIntervals cap (see D3DCAPS9) to see if D3DPRESENT_INTERVAL_THREE is supported by the driver.
D3DPRESENT_INTERVAL_FOUR The driver will wait for the vertical retrace period. IDirect3DDevice9:resent operations will not be affected more frequently than every fourth screen refresh. Check the PresentationIntervals member (see D3DCAPS9) to see if D3DPRESENT_INTERVAL_FOUR is supported by the driver.
D3DPRESENT_INTERVAL_IMMEDIATE The runtime updates the window client area immediately and might do so more than once during the adapter refresh period. This is equivalent to using D3DSWAPEFFECT_COPY in DirectX 8. IDirect3DDevice9:resent operations might be affected immediately. This option is always available for both windowed and full-screen swap chains. See remarks.

 

你没有看 SDK 里面说的啊。。。。。我贴在上面的哇。。。

 

PresentationInterval,通俗一点说,这个参数,控制了 DX 的翻页速度,暂时理解为画面的刷新速度吧

 

D3DPRESENT_INTERVAL_IMMEDIATE   立刻刷新,不等待,这样会使你的CPU占用较多

 

D3DPRESENT_INTERVAL_DEFAULT 等于 D3DPRESENT_INTERVAL_ONE :暂时理解为:将刷新速度放慢一点,使你的DX的刷新速度,不超过你显示器设定的刷新速度,比如,你的显示器设定为 70HZ,那么你选用这个参数的话,你程序的FPS 不会超过 70

 

D3DPRESENT_INTERVAL_TWO

D3DPRESENT_INTERVAL_THREE

D3DPRESENT_INTERVAL_FOUR

 

你可以看到,他们都是在最后一个下划线的变化,2,3,4,可以理解为,比 D3DPRESENT_INTERVAL_DEFAULT 或者 D3DPRESENT_INTERVAL_ONE 刷新得更慢,FOUR 刷新最慢,THREE其次。。以此类推

 

楼主啊。。好好阅读一下SDK吧,那才是最正宗的解释。。。英语要努把力啊。。

 

发表于 2009-2-25 09:16:14 | 显示全部楼层

楼上说的对

 

D3DPRESENT_INTERVAL_DEFAULT   //=D3DPRESENT_INTERVAL_ONE
D3DPRESENT_INTERVAL_ONE    //每1屏刷新周期进行一次前后台缓冲内容的交换,窗口全屏格式都适用
D3DPRESENT_INTERVAL_TWO    //每2屏刷新周期进行一次前后台缓冲内容的交换,通过d3dcaps9中的PresentationIntervals检查
D3DPRESENT_INTERVAL_THREE   //每3屏刷新周期进行一次前后台缓冲内容的交换
D3DPRESENT_INTERVAL_FOUR   //每4屏刷新周期进行一次前后台缓冲内容的交换
D3DPRESENT_INTERVAL_IMMEDIATE  //图形绘制完后,立即将内容复制到前台缓存。相当于Directx8.0中用D3DSWAPEFFECT_COPY IDirect3DDevice9:resent将立即执行。

 

 

D3DPRESENT_INTERVAL_DEFAULT是让你的刷新速度和屏幕的保持一致,比如说一般的液晶屏幕刷新都是60,所以你的游戏的屏幕和后台缓冲区之间的交换速度也是60;

D3DPRESENT_INTERVAL_IMMEDIATE是立即刷新,他不管你的屏幕刷新率是多少,只要代码执行完了就刷新,这样可以提高你的FPS值。使用D3DPRESENT_INTERVAL_IMMEDIATE会大大提高前台与后台的反转速度,这样CPU就不会有空闲时间,你的CPU使用率就高了;不过这样完全没有必要,因为每秒显示到屏幕上多少张画面还是决定于你的显示器的刷新率,而且这样做会让屏幕看起来有种“撕裂”的感觉,效果并不是很好,一般都采用D3DPRESENT_INTERVAL_DEFAULT

 楼主| 发表于 2009-2-25 22:09:52 | 显示全部楼层

既然都講到FPS了

那在下想在請問一下

一般的FPS都是用PresentationInterval這個在控制的嗎???

因為一般遊戲正常的FPS都是60

但在下不知道該怎麼顯示目前的FPS

而且在下也不會控制FPS的快慢

有聽說用SLEEP就行了

但很多人說用SLEEP來控制FPS很糟!!!

发表于 2009-2-26 00:16:45 | 显示全部楼层

FPS跟sleep没有多大的关系

FPS就是一秒钟的渲染次数:在你的渲染循环里i=0,渲染一帧就给变量i+1,直到一秒钟,你输出i变成多少了就是这一秒钟的FPS值嘛~~~

Sleep是给系统一个空闲时间,不要你这个程序独占CPU,给系统一个透气的机会,让他做点自己的事情。

 楼主| 发表于 2009-2-26 00:25:13 | 显示全部楼层
QUOTE:
以下是引用蚊子在2009-2-26 0:16:45的发言:

FPS跟sleep没有多大的关系

FPS就是一秒钟的渲染次数:在你的渲染循环里i=0,渲染一帧就给变量i+1,直到一秒钟,你输出i变成多少了就是这一秒钟的FPS值嘛~~~

Sleep是给系统一个空闲时间,不要你这个程序独占CPU,给系统一个透气的机会,让他做点自己的事情。

顯示FPS這樣子設定就行了???

原來這麼簡單喔!!!

在下想了很久了耶!!!

原來這的簡單就能解決了喔!!!

多謝指導!!!

 

可以的話...

在下能否再問一下

就是要如何設定讓遊戲一秒鐘渲染60張圖呢???

发表于 2009-2-26 08:08:02 | 显示全部楼层

FPS 是由多方面的因素决定的:

1.PresentationInterval

2.游戏的逻辑部分所耗的时间

3.渲染所花费的时间

 

这应该算是三大因素了吧。当然,还有游戏运行环境的因素,比如,硬件啦,操作系统啦。。。。。

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|3D数字艺术论坛 ( 沪ICP备14023054号 )

GMT+8, 2025-2-6 08:58

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表